:root {
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ink: #fff;
  --ink-2: rgba(255, 255, 255, 0.68);
  --ink-3: rgba(255, 255, 255, 0.44);
  --hairline: rgba(255, 255, 255, 0.09);
  --surface: rgba(19, 27, 68, 0.74);
  --well: rgba(0, 0, 0, 0.26);

  --red-hi: #ff9393;
  --red: #f0384a;
  --red-lo: #b9182f;
  --red-rim: #850c20;
  --yellow-hi: #fff3ae;
  --yellow: #ffc92e;
  --yellow-lo: #e39c00;
  --yellow-rim: #a56a00;
  --gold-hi: #fff2c2;
  --gold: #ffd966;
  --gold-lo: #f4a21e;
  --board-hi: #4d88ff;
  --board: #2b5ef3;

  --spring: cubic-bezier(0.3, 1.35, 0.5, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.3, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #070b22;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
}

kbd {
  font: inherit;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Background ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: linear-gradient(#131c4b, #0a1032 55%, #05081c);
}

.backdrop > div {
  position: absolute;
  inset: 0;
  transition: opacity 0.9s ease-in-out;
}

.glow-board {
  background: radial-gradient(620px circle at 50% 12%, rgba(43, 94, 243, 0.3), transparent 70%);
}

.glow-human {
  background: radial-gradient(520px circle at 6% 55%, rgba(240, 56, 74, 0.3), transparent 70%);
  opacity: 0.28;
}

.glow-ai {
  background: radial-gradient(520px circle at 94% 55%, rgba(255, 201, 46, 0.22), transparent 70%);
  opacity: 0.28;
}

body[data-glow="human"] .glow-human,
body[data-glow="ai"] .glow-ai {
  opacity: 1;
}

.dots {
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 0.9px, transparent 1.2px);
  background-size: 26px 26px;
  background-position: 13px 13px;
  opacity: 0.5;
}

.vignette {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.45));
}

/* ---------- App shell ---------- */

.app {
  height: 100dvh;
  min-height: 700px;
  max-width: 1480px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(30px, env(safe-area-inset-right)) 16px max(30px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  filter: drop-shadow(0 4px 10px rgba(43, 94, 243, 0.5));
  flex: none;
}

.brand-text {
  display: grid;
  min-width: 0;
}

.brand-name {
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.round-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline);
}

.round-label {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.round-value {
  font-size: 15px;
  font-weight: 900;
  display: inline-block;
}

.round-draws {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
}

.round-draws[hidden] {
  display: none;
}

.round-draws i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-3);
}

.actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Buttons ---------- */

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
  color: #3b2400;
  white-space: nowrap;
  background: linear-gradient(#ffe586, #ffb524);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 4px 10px -2px rgba(255, 181, 36, 0.4);
  cursor: pointer;
  transition: transform 0.25s var(--spring), box-shadow 0.25s ease, filter 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.primary-button:hover {
  transform: scale(1.03);
  filter: brightness(1.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 6px 18px -2px rgba(255, 181, 36, 0.6);
}

.primary-button:active {
  transform: scale(0.95);
}

.button-icon {
  display: inline-flex;
  width: 13px;
  height: 13px;
}

.button-icon svg {
  width: 100%;
  height: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.2s var(--spring);
  -webkit-tap-highlight-color: transparent;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.icon-button:active {
  transform: scale(0.9);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button .swap {
  animation: icon-swap 0.32s var(--spring);
}

@keyframes icon-swap {
  from {
    transform: scale(0.4) rotate(-20deg);
    opacity: 0;
  }
}

:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.keycap {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.keycap.dark {
  color: rgba(59, 36, 0, 0.7);
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.12);
}

/* ---------- Arena ---------- */

.arena {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr) 238px;
  gap: 26px;
  align-items: center;
  min-height: 0;
  padding-top: 18px;
}

.stage {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.board-wrap {
  flex: 1 1 auto;
  min-height: 300px;
  width: 100%;
  container-type: size;
  display: grid;
  place-items: center;
}

.board-box {
  position: relative;
  width: min(100cqw, 100cqh * 762 / 820);
  aspect-ratio: 762 / 820;
  container-type: inline-size;
}

/* ---------- Discs drawn in CSS (avatars, tray, pickers) ---------- */

.chip {
  --hi: var(--red-hi);
  --base: var(--red);
  --lo: var(--red-lo);
  --rim: var(--red-rim);
  position: relative;
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, var(--hi), var(--base) 50%, var(--lo) 100%);
  box-shadow: inset 0.06em 0.06em 0 rgba(255, 255, 255, 0.35), inset -0.06em -0.06em 0 rgba(0, 0, 0, 0.2);
}

.chip.yellow {
  --hi: var(--yellow-hi);
  --base: var(--yellow);
  --lo: var(--yellow-lo);
  --rim: var(--yellow-rim);
}

.chip::after {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  box-shadow: inset 1px 1px 0 0 color-mix(in srgb, var(--rim) 70%, transparent),
    inset -1px -1px 0 0 color-mix(in srgb, var(--hi) 75%, transparent);
}

.chip::before {
  content: "";
  position: absolute;
  left: 14%;
  top: 6%;
  width: 54%;
  height: 32%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.5), transparent);
}

.chip.small {
  width: 14px;
  height: 14px;
}

/* ---------- Player cards ---------- */

.card {
  --tint: var(--red);
  position: relative;
  height: min(600px, 100%);
  padding: 20px 22px;
  border-radius: 26px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: scale(0.975);
  transition: transform 0.45s var(--spring), box-shadow 0.45s ease, border-color 0.45s ease, opacity 0.45s ease;
}

.card[data-disc="ai"] {
  --tint: var(--yellow);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(color-mix(in srgb, var(--tint) 14%, transparent), transparent 50%);
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}

.card[data-active="true"] {
  transform: none;
  border-color: color-mix(in srgb, var(--tint) 75%, transparent);
  box-shadow: 0 0 34px -6px color-mix(in srgb, var(--tint) 50%, transparent), 0 18px 40px -14px rgba(0, 0, 0, 0.5);
}

.card[data-active="true"]::before {
  opacity: 1;
}

.card[data-status="defeated"] {
  opacity: 0.72;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.avatar {
  --size: 72px;
  position: relative;
  width: var(--size);
  height: var(--size);
  flex: none;
  display: grid;
  place-items: center;
}

.avatar > * {
  grid-area: 1 / 1;
}

.avatar .chip {
  width: 80.5%;
  height: 80.5%;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), inset -2px -2px 0 rgba(0, 0, 0, 0.2),
    0 3px 12px -2px color-mix(in srgb, var(--base) 55%, transparent);
}

.avatar .glyph {
  width: 30%;
  height: 30%;
  color: #fff;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
  z-index: 1;
}

.card[data-disc="ai"] .avatar .glyph {
  color: rgba(94, 59, 0, 0.86);
}

.avatar-ring,
.avatar-spinner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.avatar-ring {
  border: 2px solid color-mix(in srgb, var(--tint) 75%, transparent);
}

.card[data-status="your-move"] .avatar-ring {
  opacity: 1;
  animation: ring-breathe 0.9s ease-in-out infinite alternate;
}

@keyframes ring-breathe {
  from {
    transform: scale(0.97);
    opacity: 1;
  }
  to {
    transform: scale(1.06);
    opacity: 0.35;
  }
}

.avatar-spinner {
  border: 2px solid color-mix(in srgb, var(--tint) 15%, transparent);
  border-top-color: var(--tint);
}

.card[data-status="thinking"] .avatar-spinner {
  opacity: 1;
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.avatar .crown {
  width: 25%;
  height: 25%;
  align-self: start;
  justify-self: end;
  margin: -6% -2% 0 0;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(255, 217, 102, 0.8));
  transform: rotate(-18deg) scale(0.2);
  transform-origin: bottom center;
  opacity: 0;
  transition: transform 0.45s var(--spring), opacity 0.3s ease;
  z-index: 2;
}

.card[data-status="winner"] .avatar .crown {
  transform: rotate(-18deg) scale(1);
  opacity: 1;
}

.who {
  min-width: 0;
}

.name {
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.name.long {
  font-size: 17px;
}

.caption {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
}

.status-pill {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  margin: 16px 0 0;
  padding: 0 13px 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--hairline);
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-3);
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  white-space: nowrap;
}

.card[data-active="true"] .status-pill,
.card[data-status="winner"] .status-pill {
  color: var(--ink);
  background: color-mix(in srgb, var(--tint) 16%, transparent);
  border-color: color-mix(in srgb, var(--tint) 35%, transparent);
}

.indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 18px;
  height: 10px;
}

.indicator i {
  display: none;
  width: 4.5px;
  height: 4.5px;
  border-radius: 50%;
  background: var(--tint);
}

.card[data-status="your-move"] .indicator i:first-child {
  display: block;
  width: 8px;
  height: 8px;
  animation: blink 0.7s ease-in-out infinite alternate;
}

.card[data-status="waiting"] .indicator i:first-child,
.card[data-status="defeated"] .indicator i:first-child {
  display: block;
  width: 7px;
  height: 7px;
  background: var(--ink-3);
}

.card[data-status="thinking"] .indicator i {
  display: block;
  animation: hop 0.9s ease-in-out infinite;
}

.card[data-status="thinking"] .indicator i:nth-child(2) {
  animation-delay: 0.14s;
}

.card[data-status="thinking"] .indicator i:nth-child(3) {
  animation-delay: 0.28s;
}

.indicator svg {
  display: none;
  width: 11px;
  height: 11px;
}

.card[data-status="winner"] .indicator .crown-icon {
  display: block;
  color: var(--gold);
}

.card[data-status="draw"] .indicator .equal-icon {
  display: block;
  color: var(--ink-3);
}

@keyframes blink {
  to {
    opacity: 0.35;
  }
}

@keyframes hop {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.spacer {
  flex: 1 1 auto;
  min-height: 12px;
}

.score {
  display: grid;
}

.wins {
  display: grid;
  justify-items: start;
  font-size: 50px;
  font-weight: 900;
  line-height: 1.05;
  transform-origin: 0 100%;
  overflow: hidden;
  padding-bottom: 2px;
}

.wins-value {
  grid-area: 1 / 1;
  background: linear-gradient(#fff, color-mix(in srgb, var(--tint) 90%, transparent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wins-label,
.section-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.tray {
  margin-top: 14px;
}

.tray-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 9px;
}

.tray-count {
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-2);
}

.tray-grid {
  display: grid;
  grid-template-columns: repeat(7, 18px);
  gap: 6px;
}

.slot {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.slot .chip {
  position: absolute;
  inset: 0;
  transition: transform 0.35s var(--spring), opacity 0.25s ease;
}

.slot.gone .chip {
  transform: scale(0.2);
  opacity: 0;
}

.card-foot {
  border-top: 1px solid var(--hairline);
  padding-top: 16px;
  display: grid;
  gap: 10px;
}

.note {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink-3);
}

/* ---------- Pickers ---------- */

.segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 999px;
  background: var(--well);
  border: 1px solid var(--hairline);
}

.segmented .thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transform: translateX(calc(var(--index, 0) * 100%));
  transition: transform 0.32s var(--spring);
}

.segmented button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.2s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.segmented button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.segmented button[aria-checked="true"] {
  color: var(--ink);
}

.segmented button .chip {
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.segmented button[aria-checked="true"] .chip {
  opacity: 1;
}

.levels {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 4px;
  border-radius: 16px;
  background: var(--well);
  border: 1px solid var(--hairline);
}

.levels .thumb {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 4px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid color-mix(in srgb, var(--yellow) 35%, transparent);
  transform: translateY(calc(var(--index, 0) * 36px));
  transition: transform 0.32s var(--spring);
}

.levels button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: color 0.2s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.levels button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.levels button[aria-checked="true"] {
  color: var(--ink);
}

.level-name {
  flex: 1;
}

.pips {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 13px;
}

.pips i {
  width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
  transition: background 0.2s ease;
}

.pips i:nth-child(1) {
  height: 6px;
}

.pips i:nth-child(2) {
  height: 9.5px;
}

.pips i:nth-child(3) {
  height: 13px;
}

.pips i.on {
  background: var(--ink-3);
}

.levels button[aria-checked="true"] .pips i.on {
  background: var(--yellow);
}

.levels .check {
  display: inline-flex;
  width: 12px;
  height: 12px;
  color: var(--yellow);
  transform: scale(0.4);
  opacity: 0;
  transition: transform 0.3s var(--spring), opacity 0.2s ease;
}

.levels .check svg {
  width: 100%;
  height: 100%;
}

.levels button[aria-checked="true"] .check {
  transform: none;
  opacity: 1;
}

/* ---------- Board ---------- */

.board-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}

.board-svg .hit {
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

.board-svg .lane-disc {
  transition: transform 0.26s var(--spring);
}

.board-svg .lane-disc.ai {
  transition: transform 0.42s cubic-bezier(0.3, 1.2, 0.5, 1);
}

.board-svg .lane-dim {
  transition: opacity 0.15s ease;
}

.board-svg .lane-dim.dimmed {
  opacity: 0.35;
}

.board-svg .column-glow {
  opacity: 0;
  mix-blend-mode: plus-lighter;
  transition: transform 0.26s cubic-bezier(0.3, 1.2, 0.5, 1), opacity 0.18s ease-out;
  pointer-events: none;
}

.board-svg .column-glow.shown {
  opacity: 1;
}

.board-svg .ghost use {
  animation: ghost-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes ghost-pulse {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 0.38;
  }
}

.board-svg .disc {
  transition: opacity 0.45s ease-in-out;
}

.board-svg .disc.dim {
  opacity: 0.4;
}

.board-svg .glint {
  fill: #fff;
  opacity: 0;
}

.board-svg .disc.win .glint {
  animation: glint 0.75s ease-in-out infinite alternate;
}

@keyframes glint {
  to {
    opacity: 0.16;
  }
}

.board-svg .ring-pulse {
  animation: ring-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes ring-pulse {
  from {
    transform: scale(0.98);
  }
  to {
    transform: scale(1.05);
  }
}

.board-svg .last-ring {
  opacity: 0;
}

.board-svg .last-ring.shown {
  opacity: 1;
  transition: opacity 0.25s ease;
}

/* ---------- Result banner ---------- */

.banner {
  position: absolute;
  top: 6.83%;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.95em;
  padding: 0.6em;
  padding-left: 0.65em;
  border-radius: 999px;
  font-size: clamp(10px, 2.35cqw, 15px);
  background: rgba(16, 23, 61, 0.94);
  border: 1.5px solid color-mix(in srgb, var(--banner-glow, #fff) 60%, transparent);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.45), 0 0 26px color-mix(in srgb, var(--banner-glow, #fff) 22%, transparent);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) translateY(-1.4em) scale(0.82);
  transition: opacity 0.25s ease, transform 0.5s var(--spring);
}

.banner.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.banner[data-outcome="win"] {
  --banner-glow: var(--gold);
}

.banner[data-outcome="loss"] {
  --banner-glow: var(--yellow);
}

.banner-badge {
  display: grid;
  place-items: center;
  width: 2.75em;
  height: 2.75em;
  border-radius: 50%;
  flex: none;
  color: #4a2e00;
  background: linear-gradient(var(--gold-hi), var(--gold-lo));
  box-shadow: 0 0 0.7em color-mix(in srgb, var(--banner-glow, #fff) 60%, transparent);
}

.banner[data-outcome="loss"] .banner-badge {
  background: linear-gradient(var(--yellow-hi), var(--yellow-lo));
}

.banner[data-outcome="draw"] .banner-badge {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.banner-badge svg {
  width: 45%;
  height: 45%;
}

.banner-text {
  display: grid;
  gap: 0.05em;
}

.banner-title {
  font-size: 1.45em;
  font-weight: 900;
  line-height: 1.1;
}

.banner-detail {
  font-size: 0.86em;
  font-weight: 700;
  color: var(--ink-2);
}

.banner .primary-button {
  height: 2.6em;
  padding: 0 1.15em;
  font-size: 1em;
  gap: 0.5em;
  margin-left: 0.6em;
}

.banner .button-icon {
  width: 0.85em;
  height: 0.85em;
}

/* ---------- Commentary ---------- */

.commentary {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(640px, 100%);
  min-height: 40px;
  margin: 0;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hairline);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.commentary-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--commentary-tint, var(--red));
  transition: color 0.3s ease;
}

.commentary-icon svg {
  width: 15px;
  height: 15px;
}

.commentary-text {
  display: grid;
  overflow: hidden;
  min-width: 0;
}

.commentary-text > span {
  grid-area: 1 / 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.commentary-text .entering {
  animation: line-in 0.26s var(--ease-out) 0.12s both;
}

.commentary-text .leaving {
  animation: line-out 0.12s ease-in both;
}

@keyframes line-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes line-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---------- Footer hints ---------- */

.hints {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding-top: 16px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hint .keycap + .keycap {
  margin-left: -3px;
}

.mobile-settings {
  display: none;
}

/* ---------- How to play ---------- */

.howto {
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px 30px 24px;
}

.howto h2 {
  margin: 0 0 24px;
  font-size: 26px;
  font-weight: 900;
  text-align: center;
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.howto article {
  padding: 22px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.howto-step {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
  color: #3b2400;
  background: linear-gradient(#ffe586, #ffb524);
}

.howto h3 {
  margin: 14px 0 6px;
  font-size: 17px;
  font-weight: 900;
}

.howto p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--ink-2);
}

.site-footer {
  padding: 20px 30px max(28px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
}

.site-footer p {
  margin: 0;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 14px 18px;
  border-radius: 14px;
  background: #b9182f;
  text-align: center;
}

/* ---------- Confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.confetti.running {
  opacity: 1;
}

/* ---------- Entrance ---------- */

body:not(.ready) .topbar,
body:not(.ready) .hints,
body:not(.ready) .commentary {
  opacity: 0;
}

body:not(.ready) #card-human {
  opacity: 0;
  translate: -40px 0;
}

body:not(.ready) #card-ai {
  opacity: 0;
  translate: 40px 0;
}

body:not(.ready) .board-box {
  opacity: 0;
  translate: 0 24px;
  scale: 0.94;
}

.topbar,
.hints,
.commentary,
#card-human,
#card-ai,
.board-box {
  transition-property: opacity, translate, scale, transform, box-shadow, border-color;
  transition-duration: 0.7s, 0.8s, 0.8s, 0.45s, 0.45s, 0.45s;
  transition-timing-function: ease, var(--spring), var(--spring), var(--spring), ease, ease;
}

/* ---------- Compact layout (tablets and phones) ---------- */

@media (max-width: 999px) {
  .app {
    height: auto;
    min-height: 0;
    padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    grid-template-rows: auto auto auto auto;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .round-badge {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    height: 28px;
  }

  .arena {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "human ai"
      "stage stage";
    gap: 10px;
    padding-top: 12px;
    align-items: stretch;
  }

  #card-human {
    grid-area: human;
  }

  #card-ai {
    grid-area: ai;
  }

  .stage {
    grid-area: stage;
    height: auto;
    gap: 10px;
  }

  .card {
    height: auto;
    padding: 12px 14px;
    border-radius: 20px;
    transform: none;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "avatar who score"
      "status status status";
    column-gap: 9px;
    row-gap: 8px;
    align-items: center;
  }

  .card-head {
    display: contents;
  }

  .avatar {
    --size: 40px;
    grid-area: avatar;
  }

  .who {
    grid-area: who;
  }

  .name,
  .name.long {
    font-size: 16px;
  }

  .caption {
    display: none;
  }

  .status-pill {
    grid-area: status;
    justify-self: stretch;
    margin: 0;
    height: 24px;
    padding: 0 9px 0 6px;
    font-size: 11.5px;
    gap: 5px;
  }

  .score {
    grid-area: score;
    justify-items: end;
  }

  .wins {
    font-size: 28px;
    justify-items: end;
    transform-origin: 100% 100%;
  }

  .wins-label {
    font-size: 8.5px;
    letter-spacing: 0.1em;
    text-align: right;
    margin-top: -2px;
  }

  .tray,
  .card-foot,
  .card .spacer {
    display: none;
  }

  .board-wrap {
    container-type: inline-size;
    min-height: 0;
    flex: none;
  }

  .board-box {
    width: min(100%, 560px);
    margin: 0 auto;
  }

  .commentary {
    max-width: 100%;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 18px;
  }

  .commentary-text > span {
    white-space: normal;
  }

  .mobile-settings {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-top: 14px;
  }

  .setting {
    display: grid;
    gap: 9px;
    align-content: start;
    padding: 14px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .hints {
    display: none;
  }

  .howto {
    padding-top: 40px;
  }

  .howto-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .brand-tag {
    display: none;
  }

  .brand-name {
    font-size: 20px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .actions {
    gap: 6px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .help-link {
    display: none;
  }

  #new-game-button {
    height: 34px;
    padding: 0 14px;
  }

  #new-game-button .keycap {
    display: none;
  }

  .mobile-settings {
    grid-template-columns: 1fr;
  }

  .howto h2 {
    font-size: 22px;
  }
}

@media (hover: none) {
  .hints,
  .keycap {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 404 ---------- */

.not-found {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.not-found img {
  border-radius: 22px;
  filter: drop-shadow(0 10px 24px rgba(43, 94, 243, 0.5));
}

.not-found h1 {
  margin: 10px 0 0;
  font-size: 30px;
  font-weight: 900;
}

.not-found p {
  margin: 0 0 8px;
  color: var(--ink-2);
}

.not-found .primary-button {
  text-decoration: none;
}
