* { box-sizing: border-box }
[hidden] { display: none !important }
:root { color-scheme: dark; font-family: "Courier New", monospace; background: #08090a; color: #e3e3dd }
body { margin: 0; overscroll-behavior: none }
.cabinet {
  width: 100%; height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #08090a;
}
.playfield { container-type: size; display: grid; place-items: center; min-height: 0; background: black }
.screen { position: relative; width: min(100cqw, calc(100cqh * 496 / 360)); aspect-ratio: 496/360; background: #000 url('assets/title.png') center / 100% 100%; overflow: hidden }
canvas, video { display: block; width: 100%; height: 100%; position: absolute; inset: 0; image-rendering: pixelated; outline: none }
canvas:focus-visible { outline: 1px solid #ede446; outline-offset: -1px }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem; background: #000b; text-align: center }
.overlay.title { justify-content: flex-end; padding-bottom: 5%; background: transparent }
h1 { margin: 0; font: bold clamp(1.2rem, 4vw, 2.5rem)/1 monospace; text-transform: uppercase; letter-spacing: .1em }
button { color: inherit; cursor: pointer; font: inherit; touch-action: manipulation }
button:focus-visible { outline: 2px solid #f6ec38; outline-offset: 2px }
.primary { border: 2px solid #f8ed21; box-shadow: 3px 3px #000; background: #080909; color: #fff138; padding: .65em 1.2em; font: 800 clamp(.95rem, 2.4vw, 1.35rem)/1 monospace; text-transform: uppercase; letter-spacing: .09em }
.primary:hover { color: black; background: #fff138 }
.deck, .keys, .keys span, .options, .touch, .touch div { display: flex; align-items: center }
.deck { min-height: 44px; padding: 4px 12px; justify-content: space-between; gap: .5rem }
.keys { flex-wrap: wrap; gap: .35rem 1.1rem; color: #adada8; font-size: .85rem }
.keys span { gap: .27rem; white-space: nowrap }
kbd { font: bold .8rem monospace; color: #ecece6; padding: .1rem .26rem; border: 1px solid #555652; border-radius: 2px; min-width: 1.45em; text-align: center }
.options { gap: .3rem; margin-left: auto }
.options button, .touch button { background: #111314; color: #dedfd7; border: 1px solid #444647; border-radius: 2px; min-width: 2.3rem; height: 2rem }
.options button:hover, .touch button:active, .touch button.held { border-color: #eee42c; color: #eee42c }
.options svg { width: 1.2rem; height: 1.2rem; display: block; margin: auto; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round }
.touch { display: none; justify-content: space-between; gap: .5rem; user-select: none; -webkit-user-select: none }
.touch div { gap: .35rem }
.touch button { touch-action: none; min-width: 2.85rem; height: 2.8rem; font-weight: bold }
.sr-only { width: 1px; height: 1px; position: absolute; overflow: hidden; clip-path: inset(50%) }
@media (pointer: coarse), (max-width: 620px) {

  .keys { display: none }
  .touch { display: flex; padding: 2px 6px 4px; gap: 2px }
  .touch div { gap: 3px }
  .deck { min-height: 40px }

}
.overlay.title { gap: .4rem }
.duel { border: 1px solid #67b24a; color: #cbf6aa; background: #10190f; padding: .45em .85em; font-weight: bold }
.duel:hover { background: #234025 }

@media (orientation: landscape) and (max-height: 550px) and (pointer: coarse) {
  .cabinet { position: relative; grid-template-rows: minmax(0,1fr) }
  .deck, .touch { position: absolute; right: env(safe-area-inset-right); left: env(safe-area-inset-left); pointer-events: none }
  .deck { top: env(safe-area-inset-top) }
  .touch { bottom: env(safe-area-inset-bottom) }
  .deck button, .touch button { pointer-events: auto; background: #111314df }
}
.dash-cooling [data-key="dash"], .dash-cooling .dash-key { color: #858783; border-color: #393c3d }
.overlay:not(.title) { gap: clamp(.35rem, 1.6cqh, 1rem); background: #06090dea }
.overlay.defeat:not(.selecting-level) {
  background: linear-gradient(to bottom, #05081155, #05081199 42%, #05081122 77%);
  padding-bottom: 12%;
}
.overlay.defeat:not(.selecting-level) h1 {
  color: #fff2c9; font-size: clamp(1.65rem, 7cqw, 3.5rem);
  text-shadow: 2px 2px #893e37, 4px 4px #151223;
}
#menu-detail { margin: 0 0 .2em; color: #c4d1ce; font-size: clamp(.8rem, 2cqw, 1rem) }
.menu-button { background: #121a1d; color: #e6eee5; border: 1px solid #64716c; padding: .5em .9em; min-height: 2.2em; font-weight: bold }
.menu-button:hover, .menu-button:focus-visible { background: #24362d; color: #ddffb2 }
.overlay.selecting-level { padding: clamp(.4rem, 2cqh, 1rem); }
.selecting-level > :not(#levels) { flex: none }
#levels {
  position: relative; width: min(100%, 27rem); min-height: 0; flex: 0 1 auto;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #64716c #121a1d;
  padding: .3rem .45rem; text-align: left;
}
.level-chapter + .level-chapter { margin-top: .75rem }
.chapter-heading { margin: 0 0 .3rem; color: #f5d977; font-size: clamp(.8rem, 2cqw, 1rem); line-height: 1.25 }
.level-chapter p { margin: 0 0 .35rem; font-size: .8rem; line-height: 1.3; color: #c4d1ce }
.level-waves { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem }
#levels button { width: 100%; padding: .4em; font-size: clamp(.8rem, 2.4cqw, 1rem); line-height: 1.25; }
.level-chapter > button { margin-top: .35rem }
@media (orientation: landscape) and (max-height: 550px) and (pointer: coarse) {
  .overlay.selecting-level { padding-block: 2.2rem 3rem }
}
#levels button:disabled { color: #aaa8a0; background: #202022; border-color: #414342; cursor: default }
@media (max-width: 420px) { .touch button { min-width: 2.4rem; padding: .24em; } }
