:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090d19;
  color: #eff4ff;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: radial-gradient(circle at 50% 0%, #1c2d54 0%, #090d19 55%); }
.app { width: min(100% - 32px, 900px); margin: 0 auto; padding: 32px 0 40px; }
.masthead { text-align: center; margin-bottom: 22px; }
.eyebrow { color: #8fa6d8; font-size: .7rem; letter-spacing: .28em; font-weight: 700; margin: 0 0 4px; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.4rem); font-style: italic; letter-spacing: .1em; line-height: 1; text-shadow: 4px 4px 0 #263a68; }
.game-layout { display: grid; grid-template-columns: 150px 360px 150px; align-items: start; justify-content: center; gap: 18px; }
.panel { display: grid; gap: 14px; }
.card { overflow: hidden; border: 1px solid #2a3b65; border-radius: 10px; background: rgba(16, 25, 46, .86); box-shadow: 0 12px 30px rgba(0, 0, 0, .2); }
.card h2 { margin: 0; padding: 11px 13px 8px; color: #9eb8f8; font-size: .67rem; letter-spacing: .14em; text-transform: uppercase; }
.piece-canvas, .next-canvas { display: block; width: 100%; height: auto; }
.board-wrap { position: relative; border: 5px solid #263a68; background: #0b1224; box-shadow: 0 14px 38px rgba(0, 0, 0, .36); }
#board { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.game-over { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; background: rgba(5, 8, 17, .72); backdrop-filter: blur(2px); }
.game-over[hidden] { display: none; }
.game-over p { margin: 0; color: #ff657f; font-size: 1.55rem; font-weight: 900; letter-spacing: .12em; }
.game-over span { margin-top: 9px; color: #e6ecff; font-size: .78rem; }
.stats { padding: 10px 13px; }
.stats div { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-bottom: 1px solid #293858; }
.stats div:last-child { border: 0; }
.stats span { color: #9ab0de; font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; }
.stats strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.controls { padding-bottom: 9px; }
.controls dl { margin: 0; padding: 0 12px; }
.controls dl div { display: grid; grid-template-columns: 1fr auto; gap: 7px; padding: 6px 0; border-bottom: 1px solid #253452; }
.controls dl div:last-child { border: 0; }
.controls dt, .controls dd { margin: 0; font-size: .67rem; }
.controls dt { color: #a5b7df; }.controls dd { color: #f1f5ff; font-weight: 700; text-align: right; white-space: nowrap; }
.status { min-height: 1.3em; margin: 18px 0 0; color: #adc1ef; text-align: center; font-size: .78rem; letter-spacing: .04em; }

@media (max-width: 730px) {
  .app { width: min(100% - 20px, 520px); padding-top: 20px; }
  .game-layout { grid-template-columns: 1fr 1fr; grid-template-areas: "board board" "left right"; gap: 12px; }
  .board-wrap { grid-area: board; width: min(100%, 360px); justify-self: center; }
  .left-panel { grid-area: left; }.right-panel { grid-area: right; }
  .left-panel { grid-template-columns: 1fr 1fr; }.left-panel .controls { grid-column: span 1; }
  .piece-canvas { max-height: 112px; object-fit: contain; }
}
@media (max-width: 420px) {
  .app { width: min(100% - 12px, 420px); }
  .game-layout { gap: 8px; }
  .left-panel { display: block; }.left-panel .controls { margin-top: 8px; }
  .controls dt, .controls dd { font-size: .6rem; }
}
