:root {
  color-scheme: dark;
  --bg: #101427;
  --panel: #191e35;
  --edge: #323955;
  --text: #f6f2ff;
  --quiet: #c0c6df;
  --accent: #ffc37a;
  font: 1rem/1.55 system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; background: radial-gradient(ellipse at 75% 0%, #252044, transparent 54%); }
button { color: inherit; font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .48; cursor: default; }
button:focus-visible { outline: 2px solid #fff0d9; outline-offset: 3px; }
[hidden] { display: none !important; }

.arcade { width: min(calc(100% - 2rem), 48rem); margin: 0 auto; padding: clamp(1.4rem, 5vh, 3.6rem) 0 2.5rem; }
.header { display: flex; gap: .95rem; align-items: center; margin-bottom: clamp(1.15rem, 3vh, 2rem); }
.header h1 { font-size: clamp(2.45rem, 8vw, 5rem); font-weight: 900; line-height: .94; letter-spacing: -.07em; margin: 0; }
.header p { color: var(--quiet); margin: .55rem 0 0; }
.mark { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); gap: 3px; width: clamp(2.65rem, 7vw, 4.1rem); aspect-ratio: 1; padding: .65rem; border-radius: 19%; background: #292c4a; border: 1px solid #43476b; rotate: -8deg; flex: none; }
.mark i { background: var(--accent); border-radius: 2px; }
.mark i:nth-child(1) { grid-area: 1 / 2; background: #a99bff; }
.mark i:nth-child(2) { grid-area: 2 / 1; }
.mark i:nth-child(3) { grid-area: 2 / 2; }
.mark i:nth-child(4) { grid-area: 2 / 3; }
.mark i:nth-child(5) { grid-area: 3 / 2; background: #79dfc7; }

.layout { display: grid; grid-template-columns: minmax(0, 23rem) minmax(0, 1fr); grid-template-rows: min-content 1fr; grid-template-areas: "field hud" "field controls"; gap: 1rem clamp(1.2rem, 4vw, 2rem); align-items: start; align-content: start; }
.field { grid-area: field; position: relative; width: 100%; max-width: 50svh; aspect-ratio: 9 / 16; overflow: hidden; border: 1px solid #525679; border-radius: 1.1rem; box-shadow: 0 6px 0 #090c19, 0 1rem 3.5rem #090c195f; background: #11172d; }
.field canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: auto 0 0; display: grid; justify-items: center; padding: 3.2rem .8rem 14%; background: linear-gradient(transparent, #101527 55%); text-align: center; }
.overlay h2 { margin: 0 0 .65rem; line-height: 1.05; letter-spacing: -.045em; font-weight: 850; font-size: clamp(1.55rem, 4vw, 2.45rem); }
.overlay p { margin: 0 0 .35rem; color: var(--quiet); }
.primary { min-width: 9.2rem; min-height: 3rem; padding: .45rem 1rem; border: 0; border-radius: .58rem; background: var(--accent); color: #211934; font-weight: 800; box-shadow: 0 4px 0 #b47152; }
.primary:hover { background: #ffdaa7; }
.primary:active { translate: 0 2px; box-shadow: 0 2px 0 #b47152; }

.hud { grid-area: hud; display: grid; gap: .8rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin: 0; }
.stats > div, .next, .controls { border: 1px solid var(--edge); border-radius: .82rem; background: var(--panel); }
.stats > div { min-width: 0; padding: .52rem .78rem; }
.stats dt { color: var(--quiet); font-weight: 650; font-size: .89rem; }
.stats dd { margin: 0; font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 850; line-height: 1.12; font-variant-numeric: tabular-nums; letter-spacing: -.045em; overflow-wrap: anywhere; }
.stats .total { background: #373158; border-color: #6a61a0; }
.stats .total dd { color: #ffe1c0; }
.next { display: flex; align-items: center; justify-content: space-between; padding: .2rem .95rem; }
.next p { margin: 0; font-weight: 700; }
.next canvas { display: block; max-width: 55%; width: 6.75rem; }
.controls { grid-area: controls; padding: 1rem; align-self: start; }
.controls h2 { font-size: 1rem; margin: 0 0 .65rem; }
.controls p { color: var(--quiet); margin: .65rem 0 0; font-size: .9rem; }
.pad { display: grid; grid-template-columns: repeat(5, minmax(2.3rem, 1fr)); gap: .35rem; }
.pad button, .actions button { min-height: 2.65rem; border: 1px solid #505776; border-radius: .52rem; background: #252b47; }
.pad button { font-size: 1.35rem; line-height: 1; }
.pad button:last-child { background: #3e365e; }
.pad button:hover, .actions button:not(:disabled):hover { background: #433d69; }
.actions { display: flex; gap: .5rem; margin-top: .8rem; }
.actions button { padding: .36rem .68rem; }
kbd { display: inline-block; font: 650 .82em/1 system-ui, sans-serif; background: #242a44; padding: .2em .32em; border: 1px solid #47506e; border-radius: .23rem; white-space: nowrap; }

@media (max-width: 40rem) {
  .arcade { width: min(calc(100% - 1.4rem), 26rem); padding-top: 1.2rem; }
  .header { margin-bottom: .9rem; }
  .header p { margin-top: .38rem; font-size: .9rem; }
  .layout { grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "hud" "field" "controls"; gap: .8rem; }
  .field { justify-self: center; max-width: min(83vw, 42svh); }
  .hud { grid-template-columns: 1fr minmax(4rem, 19%); gap: .4rem; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; }
  .stats > div { padding: .34rem .35rem; }
  .stats dt { font-size: .79rem; }
  .stats dd { font-size: clamp(1.16rem, 5vw, 1.6rem); }
  .next { flex-direction: column; justify-content: center; padding: .13rem; font-size: .78rem; }
  .next canvas { width: 3rem; max-width: 100%; }
  .controls { padding: .7rem; }
  .controls h2 { margin-bottom: .45rem; }
  .pad button { min-height: 2.75rem; }
}

@media (pointer: coarse) {
  .key-hint { display: none; }
}
