:root {
  color-scheme: dark;
  --paper: #fff2d5;
  --muted: #b9cfc0;
  --gold: #ffcd73;
  --gold-dark: #31200f;
  --panel: #18392e;
  --stroke: #42614b;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f2922;
  color: var(--paper);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -10%, #335440 0, transparent 59%),
    radial-gradient(ellipse at 18% 95%, #183830 0, transparent 56%), #102720;
}
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .66; }
a { color: inherit; }
:focus-visible { outline: 3px solid #ffe3a1; outline-offset: 3px; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.topbar svg, .arena-hud svg, .side svg:not(.avatar), .dialog-inner svg {
  width: 1.18em;
  height: 1.18em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.shell { width: min(100%, 1330px); margin-inline: auto; padding: 0 clamp(14px, 3.3vw, 46px) 30px; }
.topbar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #a7bb932e; }
.home-link, .utility, .side-foot a { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-weight: 750; white-space: nowrap; }
.home-link { min-height: 44px; color: #f2dbac; }
.home-link:hover, .side-foot a:hover { color: #fff4d9; text-decoration: underline; }
.top-actions { display: flex; gap: 7px; }
.utility {
  justify-content: center;
  min-height: 44px;
  color: #edf0d6;
  background: #153227;
  border: 1px solid #59735a;
  border-radius: 11px;
  padding: 6px 11px;
  font-size: .88rem;
}
.utility:hover, .secondary:hover { background: #2d5140; }
.heading { padding: 25px 0 23px; }
.eyebrow { margin: 0; color: var(--gold); font-size: .68rem; font-weight: 850; letter-spacing: .19em; line-height: 1.5; }
.heading .eyebrow { display: flex; align-items: center; gap: 9px; }
.heading .eyebrow span { width: 20px; height: 2px; background: #ffcb72; border-radius: 2px; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 {
  margin: 4px 0 2px;
  font-size: clamp(2.1rem, 5.5vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -.052em;
  color: #ffdf9e;
  text-shadow: 0 3px 16px #0d241c82;
}
h1 span { color: var(--paper); }
.heading > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: clamp(.88rem, 1.35vw, 1.07rem); }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(255px, 320px); gap: clamp(14px, 2vw, 24px); align-items: start; }
.arena {
  overflow: hidden;
  background: #19392c;
  border: 1px solid var(--stroke);
  border-radius: 21px;
  box-shadow: 0 12px 30px #06161073;
}
.arena-hud, .arena-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 15px; }
.arena-hud { min-height: 48px; background: linear-gradient(90deg, #244735, #17392e); font-size: clamp(.8rem, 1.8vw, .99rem); }
.turn, .streak { display: flex; align-items: center; gap: 8px; font-weight: 750; }
#turn-pip { width: 10px; height: 10px; border-radius: 50%; background: #ffe196; box-shadow: 0 0 10px #ffe1968c; flex: none; }
#turn-pip[data-color="red"] { background: #ff8467; box-shadow: 0 0 9px #ff846787; }
#turn-pip[data-color="blue"] { background: #62d8e9; box-shadow: 0 0 9px #62d8e98a; }
.streak { color: #ffd385; white-space: nowrap; }
.streak strong { padding-left: 2px; font-variant-numeric: tabular-nums; }
.stage { position: relative; isolation: isolate; background: #254b3b; }
#board { display: block; width: 100%; max-height: min(61vh, 650px); overflow: hidden; touch-action: none; user-select: none; }
#board .square { stroke-linejoin: round; outline: none; }
#board .square.movable { cursor: grab; }
#board .square.destination { cursor: pointer; }
#board.dragging, #board.dragging .square { cursor: grabbing; }
#board .square:focus-visible { stroke: #fff9e2; stroke-width: 3; }
#board .square.selected { stroke: #ffecb8; stroke-width: 2.5; }
#board .square.destination { stroke: #fbe698; stroke-width: 1.3; }
#board .square.destination:focus-visible, #board .square.selected:focus-visible { stroke: #fff; stroke-width: 4; }
#board .decoration, #board .piece-layer, #board .effects, #board .motion, #board .indicators { pointer-events: none; }
.table-label { position: absolute; bottom: 3.2%; left: 50%; translate: -50% 0; color: #ffdd98; letter-spacing: .19em; font-size: clamp(.49rem, 1vw, .68rem); font-weight: 850; white-space: nowrap; text-shadow: 0 2px #533823; pointer-events: none; }
.table-label span { color: #fff0ba; margin-inline: 3px; }
.win-celebration { position: absolute; z-index: 2; inset: 0; display: grid; place-items: center; overflow: hidden; pointer-events: none; }
.win-confetti { position: absolute; inset: 0; }
.win-confetti i {
  position: absolute; left: 50%; top: 53%; display: block; width: clamp(5px, 1.2vw, 11px); height: clamp(9px, 1.8vw, 18px);
  border-radius: 2px; background: var(--confetti-color); opacity: 0;
  animation: checkers-confetti var(--fall-time) both;
}
.win-confetti i:nth-child(3n) { height: clamp(5px, 1.2vw, 11px); border-radius: 50%; }
.win-confetti i:nth-child(5n) { width: clamp(3px, .6vw, 6px); }
.win-message {
  position: relative; display: flex; align-items: center; gap: .19em;
  margin: 0; padding: .2em .44em .24em; border: 1px solid #ffe9a4d9; border-radius: .25em;
  color: #fff1b5; background: linear-gradient(130deg, #244738cf, #172d25ce);
  box-shadow: 0 7px 32px #14271d77; text-shadow: 0 2px 5px #0d201a;
  font: bold clamp(2.15rem, 8.5vw, 5.5rem)/1.03 Georgia, "Times New Roman", serif; white-space: nowrap;
  animation: checkers-win-message 3200ms both;
}
.win-message svg { width: .8em; height: .8em; fill: none; stroke: #ffd273; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes checkers-confetti {
  from { transform: translate3d(0,0,0) rotate(0) scale(.45); opacity: 0; animation-timing-function: cubic-bezier(.14,.7,.33,1); }
  9% { opacity: 1; }
  38% { transform: translate3d(var(--peak-x),var(--peak-y),0) rotate(var(--turn)); opacity: 1; animation-timing-function: cubic-bezier(.38,.1,.72,1); }
  79% { opacity: .92; }
  to { transform: translate3d(var(--land-x),var(--land-y),0) rotate(var(--spin)) scale(.75); opacity: 0; }
}
@keyframes checkers-win-message {
  from { opacity: 0; transform: translateY(8px) scale(.93); }
  9%, 86% { opacity: 1; transform: none; }
  to { opacity: 0; }
}
.arena-foot { min-height: 53px; border-top: 1px solid #4d6e51; background: #163328; }
.arena-foot p { margin: 0; font-size: .84rem; color: #dbe6cd; line-height: 1.35; }
.piece-counts, .piece-counts > span { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.piece-counts { gap: 10px; font-size: .76rem; color: #e5d8b6; }
.piece-counts strong { color: #fff0c6; }
.swatch { display: inline-block; width: 15px; height: 15px; border: 1px solid #fff8; border-radius: 50%; box-shadow: inset 0 -2px 2px #180d3055, 0 1px 2px #0008; vertical-align: middle; flex: none; }
.swatch.red { background: linear-gradient(#ff9b76, #cc4e43); }
.swatch.blue { background: linear-gradient(#93e3ed, #227f9e); }
.panel { background: linear-gradient(153deg, #244836, #19382d 72%); border: 1px solid #55735a; border-radius: 20px; padding: 19px; box-shadow: 0 12px 24px #07170e55; }
.panel h2 { color: #fff1d4; margin: 4px 0 12px; font-size: clamp(1.48rem, 2.5vw, 2rem); line-height: 1.1; letter-spacing: -.03em; }
.opponents { display: grid; gap: 7px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opponent {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 5px 3px 7px;
  border-radius: 13px;
  border: 1px solid #526e57;
  background: #17362a;
  color: var(--paper);
}
.opponent:hover { border-color: var(--tint); background: #325440; }
.opponent[aria-pressed=true] { border-color: var(--tint); background: radial-gradient(ellipse at 50% 12%, #50684c, #294a36 85%); box-shadow: inset 0 0 0 1px var(--tint); }
.opponent[aria-pressed=true]::after { position: absolute; right: 7px; top: 7px; content: ""; background: var(--tint); width: 7px; height: 7px; border-radius: 50%; }
.avatar { width: 52px; height: 45px; display: block; overflow: visible; }
.opponent strong { font-size: .91rem; }
.opponent small { color: var(--tint); font-size: .71rem; line-height: 1.4; }
.rival-note { min-height: 41px; display: flex; align-items: center; gap: 6px; color: #d6e4ca; font-size: .79rem; line-height: 1.25; margin-top: 5px; }
.prize { display: flex; align-items: center; gap: 6px; color: #ffdb8c; font-size: .85rem; font-weight: 750; }
.color-picker { display: flex; gap: 7px; border: 0; margin: 4px 0 13px; padding: 0; min-width: 0; }
.color-picker legend { color: #f1dfb7; padding: 0 0 5px; font-size: .79rem; font-weight: 750; }
.color-picker label { flex: 1; position: relative; min-width: 0; }
.color-picker input { position: absolute; opacity: 0; }
.color-picker label span { display: flex; align-items: center; justify-content: center; min-height: 44px; gap: 5px; padding: 4px; white-space: nowrap; border: 1px solid #69816b; border-radius: 9px; color: #e8f0d5; background: #19362c; font-size: .78rem; cursor: pointer; }
.color-picker input:checked + span { background: #365541; border-color: #ffdc96; box-shadow: inset 0 0 0 1px #ffdc96; }
.color-picker input:focus-visible + span { outline: 3px solid #ffe3a1; outline-offset: 3px; }
.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 11px;
  min-height: 45px;
  padding: 8px 14px;
  font-weight: 850;
  text-align: center;
}
.primary { width: 100%; color: #2e2315; background: linear-gradient(#ffdf93, #f1ab52); border: 1px solid #ffdfa0; box-shadow: 0 2px 0 #8e572b, inset 0 1px 0 #fff5be; }
.primary:hover { background: linear-gradient(#fff0b6, #ffc66c); }
.primary:active { transform: translateY(1px); }
.secondary { color: #e7efda; background: #18362c; border: 1px solid #769078; font-size: .85rem; }
.side-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: .77rem; padding: 7px 3px 0; }
.side-foot a { min-height: 40px; color: #f3dfae; }
.text-button { color: #f3dfae; background: none; border: 0; font: inherit; font-weight: 750; min-height: 44px; padding: 3px; }
.text-button:hover { text-decoration: underline; }
.side-foot strong { color: #ffe29b; }
.match-rival { display: flex; align-items: center; gap: 12px; margin: 12px 0 8px; }
.match-rival .avatar { width: 66px; height: 56px; }
.match-rival h2 { margin: 0; }
.match-rival p { margin: 3px 0 0; font-size: .8rem; color: var(--tint); }
.match-note { margin: 17px 0; padding: 12px; background: #143329; border: 1px solid #486953; border-radius: 10px; display: flex; align-items: center; gap: 8px; }
.match-note svg { color: var(--gold); }
.match-note p, .match-outcome > p:not(.eyebrow) { margin: 0; font-size: .87rem; color: #e1e9cc; line-height: 1.42; }
.match-panel .secondary { width: 100%; }
.match-outcome { margin: 17px 0 12px; border-top: 1px solid #67816c; padding-top: 14px; }
#earned { margin: 8px 0; padding: 0; display: flex; gap: 5px; flex-wrap: wrap; list-style: none; }
#earned:empty { display: none; }
#earned li { background: #415635; border: 1px solid #777e50; color: #fff1bb; border-radius: 5px; padding: 4px 6px; font-size: .74rem; }
.match-outcome .primary { margin-top: 10px; }
.save-note { margin: 8px 0 0; color: #ffe2ad; font-size: .88rem; }
dialog { width: min(480px, calc(100% - 24px)); max-height: 88dvh; padding: 0; border-radius: 17px; border: 1px solid #7b956d; background: #1c3c2f; color: var(--paper); box-shadow: 0 14px 65px #000a; }
dialog::backdrop { background: #071a15bc; }
.dialog-inner { padding: clamp(17px, 4vw, 26px); }
.dialog-inner h2 { margin: 4px 0 12px; font-size: 1.9rem; }
.dialog-inner p, .rules { line-height: 1.45; }
.dialog-inner p:not(.eyebrow), .rules { color: #e1ebd6; }
.rules { padding-left: 1.3em; }
.rules li { margin-block: 8px; }
.rules strong { color: #fff0c5; }
.dialog-actions { display: flex; gap: 8px; }
.dialog-actions .primary { width: auto; flex: 1; }
@media (max-width: 870px) {
  .arena-foot { align-items: flex-start; flex-direction: column; gap: 6px; }
}
@media (max-width: 700px) {
  .workbench { display: flex; flex-direction: column; gap: 11px; }
  .arena, .side { width: 100%; }
  .heading { padding: 15px 0 13px; }
  .heading > p:last-child { margin-top: 5px; }
  .topbar { min-height: 52px; flex-wrap: wrap; padding-block: 3px; }
  .top-actions { flex-wrap: wrap; min-width: 0; max-width: 100%; }
  .shell { padding-inline: clamp(8px, 2.8vw, 20px); }
  .arena, .panel { border-radius: 15px; }
  .arena-hud, .arena-foot { min-height: 38px; padding: 7px 10px; }
  .arena-foot p { font-size: .79rem; }
  #board { max-height: none; }
  .panel { padding: 12px; }
  .panel h2 { margin-bottom: 8px; }
  .opponents { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .opponent { padding-block: 4px; }
  .opponent .avatar { width: 41px; height: 37px; }
  .opponent strong { font-size: .8rem; }
  .color-picker label span { font-size: .85rem; }
  .rival-note { min-height: 28px; }
  .match-note { margin: 9px 0; }
  .side-foot { padding-top: 1px; }
}
@media (max-width: 410px) {
  .utility { padding-inline: 7px; font-size: .75rem; }
  .home-link { font-size: .8rem; }
  .top-actions { gap: 4px; }
}
@media (max-width: 380px) {
  .topbar { gap: 7px; }
  .home-link, .utility { gap: 4px; white-space: normal; }
  .utility { padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .win-message { animation: none !important; }
  .win-confetti { display: none; }
}
