:root {
  --ink: #1b2740; --ink2: rgba(27,39,64,.62);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  --spring: cubic-bezier(.2,.9,.25,1.15);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3b08f; overscroll-behavior: none; }
body { position: fixed; inset: 0; font-family: var(--font); color: var(--ink); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; -webkit-font-smoothing: antialiased; }
html.pre body > section, html.pre #hud { opacity: 0; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

#game { position: fixed; left: 0; top: 0; width: 100vw; height: 100lvh; height: calc(100lvh + 0px); display: block; background: linear-gradient(#8f9fd8, #f6a7a0 45%, #ffcf9e 52%, #4f7f8f); }
#stage { position: fixed; inset: 0; touch-action: none; }

/* Liquid glass */
.glass {
  background: linear-gradient(180deg, rgba(255,255,255,.46), rgba(255,255,255,.22));
  -webkit-backdrop-filter: blur(18px) saturate(170%); backdrop-filter: blur(18px) saturate(170%);
  border: .5px solid rgba(255,255,255,.65);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75), inset 0 -1px 0 rgba(255,255,255,.18), 0 8px 28px rgba(80,40,30,.16);
}
.pill { border-radius: 999px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; letter-spacing: .02em; }
.pill.small { padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--ink); }
.pill.big { padding: 17px 34px; font-size: 18px; font-weight: 700; }
.round { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
.timer { position: absolute; left: 16px; top: calc(var(--sat) + 10px); width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; }
.timer svg { position: absolute; inset: 4px; width: 50px; height: 50px; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 3; stroke-linecap: round; }
.timer .track { stroke: rgba(27,39,64,.12); }
#ringfill { stroke: #ff7a5e; stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset .3s linear; }
#time { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low #time { color: #e2452f; }
.scorebox { position: absolute; left: 50%; top: calc(var(--sat) + 6px); transform: translateX(-50%); text-align: center; }
#score { font-size: 46px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: #fff; text-shadow: 0 2px 14px rgba(120,50,30,.35), 0 1px 2px rgba(120,50,30,.25); line-height: 1.05; }
.sub { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 2px; font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.95); text-shadow: 0 1px 6px rgba(120,50,30,.4); }
.combo { padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.28); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-weight: 800; transition: background .25s, transform .25s var(--spring); }
.combo.hot { background: linear-gradient(90deg, #ff8a65, #ff5f8a); color: #fff; transform: scale(1.12); text-shadow: none; }
#mute { position: fixed; right: 16px; top: calc(var(--sat) + 17px); z-index: 20; color: var(--ink); }
#mute svg { width: 22px; height: 22px; }
#mute .offi, #mute.off .on { display: none; }
#mute.off .offi { display: block; }

#pops { position: fixed; left: 0; right: 0; top: 34%; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 5; }
.pop { font-weight: 800; color: #fff; text-shadow: 0 2px 16px rgba(110,40,30,.45), 0 1px 2px rgba(110,40,30,.3); white-space: nowrap; }
.pop.trick { font-size: 24px; letter-spacing: .01em; }
.pop.points { font-size: 34px; background: linear-gradient(180deg, #fff, #ffe2c9); -webkit-background-clip: text; background-clip: text; }
.pop.small { font-size: 16px; opacity: .95; }
.pop.bad { font-size: 20px; color: #fff; padding: 6px 16px; border-radius: 999px; background: rgba(40,50,80,.28); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); text-shadow: none; }
#hint { position: fixed; left: 50%; bottom: calc(var(--sab) + 26px); transform: translateX(-50%); padding: 11px 18px; border-radius: 999px; font-size: 14.5px; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 6; }
#charge { position: fixed; left: -36px; top: -36px; width: 72px; height: 72px; pointer-events: none; z-index: 6; }
#charge svg { width: 72px; height: 72px; transform: rotate(-90deg); }
#charge circle { fill: none; stroke-width: 4; stroke-linecap: round; }
#charge .track { stroke: rgba(255,255,255,.35); fill: rgba(255,255,255,.12); }
#charge .fill { stroke: #fff; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--p, 0) * 100); filter: drop-shadow(0 0 6px rgba(255,140,90,.8)); }

/* slow-mo vignette */
html::after { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(255,120,90,.22)); opacity: 0; transition: opacity .25s; z-index: 1; }
html.slowmo::after { opacity: 1; }

/* Title */
#title { position: fixed; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(var(--sat) + 74px) 24px calc(var(--sab) + 34px); z-index: 10; }
#title .top { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.kicker { font-size: 12px; letter-spacing: .32em; font-weight: 700; color: rgba(255,255,255,.92); text-shadow: 0 1px 8px rgba(120,50,30,.35); }
h1 { margin: 0; font-size: 50px; font-weight: 800; letter-spacing: .04em; color: #fff; text-shadow: 0 4px 28px rgba(140,60,40,.38), 0 1px 3px rgba(140,60,40,.25); }
#title .bottom { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.howto { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: #fff; font-size: 14.5px; font-weight: 600; text-shadow: 0 1px 8px rgba(30,40,70,.45); }
.howto li { display: flex; align-items: center; gap: 10px; }
.howto svg { width: 22px; height: 22px; flex: none; filter: drop-shadow(0 1px 4px rgba(30,40,70,.35)); }
#startBtn { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* Result */
#result { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; z-index: 10; background: linear-gradient(180deg, rgba(255,220,200,.05), rgba(60,40,70,.18)); }
.sheet { width: min(340px, 100%); border-radius: 36px; padding: 28px 24px 22px; text-align: center; }
.label { font-size: 13px; font-weight: 700; letter-spacing: .2em; color: var(--ink2); }
.big { font-size: 64px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0 6px; }
.newbadge { display: inline-block; padding: 5px 12px; border-radius: 999px; background: linear-gradient(90deg, #ff8a65, #ff5f8a); color: #fff; font-weight: 800; font-size: 13px; margin-bottom: 6px; }
.muted { color: var(--ink2); font-weight: 600; font-size: 15px; }
.stats { margin-top: 14px; white-space: pre-line; font-size: 13.5px; line-height: 1.7; color: var(--ink2); font-weight: 500; }
.btns { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.pill.primary { padding: 15px; font-size: 17px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #ff8f6b, #ff6d8a); box-shadow: 0 8px 22px rgba(255,100,110,.35), inset 0 1px 0 rgba(255,255,255,.4); }
.pill.ghost { padding: 11px; font-size: 15px; color: var(--ink2); }
button:active { transform: scale(.96); transition: transform .1s; }

#pause { position: fixed; inset: 0; display: grid; place-items: center; z-index: 15; background: rgba(40,40,70,.15); }
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: grid; place-items: center; position: fixed; inset: 0; z-index: 50; background: linear-gradient(#8f9fd8, #f6a7a0 60%, #ffcf9e); }
}

/* ---- v2 ---- */
#cue { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 4; opacity: 0; transition: opacity .12s; }
#cue i { position: absolute; left: -46px; top: -46px; width: 92px; height: 92px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); box-shadow: 0 0 18px rgba(255,255,255,.6), inset 0 0 14px rgba(255,255,255,.35); transform: scale(1.4); transition: transform .25s cubic-bezier(.2,.9,.3,1.2), border-color .15s, box-shadow .15s; }
#cue .lbl { position: absolute; left: 0; top: -84px; transform: translateX(-50%); white-space: nowrap; font-weight: 900; font-size: 22px; color: #fff; letter-spacing: .04em; text-shadow: 0 2px 12px rgba(120,40,30,.5); }
#cue.soon { opacity: .55; }
#cue.soon i { transform: scale(1.6); }
#cue.ready, #cue.now, #cue.spin, #cue.release { opacity: 1; }
#cue.ready i { transform: scale(1.05); }
#cue.now i { transform: scale(.9); border-color: #ffe08a; box-shadow: 0 0 26px 6px rgba(255,214,120,.85), inset 0 0 18px rgba(255,230,160,.7); animation: cuepulse .32s ease-in-out infinite alternate; }
#cue.now .lbl { color: #fff6d8; font-size: 28px; text-shadow: 0 0 18px rgba(255,170,60,.9), 0 2px 8px rgba(120,40,30,.5); }
#cue.spin i { opacity: 0; }
#cue.spin .lbl { top: -40px; font-size: 26px; }
#cue.release i { transform: scale(.8); border-color: #ff8a8a; box-shadow: 0 0 22px 4px rgba(255,90,110,.75); animation: cuepulse .18s ease-in-out infinite alternate; }
#cue.release .lbl { color: #fff; font-size: 26px; text-shadow: 0 0 16px rgba(255,60,90,.9); }
@keyframes cuepulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
#mission { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 18px); font-size: 13px; padding: 8px 14px; z-index: 6; pointer-events: none; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hint { bottom: calc(var(--sab) + 66px); }
.mission-line { font-size: 13.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 8px rgba(30,40,70,.5); text-align: center; }
.mission-line.dark { color: var(--ink2); text-shadow: none; margin-top: 10px; font-size: 13px; }
#hapt { position: fixed; left: -100px; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }
.rank { font-size: 76px; font-weight: 900; line-height: 1; margin: -6px 0 6px; background: linear-gradient(180deg, #ff9a6b, #ff5f8a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 14px rgba(255,100,110,.35)); }
.rank[data-rank="S"] { background-image: linear-gradient(180deg, #ffd36b, #ff7a3d 60%, #ff4f8a); }
.rank[data-rank="C"] { background-image: linear-gradient(180deg, #8fa6c8, #5a6f96); }
.pop.perfect { font-size: 34px; font-weight: 900; letter-spacing: .06em; color: #fff6d8; text-shadow: 0 0 22px rgba(255,170,60,.9), 0 2px 6px rgba(120,40,30,.4); }
.pop.combo { font-size: 20px; padding: 4px 14px; border-radius: 999px; background: linear-gradient(90deg, #ff8a65, #ff5f8a); text-shadow: none; }
.pop.mission { font-size: 22px; padding: 7px 18px; border-radius: 999px; background: linear-gradient(90deg, #ffd36b, #ff9a5c); color: #4a2a10; text-shadow: none; }
#result .big { font-size: 52px; }
#againBtn { padding: 18px; font-size: 19px; }
