@font-face { font-family: Laserian; src: url('../fonts/LASER4.TTF') format('truetype'); font-display: swap; }
:root { color-scheme: dark; color: #fff; background: #101c1c; font-family: Arial, sans-serif; --green: #79ff00; }
* { box-sizing: border-box; letter-spacing: 0; }
html, body { margin: 0; min-height: 100%; }
body { display: grid; place-items: center; min-height: 100svh; padding: 8px; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: #fff; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
[hidden] { display: none !important; }
#game-shell { width: min(1600px, calc((100svh - 64px) * 16 / 9), calc(100vw - 16px)); }
#stage { width: 100%; aspect-ratio: 16 / 9; position: relative; overflow: hidden; isolation: isolate; background: #000; }
#game { width: 100%; height: 100%; display: block; }
svg { width: 21px; height: 21px; flex-shrink: 0; pointer-events: none; }
.icon-button { width: 40px; height: 40px; flex: 0 0 40px; display: inline-flex; justify-content: center; align-items: center; padding: 8px; border: 1px solid #8fb6b2; border-radius: 4px; background: #102b2ae6; color: #fff; text-decoration: none; }
.icon-button:hover { border-color: var(--green); background: #284e41; }
.primary, .secondary { min-height: 44px; display: inline-flex; justify-content: center; align-items: center; gap: 9px; padding: 10px 18px; border: 2px solid #060c06; border-radius: 4px; font: 17px Laserian, Impact, sans-serif; text-shadow: -1px -1px #000, 1px -1px #000, -1px 1px #000, 1px 1px #000; }
.primary { background: #65db00; box-shadow: 0 0 0 1px #b5ff7e, 0 0 20px #72ff0029; }
.primary:hover { background: #7aee13; }
.secondary { background: #163b36; border-color: #6fa295; }
.secondary:hover { background: #285446; }
.overlay { position: absolute; inset: 0; z-index: 4; }
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: #000; }
.loading-screen h1 { margin: 0; padding: 0 20px; font: 27px Laserian, Arial, sans-serif; text-align: center; }
.loading-screen progress { width: 55%; height: 8px; accent-color: var(--green); }
.loading-screen p { font-size: 12px; text-align: center; }
.menu { background: linear-gradient(90deg, #091a26b8, #091a2620 56%, transparent); }
.menu h1 { position: absolute; left: 7%; top: 12%; margin: 0; font: 900 72px/.98 'Arial Black', Impact, sans-serif; color: #fffbd7; -webkit-text-stroke: 1px #222616; paint-order: stroke fill; text-shadow: 3px 4px #243b24, 5px 7px #051b1f; }
.menu h1 span { color: #ccf5ff; }
.menu h1 em { font-style: normal; color: #ffe77d; }
.menu-actions { position: absolute; bottom: 13%; left: 7%; display: grid; width: 235px; gap: 12px; }
#play { min-height: 54px; font-size: 24px; }
#hud { position: absolute; top: 14px; left: 22px; right: 14px; display: flex; align-items: flex-start; gap: 24px; pointer-events: none; text-shadow: 0 2px 3px #092527, 1px 0 #092527, -1px 0 #092527; }
#hud > div { display: grid; gap: 3px; }
#hud span { font-size: 10px; font-weight: bold; }
#hud strong { font: 26px Laserian, Arial, sans-serif; font-variant-numeric: tabular-nums; }
.hud-score { min-width: 90px; }
.wave-stat { margin-right: auto; }
#lives { display: flex; gap: 4px; height: 27px; align-items: center; }
#lives svg { color: #fff1ba; fill: #54d8ef; width: 22px; }
#lives svg.lost { fill: #263c3b; color: #63837e; opacity: .7; }
#pause { pointer-events: auto; }
#combo { position: absolute; top: 84px; left: 22px; color: #173a27; background: #eeffd8e8; padding: 5px 9px; font-weight: bold; font-size: 12px; border-left: 3px solid #508b0a; }
#spell-form { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; width: 370px; max-width: calc(100% - 32px); height: 54px; background: #092725f5; border: 2px solid #bbefbb; border-radius: 5px; padding: 5px 6px 5px 13px; box-shadow: 0 3px 0 #051b1f; }
#spell-form label { display: flex; align-items: center; gap: 7px; color: #c6f7bd; font-size: 10px; font-weight: bold; }
#spell-input { flex: 1; width: 100%; min-width: 0; background: transparent; color: #fff; border: none; outline: none; height: 38px; font: bold 26px 'Courier New', monospace; }
#spell-form:focus-within { border-color: #80ffd0; box-shadow: 0 0 16px #8affe059, 0 3px #051b1f; }
#spell-form[data-feedback="miss"] { border-color: #ff6767; }
#spell-form[data-feedback="hit"] { border-color: #b4ff78; }
#spell-form button { display: flex; justify-content: center; align-items: center; flex: 0 0 40px; height: 38px; border: 1px solid #8cbc94; border-radius: 3px; background: #235e45; }
.shaded { background: #071919c9; backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: center; padding: 16px; overflow-y: auto; }
.dialog { width: 100%; max-width: 390px; max-height: 100%; overflow-y: auto; background: #071512e8; border: 2px solid var(--green); border-radius: 6px; padding: 20px 24px; box-shadow: 0 0 26px #80ff0029; text-align: center; }
.dialog h2 { font: 28px Laserian, Impact, sans-serif; line-height: 1.2; margin: 0 0 14px; overflow-wrap: anywhere; }
.pause-dialog { display: grid; gap: 16px; }
.slider-label { display: flex; justify-content: space-between; font: 15px Laserian, Arial, sans-serif; }
output { font: bold 15px Arial, sans-serif; }
input[type="range"] { accent-color: var(--green); width: 100%; height: 24px; margin: 0 0 12px; }
.game-over { color: #ff2525; text-shadow: 0 0 16px #ff000055, 1px 2px #000; }
#run-summary { display: grid; gap: 5px; margin-bottom: 12px; }
#run-summary span { font: 10px Laserian, Arial, sans-serif; }
#final-score { font: 28px Laserian, Arial, sans-serif; }
#run-details { font-size: 11px; color: #c0d9c9; }
#score-form { margin: 12px 0; }
#score-form label { display: block; font: 11px Laserian, Arial, sans-serif; margin-bottom: 8px; }
.name-row { display: flex; gap: 8px; }
#player-name { min-width: 0; width: 100%; height: 42px; border: 1px solid #83ab8b; border-radius: 3px; background: #0009; color: white; padding: 5px 12px; text-transform: uppercase; font: 22px Arial, sans-serif; text-align: center; }
#submit-score { flex: 0 0 46px; min-height: 42px; padding: 8px; }
#top10-label { font: 18px Laserian, Arial, sans-serif; color: var(--green); margin: 10px 0; }
#leaderboard { list-style: none; padding: 0; margin: 0; font: 15px Arial, sans-serif; font-variant-numeric: tabular-nums; }
#leaderboard li { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; text-align: left; min-height: 25px; border-bottom: 1px solid #d8ffd812; }
#leaderboard .rank { font-size: 12px; color: #91ae9c; }
#leaderboard li:first-child { color: #e2ffab; }
#score-status { font-size: 11px; line-height: 1.4; color: #bed7c8; margin: 10px 0; min-height: 15px; }
#scores-back { width: 100%; }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; z-index: 9; pointer-events: none; transition: opacity .4s ease; }
#fade.active { opacity: 1; }
.game-toolbar { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-toolbar span { font-size: 10px; font-weight: bold; color: #b4d2c6; }
.game-toolbar .icon-button { border: none; background: transparent; }
#game-shell:fullscreen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; background: #101c1c; }
#game-shell:fullscreen #stage { width: min(100vw, calc((100dvh - 48px) * 16 / 9)); flex-shrink: 0; }
#game-shell:fullscreen .game-toolbar { width: min(600px, 100vw); flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 1100px) {
  .menu h1 { font-size: 53px; }
  .menu-actions { width: 200px; gap: 8px; }
  #play { min-height: 46px; font-size: 21px; }
}
@media (max-height: 650px) and (orientation: landscape) {
  body { padding: 0; }
  #game-shell { width: min(100vw, calc((100svh - 36px) * 16 / 9)); }
  .game-toolbar { height: 36px; }
  .menu h1 { font-size: 36px; }
  .menu-actions { width: 165px; bottom: 10%; gap: 6px; }
  #play { font-size: 17px; min-height: 36px; padding: 5px; }
  .menu-actions .secondary { min-height: 32px; font-size: 12px; padding: 5px; }
  #hud { top: 8px; left: 12px; gap: 14px; }
  #hud strong { font-size: 18px; }
  #hud span { font-size: 8px; }
  #spell-form { height: 42px; bottom: 8px; width: 300px; }
  #spell-input { font-size: 22px; height: 30px; }
  #spell-form button { height: 30px; flex-basis: 35px; }
  #combo { top: 61px; left: 12px; font-size: 10px; }
  .shaded { position: fixed; z-index: 20; }
  .pause-dialog { gap: 8px; padding: 14px 20px; }
  .pause-dialog h2 { margin-bottom: 4px; font-size: 24px; }
  .pause-dialog input[type="range"] { margin-bottom: 4px; }
}
@media (max-width: 600px) and (orientation: portrait) {
  body { padding: 0; }
  #game-shell { width: 100vw; }
  .menu h1 { top: 10%; left: 6%; font-size: 26px; }
  .menu-actions { left: 6%; bottom: 8%; width: 130px; gap: 5px; }
  #play { min-height: 29px; padding: 4px; font-size: 14px; }
  .menu-actions .secondary { min-height: 27px; padding: 4px; font-size: 10px; }
  .menu-actions svg { width: 15px; height: 15px; }
  #hud { top: 5px; left: 8px; right: 6px; gap: 10px; }
  #hud span { font-size: 7px; }
  #hud strong { font-size: 15px; }
  .hud-score { min-width: 55px; }
  #lives { height: 18px; gap: 2px; }
  #lives svg { width: 15px; height: 15px; }
  #pause { width: 28px; height: 28px; flex-basis: 28px; padding: 5px; }
  #spell-form { bottom: 5px; height: 34px; width: 245px; gap: 6px; padding: 3px 4px 3px 8px; }
  #spell-form label span { display: none; }
  #spell-form label svg { width: 17px; }
  #spell-input { height: 26px; font-size: 19px; }
  #spell-form button { height: 26px; flex-basis: 30px; }
  #spell-form button svg { width: 17px; }
  #combo { top: 39px; left: 8px; font-size: 8px; padding: 3px 5px; }
  .shaded { position: fixed; z-index: 20; padding: 12px; }
  .dialog { padding: 18px; }
  .dialog h2 { font-size: 23px; }
  .loading-screen { gap: 9px; }
  .loading-screen h1 { font-size: 15px; }
  .loading-screen p { font-size: 10px; margin: 0; }
}
@media (prefers-reduced-motion: reduce) { #fade { transition: none; } .shaded { backdrop-filter: none; } }
