:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #100d1c;
  color: #f8f2fc;
  --muted: #bcb0cb;
  --yellow: #ffcf6c;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100svh;
  padding: max(22px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse at 50% -12%, #352345 0, transparent 65%),
    radial-gradient(circle, #a98abd20 1px, transparent 1px) 0 0 / 15px 15px,
    #100d1c;
}

button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #8ff5ef; outline-offset: 3px; }
button, .screen { touch-action: manipulation; }
.arcade { width: min(100%, 1110px); margin: 0 auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: clamp(16px, 2.15vw, 26px); font-weight: 950; letter-spacing: -.065em; white-space: nowrap; }
.brand-accent { color: var(--yellow); }
.brand-icon { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; background: #ffcf6c; box-shadow: inset 0 -3px #bb7639; }
.brand-icon i { width: 23px; height: 23px; background: #231730; clip-path: polygon(0 36%,20% 36%,20% 20%,36% 20%,36% 0,64% 0,64% 20%,80% 20%,80% 36%,100% 36%,100% 64%,80% 64%,80% 80%,64% 80%,64% 100%,36% 100%,36% 80%,20% 80%,20% 64%,0 64%); }
.stages { display: flex; align-items: center; gap: 9px; }
.stage { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid #6e567644; border-radius: 8px; color: #b9abc7; font-size: 12px; font-weight: 700; white-space: nowrap; }
.stage b { font: 800 11px var(--mono); }
.stage.current { border-color: #ffc77066; color: #ffdd91; background: #ffc77016; }
.stage.done { color: #9ce5d5; border-color: #9ce5d54a; }
.stage-line { width: 15px; height: 1px; background: #6d597f; }

.cabinet { padding: 8px 8px 0; background: #211931; border: 1px solid #69537c; border-radius: 16px; box-shadow: 0 14px 46px #070510bc, inset 0 1px #ffffff0e; }
.screen { aspect-ratio: 16 / 9; position: relative; overflow: hidden; isolation: isolate; background: #252044; border: 1px solid #8f72a868; border-radius: 10px; container-type: inline-size; user-select: none; -webkit-user-select: none; }
canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.hud { position: absolute; z-index: 3; inset: clamp(8px, 2.2cqw, 22px) clamp(8px, 2.4cqw, 26px) auto; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.hud-group { display: flex; align-items: center; gap: clamp(4px, .9cqw, 9px); }
.hud-box, .icon-button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; background: #161125e8; border: 1px solid #b89bcd70; border-radius: 8px; box-shadow: 0 2px #120e22b3; }
.heart { width: 15px; height: 14px; background: #fa7590; clip-path: polygon(0 20%,14% 20%,14% 0,38% 0,38% 15%,62% 15%,62% 0,86% 0,86% 20%,100% 20%,100% 53%,50% 100%,0 53%); }
.heart.empty { background: #5c4b6c; }
.points { color: #ffe3a1; font: 800 13px var(--mono); font-variant-numeric: tabular-nums; }
.shard { width: 12px; height: 15px; background: #ffd56e; clip-path: polygon(50% 0,100% 40%,100% 64%,50% 100%,0 64%,0 40%); }
.boost { padding-inline: 7px 9px; color: #a0f5ec; font-size: 12px; }
.boost-track { width: clamp(28px, 6.5cqw, 73px); height: 5px; border-radius: 4px; background: #493b60; overflow: hidden; }
#boost-fill { display: block; height: 100%; background: #78f5e8; transform-origin: left; }
.icon-button { pointer-events: auto; padding: 0; width: 39px; font-weight: 900; color: #f9eefc; }
.icon-button:hover { background: #352748; }
.speaker { width: 15px; height: 14px; background: currentColor; clip-path: polygon(0 30%,30% 30%,73% 0,73% 100%,30% 70%,0 70%); }
.sound-mark { margin-left: -5px; font: 800 13px var(--mono); }

.overlay { position: absolute; z-index: 2; inset: 0; display: flex; align-items: center; pointer-events: none; background: linear-gradient(90deg, #171027f5 0%, #211435e8 29%, #21143584 54%, #2114350d 81%); }
.overlay-content { pointer-events: auto; margin: 7cqw 0 0 6%; max-width: 58%; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: #ffe199; font: 800 clamp(10px, 1.35cqw, 14px) var(--mono); letter-spacing: .13em; margin: 0 0 10px; }
.eyebrow i, .tip i { display: inline-block; width: 8px; height: 8px; background: #ffd477; transform: rotate(45deg); flex: none; }
.splash-title { font-size: clamp(34px, 8.25cqw, 91px); letter-spacing: -.078em; line-height: .9; font-weight: 1000; margin: 0; text-shadow: 0 4px #281b3b; }
.splash-title span { color: var(--yellow); }
.overlay-copy { max-width: 315px; margin: 13px 0 18px; color: #e9dced; font-size: clamp(13px, 1.55cqw, 17px); line-height: 1.45; }
.primary { border: 1px solid #ffdf8d; border-radius: 9px; background: #ffd371; color: #261930; font-weight: 900; display: inline-flex; gap: 16px; align-items: center; padding: 11px 15px; box-shadow: 0 4px #a96237, inset 0 1px #fff2ac; }
.primary:hover { background: #ffe194; }
.primary:active { transform: translateY(2px); box-shadow: 0 2px #a96237; }
.play-icon { font-size: 11px; }
.toast { position: absolute; z-index: 4; inset: auto 0 7%; width: max-content; max-width: 92%; margin: 0 auto; padding: 8px 12px; background: #171325ed; border: 1px solid #b794cc; border-radius: 7px; color: #ffdc88; text-align: center; font: 800 clamp(11px, 1.45cqw, 15px) var(--mono); pointer-events: none; }

.controls { min-height: 54px; padding: 8px 9px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.key-guide { display: flex; align-items: center; flex-wrap: wrap; gap: clamp(7px, 2vw, 20px); }
.key-guide > span { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
kbd { min-width: 23px; padding: 2px 4px; border: 1px solid #645172; border-radius: 5px; background: #302440; color: #fbf0fc; font: 800 12px var(--mono); text-align: center; box-shadow: 0 2px #171020; }
.wide-key { padding-inline: 6px; }
.tip { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.tip i { width: 6px; height: 6px; background: #ab8de6; }
.touch-pad { display: none; width: 100%; justify-content: space-between; align-items: center; gap: 14px; touch-action: none; user-select: none; -webkit-user-select: none; }
.touch-directions { display: flex; gap: 8px; }
.touch-pad button { border: 1px solid #8b6eac; border-radius: 11px; min-width: 59px; height: 56px; padding: 0 12px; box-shadow: 0 3px #120d20; background: #3a2a50; touch-action: none; font: 900 26px var(--mono); }
.touch-pad button.held { transform: translateY(2px); box-shadow: 0 1px #120d20; background: #624d7c; }
.touch-pad .touch-jump { min-width: 103px; background: #ffd371; color: #261930; border-color: #ffdf8d; box-shadow: 0 3px #a96237; }
.touch-pad .touch-jump.held { background: #ffe194; box-shadow: 0 1px #a96237; }
.touch-jump span { font: 900 14px Inter, ui-sans-serif, system-ui, sans-serif; vertical-align: 2px; }

@media (pointer: coarse), (hover: none) {
  .touch-pad { display: flex; }
  .controls { padding: 11px 6px 13px; }
  .key-guide, .tip { display: none; }
}

@media (max-width: 680px) and (orientation: portrait) {
  body { padding-top: max(15px, env(safe-area-inset-top)); }
  .screen { aspect-ratio: 6 / 5; }
  .cabinet { padding: 5px 5px 0; border-radius: 13px; }
  .overlay { background: linear-gradient(90deg, #171027f5 0%, #211435e5 38%, #21143555 74%, #2114350d); }
  .overlay-content { max-width: 78%; margin-left: 7%; }
  .splash-title { font-size: clamp(34px, 11cqw, 65px); }
  .overlay-copy { max-width: 235px; }
  .brand-icon { width: 30px; height: 30px; border-radius: 7px; }
  .brand-icon i { width: 18px; height: 18px; }
  .stage { gap: 4px; padding: 5px 6px; font-size: 10px; }
  .stages { gap: 4px; }
  .stage-line { display: none; }
  .hud-box { min-height: 32px; padding-inline: 6px; gap: 4px; }
  .icon-button { min-height: 34px; width: 36px; }
  .heart { width: 12px; height: 11px; }
  .points { font-size: 11px; }
  .shard { width: 9px; height: 11px; }
  .tip { display: none; }
}

@media (max-width: 350px) {
  .brand { gap: 6px; }
  .stage b { display: none; }
  .touch-pad button { min-width: 51px; }
}

@media (max-height: 540px) and (orientation: landscape) and (pointer: coarse) {
  body { padding-top: max(5px, env(safe-area-inset-top)); padding-bottom: max(5px, env(safe-area-inset-bottom)); }
  .arcade { width: min(100%, calc((100svh - 80px) * 16 / 9 + 155px)); }
  .masthead { margin: 0 0 4px; }
  .brand-icon { width: 27px; height: 27px; border-radius: 7px; }
  .brand-icon i { width: 17px; height: 17px; }
  .cabinet { padding: 5px 71px 5px 76px; position: relative; }
  .controls { position: absolute; inset: 0; padding: 5px; pointer-events: none; }
  .touch-pad { align-items: flex-end; padding-bottom: 9px; pointer-events: none; }
  .touch-pad button { pointer-events: auto; min-width: 62px; height: 44px; padding: 0 4px; }
  .touch-directions { flex-direction: column; gap: 6px; }
  .touch-pad .touch-jump { min-width: 60px; }
  .touch-jump span { display: none; }
  .hud-box, .icon-button { min-height: 30px; }
  .icon-button { width: 33px; }
  .overlay-copy { margin-block: 8px 10px; }
  .primary { padding: 7px 11px; }
}
