@font-face { font-family: 'Pixelify'; src: url('../fonts/pixelify.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
:root {
  --ink: #fbeed2; --dim: #c9b991; --warm: #ffb347; --gold: #f5c542; --red: #c4462b;
  --panel: rgba(9, 12, 34, 0.92); --edge: #6b4a24; --edge2: #2a1c10;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #070b24; color: var(--ink); overflow: hidden;
  touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; font-family: 'Pixelify', ui-monospace, monospace; -webkit-text-size-adjust: 100%; }
#stage { position: fixed; inset: 0; overflow: hidden; }
#cv { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
button { font: inherit; color: var(--ink); background: #3a2414; border: 2px solid var(--edge); border-bottom-color: var(--edge2);
  border-right-color: var(--edge2); padding: 10px 16px; min-height: 44px; font-size: 18px; cursor: pointer; touch-action: manipulation;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.35); }
button:active { transform: translateY(1px); box-shadow: none; }
button.big { background: #8a3a1c; border-color: #d8823c; border-bottom-color: #4a1c0c; border-right-color: #4a1c0c; font-size: 20px; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button[disabled] { opacity: .45; cursor: default; }
a { color: var(--gold); }
h2 { margin: 0 0 12px; font-size: 24px; color: var(--warm); font-weight: 700; letter-spacing: .5px; }
p { line-height: 1.4; margin: 8px 0; }
.note { color: var(--dim); font-size: 14px; }
b.c { color: #f38a62; } b.r { color: var(--gold); }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(16px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl)); z-index: 10; }
.screen[hidden], [hidden] { display: none !important; }
.panel { background: rgba(4, 6, 20, 0.55); overflow-y: auto; touch-action: pan-y; display: flex; }
.box { margin: auto; width: min(520px, 100%); background: var(--panel); border: 2px solid var(--edge); padding: 16px 18px 6px;
  box-shadow: 0 4px 0 rgba(0,0,0,.5); }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 12px 0; }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: stretch; width: min(320px, 100%); }

.title { justify-content: space-between; background: linear-gradient(rgba(7,11,36,.15), rgba(7,11,36,0) 40%); pointer-events: none; }
.title > * { pointer-events: auto; }
.logo { text-align: center; margin-top: 4vh; text-shadow: 0 3px 0 #2a120a, 0 0 18px rgba(255,150,60,.45); }
.logo .l1 { display: block; font-size: clamp(34px, 11vw, 64px); color: var(--warm); font-weight: 700; letter-spacing: 2px; }
.logo .l2 { display: block; font-size: clamp(26px, 8vw, 44px); color: var(--ink); font-weight: 700; letter-spacing: 6px; }
.title .menu { margin-bottom: 2vh; }
.title .menu button { background: rgba(58, 36, 20, .92); }
.title .menu button.big { background: #8a3a1c; }
.tipline { text-align: center; max-width: 520px; text-shadow: 0 1px 0 #000; }

.nights { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.nights li button { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 10px 12px; font-size: 16px; }
.nights .n { color: var(--warm); font-weight: 700; }
.nights .s { grid-column: 1 / -1; color: var(--ink); font-size: 14px; }
.nights .b { grid-column: 1 / -1; color: var(--dim); font-size: 13px; }
.nights .lmp { letter-spacing: 2px; }
.lamp { display: inline-block; width: 12px; height: 16px; margin: 0 2px; vertical-align: middle;
  background: #2a2a38; clip-path: polygon(30% 0, 70% 0, 70% 25%, 100% 40%, 100% 100%, 0 100%, 0 40%, 30% 25%); }
.lamp.on { background: var(--warm); box-shadow: 0 0 10px var(--warm); }
.lamps { text-align: center; padding: 6px 0 10px; }
.lamps .lamp { width: 24px; height: 32px; margin: 0 6px; }

.card .kicker, .results .kicker { color: var(--dim); font-size: 16px; letter-spacing: 1px; }
.card h2, .results h2 { margin-top: 2px; font-size: 28px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font-size: 18px; }
.stats dt { color: var(--dim); } .stats dd { margin: 0; text-align: right; }
.grades { font-size: 14px; color: var(--dim); }

.ending #eText p { font-size: 20px; text-align: center; opacity: 0; animation: fadein 1.6s forwards; }
.ending #eText p:nth-child(2) { animation-delay: 1.6s; } .ending #eText p:nth-child(3) { animation-delay: 3.4s; }
.ending #eText { padding: 8px 0; }
@keyframes fadein { to { opacity: 1; } }

.slider { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.slider input { width: 55%; accent-color: var(--warm); touch-action: pan-x; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.seg { display: flex; align-items: center; gap: 4px; }
.seg button { padding: 6px 10px; font-size: 16px; min-width: 44px; }
.seg button.on { background: #8a3a1c; border-color: #d8823c; }
.seg output { min-width: 84px; text-align: center; }
.check { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--warm); }

/* play HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.hud-top { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(6px + var(--st)) calc(8px + var(--sr)) 0 calc(10px + var(--sl)); text-shadow: 0 2px 0 #000; }
#hNight { color: var(--warm); font-size: 15px; } #hSong { font-size: 13px; color: var(--dim); max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-r { display: flex; align-items: center; gap: 10px; }
#hScore { font-size: 22px; font-variant-numeric: tabular-nums; }
button.icon { pointer-events: auto; min-width: 44px; min-height: 44px; padding: 4px; font-size: 14px; background: rgba(20,14,10,.7); }
#yard { position: absolute; left: calc(10px + var(--sl)); top: calc(44px + var(--st)); display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--dim); }
#yard i { display: block; width: 90px; height: 8px; background: rgba(0,0,0,.6); border: 1px solid #5a4020; }
#yard b { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, #a8431c, var(--warm), #ffe9a8); transition: width .15s linear; }
#caption { position: absolute; left: 50%; transform: translateX(-50%); width: min(92vw, 640px); text-align: center; font-size: clamp(15px, 4.2vw, 22px);
  color: #fff3d6; text-shadow: 0 2px 0 #000, 0 0 8px #000; line-height: 1.25; transition: opacity .25s; }
#caption .next { display: block; font-size: .7em; color: var(--dim); margin-top: 2px; }
#judge, #combo { position: absolute; left: 50%; transform: translateX(-50%); text-align: center; white-space: nowrap; text-shadow: 0 2px 0 #000; }
#judge { font-size: 20px; font-weight: 700; color: #fff1a8; }
#judge.pop { animation: pop .35s ease-out; }
#judge.miss { color: #ff8f6b; } #judge.close { color: #e7c9a0; } #judge.count { color: var(--warm); font-size: 28px; }
#combo { font-size: 14px; color: var(--ink); }
#solo { position: absolute; left: 50%; top: calc(64px + var(--st)); transform: translateX(-50%); font-size: 30px; font-weight: 700; letter-spacing: 6px;
  color: var(--warm); text-shadow: 0 3px 0 #2a120a, 0 0 14px rgba(255,150,60,.6); }
.lanes { display: grid; gap: 10px; }
.lanes button { display: grid; gap: 4px; text-align: left; padding: 14px 16px; }
.lanes .ln { font-size: 22px; font-weight: 700; color: var(--warm); } .lanes button.big .ln { color: #fff1d0; }
.lanes .lb { font-size: 15px; color: var(--ink); } .lanes .lp { font-size: 13px; color: var(--dim); }
@keyframes pop { from { scale: 1.35; } to { scale: 1; } }
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
#labels span { position: absolute; transform: translate(-50%, -50%); font-size: 16px; font-weight: 700; color: #3b2410; opacity: .8; }
#labels #lR { color: #f5d77a; text-shadow: 0 1px 0 #000; }
#keys { position: absolute; left: 0; right: 0; bottom: calc(4px + var(--sb)); text-align: center; font-size: 12px; color: var(--dim); z-index: 4; pointer-events: none; text-shadow: 0 1px 0 #000; }

.calib { background: transparent; justify-content: flex-start; pointer-events: none; padding-top: calc(70px + var(--st)); }
.calbox { pointer-events: auto; background: var(--panel); border: 2px solid var(--edge); padding: 12px 18px; text-align: center; width: min(420px, 100%); }
#toast { position: fixed; left: 50%; bottom: calc(20px + var(--sb)); transform: translateX(-50%); background: var(--panel); border: 2px solid var(--edge);
  padding: 10px 14px; z-index: 30; font-size: 15px; max-width: 90vw; }
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .logo { margin-top: 0; } .logo .l1 { font-size: 40px; } .logo .l2 { font-size: 28px; }
  .title .menu { display: grid; grid-template-columns: 1fr 1fr; width: min(560px, 100%); margin-bottom: 0; }
  .tipline { font-size: 12px; margin: 4px 0 0; }
}
@media (prefers-reduced-motion: reduce) { #judge.pop { animation: none; } .ending #eText p { animation-duration: .01s; } }
