/* Byte Tanks – old-school arcade UI around a fixed 960×720 canvas (letterboxed). */
@font-face { font-family: 'Pixel'; src: url(assets/pixel-latin.woff2) format('woff2'); font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Pixel'; src: url(assets/pixel-latin-ext.woff2) format('woff2'); font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }

:root { --yellow: #ffd23f; --cyan: #3ee6ff; --pink: #ff4fd8; --magenta: #e83a8c; --green: #5cff6c; --red: #ff3b3b; --grey: #9a9a9a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; overflow: hidden;
  font: 14px/1.6 'Pixel', ui-monospace, monospace; -webkit-font-smoothing: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

#stage { position: fixed; inset: 0; display: grid; place-items: center; }
#game { display: block; width: min(100vw, calc(100vh * 4 / 3)); height: auto; aspect-ratio: 4 / 3; image-rendering: pixelated; }
@supports (height: 100dvh) { #game { width: min(100vw, calc(100dvh * 4 / 3)); } }

.screen { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px; background: #000; text-align: center; overflow: auto; }
#pause, #over { background: rgba(0, 0, 0, .88); }
.screen[hidden], #touch[hidden], #rotate[hidden] { display: none; }
.back { position: absolute; left: 18px; top: 16px; color: var(--grey); text-decoration: none; font-size: 11px; }
.back:hover { color: #fff; }
.title { margin: 0; font-size: clamp(34px, 8vw, 84px); font-weight: 400; line-height: 1.05; color: var(--magenta); text-shadow: 6px 6px 0 #5a0d35; letter-spacing: 4px; }
.title span { color: var(--yellow); text-shadow: 6px 6px 0 #7a5200; }
.modes { display: grid; gap: 10px; }
.modes button { font-size: clamp(14px, 2vw, 18px); padding: 4px 0 4px 34px; position: relative; text-align: left; }
.modes button.on::before { content: ''; position: absolute; left: 0; top: 50%; width: 20px; height: 20px; margin-top: -11px;
  background: linear-gradient(var(--magenta), var(--magenta)) 7px 0 / 6px 10px no-repeat, linear-gradient(#8a1c55, #8a1c55) 0 4px / 4px 16px no-repeat,
  linear-gradient(#8a1c55, #8a1c55) 16px 4px / 4px 16px no-repeat, linear-gradient(var(--magenta), var(--magenta)) 4px 7px / 12px 12px no-repeat; transform: rotate(90deg); }
.press { margin: 0; font-size: 12px; color: var(--grey); }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.big { margin: 0; font-size: clamp(26px, 5.5vw, 54px); font-weight: 400; color: var(--red); text-shadow: 5px 5px 0 #550000; }
.big.yellow { color: var(--yellow); text-shadow: 5px 5px 0 #7a5200; }
.help { color: var(--grey); font-size: 10px; margin: 0; }
.credit { color: #666; font-size: 9px; margin: 0; }
.result { margin: 0; font-size: clamp(11px, 1.6vw, 15px); }
.result b { color: var(--yellow); font-weight: 400; }

.hiscores { width: min(560px, 100%); }
.hiscores h2 { margin: 0 0 10px; font-size: 14px; font-weight: 400; color: var(--cyan); }
.hiscores ol { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.hiscores li { display: grid; grid-template-columns: 4.5em 1fr 6em 6em; gap: 10px; padding: 3px 0; text-align: left; font-variant-numeric: tabular-nums; }
.hiscores li:nth-child(1) { color: var(--yellow); } .hiscores li:nth-child(2) { color: var(--cyan); } .hiscores li:nth-child(3) { color: var(--pink); }
.hiscores li.me { color: var(--green); position: relative; }
.hiscores li.me::before { content: ">"; position: absolute; left: -1.6em; animation: blink 1s steps(1) infinite; }
.hiscores li.empty { display: block; text-align: center; color: var(--grey); }
.hiscores .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
.hiscores .sc, .hiscores .tm { text-align: right; }

#saveForm { display: grid; gap: 8px; justify-items: center; }
#saveForm[hidden] { display: none; }
.new-hi { margin: 0; color: var(--green); font-size: 14px; }
#saveForm label { font-size: 12px; }
.name-row { display: flex; gap: 8px; }
#saveForm input { font: inherit; font-size: 14px; width: min(340px, 64vw); padding: 10px; background: #000; color: var(--yellow); border: 3px solid #fff;
  text-transform: uppercase; text-align: center; outline: none; user-select: text; -webkit-user-select: text; caret-color: var(--yellow); }
#saveForm input:focus { border-color: var(--yellow); }
#saveForm input::placeholder { color: #555; }
#btnSave { padding: 10px 16px; background: #fff; color: #000; border: 3px solid #fff; }
#btnSave:hover, #btnSave:focus { background: var(--yellow); border-color: var(--yellow); outline: none; }
#saveForm small { color: #666; font-size: 9px; }
.form-msg { margin: 0; min-height: 1.4em; font-size: 11px; }
.form-msg.ok { color: var(--green); } .form-msg.err { color: var(--red); }

.choices { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; }
#pause .choices { flex-direction: column; gap: 14px; }
.choices button { font-size: 14px; padding: 4px 0 4px 22px; position: relative; }
.choices button:hover, .choices button:focus-visible { color: var(--yellow); outline: none; }
.choices button:hover::before, .choices button:focus-visible::before { content: '>'; position: absolute; left: 0; animation: blink 1s steps(1) infinite; }

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

/* touch controls */
#touch { position: absolute; inset: auto 0 0 0; z-index: 6; display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none;
  padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.dpad { pointer-events: auto; display: grid; grid-template: 'a u b' 58px 'l c r' 58px 'd v e' 58px / 58px 58px 58px; }
.dpad button { border: 3px solid rgba(255,255,255,.6); background: rgba(0,0,0,.45); color: #fff; font-size: 16px; touch-action: none; }
.dpad [data-dir=up] { grid-area: u; } .dpad [data-dir=left] { grid-area: l; } .dpad [data-dir=right] { grid-area: r; } .dpad [data-dir=down] { grid-area: v; }
.dpad button.down, .right-pad button.down { background: var(--yellow); color: #000; }
.right-pad { pointer-events: auto; display: flex; gap: 12px; align-items: flex-end; }
.right-pad button { border: 3px solid rgba(255,255,255,.6); background: rgba(0,0,0,.45); color: #fff; touch-action: none; }
.right-pad .small { width: 46px; height: 46px; font-size: 11px; }
.right-pad .fire { width: 96px; height: 96px; font-size: 14px; border-color: var(--magenta); color: var(--magenta); }

#rotate { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: #000; color: var(--yellow); font-size: 14px; padding: 20px; text-align: center; }
@media (max-height: 520px) { .screen { gap: 10px; padding: 12px; justify-content: flex-start; } .hiscores ol { font-size: 10px; } }
@media (prefers-reduced-motion: reduce) { .blink, .hiscores li.me::before { animation: none; } }
