:root {
  color-scheme: dark;
  --paper: #0e0a14;
  --chassis: #241a33;
  --border: #8773a5;
  --ink: #fdf6f3;
  --muted: #d6c9e2;
  --pink: #ff81ba;
  --lime: #deff62;
  --cyan: #68f6e7;
  --violet: #b5a1ff;
  --gold: #ffe272;
  --key-ink: #08060b;
  --track: #342946;
  font: 100%/1.45 system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0, #392450 0, var(--paper) 62%);
}
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.key.primary:focus-visible { outline-color: var(--ink); box-shadow: inset 0 0 0 3px var(--key-ink); }
.site-bar {
  max-width: 76rem;
  margin: 0 auto;
  padding: env(safe-area-inset-top) max(.75rem, env(safe-area-inset-right)) 0 max(.75rem, env(safe-area-inset-left));
}
.exit {
  display: inline-flex;
  gap: .5em;
  align-items: center;
  min-height: 44px;
  padding: 0 .65rem;
  text-decoration: none;
  font-weight: 700;
}
.exit:hover { text-decoration: underline; }
.exit span, .back span { color: var(--pink); font-size: 1.35em; }
main {
  display: grid;
  place-items: center;
  padding: .5rem max(.75rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
  min-height: calc(100vh - 44px);
  min-height: calc(100svh - 44px);
}
.cabinet {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  background: linear-gradient(155deg, #39294c, var(--chassis) 57%, #1b1326);
  box-shadow: 0 1rem 2rem #0009, inset 0 1px 0 #ffffff24;
}
.home {
  max-width: 73.75rem;
  padding: clamp(.625rem, 2vw, 1rem);
  display: grid;
  gap: clamp(.625rem, 2vw, 1.15rem);
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  align-items: stretch;
  border-radius: .9rem .875rem .9rem .875rem;
}
.crt {
  position: relative;
  min-width: 0;
  min-height: 18rem;
  height: clamp(18rem, 63vh, 37rem);
  overflow: hidden;
  padding: .3rem;
  border: 1px solid var(--border);
  background: var(--paper);
  clip-path: polygon(.8rem 0, calc(100% - .8rem) 0, 100% .8rem, 100% calc(100% - .8rem), calc(100% - .8rem) 100%, .8rem 100%, 0 calc(100% - .8rem), 0 .8rem);
}
.crt img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: 28% center; image-rendering: pixelated; }
.crt::after {
  content: "";
  position: absolute;
  inset: .3rem;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, #0002 0 1px, transparent 1px 4px), linear-gradient(#0003, transparent 22% 75%, #0006);
  box-shadow: inset 0 0 .6rem .2rem #0009;
}
.title-deck { display: grid; align-content: center; gap: .75rem; min-width: 0; }
.marquee {
  min-width: 0;
  margin: 0;
  padding: .75rem .85rem;
  border-inline-start: 2px solid var(--pink);
  border-radius: 0 .5rem .5rem 0;
  background: var(--paper);
  font-weight: 1000;
  line-height: .92;
}
.marquee-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .35em; font-size: clamp(1rem, 2vw, 1.7rem); letter-spacing: .12em; }
.marquee strong {
  display: block;
  color: var(--pink);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  font-stretch: condensed;
  font-size: clamp(1.75rem, 4.6vw, 4.2rem);
  font-style: italic;
  font-weight: 1000;
  letter-spacing: -.085em;
  margin-top: .24em;
  overflow-wrap: anywhere;
}
.marquee strong span { white-space: nowrap; }
.lane-lights { display: inline-flex; gap: .16rem; flex: none; }
.lane-lights i { width: .78rem; height: .16rem; background: var(--cyan); }
.lane-lights i:nth-child(2) { background: var(--pink); }
.lane-lights i:nth-child(3) { background: var(--violet); }
.lane-lights i:nth-child(4) { background: var(--gold); }
.deck, .dialog-actions { display: grid; gap: .55rem; }
.key {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .52em;
  min-height: 46px;
  min-width: 44px;
  padding: .6em .75em;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: .35rem;
  text-align: center;
  font-weight: 750;
  line-height: 1.22;
}
.key:hover:not(:disabled) { background: var(--track); }
.key:active:not(:disabled) { box-shadow: inset 0 2px 3px #0009; }
.key:disabled { opacity: .65; cursor: wait; }
.primary {
  min-height: 56px;
  background: var(--lime);
  border-color: var(--lime);
  color: var(--key-ink);
  box-shadow: inset 0 -.24rem 0 #0005;
}
.primary:hover:not(:disabled) { background: #edff99; }
.start-key {
  min-height: 68px;
  justify-content: flex-start;
  gap: .85rem;
  padding: .68rem .8rem;
  text-align: left;
}
.start-key strong { display: block; font-size: clamp(1.16rem, 2vw, 1.55rem); font-weight: 920; }
.start-key small { display: block; margin-top: .2em; font: 680 .82rem/1.2 ui-monospace, Menlo, Consolas, monospace; }
.play-mark { width: 1rem; height: 1.12rem; flex: none; background: currentColor; clip-path: polygon(0 0,100% 50%,0 100%); }
.forward { margin-inline-start: auto; flex: none; }
.secondary-keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.panel { max-width: 47rem; padding: clamp(.75rem, 2.6vw, 1.5rem); border-radius: .8rem; }
.panel h2, dialog h2 { margin: 0 0 .2em; line-height: 1.08; font-size: clamp(1.6rem, 5vw, 2.5rem); }
.panel > .primary { margin-top: .55rem; width: 100%; }
#load-status:empty, #resume-status:empty { display: none; }
.back { margin-bottom: .7rem; }
.song-plate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .65fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--paper);
}
.song-plate div { padding: .7rem; }
.song-plate p { margin: .1em 0; }
.song-plate img { width: 100%; height: 100%; max-height: 8rem; object-fit: cover; image-rendering: pixelated; }
.kicker { margin: 0; color: var(--cyan); font: 700 .85rem/1.3 ui-monospace, Menlo, Consolas, monospace; }
fieldset { border: 0; padding: 0; margin: 1rem 0 .5rem; min-inline-size: 0; }
legend { font-weight: 800; margin: 0 0 .38rem; padding: 0; }
.difficulty { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem; }
.difficulty .key { position: relative; }
.difficulty input { position: absolute; opacity: 0; }
.difficulty label:focus-within { outline: 3px solid var(--cyan); outline-offset: 2px; }
.difficulty label:has(:checked) { border-color: var(--lime); box-shadow: inset 0 -.25rem 0 var(--lime); }
.toggle { display: flex; align-items: center; gap: .65rem; min-height: 44px; cursor: pointer; font-weight: 700; }
.toggle input { width: 1.2rem; height: 1.2rem; flex: none; accent-color: var(--lime); }
.hint { margin: 0 0 .5rem; color: var(--muted); }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.game-header h2 { margin: .15rem 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: .75rem 0; }
.stats div { min-width: 0; border: 1px solid var(--border); padding: .35rem .45rem; background: var(--paper); }
.stats dt { color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.stats dd { margin: 0; font-size: 1.08rem; font-weight: 850; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
progress { display: block; width: 100%; height: .35rem; border: 0; background: var(--track); color: var(--lime); accent-color: var(--lime); }
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--lime); }
progress::-moz-progress-bar { background: var(--lime); }
.playfield {
  position: relative;
  min-height: 10rem;
  height: clamp(10rem, 43vh, 24rem);
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--border);
}
.playfield canvas { display: block; width: 100%; height: 100%; }
.feedback {
  position: absolute;
  top: .5rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  padding: .1em .65em;
  font: 900 clamp(.95rem, 3vw, 1.45rem)/1.35 ui-monospace, monospace;
  text-align: center;
  pointer-events: none;
}
.feedback:empty { display: none; }
.step-display { height: 100%; display: grid; align-content: center; justify-items: center; gap: .4rem; }
.step-display strong { color: var(--ink); font-size: 4rem; line-height: .9; }
.step-display span { font-weight: 800; }
.cue { margin: .55em 0; min-height: 1.5em; }
.pads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.pad { min-height: 58px; flex-direction: column; gap: .08em; touch-action: none; border-color: var(--pad-color); }
.pad [aria-hidden] { font-size: 1.6em; line-height: 1; color: var(--pad-color); }
.pad kbd { font: 600 .75em/1.2 ui-monospace, monospace; }
.pad[data-down="true"] { background: var(--pad-color); color: var(--key-ink); }
.pad[data-down="true"] [aria-hidden] { color: var(--key-ink); }
dialog { width: min(28rem, 93vw); max-height: 90vh; padding: clamp(.85rem, 4vw, 1.4rem); border: 1px solid var(--border); border-radius: .7rem; background: var(--chassis); color: var(--ink); }
dialog::backdrop { background: #05040be0; }
dialog input[type="range"] { display: block; min-height: 44px; width: 100%; margin: 0 0 .35rem; accent-color: var(--lime); }
dialog output { color: var(--lime); }
dialog .primary { margin-top: .35rem; }
dialog form > .primary { width: 100%; }
@keyframes power-on { from { opacity: .5; } to { opacity: 1; } }
html:not([data-reduced="true"]) .crt img { animation: power-on 400ms ease-out both; }
html[data-contrast="true"] {
  --paper: #000;
  --chassis: #000;
  --border: #fff;
  --ink: #fff;
  --muted: #fff;
  --pink: #fff;
  --lime: #fff;
  --cyan: #fff;
  --violet: #fff;
  --gold: #fff;
  --key-ink: #000;
  --track: #292929;
}
[data-contrast="true"] :is(body, .cabinet) { background: var(--paper); }
[data-contrast="true"] .crt::after { display: none; }
[data-contrast="true"] .primary:hover:not(:disabled) { background: #ddd; }
@media (max-width: 51rem) {
  .home { max-width: 44rem; grid-template-columns: 1fr; }
  .title-deck { display: contents; }
  .marquee { grid-row: 1; }
  .marquee-top { font-size: clamp(1rem, 4vw, 1.7rem); }
  .marquee strong { font-size: clamp(1.95rem, 10vw, 4.5rem); }
  .crt { min-height: 12rem; height: clamp(12rem, 48vh, 29rem); }
  .crt img { object-position: 15% center; }
}
@media (max-width: 27rem) {
  .difficulty { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pad { gap: .12rem; }
  .marquee strong { letter-spacing: -.07em; }
}
@media (max-width: 19rem) {
  .secondary-keys { grid-template-columns: minmax(0, 1fr); }
  .lane-lights, .forward { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html .home .crt img { animation: none !important; }
}
@media (forced-colors: active) {
  :focus-visible, .difficulty label:focus-within { outline: 3px solid Highlight !important; }
  .difficulty label:has(:checked) { border: 3px solid Highlight; }
  .play-mark { forced-color-adjust: none; background: ButtonText; }
  .pad[data-down="true"] { border: 3px solid Highlight; }
}
[data-contrast="true"] .pad { --pad-color: #fff !important; }
