:root {
  color-scheme: dark;
  --bg: #0d1222;
  --ink: #fff8ee;
  --muted: #b9c4d8;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(12, 21, 42, 0.94);
  --blue: #54c7ff;
  --store-blue: #1266ff;
  --yellow: #ffd166;
  --pink: #ff5ca8;
  --green: #5de49b;
  --dark-square: #25508f;
  --light-square: #e8eef8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 92, 168, 0.2), transparent 28%),
    radial-gradient(circle at 84% 12%, rgba(84, 199, 255, 0.24), transparent 30%),
    linear-gradient(155deg, #08122d 0%, #102b68 50%, #090f1f 100%);
  color: var(--ink);
  overscroll-behavior-x: none;
  touch-action: pan-y;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
}

.shell {
  position: relative;
  display: grid;
  left: var(--visual-viewport-offset-left, 0px);
  width: min(100%, var(--visual-viewport-width, 100%));
  max-width: 100%;
  height: 100svh;
  min-height: 100svh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  place-items: start center;
}

@supports (height: 100dvh) {
  .shell {
    height: 100dvh;
    min-height: 100dvh;
  }
}

.game {
  display: grid;
  grid-template-rows: repeat(6, auto);
  gap: clamp(3px, 0.65dvh, 6px);
  width: 100%;
  max-width: 520px;
  min-width: 0;
  overflow-x: hidden;
  min-height: min(100%, 920px);
  min-height: 0;
}

.brand-header {
  display: grid;
  place-items: center;
  min-height: clamp(30px, 4.8dvh, 42px);
  text-align: center;
}

.chess-logo {
  color: transparent;
  font-size: clamp(1.35rem, min(6.4dvw, 5dvh), 2.6rem);
  font-weight: 1000;
  line-height: 0.92;
  background: linear-gradient(90deg, #fff8ee 0%, #ffd166 35%, #54c7ff 72%, #ffffff 100%);
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 4px 0 rgba(5, 10, 24, 0.5)) drop-shadow(0 0 14px rgba(84, 199, 255, 0.3));
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-tag {
  margin-top: 2px;
  color: rgba(255, 248, 238, 0.76);
  font-size: clamp(0.58rem, min(2dvw, 1.5dvh), 0.78rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.opponent-card {
  position: relative;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 82px;
  padding: 5px 44px 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.opponent-clock {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(84, 199, 255, 0.95);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, rgba(18, 102, 255, 0.38) 48% 52%, transparent 53%),
    linear-gradient(transparent 47%, rgba(18, 102, 255, 0.38) 48% 52%, transparent 53%),
    #f8fafc;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.3);
}

.clock-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0b3c8c;
  transform: translate(-50%, -50%);
}

.clock-hand {
  position: absolute;
  left: calc(50% - 1px);
  bottom: 50%;
  width: 2px;
  height: 10px;
  border-radius: 2px;
  background: #1266ff;
  transform-origin: 50% 100%;
  animation: opponentClockSpin 12s linear infinite;
  animation-play-state: paused;
}

.opponent-clock.running .clock-hand {
  animation-play-state: running;
}

.opponent-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-card p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  position: relative;
  width: 70px;
  height: 73px;
}

.avatar.computer-portrait {
  overflow: hidden;
  border: 2px solid rgba(170, 222, 255, 0.72);
  border-radius: 14px;
  background-color: #f8fafc;
  background-image: url("../../assets/arcade/chesspunk-opponents.png");
  background-repeat: no-repeat;
  background-size: 1000% auto;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.avatar.computer-portrait::before {
  content: none;
}

.avatar.computer-portrait .hair,
.avatar.computer-portrait .head,
.avatar.computer-portrait .shoulders {
  display: none;
}

.avatar::before {
  content: "";
  position: absolute;
  left: 14px;
  top: -1px;
  width: 30px;
  height: 12px;
  border: 2px solid rgba(10, 16, 32, 0.78);
  border-radius: 10px 10px 4px 4px;
  background: #ffffff;
  z-index: 6;
}

.avatar .head {
  position: absolute;
  left: 11px;
  top: 8px;
  width: 36px;
  height: 38px;
  border: 2px solid rgba(10, 16, 32, 0.75);
  border-radius: 45% 45% 48% 48%;
  background: linear-gradient(145deg, #ffe0c2, #f1aa80);
  box-shadow: inset -5px -5px 0 rgba(150, 78, 52, 0.18), 0 6px 12px rgba(0, 0, 0, 0.26);
  z-index: 2;
}

.avatar .hair {
  position: absolute;
  left: 9px;
  top: 4px;
  width: 40px;
  height: 23px;
  border: 2px solid rgba(10, 16, 32, 0.8);
  border-radius: 48% 52% 35% 35%;
  background: linear-gradient(145deg, #8b552c, #4b2d19);
  z-index: 3;
}

.avatar.male .hair::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 18px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 214, 158, 0.16);
  transform: rotate(-18deg);
}

.avatar.female .hair {
  left: 5px;
  top: 1px;
  width: 48px;
  height: 39px;
  border-radius: 50% 50% 44% 44%;
  background: linear-gradient(145deg, #ffe68a, #d59b22);
  z-index: 1;
}

.avatar.female .hair::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: -14px;
  height: 25px;
  border: 2px solid rgba(10, 16, 32, 0.65);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  background: linear-gradient(145deg, #ffe68a, #c78316);
  z-index: -1;
}

.avatar.female .head {
  top: 10px;
  border-radius: 48% 48% 52% 52%;
  z-index: 3;
}

.avatar.female .eye,
.avatar.female .mouth {
  z-index: 4;
}

.avatar.female .eye {
  top: 16px;
  width: 6px;
  height: 6px;
  background: #263044;
}

.avatar.female .mouth {
  left: 11px;
  bottom: 6px;
  width: 14px;
  height: 7px;
  border-bottom: 2px solid #9b2e63;
}

.avatar.female .shoulders {
  background: linear-gradient(135deg, #ff7eb8, #7aa7ff);
}

.avatar .shoulders {
  position: absolute;
  left: 5px;
  bottom: 2px;
  width: 48px;
  height: 22px;
  border: 2px solid rgba(10, 16, 32, 0.72);
  border-radius: 24px 24px 10px 10px;
  background: linear-gradient(135deg, var(--blue), var(--store-blue));
  z-index: 1;
}

.avatar .eye {
  position: absolute;
  top: 17px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #111827;
}

.avatar .eye.left {
  left: 9px;
}

.avatar .eye.right {
  right: 9px;
}

.avatar .mouth {
  position: absolute;
  left: 12px;
  bottom: 6px;
  width: 12px;
  height: 6px;
  border-bottom: 2px solid #111827;
  border-radius: 0 0 12px 12px;
}

.avatar.opponent-1::before { left: 13px; top: 0; width: 31px; height: 10px; border-radius: 4px 4px 10px 10px; background: linear-gradient(135deg, #0f172a, #2563eb); }
.avatar.opponent-1 .hair { background: linear-gradient(145deg, #6b3f22, #2f1a0e); border-radius: 54% 46% 34% 44%; }
.avatar.opponent-1 .shoulders { background: linear-gradient(135deg, #1d4ed8, #38bdf8); }

.avatar.opponent-2::before { left: 15px; top: -2px; width: 28px; height: 13px; border-radius: 50% 50% 8px 8px; background: linear-gradient(135deg, #fef08a, #fb7185); }
.avatar.opponent-2 .hair { background: linear-gradient(145deg, #f9d566, #b97813); border-radius: 58% 42% 48% 40%; }
.avatar.opponent-2 .shoulders { background: linear-gradient(135deg, #fb7185, #fef08a); }

.avatar.opponent-3::before { left: 11px; top: 1px; width: 35px; height: 9px; border-radius: 12px 12px 3px 3px; background: linear-gradient(135deg, #14532d, #22c55e); }
.avatar.opponent-3 .hair { background: linear-gradient(145deg, #111827, #4b5563); border-radius: 45% 55% 38% 30%; }
.avatar.opponent-3 .shoulders { background: linear-gradient(135deg, #16a34a, #0f766e); }

.avatar.opponent-4::before { left: 18px; top: -4px; width: 22px; height: 15px; border-radius: 50% 50% 4px 4px; background: linear-gradient(135deg, #a855f7, #f472b6); }
.avatar.opponent-4 .hair { background: linear-gradient(145deg, #7c2d12, #f97316); border-radius: 46% 54% 40% 50%; }
.avatar.opponent-4 .shoulders { background: linear-gradient(135deg, #9333ea, #f472b6); }

.avatar.opponent-5::before { left: 12px; top: -2px; width: 34px; height: 12px; border-radius: 3px 3px 11px 11px; background: linear-gradient(135deg, #dc2626, #facc15); }
.avatar.opponent-5 .hair { background: linear-gradient(145deg, #4b2d19, #1f1309); border-radius: 60% 40% 32% 48%; }
.avatar.opponent-5 .shoulders { background: linear-gradient(135deg, #dc2626, #ea580c); }

.avatar.opponent-6::before { left: 14px; top: -1px; width: 30px; height: 12px; border-radius: 10px 3px 10px 3px; background: linear-gradient(135deg, #38bdf8, #0f766e); }
.avatar.opponent-6 .hair { background: linear-gradient(145deg, #ffe08a, #c2410c); border-radius: 52% 48% 46% 42%; }
.avatar.opponent-6 .shoulders { background: linear-gradient(135deg, #06b6d4, #14b8a6); }

.avatar.opponent-7::before { left: 15px; top: -3px; width: 29px; height: 15px; border-radius: 4px 14px 4px 14px; background: linear-gradient(135deg, #334155, #94a3b8); }
.avatar.opponent-7 .hair { background: linear-gradient(145deg, #9a3412, #431407); border-radius: 42% 58% 34% 44%; }
.avatar.opponent-7 .shoulders { background: linear-gradient(135deg, #475569, #0ea5e9); }

.avatar.opponent-8::before { left: 9px; top: 1px; width: 39px; height: 9px; border-radius: 20px 20px 5px 5px; background: linear-gradient(135deg, #f9a8d4, #60a5fa); }
.avatar.opponent-8 .hair { background: linear-gradient(145deg, #eab308, #854d0e); border-radius: 50% 50% 45% 45%; }
.avatar.opponent-8 .shoulders { background: linear-gradient(135deg, #f9a8d4, #818cf8); }

.avatar.opponent-9::before { left: 17px; top: -2px; width: 24px; height: 14px; border-radius: 9px 9px 2px 2px; background: linear-gradient(135deg, #111827, #f8fafc); }
.avatar.opponent-9 .hair { background: linear-gradient(145deg, #78350f, #292524); border-radius: 55% 45% 30% 36%; }
.avatar.opponent-9 .shoulders { background: linear-gradient(135deg, #111827, #64748b); }

.avatar.opponent-10::before { left: 13px; top: -3px; width: 32px; height: 14px; border-radius: 50% 50% 0 0; background: linear-gradient(135deg, #22d3ee, #2563eb); }
.avatar.opponent-10 .hair { background: linear-gradient(145deg, #facc15, #ca8a04); border-radius: 48% 52% 42% 48%; }
.avatar.opponent-10 .shoulders { background: linear-gradient(135deg, #2563eb, #22d3ee); }

.avatar.opponent-11::before { left: 10px; top: 0; width: 38px; height: 10px; border-radius: 2px 14px 2px 14px; background: linear-gradient(135deg, #7f1d1d, #f87171); }
.avatar.opponent-11 .hair { background: linear-gradient(145deg, #3f2a1d, #17120c); border-radius: 50% 50% 30% 46%; }
.avatar.opponent-11 .shoulders { background: linear-gradient(135deg, #991b1b, #f97316); }

.avatar.opponent-12::before { left: 17px; top: -4px; width: 24px; height: 16px; border-radius: 12px 12px 5px 5px; background: linear-gradient(135deg, #bef264, #16a34a); }
.avatar.opponent-12 .hair { background: linear-gradient(145deg, #fbbf24, #92400e); border-radius: 56% 44% 44% 52%; }
.avatar.opponent-12 .shoulders { background: linear-gradient(135deg, #84cc16, #22c55e); }

.avatar.opponent-13::before { left: 14px; top: -1px; width: 30px; height: 13px; border-radius: 4px 4px 14px 14px; background: linear-gradient(135deg, #312e81, #818cf8); }
.avatar.opponent-13 .hair { background: linear-gradient(145deg, #525252, #171717); border-radius: 44% 56% 38% 34%; }
.avatar.opponent-13 .shoulders { background: linear-gradient(135deg, #4338ca, #60a5fa); }

.avatar.opponent-14::before { left: 12px; top: 0; width: 34px; height: 11px; border-radius: 16px 16px 4px 4px; background: linear-gradient(135deg, #fb923c, #fde68a); }
.avatar.opponent-14 .hair { background: linear-gradient(145deg, #fef3c7, #d97706); border-radius: 50% 50% 42% 42%; }
.avatar.opponent-14 .shoulders { background: linear-gradient(135deg, #f97316, #facc15); }

.avatar.opponent-15::before { left: 16px; top: -3px; width: 26px; height: 15px; border-radius: 50% 12% 50% 12%; background: linear-gradient(135deg, #0f172a, #14b8a6); }
.avatar.opponent-15 .hair { background: linear-gradient(145deg, #451a03, #1c0a00); border-radius: 58% 42% 40% 30%; }
.avatar.opponent-15 .shoulders { background: linear-gradient(135deg, #0f766e, #0891b2); }

.avatar.opponent-16::before { left: 15px; top: -2px; width: 28px; height: 14px; border-radius: 7px 7px 12px 12px; background: linear-gradient(135deg, #e879f9, #7c3aed); }
.avatar.opponent-16 .hair { background: linear-gradient(145deg, #fde68a, #a16207); border-radius: 54% 46% 48% 38%; }
.avatar.opponent-16 .shoulders { background: linear-gradient(135deg, #a855f7, #e879f9); }

.avatar.opponent-17::before { left: 9px; top: 1px; width: 40px; height: 9px; border-radius: 4px 4px 18px 18px; background: linear-gradient(135deg, #064e3b, #34d399); }
.avatar.opponent-17 .hair { background: linear-gradient(145deg, #1f2937, #020617); border-radius: 48% 52% 28% 44%; }
.avatar.opponent-17 .shoulders { background: linear-gradient(135deg, #047857, #10b981); }

.avatar.opponent-18::before { left: 18px; top: -5px; width: 22px; height: 17px; border-radius: 50% 50% 8px 8px; background: linear-gradient(135deg, #fda4af, #be123c); }
.avatar.opponent-18 .hair { background: linear-gradient(145deg, #fcd34d, #b45309); border-radius: 52% 48% 50% 40%; }
.avatar.opponent-18 .shoulders { background: linear-gradient(135deg, #be123c, #fda4af); }

.avatar.opponent-19::before { left: 13px; top: -2px; width: 32px; height: 15px; border-radius: 3px 16px 3px 16px; background: linear-gradient(135deg, #1e293b, #38bdf8); }
.avatar.opponent-19 .hair { background: linear-gradient(145deg, #7c2d12, #292524); border-radius: 42% 58% 32% 48%; }
.avatar.opponent-19 .shoulders { background: linear-gradient(135deg, #0f172a, #2563eb); }

.avatar.opponent-20::before { left: 11px; top: -4px; width: 36px; height: 16px; border-radius: 16px 16px 3px 3px; background: linear-gradient(135deg, #f8fafc, #2563eb 48%, #facc15); }
.avatar.opponent-20 .hair { background: linear-gradient(145deg, #fde68a, #b7791f); border-radius: 50% 50% 46% 46%; }
.avatar.opponent-20 .shoulders { background: linear-gradient(135deg, #2563eb, #facc15); }

.avatar.thinking .eye {
  height: 3px;
  border-radius: 4px;
}

.avatar.thinking .mouth {
  left: 15px;
  width: 6px;
  height: 6px;
  border: 2px solid #111827;
  border-radius: 50%;
}

.avatar.thinking::after {
  content: "?";
  position: absolute;
  right: -2px;
  top: -6px;
  display: grid;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  place-items: center;
  background: var(--yellow);
  color: #111827;
  font-weight: 950;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.24);
  z-index: 4;
}

.topbar,
.bottombar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 10px;
}

.bottombar {
  grid-template-columns: repeat(5, 1fr);
}

.topbar {
  display: block;
}

.turn-moves {
  text-align: center;
}

.turn-moves span {
  color: var(--muted);
  font-size: clamp(0.82rem, 3.2dvw, 1rem);
  font-weight: 850;
}

.metric.turn-moves strong {
  display: inline;
  margin: 0;
  color: var(--ink);
  font-size: inherit;
}

.metric {
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.metric.center {
  text-align: center;
}

.metric.right {
  text-align: right;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  font-size: clamp(0.98rem, 3.5dvh, 1.45rem);
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-wrap {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: 24px auto 24px;
  gap: 2px;
  place-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  contain: inline-size;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    rgba(4, 10, 28, 0.8);
  background-size: 34px 34px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 18px 45px rgba(0, 0, 0, 0.3);
}

.captured-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  min-height: 22px;
  padding: 1px 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(216, 231, 248, 0.9);
}

.captured-row .captured-label {
  color: #243854;
}

.captured-row .captured-empty {
  color: #50647f;
}

.captured-row.bottom {
  justify-content: flex-start;
}

.captured-row.top {
  justify-content: flex-start;
}

.captured-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.captured-empty {
  color: rgba(255, 248, 238, 0.44);
  font-size: 0.72rem;
  font-weight: 800;
}

.captured-group {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.captured-group .captured-piece + .captured-piece {
  margin-left: -10px;
}

.captured-group .captured-piece {
  position: relative;
}

.captured-group .captured-piece:nth-child(1) { z-index: 1; }
.captured-group .captured-piece:nth-child(2) { z-index: 2; }
.captured-group .captured-piece:nth-child(3) { z-index: 3; }
.captured-group .captured-piece:nth-child(4) { z-index: 4; }
.captured-group .captured-piece:nth-child(5) { z-index: 5; }
.captured-group .captured-piece:nth-child(6) { z-index: 6; }
.captured-group .captured-piece:nth-child(7) { z-index: 7; }
.captured-group .captured-piece:nth-child(8) { z-index: 8; }

.material-score {
  flex: 0 0 auto;
  min-width: 30px;
  margin-left: auto;
  color: #0b3c8c;
  font-size: 0.78rem;
  font-weight: 1000;
  text-align: right;
}

.captured-piece {
  display: inline-grid;
  width: 20px;
  height: 24px;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 950;
  line-height: 1;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55),
    0 3px 0 rgba(83, 58, 22, 0.42),
    0 7px 10px rgba(0, 0, 0, 0.34);
  -webkit-text-stroke: 1px rgba(96, 70, 32, 0.5);
}

.captured-piece.white {
  color: #fff6d8;
}

.captured-piece.black {
  color: #05070b;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18),
    0 3px 0 rgba(0, 0, 0, 0.72),
    0 7px 10px rgba(0, 0, 0, 0.5);
  -webkit-text-stroke: 1px rgba(237, 232, 218, 0.22);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
  touch-action: none;
  transition: none;
}

.square {
  position: relative;
  z-index: 2;
  display: grid;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  place-items: center;
  cursor: pointer;
  font-size: clamp(1.65rem, 10dvw, 3.25rem);
  line-height: 1;
  overflow: hidden;
  touch-action: none;
}

.watermark-letter {
  position: relative;
  z-index: 3;
  color: rgba(7, 17, 40, 0.18);
  font-size: clamp(1.75rem, 10.5dvw, 3.4rem);
  font-weight: 1000;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
  text-transform: uppercase;
}

.coordinate {
  position: absolute;
  z-index: 7;
  left: 3px;
  color: rgba(7, 17, 40, 0.8);
  font-size: clamp(0.48rem, 1.9dvw, 0.68rem);
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
  text-transform: lowercase;
}

.rank-coordinate {
  top: 3px;
}

.file-coordinate {
  bottom: 3px;
}

.square.dark .coordinate {
  color: rgba(255, 255, 255, 0.86);
}

.square.light {
  background: var(--light-square);
}

.square.dark {
  background: var(--dark-square);
}

.square.selected {
  box-shadow: inset 0 0 0 5px var(--yellow);
}

.square.last {
  box-shadow: inset 0 0 0 4px rgba(255, 209, 102, 0.52);
}

.square.check {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 92, 104, 0.82), rgba(255, 209, 102, 0.46) 42%, transparent 72%),
    var(--light-square);
  box-shadow: inset 0 0 0 5px rgba(255, 64, 88, 0.88), 0 0 22px rgba(255, 64, 88, 0.58);
}

.square.dark.check {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 92, 104, 0.82), rgba(255, 209, 102, 0.42) 42%, transparent 72%),
    var(--dark-square);
}

.square.legal::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(18, 102, 255, 0.42);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.square.capture::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 12%;
  border: 4px solid rgba(255, 92, 168, 0.72);
  border-radius: 50%;
}

.piece {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  place-items: center;
  font-size: clamp(2rem, 10.5dvw, 3.55rem);
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", "Arial Unicode MS", serif;
  font-weight: 950;
  transform: none;
  text-shadow:
    -1px -1px 0 #fffdf0,
    1px 1px 0 #b68d4d,
    2px 3px 0 #8f672e,
    4px 7px 8px rgba(34, 20, 6, 0.42),
    0 13px 16px rgba(0, 0, 0, 0.32);
  -webkit-text-stroke: 1.1px rgba(94, 67, 30, 0.5);
}

.piece.white {
  color: #fff6d8;
}

.piece.black {
  color: #05070b;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.28),
    1px 1px 0 #4a4f5a,
    2px 3px 0 #000,
    4px 7px 8px rgba(0, 0, 0, 0.62),
    0 13px 16px rgba(0, 0, 0, 0.44);
  -webkit-text-stroke: 1.1px rgba(237, 232, 218, 0.18);
}

.piece.piece-p,
.piece.piece-bp,
.piece.piece-wp {
  font-size: clamp(2rem, 10.5dvw, 3.55rem);
  line-height: 1;
  transform: none;
}

.piece.black.piece-p,
.piece.piece-bp {
  font-size: clamp(2rem, 10.5dvw, 3.55rem);
  transform: none;
}

.capture-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.flying-piece {
  position: absolute;
  display: grid;
  width: var(--piece-size);
  height: var(--piece-size);
  border: 0;
  border-radius: 0;
  place-items: center;
  color: #fff6d8;
  background: transparent;
  box-shadow: none;
  font-size: calc(var(--piece-size) * 0.82);
  font-weight: 950;
  transform: translate(-50%, -50%);
  animation: captureDrop 760ms cubic-bezier(0.2, 0.72, 0.28, 1) forwards;
  text-shadow:
    -1px -1px 0 #fffdf0,
    1px 1px 0 #b68d4d,
    2px 3px 0 #8f672e,
    4px 7px 8px rgba(34, 20, 6, 0.42);
  -webkit-text-stroke: 1px rgba(96, 70, 32, 0.54);
}

.moving-piece {
  position: absolute;
  display: grid;
  width: var(--piece-size);
  height: var(--piece-size);
  place-items: center;
  color: #fff6d8;
  font-size: calc(var(--piece-size) * 0.82);
  font-weight: 950;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: movePiece 780ms cubic-bezier(0.2, 0.72, 0.28, 1) forwards;
  text-shadow:
    -1px -1px 0 #fffdf0,
    1px 1px 0 #b68d4d,
    2px 3px 0 #8f672e,
    4px 7px 8px rgba(34, 20, 6, 0.42);
  -webkit-text-stroke: 1px rgba(96, 70, 32, 0.54);
}

.flying-piece.black {
  color: #05070b;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.28),
    1px 1px 0 #4a4f5a,
    2px 3px 0 #000,
    4px 7px 8px rgba(0, 0, 0, 0.62);
  -webkit-text-stroke: 1px rgba(237, 232, 218, 0.18);
}

.moving-piece.black {
  color: #05070b;
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.28),
    1px 1px 0 #4a4f5a,
    2px 3px 0 #000,
    4px 7px 8px rgba(0, 0, 0, 0.62);
  -webkit-text-stroke: 1px rgba(237, 232, 218, 0.18);
}
.piece-animation-hidden {
  visibility: hidden;
}

.pawn-capture-attacker {
  z-index: 8;
  animation: pawnCaptureSlam var(--pawn-attack-duration, 900ms)
    cubic-bezier(0.2, 0.78, 0.28, 1) forwards;
}

.pawn-capture-victim {
  z-index: 7;
  transform-origin: 50% 82%;
  animation: pawnCaptureTopple var(--pawn-capture-duration, 1260ms)
    cubic-bezier(0.22, 0.68, 0.28, 1) forwards;
}
.bishop-capture-attacker {
  z-index: 8;
  animation: movePiece var(--bishop-move-duration, 600ms)
    cubic-bezier(0.16, 0.76, 0.24, 1) forwards;
}

.bishop-capture-victim {
  z-index: 7;
  animation: bishopCaptureKnock var(--bishop-capture-duration, 1320ms)
    cubic-bezier(0.2, 0.68, 0.24, 1) forwards;
  will-change: filter, transform;
}

.bishop-lightning-strike {
  position: absolute;
  z-index: 10;
  width: var(--bolt-width, 24px);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) rotate(var(--bolt-tilt, 0deg));
  transform-origin: 50% 0;
  clip-path: polygon(
    42% 0,
    72% 0,
    57% 24%,
    78% 24%,
    48% 51%,
    69% 51%,
    30% 100%,
    43% 62%,
    22% 62%,
    48% 34%,
    29% 34%
  );
  background: linear-gradient(90deg, #37b7ff 0 18%, #f8ffff 38% 62%, #68e7ff 82% 100%);
  filter:
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.98))
    drop-shadow(0 0 8px rgba(70, 213, 255, 0.96))
    drop-shadow(0 0 15px rgba(30, 121, 255, 0.82));
  mix-blend-mode: screen;
  animation: bishopLightningStrike var(--strike-duration, 170ms)
    steps(2, end) var(--strike-delay, 0ms) both;
}
.knight-capture-attacker {
  z-index: 8;
  transform-origin: 50% 82%;
  animation: knightCaptureLeap var(--knight-attack-duration, 1500ms)
    cubic-bezier(0.18, 0.72, 0.24, 1) forwards;
}

.knight-capture-victim {
  z-index: 7;
  animation: knightVictimRicochet var(--knight-capture-duration, 3100ms)
    cubic-bezier(0.18, 0.66, 0.24, 1) forwards;
  will-change: transform;
}

.knight-dust-cloud {
  position: absolute;
  z-index: 9;
  width: var(--dust-size, 72px);
  height: var(--dust-height, 42px);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.25);
  background:
    radial-gradient(circle at 18% 68%, rgba(226, 202, 158, 0.88) 0 18%, transparent 38%),
    radial-gradient(circle at 38% 42%, rgba(244, 224, 184, 0.9) 0 20%, transparent 42%),
    radial-gradient(circle at 61% 56%, rgba(205, 180, 137, 0.86) 0 23%, transparent 46%),
    radial-gradient(circle at 82% 70%, rgba(235, 214, 174, 0.82) 0 18%, transparent 39%);
  filter: blur(0.45px);
  animation: knightDustDissipate var(--dust-duration, 1750ms) ease-out forwards;
}

.piece,
.moving-piece,
.flying-piece,
.captured-piece {
  color: transparent !important;
  background-color: transparent;
  background-image: var(--piece-image);
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: var(--piece-width, 98%) var(--piece-height, 98%);
  text-shadow: none !important;
  -webkit-text-stroke: 0 !important;
}

.piece-k,
.piece-q,
.piece-b,
.piece-n,
.piece-r,
.piece-p {
  --piece-width: 98%;
  --piece-height: 98%;
}

.captured-piece {
  background-size: contain;
}

.smoke-poof {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--smoke-size);
  height: var(--smoke-size);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.45);
  animation: smokePoof 430ms ease-out forwards;
  background:
    radial-gradient(circle at 30% 38%, rgba(255, 255, 255, 0.9) 0 18%, transparent 19%),
    radial-gradient(circle at 62% 36%, rgba(226, 234, 246, 0.86) 0 22%, transparent 23%),
    radial-gradient(circle at 48% 66%, rgba(180, 194, 216, 0.68) 0 24%, transparent 25%);
}

.move-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

#moveList {
  display: flex;
  flex: 1 1 0;
  gap: 12px;
  min-width: 0;
  width: 0;
  min-height: 0;
  margin: 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
  list-style: none;
  scrollbar-width: thin;
  white-space: nowrap;
}

#moveList li {
  flex: 0 0 auto;
}

.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  color: var(--yellow);
  font-size: 1.35rem;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.toast.pop {
  animation: toastPop 760ms ease-out;
}

.small-button,
.primary-button,
.secondary-button,
.arcade-button,
.store-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 950;
  min-height: 46px;
}

.small-button {
  padding: 0 10px;
  background: var(--yellow);
  color: #121827;
}

.bottombar .small-button {
  min-height: 40px;
  padding-inline: 7px;
}

#undoButton,
#newButton,
#concedeButton {
  background: var(--blue);
  color: #081122;
  box-shadow: 0 8px 20px rgba(84, 199, 255, 0.22);
}

.icon-button {
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
}

.primary-button,
.secondary-button,
.arcade-button,
.store-button {
  width: 100%;
  margin-top: 12px;
  padding: 0 18px;
}

.primary-button {
  background: var(--blue);
  color: #081122;
}

.secondary-button {
  background: var(--yellow);
  color: #121827;
}

.arcade-button {
  background: #ffffff;
  color: #0d1222;
}

.store-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.thing-button {
  border-color: rgba(84, 199, 255, 0.62);
  background: rgba(84, 199, 255, 0.18);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 7, 14, 0.68);
  backdrop-filter: blur(10px);
}

.overlay.show {
  display: flex;
}

.panel {
  width: min(100%, 380px);
  max-height: calc(100svh - 28px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(18, 102, 255, 0.22), rgba(255, 92, 168, 0.08)),
    var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
}

@supports (height: 100dvh) {
  .panel {
    max-height: calc(100dvh - 28px);
  }
}

.kicker {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 8dvw, 3.25rem);
  line-height: 0.94;
}

.panel p:not(.kicker) {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.setup-controls {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.setup-controls label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.setup-controls select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 42px 0 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #101827;
  font: inherit;
  font-size: 16px;
  font-weight: 850;
  appearance: none;
  -webkit-appearance: none;
}

.select-control {
  position: relative;
  display: block;
}

.select-control::before,
.select-control::after {
  content: "";
  position: absolute;
  right: 15px;
  z-index: 2;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  pointer-events: none;
}

.select-control::before {
  top: 12px;
  border-bottom: 7px solid #1266ff;
}

.select-control::after {
  bottom: 12px;
  border-top: 7px solid #1266ff;
}

.select-control select:disabled {
  opacity: 0.68;
}

.color-picker {
  min-width: 0;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
}

.color-picker legend {
  margin-bottom: 8px;
  padding: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.color-option {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 950;
}

.color-option.selected {
  border-color: var(--yellow);
  background: rgba(255, 209, 102, 0.18);
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.18);
}

.color-option:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.color-king {
  width: 42px;
  height: 48px;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  background-size: contain;
}

.black-king {
  background-image: url("../../assets/arcade/chesspunk-pieces/black-king.png?v=20260718-chesspunk-initial-copy");
}

.white-king {
  background-image: url("../../assets/arcade/chesspunk-pieces/white-king.png?v=20260718-chesspunk-initial-copy");
}

.win-form {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.win-form[hidden] {
  display: none !important;
}

.win-form label,
.recent-wins h2 {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.win-fields {
  display: grid;
  gap: 8px;
}

.win-fields input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.92);
  color: #101827;
  font: inherit;
  font-weight: 950;
}

#winnerInitials {
  text-transform: uppercase;
}

.win-prompt {
  margin: 0;
  color: var(--yellow);
  font-weight: 850;
}

.recent-wins {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.recent-wins h2 {
  margin: 0 0 8px;
}

.recent-wins ol {
  max-height: 126px;
  margin: 0;
  padding-left: 24px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.recent-wins li {
  margin: 3px 0;
}

@keyframes toastPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.78);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -90%) scale(1);
  }
}

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

@keyframes captureDrop {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.92);
  }
  18% {
    transform: translate(-50%, calc(-50% - 42px)) scale(1.12);
  }
  72% {
    opacity: 1;
    transform: translate(calc(var(--dx) - 50%), calc(var(--dy) - 50% - 12px)) scale(0.72) rotate(8deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%)) scale(0.52) rotate(0deg);
  }
}

@keyframes movePiece {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  42% {
    transform: translate(calc(var(--dx) * 0.48 - 50%), calc(var(--dy) * 0.48 - 50% - 18px)) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%)) scale(1);
  }
}

@keyframes smokePoof {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

@keyframes pawnCaptureSlam {
  0%,
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  28%,
  34% {
    opacity: 1;
    transform:
      translate(calc(var(--recoil-x) - 50%), calc(var(--recoil-y) - 50%))
      scale(1.04)
      rotate(var(--rear-tilt));
  }
  50% {
    opacity: 1;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(1.12)
      rotate(var(--slam-tilt));
  }
  68%,
  96% {
    opacity: 1;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(1)
      rotate(0deg);
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(1)
      rotate(0deg);
  }
}

@keyframes pawnCaptureTopple {
  0%,
  13% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  17% {
    opacity: 1;
    transform: translate(calc(-50% + var(--fall-x-small)), calc(-50% + 3px)) scale(1) rotate(var(--fall-angle-small));
  }
  24%,
  85% {
    opacity: 1;
    transform: translate(calc(-50% + var(--fall-x)), calc(-50% + 10px)) scale(0.96) rotate(var(--fall-angle));
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(0.48)
      rotate(var(--fall-angle));
  }
}
@keyframes bishopLightningStrike {
  0% {
    opacity: 0;
    transform: translateX(-50%) rotate(var(--bolt-tilt, 0deg)) scaleX(0.72) scaleY(0.82);
  }
  18% {
    opacity: 1;
    transform: translateX(-50%) rotate(var(--bolt-tilt, 0deg)) scaleX(1.12) scaleY(1);
  }
  42% {
    opacity: 0.34;
  }
  62% {
    opacity: 1;
    transform: translateX(-50%) rotate(var(--bolt-tilt, 0deg)) scaleX(0.88) scaleY(1.02);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) rotate(var(--bolt-tilt, 0deg)) scaleX(1.08) scaleY(1);
  }
}

@keyframes bishopCaptureKnock {
  0%,
  6%,
  17%,
  21%,
  32%,
  36%,
  53% {
    opacity: 1;
    filter: none;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  10%,
  14% {
    opacity: 1;
    filter:
      drop-shadow(0 0 2px #fff)
      drop-shadow(0 0 7px #64e7ff)
      drop-shadow(0 0 15px #218cff);
    transform: translate(calc(-50% - 2px), calc(-50% + 1px)) scale(1.03) rotate(-2deg);
  }
  25%,
  29% {
    opacity: 1;
    filter:
      drop-shadow(0 0 2px #fff)
      drop-shadow(0 0 8px #64e7ff)
      drop-shadow(0 0 17px #218cff);
    transform: translate(calc(-50% + 2px), calc(-50% - 1px)) scale(1.04) rotate(2deg);
  }
  41%,
  48% {
    opacity: 1;
    filter:
      drop-shadow(0 0 3px #fff)
      drop-shadow(0 0 10px #71efff)
      drop-shadow(0 0 20px #167dff);
    transform: translate(calc(-50% - 2px), calc(-50% - 2px)) scale(1.07) rotate(-3deg);
  }
  60% {
    opacity: 1;
    filter:
      drop-shadow(0 0 3px #fff)
      drop-shadow(0 0 8px #64e7ff)
      drop-shadow(0 0 16px #218cff);
    transform: translate(-50%, calc(-50% - 18px)) scale(1.12) rotate(-7deg);
  }
  70% {
    opacity: 1;
    filter: none;
    transform: translate(-50%, calc(-50% - 24px)) scale(0.94) rotate(14deg);
  }
  100% {
    opacity: 0;
    filter: none;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(0.48)
      rotate(38deg);
  }
}
@keyframes knightCaptureLeap {
  0%,
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  24%,
  34% {
    opacity: 1;
    transform:
      translate(calc(var(--recoil-x) - 50%), calc(var(--recoil-y) - 50%))
      scale(1.07)
      rotate(var(--rear-tilt));
  }
  55% {
    opacity: 1;
    transform:
      translate(calc(var(--mid-dx) - 50%), calc(var(--mid-dy) - 50%))
      scale(1.12)
      rotate(var(--jump-tilt));
  }
  72% {
    opacity: 1;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--over-y) - 50%))
      scale(1.08)
      rotate(var(--down-tilt));
  }
  82% {
    opacity: 1;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(1.16, 0.9)
      rotate(0deg);
  }
  92% {
    opacity: 1;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(0.97, 1.03)
      rotate(0deg);
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(1)
      rotate(0deg);
  }
}

@keyframes knightVictimRicochet {
  0%,
  39% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  45% {
    opacity: 1;
    transform: translate(-50%, calc(-50% - 18px)) scale(1.1) rotate(24deg);
  }
  56% {
    opacity: 1;
    transform:
      translate(calc(var(--bounce-one-x) - 50%), calc(var(--bounce-one-y) - 50%))
      scale(0.92)
      rotate(138deg);
  }
  60% {
    opacity: 1;
    transform:
      translate(calc(var(--bounce-one-x) - 50%), calc(var(--bounce-one-y) - 50%))
      scale(1.04)
      rotate(172deg);
  }
  73% {
    opacity: 1;
    transform:
      translate(calc(var(--bounce-two-x) - 50%), calc(var(--bounce-two-y) - 50%))
      scale(0.9)
      rotate(308deg);
  }
  77% {
    opacity: 1;
    transform:
      translate(calc(var(--bounce-two-x) - 50%), calc(var(--bounce-two-y) - 50%))
      scale(1.02)
      rotate(342deg);
  }
  100% {
    opacity: 0;
    transform:
      translate(calc(var(--dx) - 50%), calc(var(--dy) - 50%))
      scale(0.48)
      rotate(540deg);
  }
}

@keyframes knightDustDissipate {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.25);
  }
  12% {
    opacity: 0.96;
    transform: translate(-50%, -50%) scale(0.78);
  }
  36% {
    opacity: 0.78;
    transform: translate(-50%, calc(-50% - 2px)) scale(1.08);
  }
  70% {
    opacity: 0.36;
    transform: translate(-50%, calc(-50% - 9px)) scale(1.38);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 16px)) scale(1.72);
  }
}
@media (max-height: 700px) {
  .shell {
    padding: max(5px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right))
      max(5px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .game {
    min-height: 0;
    grid-template-rows: repeat(6, auto);
  }

  .brand-header {
    min-height: 30px;
  }

  .chess-logo {
    font-size: clamp(1.15rem, 4.7dvh, 1.8rem);
  }

  .site-tag {
    display: none;
  }

  .metric {
    padding: 5px 7px;
  }

  .metric-label {
    font-size: 0.62rem;
  }

  .metric strong {
    font-size: 0.94rem;
  }

  .opponent-card {
    grid-template-columns: 62px minmax(0, 1fr);
    min-height: 66px;
    gap: 8px;
  }

  .avatar {
    width: 56px;
    height: 58px;
    transform: none;
  }

  .move-panel {
    padding: 7px;
    font-size: 0.82rem;
  }

  #moveList {
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .small-button {
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.78rem;
  }

  .overlay {
    align-items: flex-start;
    padding: 8px;
  }

  .panel {
    width: min(100%, 390px);
    max-height: calc(100svh - 16px);
    padding: 12px;
  }

  h1 {
    font-size: clamp(1.55rem, 6.8dvw, 2.25rem);
  }

  .panel p:not(.kicker) {
    margin-top: 8px;
    line-height: 1.28;
  }

  .setup-controls,
  .win-form,
  .recent-wins {
    margin-top: 10px;
  }

  .setup-controls select,
  .win-fields input {
    min-height: 38px;
  }

  .recent-wins ol {
    max-height: 72px;
    font-size: 0.78rem;
  }

  .primary-button,
  .secondary-button,
  .arcade-button,
  .store-button {
    min-height: 38px;
    margin-top: 7px;
  }
}
.arcade-store-arcade-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.22em;
  width: 100%;
  margin: 0 0 14px;
  border: 2px solid #1266ff;
  background: #ffffff;
  color: #071225;
  box-shadow: 0 0 0 2px rgba(18, 102, 255, 0.16), 0 8px 20px rgba(18, 102, 255, 0.2);
  text-transform: none;
}

.arcade-store-arcade-button span:nth-child(2) {
  color: #1266ff;
  text-transform: uppercase;
}

.arcade-store-arcade-button:hover,
.arcade-store-arcade-button:focus-visible {
  background: #ffffff;
  color: #071225;
  outline: 3px solid rgba(84, 199, 255, 0.55);
  outline-offset: 3px;
}
/* Shared 3D arcade button polish. */
.arcade-store-arcade-button {
  gap: 0;
  border: 2px solid #1266ff;
  background: linear-gradient(180deg, #ffffff 0%, #f2f8ff 44%, #d4e8ff 100%);
  color: #071225;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.95), inset 0 -4px 0 rgba(18,102,255,.2), 0 8px 20px rgba(18,102,255,.22);
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
}

.arcade-store-arcade-button .bleep-blue,
.arcade-store-arcade-button span:nth-child(2) {
  color: #1266ff;
  text-transform: uppercase;
}

.arcade-store-arcade-button:hover,
.arcade-store-arcade-button:focus-visible {
  background: linear-gradient(180deg, #ffffff 0%, #eaf4ff 42%, #bfdcff 100%);
  color: #071225;
  outline: 3px solid rgba(84,199,255,.58);
  outline-offset: 3px;
}

.primary-button {
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue, #54c7ff) 34%, #fff) 0%, var(--blue, #54c7ff) 52%, color-mix(in srgb, var(--blue, #54c7ff) 72%, #071225) 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.42), inset 0 -4px 0 rgba(5,10,24,.22), 0 8px 18px rgba(0,0,0,.26);
}

.secondary-button,
.small-button {
  background: linear-gradient(180deg, color-mix(in srgb, var(--yellow, #ffd166) 34%, #fff) 0%, var(--yellow, #ffd166) 54%, color-mix(in srgb, var(--yellow, #ffd166) 72%, #8a5a00) 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.48), inset 0 -4px 0 rgba(89,51,0,.22), 0 7px 16px rgba(0,0,0,.24);
}

.store-button,
.buy-button {
  background: linear-gradient(180deg, rgba(255,255,255,.2) 0%, rgba(255,255,255,.1) 50%, rgba(5,10,24,.22) 100%);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.2), inset 0 -4px 0 rgba(5,10,24,.22), 0 7px 16px rgba(0,0,0,.22);
}
/* Compact high-score entry row: Initials, City, Save. */
.score-form {
  display: grid;
  grid-template-columns: minmax(4.2rem, 4.9rem) minmax(0, 1fr) auto;
  gap: 6px 8px;
  align-items: end;
}

.score-form label[for="initialsInput"] {
  grid-column: 1;
  grid-row: 1;
}

.score-form label[for="cityInput"] {
  grid-column: 2;
  grid-row: 1;
}

.initials-row {
  display: contents;
}

.initials-row input,
#initialsInput {
  grid-column: 1;
  grid-row: 2;
  width: 4.8rem;
  min-width: 0;
  text-align: center;
}

.city-input,
#cityInput {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
}

.initials-row button,
.score-form button[type="submit"] {
  grid-column: 3;
  grid-row: 2;
  min-width: 4.1rem;
  padding-inline: 10px;
}

.score-form datalist {
  display: none;
}

.score-form .high-score,
#highScoreText {
  grid-column: 1 / -1;
}
/* Keep the Arcade return button visible on initials/end-game overlays. */
.overlay {
  align-items: flex-start !important;
  overflow: auto !important;
  padding-top: max(10px, env(safe-area-inset-top)) !important;
  padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
}

.panel {
  max-height: calc(100dvh - 20px) !important;
}

.arcade-store-arcade-button {
  position: sticky;
  top: 0;
  z-index: 5;
}
