:root {
  --canvas: #deeff6;
  --surface: var(--white);
  --surface-muted: #e5f3f8;
  --ink-soft: #355a70;
  --line-strong: #91bdcf;
  --primary: #159fc6;
  --primary-pressed: #137e9e;
  --primary-soft: var(--ice-soft);
  --warning: #d96b18;
  --danger: #c8383d;
  --focus: #178fb7;
  --radius-control: 4px;
  --radius-sheet: 8px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html,
body {
  min-width: 0;
  overflow-x: clip;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  padding: 0;
}

.topbar {
  box-shadow: none;
}

.brand-logo img {
  aspect-ratio: 1487 / 555;
  object-fit: contain;
}

.match-stage {
  background-image: none;
}

.match-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.match-controls > form {
  margin: 0;
}

.kingdom-input {
  position: relative;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.kingdom-input:focus-within {
  border-color: #35add1;
  box-shadow: 0 0 0 3px rgba(53, 173, 209, 0.14);
}

.kingdom-input:has(input[aria-invalid="true"]) {
  border-color: #e48b8e;
}

.kingdom-input small {
  min-height: 14px;
  margin-top: 4px;
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kingdom-input small.is-valid {
  color: #168db6;
}

.kingdom-input small.is-invalid {
  color: var(--danger);
}

.input-line input::placeholder {
  color: #a5bac6;
}

.swap-button {
  margin: 0;
}

.swap-button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.range-control {
  min-width: 0;
}

.range-control button[aria-pressed="true"] {
  color: var(--white);
  background: #35add1;
  box-shadow: inset 0 0 0 2px #178fb7, inset 0 -6px 0 rgba(21, 110, 141, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.34);
  filter: drop-shadow(0 4px 4px rgba(42, 125, 155, 0.2));
}

.range-control button:disabled {
  opacity: 0.52;
  cursor: wait;
}

.start-button:disabled {
  opacity: 0.54;
  filter: none;
  cursor: not-allowed;
}

.start-button[aria-busy="true"] {
  cursor: wait;
}

.result-stage {
  min-height: 0;
  margin: 18px -16px -16px;
  border-top: 1px solid #b9dce9;
}

.result-stage:has(> .empty-state) {
  display: none;
}

.empty-state {
  display: none;
}

.error-state,
.loading-state {
  min-height: 180px;
  padding: 28px 16px;
}

.error-state {
  color: var(--ink);
}

.error-state svg {
  color: var(--coral);
}

.loading-state {
  gap: 10px;
}

.skeleton {
  background: #d8edf5;
}

.result-header {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.summary-grid {
  position: relative;
  display: grid;
  min-height: 164px;
  grid-template-columns: minmax(0, 1fr) 78px minmax(0, 1fr);
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid #c7e4ee;
  border-radius: 0;
  background: var(--white);
}

.summary-cell {
  position: relative;
  min-width: 0;
  min-height: 164px;
  padding: 17px 12px 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 0;
}

.summary-cell::after {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  content: "";
}

.summary-side-a {
  align-items: flex-start;
  background: #e1f5fb;
}

.summary-side-a::after {
  right: -9px;
  background: #e1f5fb;
  transform: skewX(-7deg);
}

.summary-side-b {
  align-items: flex-end;
  background: #fff0df;
  text-align: right;
}

.summary-side-b::after {
  left: -9px;
  background: #fff0df;
  transform: skewX(-7deg);
}

.summary-side > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.summary-side > strong {
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.summary-total {
  margin-top: 13px;
  font-family: "Noto Sans SC Local", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.summary-side-a .summary-total {
  color: #167d9e;
}

.summary-side-b .summary-total {
  color: #ce651d;
}

.summary-lead {
  margin-top: 5px;
  padding: 3px 7px;
  color: var(--white);
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.summary-side-a .summary-lead {
  background: #31abd0;
}

.summary-side-b .summary-lead {
  background: var(--orange);
}

.summary-online-gate {
  position: absolute;
  z-index: 2;
  bottom: 9px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 42px;
  padding: 4px 7px 5px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(22, 125, 158, 0.3);
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(23, 51, 74, 0.08);
  font: 850 13px/1.25 "Noto Sans SC Local", "Microsoft YaHei", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.summary-side-a .summary-online-gate {
  left: 12px;
}

.summary-side-b .summary-online-gate {
  right: 12px;
  border-color: rgba(206, 101, 29, 0.3);
}

.summary-online-label {
  display: inline-flex;
  align-items: baseline;
  color: var(--ink);
  font-size: inherit;
  font-weight: 850;
  white-space: nowrap;
}

.summary-online-character {
  display: inline-block;
  color: inherit;
  font: inherit;
  font-style: normal;
  transform-origin: 50% 72%;
  animation: summary-online-character-pulse 2.5s ease-in-out infinite;
  animation-delay: calc(var(--char-index) * 105ms);
  will-change: transform, color;
}

.summary-online-gate b {
  color: var(--primary-pressed);
  font-size: 1.04em;
  font-weight: 900;
  line-height: 1.15;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.summary-side-b .summary-online-gate b {
  color: var(--warning);
}

.summary-online-gate:hover,
.summary-online-gate:focus-visible {
  background: var(--white);
  border-color: currentColor;
}

.summary-online-gate:active {
  transform: translateY(1px);
}

.summary-online-gate:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

@keyframes summary-online-character-pulse {
  0%,
  12%,
  100% {
    color: inherit;
    transform: scale(1);
  }

  5% {
    color: var(--primary-pressed);
    transform: scale(1.28);
  }
}

.pk-online-gate-dialog {
  width: min(calc(100% - 32px), 330px);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: var(--ink);
  background: var(--snow);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(19, 68, 92, 0.28);
}

.feature-access-dialog {
  width: min(calc(100% - 32px), 390px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(174, 207, 219, 0.9);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(18, 57, 76, 0.3);
}

.feature-access-dialog::backdrop {
  background: rgba(38, 72, 89, 0.48);
}

.feature-access-dialog[open] {
  animation: pk-dialog-in 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.feature-access-dialog-content {
  padding: 22px 20px 20px;
}

.feature-access-copy {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
}

.feature-access-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: var(--primary-pressed);
  background: #dff4fb;
  border-radius: 8px;
}

.feature-access-icon svg {
  width: 28px;
  height: 28px;
}

.feature-access-dialog h2 {
  margin: 0;
  font: 900 20px/1.28 "Winter Display", "Microsoft YaHei", sans-serif;
}

.feature-access-dialog p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.feature-access-actions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.feature-access-dialog.is-notice-only .feature-access-actions {
  grid-template-columns: 1fr;
}

.feature-access-actions button {
  min-width: 0;
  min-height: 48px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.feature-access-dismiss {
  color: var(--ink);
  background: #fff;
  border: 1px solid #b9dce8;
}

.feature-access-dialog.is-notice-only .feature-access-dismiss {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.feature-access-primary {
  color: #fff;
  background: var(--primary);
  border: 1px solid var(--primary);
}

.feature-access-dismiss:hover {
  background: #eef9fc;
}

.feature-access-primary:hover {
  background: var(--primary-pressed);
}

.feature-access-actions button:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

@media (max-width: 350px) {
  .feature-access-copy {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 11px;
  }

  .feature-access-icon {
    width: 48px;
    height: 48px;
  }

  .feature-access-dialog h2 {
    font-size: 18px;
  }
}

.pk-online-gate-dialog::backdrop {
  background: rgba(15, 47, 64, 0.5);
}

.pk-online-gate-dialog[open] {
  animation: pk-dialog-in 180ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.pk-online-gate-dialog-content {
  display: grid;
  justify-items: center;
  padding: 25px 22px 20px;
  text-align: center;
}

.pk-online-gate-step {
  width: 100%;
  display: grid;
  justify-items: center;
}

.pk-online-gate-step[hidden] {
  display: none;
}

.pk-online-gate-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #fff;
  background: var(--primary);
  clip-path: polygon(25% 0, 75% 0, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0 75%, 0 25%);
}

.pk-online-gate-icon svg {
  width: 23px;
  height: 23px;
}

.pk-online-gate-dialog h2 {
  margin: 14px 0 5px;
  font: 900 18px/1.25 "Winter Display", "Microsoft YaHei", sans-serif;
}

.pk-online-gate-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.pk-wechat-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

.pk-wechat-copy-row > strong {
  color: var(--primary-pressed);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.pk-wechat-copy {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

.pk-wechat-copy svg {
  width: 18px;
  height: 18px;
}

.pk-wechat-copy:hover,
.pk-wechat-copy.is-copied {
  background: var(--primary-pressed);
}

.pk-wechat-copy:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.pk-online-gate-dialog .pk-copy-status {
  min-height: 18px;
  margin-top: 6px;
}

.pk-online-gate-close {
  width: 100%;
  min-height: 44px;
  margin-top: 20px;
  color: #fff;
  background: var(--primary);
  border: 0;
  border-radius: 6px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.pk-online-gate-close:hover {
  background: var(--primary-pressed);
}

.pk-online-gate-close:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

@keyframes pk-dialog-in {
  from {
    opacity: 0;
    filter: blur(5px);
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .summary-online-character,
  .pk-online-gate-dialog[open] {
    animation: none;
  }
}

.summary-center {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-center img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  filter: drop-shadow(0 6px 6px rgba(55, 96, 116, 0.18));
}

.summary-center span {
  position: absolute;
  bottom: 18px;
  left: 50%;
  width: max-content;
  padding: 3px 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 9px;
  font-weight: 800;
  transform: translateX(-50%);
}

.dimension-toolbar {
  margin: 0;
  padding: 12px 14px;
  gap: 7px;
  border-bottom: 0;
  background: var(--snow);
  scrollbar-width: none;
}

.dimension-toolbar::-webkit-scrollbar {
  display: none;
}

.dimension-toolbar > span {
  display: none;
}

.dimension-button {
  min-width: max-content;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  color: #617f90;
  background: #deeff6;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  box-shadow: inset 0 0 0 2px #badde9, inset 0 -5px 0 rgba(92, 161, 186, 0.1);
  font-size: 11px;
  font-weight: 800;
}

.dimension-button.is-active {
  border: 0;
  background: #31abd0;
  color: var(--white);
  box-shadow: inset 0 0 0 2px #167d9e, inset 0 -6px 0 rgba(21, 110, 141, 0.24);
}

.matchup-section {
  margin-top: 0;
  border-top: 1px solid var(--line);
}

.match-list-head {
  min-height: 42px;
  padding: 0;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  background: #21445b;
  color: var(--white);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  font-weight: 900;
}

.match-list-head span:first-child,
.match-list-head span:last-child {
  height: 100%;
  padding: 13px 16px;
}

.match-list-head span:first-child {
  background: #31abd0;
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 100%, 0 100%);
}

.match-list-head span:nth-child(2) {
  color: #d5e7ee;
  font-size: 9px;
  text-align: center;
}

.match-list-head span:last-child {
  background: var(--orange);
  text-align: right;
  clip-path: polygon(9px 0, 100% 0, 100% 100%, 0 100%);
}

.match-row {
  position: relative;
  min-height: 104px;
  padding: 0;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

.match-row:nth-child(2n) {
  background: #f8fcfe;
}

.match-player {
  position: relative;
  min-width: 0;
  height: 100%;
  padding: 12px 10px;
  justify-content: center;
}

.match-player.is-better {
  padding-top: 32px;
}

.player-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  margin-top: 3px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 9px;
}

.match-value {
  margin-top: 10px;
  color: #486778;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.match-player.side-a.is-better .match-value {
  color: #167d9e;
}

.match-player.side-b.is-better .match-value {
  color: #ce651d;
}

.lead-mark {
  position: absolute;
  top: 9px;
  margin: 0;
  padding: 2px 5px;
  color: var(--white);
  font-size: 8px;
  font-weight: 900;
  line-height: 1.4;
}

.match-player.side-a .lead-mark {
  left: 9px;
  background: #31abd0;
}

.match-player.side-b .lead-mark {
  right: 9px;
  background: var(--orange);
}

.match-rank {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5b7d8f;
  background: #e5f4f9;
  clip-path: polygon(25% 0, 75% 0, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0 75%, 0 25%);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
}

.match-rank::before,
.match-rank::after {
  position: absolute;
  left: 50%;
  width: 1px;
  height: 36px;
  margin: 0;
  background: var(--line);
  content: "";
  transform: translateX(-50%);
}

.match-rank::before {
  bottom: 100%;
}

.match-rank::after {
  top: 100%;
}

.analysis-block {
  margin: 16px 14px;
  border-color: var(--line-strong);
  background: var(--white);
}

.app-shell > footer {
  width: 100%;
  margin: auto 0 0;
  padding: 0 12px;
  flex-wrap: wrap;
  border-top-color: #d9eaf1;
}

.app-shell > footer span {
  display: inline;
}

.app-shell > footer .footer-contact {
  flex: 0 0 100%;
  color: #557887;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}

.human-check {
  font-family: "Noto Sans SC Local", "Microsoft YaHei", sans-serif;
}

.human-check .primary-button {
  background: #159fc6;
  box-shadow: 0 8px 20px rgba(21, 159, 198, 0.2);
}

.human-check .primary-button:active:not(:disabled) {
  background: #137e9e;
}

@media (max-width: 350px) {
  .result-stage {
    margin-right: -12px;
    margin-left: -12px;
  }

  .summary-grid {
    grid-template-columns: minmax(0, 1fr) 68px minmax(0, 1fr);
  }

  .summary-cell {
    padding-right: 9px;
    padding-left: 9px;
  }

  .summary-side-a .summary-online-gate {
    left: 9px;
  }

  .summary-side-b .summary-online-gate {
    right: 9px;
  }

  .summary-online-gate {
    min-height: 37px;
    padding-inline: 4px;
    font-size: 11px;
  }

  .summary-side > strong {
    font-size: 23px;
  }

  .summary-total {
    font-size: 16px;
  }

  .match-player {
    padding-right: 7px;
    padding-left: 7px;
  }

  .kingdom-input {
    padding-inline: 8px;
  }

  .kingdom-input small {
    font-size: 8px;
  }
}

@media (min-width: 431px) {
  .app-shell {
    padding: 0;
  }
}
