@font-face { font-family: 'Anton'; src: url('../fonts/anton.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Barlow C'; src: url('../fonts/barlow-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Barlow C'; src: url('../fonts/barlow-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --red: #ff2a3a; --cyan: #22e6ff; --gold: #ffc23a; --ink: #05060c;
  --display: 'Anton', 'Impact', 'Arial Black', sans-serif;
  --cond: 'Barlow C', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --cjk: 'Noto Sans CJK SC', 'Noto Sans CJK JP', 'PingFang SC', 'Hiragino Sans', 'Microsoft YaHei', 'Yu Gothic', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); overflow: hidden; color: #fff; font-family: var(--cond); user-select: none; -webkit-user-select: none; touch-action: none; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------- boot */
#boot { position: fixed; inset: 0; background: radial-gradient(circle at 50% 60%, #2a0a0a, #05060c 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 50; transition: opacity .5s; }
#boot.done { opacity: 0; pointer-events: none; }
#boot .bt-logo { font-family: var(--display); font-size: clamp(28px, 6vw, 72px); letter-spacing: .02em; transform: skewX(-8deg); text-shadow: 3px 3px 0 var(--red), -2px -2px 0 rgba(34,230,255,.6); }
#boot .bt-msg { font-weight: 600; letter-spacing: .2em; opacity: .7; font-size: 14px; }
#boot .bt-bar { width: min(320px, 60vw); height: 3px; background: #222; overflow: hidden; }
#boot .bt-bar i { display: block; height: 100%; width: 40%; background: var(--red); animation: slide 1.1s infinite ease-in-out; }
#boot footer, .screen footer { position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-weight: 600; font-size: 13px; letter-spacing: .12em; opacity: .65; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ------------------------------------------------------------- screens */
#ui { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; display: flex; flex-direction: column; }
.screen.title { align-items: flex-start; justify-content: center; padding-left: 7vw; background: linear-gradient(90deg, rgba(5,6,12,.85) 0%, rgba(5,6,12,.35) 45%, rgba(5,6,12,0) 70%); cursor: pointer; }
.brand .site { font-weight: 800; letter-spacing: .5em; font-size: clamp(11px, 1.3vw, 16px); color: var(--cyan); margin-bottom: 10px; text-shadow: 0 0 12px rgba(34,230,255,.6); }
.logo { margin: 0; font-family: var(--display); font-weight: 400; line-height: .86; transform: skewX(-9deg); display: flex; flex-direction: column; font-size: clamp(54px, 10.5vw, 168px); letter-spacing: .005em; }
.logo span { display: block; }
.logo .l1 { color: #fff; text-shadow: 5px 5px 0 rgba(255,42,58,.85), 0 0 40px rgba(255,80,40,.35); }
.logo .l2 { color: transparent; -webkit-text-stroke: 2px #fff; text-shadow: 0 0 30px rgba(255,42,58,.6); margin-left: .35em; }
.logo .l3 { color: var(--red); text-shadow: -4px -4px 0 rgba(34,230,255,.55), 0 0 50px rgba(255,42,58,.6); }
.brand .tag { margin-top: 16px; font-weight: 600; font-size: clamp(14px, 1.6vw, 22px); letter-spacing: .1em; opacity: .85; }
.press { margin-top: 6vh; font-family: var(--display); font-size: clamp(18px, 2.2vw, 30px); letter-spacing: .25em; animation: blinkSoft 1.2s infinite; -webkit-text-stroke: 1px rgba(0,0,0,.8); text-shadow: 0 0 2px #000, 0 2px 8px rgba(0,0,0,.9); }
@keyframes blinkSoft { 50% { opacity: .7; } }
@keyframes blink { 50% { opacity: .25; } }

.screen.menu { justify-content: center; padding: 4vh 7vw; background: linear-gradient(90deg, rgba(5,6,12,.92) 0%, rgba(5,6,12,.6) 50%, rgba(5,6,12,.25) 100%); }
.brand.small .logo { font-size: clamp(32px, 5vw, 70px); flex-direction: row; gap: .25em; }
.brand.small .logo .l2 { margin-left: 0; }
.screen h2 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 5vw, 76px); margin: 0 0 2vh; transform: skewX(-8deg); text-shadow: 4px 4px 0 var(--fc, var(--red)); }
nav { display: flex; flex-direction: column; gap: 8px; margin-top: 3vh; width: min(520px, 86vw); }
.btn, .opt { pointer-events: auto; position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 16px; text-align: left; background: rgba(255,255,255,.04); border: 0; border-left: 4px solid rgba(255,255,255,.15); padding: 12px 18px; cursor: pointer; transform: skewX(-8deg); transition: background .12s, border-color .12s, transform .12s; color: #fff; }
.btn b, .opt b { font-family: var(--display); font-weight: 400; font-size: clamp(20px, 2.2vw, 30px); letter-spacing: .04em; }
.btn small { font-weight: 600; font-size: 14px; opacity: .6; letter-spacing: .05em; }
.opt span, .btn span { font-weight: 800; font-size: clamp(14px, 1.5vw, 19px); letter-spacing: .06em; color: var(--gold); }
.opt span::before { content: '◀ '; opacity: .5; } .opt span::after { content: ' ▶'; opacity: .5; }
.btn.focus, .opt.focus { background: linear-gradient(90deg, rgba(255,42,58,.4), rgba(255,42,58,.05)); border-left-color: var(--red); transform: skewX(-8deg) translateX(10px); }
.btn.go b { color: var(--gold); }
.cards { display: flex; gap: 20px; align-items: center; }
.fcard { width: min(360px, 40vw); padding: 16px 20px; background: linear-gradient(135deg, rgba(0,0,0,.6), rgba(0,0,0,.2)); border-top: 4px solid var(--fc); transform: skewX(-8deg); }
.fc-name { font-family: var(--display); font-size: clamp(26px, 3vw, 44px); color: #fff; text-shadow: 0 2px 0 var(--fc), 0 0 14px rgba(0,0,0,.6); }
.fc-song { font-weight: 800; color: var(--gold); letter-spacing: .08em; margin: 4px 0 10px; }
.fc-stats { display: flex; flex-direction: column; gap: 2px; font-weight: 600; font-size: 14px; opacity: .8; letter-spacing: .06em; }
.vs-mark { font-family: var(--display); font-size: 48px; color: var(--red); transform: skewX(-8deg); }
.keys-hint { margin-top: 3vh; font-weight: 600; opacity: .6; font-size: 14px; letter-spacing: .04em; }
.settings .cols { display: flex; gap: 4vw; flex-wrap: wrap; }
.settings .col { display: flex; flex-direction: column; gap: 8px; width: min(440px, 86vw); }
.settings .keys { flex-direction: row; gap: 18px; width: auto; }
.settings .kp { display: flex; flex-direction: column; gap: 4px; }
.settings .kp h4 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; letter-spacing: .1em; color: var(--cyan); }
.btn.key { padding: 5px 12px; min-width: 210px; } .btn.key b { font-size: 17px; } .btn.key span { color: #fff; font-size: 15px; }
.btn.key.wait span { color: var(--gold); animation: blink .6s infinite; }
.slider input { width: 55%; accent-color: var(--red); pointer-events: auto; }
.screen.pause { background: rgba(5,6,12,.75); align-items: center; }
.screen.pause nav { align-items: stretch; }
.screen.results, .screen.ending { align-items: center; background: linear-gradient(0deg, rgba(5,6,12,.85), rgba(5,6,12,0) 60%); justify-content: flex-end; padding-bottom: 10vh; }
.screen.ending p { font-size: 20px; font-weight: 600; opacity: .9; }
.loading { background: radial-gradient(circle at 50% 60%, rgba(40,8,8,.95), rgba(5,6,12,.98) 70%); align-items: center; justify-content: center; gap: 14px; pointer-events: auto; }
.ld-time { font-weight: 800; letter-spacing: .3em; color: var(--gold); font-size: 15px; }
.ld-title { font-family: var(--display); font-size: clamp(40px, 7vw, 96px); transform: skewX(-8deg); text-shadow: 4px 4px 0 var(--red); }
.ld-bar { width: min(480px, 70vw); height: 4px; background: rgba(255,255,255,.12); }
.ld-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); transform-origin: left; transform: scaleX(0); transition: transform .2s; }
.ld-tip { font-weight: 600; opacity: .55; letter-spacing: .05em; }

/* ------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-top { position: absolute; top: max(14px, env(safe-area-inset-top)); left: max(2.4vw, env(safe-area-inset-left)); right: max(2.4vw, env(safe-area-inset-right)); display: flex; align-items: flex-start; gap: 1.6vw; }
.hud-side { flex: 1; display: flex; flex-direction: column; gap: 4px; --fc: #f33; }
.hud-side.side1 { align-items: flex-end; }
.name-row { display: flex; align-items: center; gap: 12px; }
.side1 .name-row { flex-direction: row-reverse; }
.fname { font-family: var(--display); font-size: clamp(16px, 2.1vw, 30px); letter-spacing: .04em; transform: skewX(-10deg); text-shadow: 2px 2px 0 rgba(0,0,0,.8), 0 0 18px var(--fc); }
.pips { display: flex; gap: 5px; }
.pips i { width: 14px; height: 14px; transform: rotate(45deg) scale(.8); border: 2px solid rgba(255,255,255,.6); background: rgba(0,0,0,.4); }
.pips i.on { background: var(--gold); border-color: #fff; box-shadow: 0 0 10px var(--gold); }
.status { display: flex; gap: 6px; }
.st { font-style: normal; font-weight: 800; font-size: 12px; letter-spacing: .08em; padding: 2px 6px; transform: skewX(-10deg); background: rgba(0,0,0,.55); border: 1px solid currentColor; }
.st.toe, .st.shield { color: var(--cyan); } .st.steam { color: #cfc8d8; } .st.fw { color: #ff8a2a; } .st.seven { color: var(--gold); font-family: var(--cjk); }
.bar { position: relative; width: 100%; height: clamp(14px, 2.6vh, 26px); transform: skewX(-24deg); background: linear-gradient(180deg, rgba(10,10,16,.85), rgba(30,30,40,.8)); border: 2px solid rgba(255,255,255,.75); box-shadow: 0 0 0 2px rgba(0,0,0,.6), 0 4px 18px rgba(0,0,0,.5); overflow: hidden; }
.bar .fill, .bar .trail { position: absolute; inset: 0; transform-origin: left; }
.side1 .bar .fill, .side1 .bar .trail { transform-origin: right; }
.bar .trail { background: #fff; opacity: .85; }
.bar .fill { background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 55%, #fff) 0%, var(--fc) 45%, color-mix(in srgb, var(--fc) 70%, #000) 100%); box-shadow: inset 0 0 12px rgba(255,255,255,.25); transition: transform .06s; }
.bar .shine { position: absolute; left: 0; right: 0; top: 0; height: 40%; background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0)); }
.bar .ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(0,0,0,.35) calc(10% - 2px) 10%); }
.hud-side.low .bar { animation: lowpulse .5s infinite alternate; }
@keyframes lowpulse { to { border-color: var(--red); box-shadow: 0 0 0 2px rgba(0,0,0,.6), 0 0 20px rgba(255,42,58,.8); } }
.sub-row { display: flex; gap: 10px; font-weight: 800; font-size: 13px; letter-spacing: .14em; opacity: .85; }
.side1 .sub-row { flex-direction: row-reverse; }
.sub-row .label { opacity: .55; }
.hud-timer { position: relative; flex: 0 0 auto; width: clamp(64px, 7vw, 100px); height: clamp(64px, 7vw, 100px); display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: -4px; }
.hud-timer::before { content: ''; position: absolute; inset: 6px; background: rgba(5,6,12,.75); border: 2px solid rgba(255,255,255,.8); transform: rotate(45deg); box-shadow: 0 0 18px rgba(0,0,0,.6); }
.hud-timer .beat-ring { position: absolute; inset: 0; border: 2px solid var(--gold); transform-origin: center; border-radius: 50%; box-shadow: 0 0 14px rgba(255,194,58,.7); }
.hud-timer span { position: relative; font-family: var(--display); font-size: clamp(26px, 3.2vw, 46px); line-height: 1; }
.hud-timer small { position: absolute; bottom: -18px; white-space: nowrap; font-weight: 800; font-size: 12px; letter-spacing: .2em; color: var(--gold); text-shadow: 0 1px 2px #000; }
.hud-timer.hurry span { color: var(--red); animation: blink .5s infinite; }
.hud-cres { position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); width: min(34vw, 420px); --fc: #f33; display: flex; flex-direction: column; gap: 3px; }
.hud-cres.side0 { left: max(2.4vw, env(safe-area-inset-left)); }
.hud-cres.side1 { right: max(2.4vw, env(safe-area-inset-right)); align-items: flex-end; }
.cres-label { font-weight: 800; font-size: 12px; letter-spacing: .3em; opacity: .7; }
.cres-bar { width: 100%; height: 10px; transform: skewX(-24deg); background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.5); overflow: hidden; }
.cres-fill { height: 100%; transform-origin: left; background: linear-gradient(90deg, #ff8a2a, var(--gold), #fff); transition: transform .15s; }
.side1 .cres-fill { transform-origin: right; }
.hud-cres.full .cres-bar { border-color: var(--gold); box-shadow: 0 0 16px var(--gold); animation: crespulse .3s infinite alternate; }
@keyframes crespulse { to { box-shadow: 0 0 28px #fff; } }
.cres-ready { display: none; font-family: var(--display); font-size: 18px; color: var(--gold); letter-spacing: .12em; transform: skewX(-10deg); text-shadow: 0 0 10px var(--gold); }
.hud-cres.full .cres-ready { display: block; animation: blink .4s infinite; }
.cres-label { display: flex; align-items: center; gap: 8px; }
.side1 .cres-label { flex-direction: row-reverse; }
.corner-icon { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--hc); box-shadow: 0 0 10px var(--hc), inset 0 0 8px var(--hc); background: radial-gradient(circle, var(--hc) 0 25%, rgba(0,0,0,.5) 30%); }
.corner-icon.used { filter: grayscale(1); opacity: .3; box-shadow: none; }

.hud-callouts { position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + clamp(70px, 12vh, 110px)); display: flex; flex-direction: column; gap: 4px; }
.hud-callouts.side0 { left: 3vw; align-items: flex-start; } .hud-callouts.side1 { right: 3vw; align-items: flex-end; }
.callout { font-family: var(--display); font-size: clamp(16px, 2vw, 28px); letter-spacing: .05em; transform: skewX(-10deg); text-shadow: 2px 2px 0 #000, 0 0 14px rgba(0,0,0,.8); animation: callin .18s ease-out, fadeout .4s .9s forwards; }
.callout.move { color: #fff; font-size: clamp(14px, 1.6vw, 22px); opacity: .9; }
.callout.chain { color: var(--gold); font-size: clamp(22px, 2.8vw, 40px); text-shadow: 3px 3px 0 var(--red), 0 0 20px rgba(255,194,58,.6); }
.callout.held { color: var(--cyan); } .callout.off { color: #ff6ad5; } .callout.burn { color: #ff8a2a; } .callout.assist { color: #fff; text-shadow: 3px 3px 0 var(--red); } .callout.buff { color: var(--cyan); }
@keyframes callin { from { transform: skewX(-10deg) translateX(-30px) scale(1.4); opacity: 0; } }
@keyframes fadeout { to { opacity: 0; transform: skewX(-10deg) translateY(-10px); } }

.hud-card { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.card { position: relative; display: flex; flex-direction: column; align-items: center; animation: slam .22s cubic-bezier(.2,1.6,.4,1); }
.card.out { animation: cardout .35s forwards; }
.card .slash { position: absolute; left: -30vw; right: -30vw; top: 50%; height: 46%; transform: translateY(-50%) skewY(-4deg); background: linear-gradient(90deg, transparent, rgba(0,0,0,.75) 20%, rgba(0,0,0,.75) 80%, transparent); border-top: 3px solid var(--red); border-bottom: 3px solid var(--red); }
.card .txt { position: relative; font-family: var(--display); font-size: clamp(56px, 12vw, 190px); line-height: 1; transform: skewX(-10deg); color: #fff; letter-spacing: .01em; text-shadow: 1px 0 0 rgba(34,230,255,.8), -1px 0 0 rgba(255,42,58,.8), 6px 6px 0 rgba(150,10,20,.9), 0 0 50px rgba(255,80,40,.45); -webkit-text-stroke: 1px rgba(0,0,0,.35); white-space: nowrap; }
.card .sub { position: relative; margin-top: 8px; font-weight: 800; font-size: clamp(16px, 2.2vw, 30px); letter-spacing: .2em; color: var(--gold); font-family: var(--cond), var(--cjk); text-shadow: 0 2px 4px #000; }
.card.play .txt { font-size: clamp(80px, 17vw, 260px); color: var(--gold); text-shadow: 1px 0 0 rgba(255,255,255,.6), 7px 7px 0 var(--red), 0 0 70px rgba(255,194,58,.5); }
.card.ko .txt { color: #fff; text-shadow: 1px 0 0 rgba(34,230,255,.8), -1px 0 0 var(--red), 7px 7px 0 #000, 0 0 80px rgba(255,42,58,.8); }
.card.drop .txt { color: var(--gold); font-size: clamp(60px, 13vw, 200px); }
.card.seven .txt { font-size: clamp(34px, 6vw, 96px); }
.card.winline { animation: slam .3s cubic-bezier(.2,1.6,.4,1); margin-top: 32vh; }
.winline .who { font-family: var(--display); font-size: clamp(34px, 5vw, 80px); transform: skewX(-10deg); text-shadow: 5px 5px 0 var(--fc); }
.winline .cjk { font-family: var(--cjk); font-weight: 900; font-size: clamp(28px, 4.4vw, 68px); margin-top: 6px; text-shadow: 0 0 30px rgba(255,194,58,.5), 3px 3px 0 #000; }
.winline .en { font-weight: 800; font-size: clamp(16px, 2vw, 28px); letter-spacing: .2em; color: var(--gold); margin-top: 4px; text-shadow: 0 2px 6px #000; }
@keyframes slam { from { transform: scale(2.6); opacity: 0; filter: blur(10px); } 70% { transform: scale(.96); opacity: 1; filter: blur(0); } to { transform: scale(1); } }
@keyframes cardout { to { transform: scale(1.12); opacity: 0; filter: blur(6px); } }
.hud-panel { position: absolute; left: 50%; bottom: 14vh; transform: translateX(-50%); display: flex; gap: 2vw; }
.hud-panel .help { width: min(40vw, 440px); padding: 14px 18px; background: rgba(5,6,12,.82); border-left: 4px solid var(--hc); display: flex; flex-direction: column; gap: 2px; transform: skewX(-6deg); animation: callin .25s; }
.help b { font-family: var(--display); font-weight: 400; font-size: 24px; color: var(--hc); letter-spacing: .05em; }
.help .what { font-weight: 800; color: #fff; letter-spacing: .1em; }
.help span { font-weight: 600; opacity: .85; } .help i { margin-top: 6px; color: var(--gold); font-weight: 600; }
.hud-movelist { position: absolute; left: 2.4vw; top: 22vh; width: min(330px, 34vw); background: rgba(5,6,12,.7); padding: 12px 16px; border-left: 3px solid var(--cyan); font-size: 15px; }
.hud-movelist h4 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; letter-spacing: .08em; color: var(--cyan); }
.hud-movelist div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; font-weight: 600; }
.hud-movelist b { color: var(--gold); font-weight: 800; white-space: nowrap; } .hud-movelist .hint { opacity: .75; }
.hud-flash { position: absolute; inset: 0; opacity: 0; }
.hud-letterbox::before, .hud-letterbox::after { content: ''; position: absolute; left: 0; right: 0; height: 9vh; background: #000; transition: transform .45s ease; }
.hud-letterbox::before { top: 0; transform: translateY(-100%); } .hud-letterbox::after { bottom: 0; transform: translateY(100%); }
.hud-letterbox.on::before, .hud-letterbox.on::after { transform: none; }

/* ------------------------------------------------------------- touch */
#touch { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#touch .pad { position: absolute; left: max(4vw, env(safe-area-inset-left)); bottom: 7vh; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.08), rgba(255,255,255,.02)); border: 2px solid rgba(255,255,255,.22); pointer-events: auto; touch-action: none; }
#touch .knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: rgba(255,255,255,.25); border: 2px solid rgba(255,255,255,.5); }
#touch .btns { position: absolute; right: max(4vw, env(safe-area-inset-right)); bottom: 5vh; width: 210px; height: 190px; pointer-events: none; }
#touch .btns button { position: absolute; width: 74px; height: 74px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); font-family: var(--display); font-size: 15px; letter-spacing: .06em; pointer-events: auto; touch-action: none; }
#touch .btns button.on { background: rgba(255,42,58,.45); border-color: #fff; }
#touch [data-k=beat] { left: 0; top: 60px; } #touch [data-k=riff] { left: 68px; top: 116px; } #touch [data-k=hook] { left: 136px; top: 60px; } #touch [data-k=drop] { left: 68px; top: 4px; width: 74px; height: 56px; border-radius: 30px; opacity: .45; }
#touch [data-k=drop].ready { opacity: 1; border-color: var(--gold); color: var(--gold); box-shadow: 0 0 22px var(--gold), inset 0 0 14px rgba(255,194,58,.5); animation: crespulse .35s infinite alternate; }
#touch .corner-btn { position: absolute; right: calc(max(4vw, env(safe-area-inset-right)) + 220px); bottom: 6vh; width: 48px; height: 48px; border-radius: 50%; border: 2px solid #3fe0ff; background: radial-gradient(circle, #3fe0ff 0 22%, rgba(0,0,0,.4) 26%); pointer-events: auto; box-shadow: 0 0 12px #3fe0ff; }
#touch .corner-btn.used { opacity: .25; box-shadow: none; }
#touch .pause-btn { position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + 70px); left: 50%; margin-left: -20px; width: 40px; height: 34px; background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.4); display: flex; gap: 6px; align-items: center; justify-content: center; pointer-events: auto; }
#touch .pause-btn i { width: 4px; height: 14px; background: #fff; }

/* ------------------------------------------------------------- rotate prompt */
#rotate { display: none; position: fixed; inset: 0; z-index: 100; background: #05060c; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; font-weight: 800; font-size: 20px; letter-spacing: .06em; }
#rotate .phone { width: 60px; height: 100px; border: 4px solid #fff; border-radius: 10px; animation: turn 1.6s infinite ease-in-out; }
@keyframes turn { 50%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
#fps { position: fixed; right: 8px; bottom: 6px; z-index: 60; font: 600 12px var(--cond); opacity: .7; }

/* small landscape screens (phones) */
@media (max-height: 500px) {
  .screen.menu { padding: 2vh 5vw; }
  nav { gap: 4px; margin-top: 1.5vh; }
  .btn, .opt { padding: 6px 14px; }
  .btn small { display: none; }
  .fcard { padding: 8px 12px; } .fc-stats { font-size: 12px; }
  .hud-callouts { top: 104px; }
  .sub-row { display: none; }
  .hud-cres { width: 30vw; bottom: auto; top: 74px; }
  .hud-cres .cres-label { font-size: 9px; letter-spacing: .2em; }
  .cres-bar { height: 7px; }
  .cres-ready { font-size: 13px; }
  .corner-icon { width: 16px; height: 16px; }
  .screen h2 { font-size: 30px; margin-bottom: 4px; }
  .fc-name { font-size: 22px; } .fc-song { margin: 0 0 2px; font-size: 13px; }
  .fc-stats span:nth-child(2) { display: none; }
  .vs-mark { font-size: 30px; }
  .btn b, .opt b { font-size: 18px; }
  .keys-hint { margin-top: 6px; font-size: 12px; }
  .hud-panel { bottom: 4vh; } .hud-panel .help { width: 36vw; padding: 8px 12px; font-size: 13px; } .help b { font-size: 18px; }
  .card .txt { font-size: 15vw; }
  .winline .cjk { font-size: 6vw; } .winline .who { font-size: 6vw; }
  .hud-movelist { top: 90px; font-size: 12px; }
  .settings .keys { display: none; }
}

.res-line { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.res-line span { font-family: var(--cjk); font-weight: 900; font-size: clamp(22px, 3vw, 44px); text-shadow: 0 0 20px rgba(255,194,58,.4), 2px 2px 0 #000; }
.res-line small { font-weight: 800; letter-spacing: .2em; color: var(--gold); font-size: clamp(13px, 1.4vw, 20px); }
.screen.results nav { align-items: stretch; width: min(380px, 80vw); }
.card.winline { padding: 18px 8vw; background: linear-gradient(90deg, transparent, rgba(0,0,0,.65) 20%, rgba(0,0,0,.65) 80%, transparent); }

/* v2: HUD hides in cinematic (letterbox) moments; dark plate behind the top cluster */
#hud .hud-top, #hud .hud-cres { transition: opacity .3s, visibility .3s; }
#hud.cinematic .hud-top, #hud.cinematic .hud-cres, #hud.cinematic .hud-callouts { opacity: 0; visibility: hidden; }
#hud::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 15vh; background: linear-gradient(180deg, rgba(4,5,10,.72), rgba(4,5,10,.35) 60%, rgba(4,5,10,0)); pointer-events: none; transition: opacity .3s; }
#hud.cinematic::before { opacity: 0; }
.hud-timer::after { content: ''; position: absolute; inset: -10px -18px -26px; background: rgba(0,0,0,.55); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); border-radius: 10px; z-index: -1; }
.hud-timer { z-index: 1; isolation: isolate; }
.hud-card.top { align-items: flex-start; padding-top: 17vh; }
.hud-card.low { align-items: flex-end; padding-bottom: 17vh; }
.hud-card.top .card .txt, .hud-card.low .card .txt { font-size: clamp(44px, 8.5vw, 124px); }
.hud-card.top .card.play .txt, .hud-card.low .card.play .txt { font-size: clamp(54px, 10vw, 150px); }
.hud-card .card .slash { height: 60%; }
.card .txt { opacity: 1; }
/* results v2 */
.screen.results { align-items: flex-start; justify-content: center; padding: 6vh 6vw; background: linear-gradient(90deg, rgba(5,6,12,.9) 0%, rgba(5,6,12,.75) 34%, rgba(5,6,12,0) 60%); }
.screen.results .res-line { align-items: flex-start; }
.verse-sum { margin: 2vh 0 1vh; display: flex; flex-direction: column; gap: 4px; width: min(460px, 40vw); }
.verse-sum div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; background: rgba(255,255,255,.05); border-left: 3px solid var(--wc, #888); font-weight: 600; letter-spacing: .05em; transform: skewX(-8deg); }
.verse-sum b { font-family: var(--display); font-weight: 400; letter-spacing: .08em; }
.screen.ending { align-items: flex-start; justify-content: flex-end; padding: 0 6vw 9vh; background: linear-gradient(0deg, rgba(5,6,12,.75), rgba(5,6,12,0) 40%); }
.screen.ending nav { width: min(320px, 60vw); }
/* phone controls v2: corner button inside the cluster, labelled */
#touch .corner-btn { right: calc(max(4vw, env(safe-area-inset-right)) + 150px); bottom: calc(5vh + 4px); width: 54px; height: 54px; font: 400 10px var(--display); color: #bff6ff; letter-spacing: .05em; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; }
#touch .corner-btn::after { content: 'CORNER'; }
#touch .btns { width: 230px; }
@media (max-height: 500px) {
  .cres-ready { position: absolute; right: 0; top: -2px; font-size: 11px; }
  .side1 .cres-ready { right: auto; left: 0; }
  .hud-cres { width: 24vw; }
  #hud::before { height: 26vh; }
}

#touch .btns { width: 230px; height: 206px; bottom: 4vh; }
#touch .btns [data-k=beat] { left: 0; top: 70px; } #touch .btns [data-k=riff] { left: 76px; top: 112px; } #touch .btns [data-k=hook] { left: 152px; top: 70px; }
#touch .btns [data-k=drop] { left: 76px; top: 30px; width: 74px; height: 52px; border-radius: 28px; }
#touch .btns .corner-btn { position: absolute; left: 164px; top: 150px; right: auto; bottom: auto; width: 54px; height: 54px; border-radius: 50%; }

/* review 2: win caption in the left third, never over the winner */
.hud-card .card.winline { position: absolute; left: 4vw; bottom: 14vh; margin: 0; align-items: flex-start; padding: 16px 28px; width: min(40vw, 640px); background: linear-gradient(90deg, rgba(0,0,0,.72), rgba(0,0,0,.5) 80%, transparent); }
.winline .who { font-size: clamp(30px, 3.6vw, 60px); } .winline .cjk { font-size: clamp(24px, 3vw, 50px); }
/* touch: nothing shows through cards or panels */
#touch.off { visibility: hidden; }
#touch .pause-btn { top: auto; bottom: 3vh; left: 50%; margin-left: -20px; }
.hud-movelist { top: auto; bottom: 13vh; left: 2.4vw; width: min(300px, 26vw); font-size: 13px; padding: 8px 12px; }
@media (max-height: 500px) { .hud-movelist { display: none; } #touch .btns { right: max(3vw, env(safe-area-inset-right)); transform: scale(.92); transform-origin: bottom right; } }
.hud-card .card.winline .cjk { white-space: nowrap; }
@media (max-height: 500px) { .verse-sum { width: min(520px, 55vw); } .verse-sum div { padding: 3px 10px; font-size: 12px; } .verse-sum b { white-space: nowrap; } .res-line span { font-size: 22px; } }
.hud-panel .help { width: min(30vw, 400px); } .hud-panel { gap: 1.2vw; } @media (max-height: 500px) { .hud-panel .help { width: 30vw; font-size: 11px; } .help b { font-size: 15px; } }
/* QA: cards placed in a computed safe rectangle */
.hud-card.placed { position: absolute; inset: auto; display: flex; align-items: center; justify-content: center; padding: 0; }
.hud-card.placed .card .txt, .hud-card.placed .card.play .txt { font-size: var(--cfs) !important; }
.hud-card.placed .card .sub { font-size: calc(var(--cfs) * 0.22); margin-top: 2px; }
.hud-card.placed .card .slash { left: -3%; right: -3%; height: 70%; }
/* ---------------------------------------------------------- Wins Board, name entry, saved run */
.btn.cont { border-left-color: var(--gold); } .btn.cont b { color: var(--gold); }
.btn.armed { background: linear-gradient(90deg, rgba(255,42,58,.65), rgba(255,42,58,.15)); border-left-color: #fff; }
.btn.armed b { color: #fff; animation: blink .5s infinite; }
.screen .note { font-weight: 600; font-size: clamp(14px, 1.5vw, 20px); opacity: .85; margin: 0 0 1vh; letter-spacing: .04em; }
.namescreen { align-items: flex-start; }
.name-slots { display: flex; gap: clamp(8px, 1.2vw, 16px); margin: 2vh 0 2vh; }
.name-slots .slot { display: flex; flex-direction: column; align-items: center; width: clamp(54px, 6vw, 92px); padding: 6px 0; background: rgba(0,0,0,.55); border-bottom: 4px solid rgba(255,255,255,.25); transform: skewX(-8deg); cursor: pointer; pointer-events: auto; }
.name-slots .slot span { font-family: var(--display); font-size: clamp(44px, 6vw, 96px); line-height: 1.05; color: #fff; }
.name-slots .slot i { font-style: normal; font-size: clamp(12px, 1.2vw, 18px); opacity: .35; padding: 2px 10px; }
.name-slots .slot.on { border-bottom-color: var(--gold); background: rgba(255,42,58,.28); }
.name-slots .slot.on span { color: var(--gold); text-shadow: 0 0 18px rgba(255,194,58,.6); animation: blinkSoft .9s infinite; }
.name-slots .slot.on i { opacity: 1; color: var(--gold); }
.namescreen .ok-btn { width: min(320px, 70vw); }
.name-touch { display: flex; gap: 12px; align-items: center; margin: 2vh 0; pointer-events: auto; }
.name-touch input { width: min(320px, 50vw); font-family: var(--display); font-size: clamp(36px, 7vw, 72px); letter-spacing: .25em; text-transform: uppercase; background: rgba(0,0,0,.6); color: var(--gold); border: 0; border-bottom: 4px solid var(--gold); padding: 4px 14px; outline: none; transform: skewX(-8deg); user-select: text; -webkit-user-select: text; }
.name-touch .ok-btn { width: auto; padding: 12px 28px; }
.name-hint { margin-top: 1.4vh; font-weight: 800; font-size: 13px; letter-spacing: .16em; color: var(--gold); opacity: .85; }
.board { align-items: flex-start; }
.board .tabs { display: flex; gap: 6px; padding: 0; background: none; border-left: 0; width: min(900px, 90vw); }
.board .tabs em { font-style: normal; font-family: var(--display); font-size: clamp(16px, 1.8vw, 26px); letter-spacing: .05em; padding: 8px 18px; background: rgba(255,255,255,.06); opacity: .6; cursor: pointer; pointer-events: auto; }
.board .tabs em.on { opacity: 1; background: linear-gradient(90deg, rgba(255,42,58,.55), rgba(255,42,58,.15)); box-shadow: inset 0 -3px 0 var(--gold); }
.board .tabs.focus { transform: skewX(-8deg); } .board .tabs.focus em.on { box-shadow: inset 0 -3px 0 #fff; }
.board-table { width: min(900px, 90vw); margin-top: 1.2vh; background: rgba(5,6,12,.72); border-left: 4px solid var(--red); padding: 6px 14px; }
.board-table table { width: 100%; border-collapse: collapse; font-weight: 600; font-size: clamp(14px, 1.45vw, 20px); letter-spacing: .04em; }
.board-table th { text-align: left; font-weight: 800; font-size: 12px; letter-spacing: .2em; color: var(--gold); opacity: .8; padding: 6px 8px; }
.board-table td { padding: 5px 8px; border-top: 1px solid rgba(255,255,255,.07); }
.board-table td.nm { font-family: var(--display); font-weight: 400; font-size: 1.25em; letter-spacing: .12em; }
.board-table td.num { font-family: var(--display); font-weight: 400; font-size: 1.25em; color: var(--gold); }
.board-table td.dt { opacity: .6; font-size: .85em; }
.board-table td.empty { opacity: .6; padding: 18px 8px; }
.board-table tr.hl td { background: rgba(255,194,58,.16); } .board-table tr.hl td.nm { color: var(--gold); text-shadow: 0 0 12px rgba(255,194,58,.5); }
.ficon { position: relative; isolation: isolate; display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; font-style: normal; font-family: var(--display); font-size: 14px; color: #000; line-height: 1; }
.ficon::before { content: ''; position: absolute; inset: 4px; background: var(--fc); transform: rotate(45deg); z-index: -1; box-shadow: 0 0 8px var(--fc); }
.board-nav { flex-direction: row; width: min(900px, 90vw); }
.board-nav .btn { flex: 1; }
@media (max-height: 500px) {
  .board-table { padding: 2px 10px; max-height: 52vh; overflow-y: auto; pointer-events: auto; }
  .board-table td { padding: 2px 6px; } .board-table th { padding: 2px 6px; font-size: 10px; }
  .board-table table { font-size: 13px; }
  .board .tabs em { font-size: 14px; padding: 5px 10px; }
  .board h2, .namescreen h2 { font-size: 26px; margin-bottom: 2px; }
  .name-slots .slot span { font-size: 42px; }
  .name-hint { font-size: 10px; margin-top: 4px; }
}
@media (max-height: 500px) { .btn.cont small { display: inline; font-size: 12px; opacity: .85; } }
.ficon { font-size: 15px; font-weight: 400; } .board-table td:nth-child(4) { width: 40px; text-align: center; }

.sitelink { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; z-index: 5; color: #fff; text-decoration: none; font-family: var(--cond); font-weight: 800; letter-spacing: .1em; font-size: 14px; padding: 8px 16px; border-radius: 999px; background: rgba(5,6,12,.6); border: 1px solid rgba(255,255,255,.25); pointer-events: auto; }
.sitelink:hover { border-color: var(--cyan); color: var(--cyan); }
