:root {
  color-scheme: dark;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  --ink: #f5eedc;
  --night: #151c25;
  --glass: rgba(16, 26, 34, .77);
  --line: rgba(255, 244, 215, .3);
  --gold: #f0bd71;
  --mint: #87d2c0;
  --sunset: #ef7d4e;
  --logo-gold: #f4b942;
  --dusk-deep: #17393f;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--night); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button:disabled { opacity: .42; cursor: default; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; overflow: hidden; width: 100%; height: 100dvh; isolation: isolate; color: var(--ink); }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#flash { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 50%, rgba(255,230,166,.18), rgba(247,91,76,.6)); transition: opacity .18s ease; }
#flash.contact { opacity: .7; }
#flash.danger { opacity: .85; background: linear-gradient(90deg, rgba(230,70,50,.4), transparent 28%, transparent 72%, rgba(230,70,50,.4)); }
.voice-effect { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.voice-burst { position: absolute; inset: 0; --voice-color: #b4ffe7; }
.voice-burst.empty { --voice-color: #f7d7a4; }
.voice-glow { position: absolute; left: 50%; top: 64%; width: min(100vw, 560px); height: min(70vh, 490px); border-radius: 50%; transform: translate(-50%, -50%); background: radial-gradient(ellipse, rgba(116, 242, 210, .22), rgba(116, 242, 210, .07) 44%, transparent 70%); animation: voice-glow .72s ease-out both; }
.voice-burst.empty .voice-glow { width: min(66vw, 260px); height: min(32vh, 220px); background: radial-gradient(ellipse, rgba(247, 215, 164, .13), transparent 66%); }
.voice-wave { position: absolute; left: 50%; top: 66%; width: min(72vw, 390px); height: min(25vh, 180px); border: 3px solid var(--voice-color); border-radius: 50%; box-shadow: 0 0 20px rgba(118, 250, 217, .38), inset 0 0 12px rgba(118, 250, 217, .18); animation: voice-wave .66s cubic-bezier(.2,.58,.2,1) both; }
.voice-wave.second { animation-delay: .1s; border-width: 2px; }
.voice-burst.empty .voice-wave { width: min(48vw, 230px); height: min(16vh, 110px); border-width: 2px; box-shadow: 0 0 9px rgba(247, 215, 164, .2); }
.voice-phrase { position: absolute; left: 50%; top: 57%; transform: translate(-50%, 14px); padding: 6px 15px; border: 2px solid var(--voice-color); border-radius: 99px; background: rgba(18, 57, 61, .91); box-shadow: 0 6px 25px rgba(0, 0, 0, .27); color: #f5fff0; white-space: nowrap; font-size: clamp(18px, 5.3vw, 27px); font-weight: 900; letter-spacing: .04em; text-shadow: 0 1px 3px #264044; animation: voice-phrase .82s ease-out both; }
.voice-burst.empty .voice-phrase { top: 67%; padding: 4px 10px; background: rgba(68, 53, 45, .85); color: #fff2d7; font-size: clamp(12px, 3.6vw, 16px); }
@keyframes voice-glow { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.35); } 16% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -58%) scale(1.1); } }
@keyframes voice-wave { 0% { opacity: 0; transform: translate(-50%, -10%) scale(.28); } 15% { opacity: .95; } 100% { opacity: 0; transform: translate(-50%, -145%) scale(1.42); } }
@keyframes voice-phrase { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.9); } 14% { opacity: 1; transform: translate(-50%, 0) scale(1.04); } 55% { opacity: 1; transform: translate(-50%, -9px); } 100% { opacity: 0; transform: translate(-50%, -27px); } }
.hud { position: absolute; z-index: 2; top: 0; left: 0; right: 0; padding: max(11px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 9px max(12px, env(safe-area-inset-left)); background: linear-gradient(to bottom, rgba(10,17,25,.87), rgba(10,17,25,.63) 75%, transparent); pointer-events: none; }
.hud-line { min-height: 38px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.stage-chip { flex: none; display: inline-flex; gap: 7px; align-items: baseline; background: #fff6e8; border-radius: 7px; padding: 4px 11px; box-shadow: 4px 4px 0 rgba(23,57,63,.7); transform: skewX(-6deg); }
.stage-chip > * { display: inline-block; transform: skewX(6deg); }
.stage-chip .stage-number { color: #b35a30; }
.stage-chip #stage-name { color: #22303a; }
.stage-number { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: var(--gold); }
#stage-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: clamp(12px, 3.6vw, 15px); font-weight: 750; letter-spacing: .025em; }
.time { background: #fff6e8; color: #22303a; border-radius: 7px; padding: 4px 11px; box-shadow: 4px 4px 0 rgba(23,57,63,.7); transform: skewX(-6deg); margin-left: auto; font-variant-numeric: tabular-nums; font-size: clamp(15px, 4vw, 19px); font-weight: 800; letter-spacing: -.03em; }
.icon-button { flex: none; width: 38px; height: 38px; border: 0; border-radius: 10px; background: #fff6e8; color: #22303a; box-shadow: 4px 4px 0 rgba(23,57,63,.7); display: grid; place-items: center; font-size: 18px; pointer-events: auto; }
.icon-button:active { background: #fdeed3; }
#sound[aria-pressed="false"] { color: #8b979c; }
.progress { height: 10px; margin-top: 6px; border-radius: 4px; background: rgba(255,246,232,.25); overflow: visible; }
.progress > span { width: 0; height: 100%; display: block; background: repeating-linear-gradient(-55deg, #f4b942 0 12px, #ef7d4e 12px 24px); border-radius: 4px; box-shadow: none; position: relative; transition: width .1s linear; }
.progress > span::after { content: ""; position: absolute; right: -8px; top: 50%; transform: translateY(-50%); border: 5px solid transparent; border-right: 0; border-left: 6px solid #ef7d4e; }
.hud-detail { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; color: rgba(255,248,229,.82); font-size: 11px; line-height: 1.3; font-weight: 700; text-shadow: 0 1px 3px #131820; }
#flow { min-width: 0; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.waiting { flex: none; padding: 2px 9px; border: 1px solid transparent; border-radius: 7px; color: #5a3d16; background: #f4b942; transform: skewX(-6deg); box-shadow: 4px 4px 0 rgba(23,57,63,.7); }
#hits { flex: none; font-variant-numeric: tabular-nums; }
.cue { background: rgba(23,40,47,.93); padding: 6px 16px; border-radius: 8px; position: absolute; z-index: 2; top: calc(max(11px, env(safe-area-inset-top)) + 92px); left: 50%; transform: translateX(-50%); max-width: min(90vw, 480px); min-height: 0; text-align: center; color: #fff7dd; font-size: clamp(13px, 3.7vw, 18px); font-weight: 800; line-height: 1.5; letter-spacing: .06em; text-shadow: 0 2px 5px #15202a, 0 0 15px #15202a; pointer-events: none; opacity: 0; transition: opacity .2s ease; }
.cue::before, .cue::after { content: ""; position: absolute; top: 50%; margin-top: -2px; width: 40px; height: 4px; border-radius: 99px; background: linear-gradient(90deg, transparent, #a8d8cf); }
.cue::before { left: -50px; }
.cue::after { right: -50px; transform: scaleX(-1); }
.cue.show { opacity: 1; }
.cue.suppressed { opacity: 0; }
.road-warning { position: absolute; z-index: 2; left: 50%; top: calc(max(11px, env(safe-area-inset-top)) + 119px); transform: translateX(-50%); max-width: min(94vw, 410px); padding: 8px 13px; border: 1px solid rgba(255,205,149,.8); border-radius: 99px; background: rgba(63,27,22,.9); box-shadow: 0 5px 20px rgba(0,0,0,.22); color: #fff0d5; font-size: 12px; font-weight: 800; white-space: nowrap; pointer-events: none; }
.road-warning.green { background: rgba(23,74,66,.9); border-color: var(--mint); }
.road-warning.caution { background: rgba(80, 61, 29, .93); border-color: #ffe0a3; }
.hint { position: absolute; z-index: 2; left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 94px); transform: translateX(-50%); border: 1px solid rgba(255,250,224,.24); border-radius: 99px; padding: 5px 11px; background: rgba(13,24,30,.55); white-space: nowrap; color: rgba(255,249,229,.89); font-size: 10px; font-weight: 700; letter-spacing: .02em; pointer-events: none; }
.controls { position: absolute; z-index: 3; left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: clamp(6px, 2vw, 15px); align-items: stretch; justify-content: space-between; pointer-events: none; }
.controls button { min-height: 78px; color: #fff8e6; border: 1px solid rgba(255,248,225,.65); background: rgba(15,29,38,.76); box-shadow: 0 7px 20px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.09); touch-action: none; user-select: none; -webkit-user-select: none; pointer-events: auto; }
.controls button:active, .controls button.active { background: rgba(42,87,85,.9); transform: translateY(2px); }
.steer { flex: 0 1 115px; min-width: 68px; border-radius: 16px; font-size: 33px; line-height: 1; font-weight: 300; }
.steer small { display: block; margin-top: 3px; font-size: 10px; line-height: 1.1; font-weight: 800; }
.call { flex: 1 1 126px; max-width: 190px; min-width: 110px; border-radius: 16px; border-color: var(--gold) !important; background: rgba(91,61,49,.84) !important; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; }
.call span { font-weight: 900; font-size: clamp(12px, 3.5vw, 17px); letter-spacing: -.03em; white-space: nowrap; }
.call small { font-size: 10px; letter-spacing: .02em; color: #ffdda3; }
.call-gauge { display: block; width: 74%; height: 6px; border-radius: 999px; background: rgba(255, 246, 232, .25); overflow: hidden; }
.call-gauge i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #57cf9f, #99eed2); transition: width .15s linear; }
.call:active, .call.active { background: rgba(161,96,65,.95) !important; }
.call.ready { border-color: #99eed2 !important; background: rgba(33,104,89,.94) !important; box-shadow: 0 0 0 3px rgba(153,238,210,.18), 0 7px 20px rgba(0,0,0,.25); }
.call.ready small { color: #c9ffe9; }
.call.fired { box-shadow: 0 0 0 5px rgba(153,238,210,.3), 0 0 26px rgba(153,238,210,.35), 0 7px 20px rgba(0,0,0,.25); }
.overlay { position: absolute; z-index: 5; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); background: rgba(9,17,24,.67); backdrop-filter: blur(9px); overflow-y: auto; }
.finale-result { background: rgba(9,17,24,.2); backdrop-filter: none; align-items: flex-start; padding-top: max(49vh, env(safe-area-inset-top)); }
.finale-result .overlay-card { margin: 0 auto; flex: none; }
@media (min-width: 760px) {
  .finale-result { justify-content: flex-end; align-items: center; padding-top: max(16px, env(safe-area-inset-top)); }
  .finale-result .overlay-card { margin: auto 2vw auto 0; }
}
.overlay-card { position: relative; width: min(100%, 440px); margin: auto; padding: clamp(23px, 6vw, 36px); border: 1px solid rgba(255,239,207,.63); border-radius: 18px; background: linear-gradient(160deg, #f9f0d9, #e9dfcc 60%, #d8d5c4); color: #193039; box-shadow: 7px 7px 0 rgba(23,57,63,.9), inset 0 1px 0 #fff6e8; }
.confetti { position: absolute; z-index: 1; inset: 0; overflow: hidden; pointer-events: none; border-radius: 18px; }
.scene-confetti { z-index: 4; border-radius: 0; }
.celebrating .hud, .celebrating .controls, .celebrating .cue,
.celebrating .road-warning, .celebrating .hint, .celebrating #flash { display: none; }
.confetti i { position: absolute; top: -12px; animation: confetti-fall 3s ease-in both; }
@keyframes confetti-fall {
  0% { transform: translate(0, 0) skewX(-12deg) rotate(-20deg); opacity: 1; }
  50% { transform: translate(14px, 240px) skewX(-12deg) rotate(100deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(-8px, 480px) skewX(-12deg) rotate(220deg); opacity: 0; }
}
.overlay-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; border-radius: 18px 18px 0 0; background: repeating-linear-gradient(-55deg, #ef7d4e 0 26px, #f4b942 26px 52px, #78b6ab 52px 78px); }
.kicker { transform: skewX(-6deg); transform-origin: left center; display: block; margin-bottom: 13px; color: #8b523d; font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.overlay h1 { transform: skewX(-6deg); transform-origin: left center; margin: 0; color: #152e36; font-size: clamp(31px, 9vw, 48px); letter-spacing: -.07em; line-height: 1.17; }
.logo-wrap { position: relative; margin: -2px -13px 0; }
.logo-wrap::after { content: ""; display: block; width: 120px; height: 15px; margin-top: 2px; background-repeat: no-repeat; background-image: linear-gradient(90deg, transparent, rgba(23,57,63,.5) 30%, rgba(120,182,171,.85)), linear-gradient(90deg, transparent, rgba(23,57,63,.5) 30%, rgba(120,182,171,.85)), linear-gradient(90deg, transparent, rgba(23,57,63,.5) 30%, rgba(120,182,171,.85)); background-size: 120px 4px, 84px 4px, 52px 3px; background-position: left 0 top 0, left 22px top 6px, left 44px top 12px; }
.logo-wrap img { display: block; width: 100%; height: auto; }
.with-logo #overlay-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.overlay-lead { margin: 14px 0 0; font-size: clamp(16px, 4.4vw, 21px); font-weight: 850; line-height: 1.55; }
.overlay-extra { margin: 11px 0 0; font-size: 13px; line-height: 1.7; font-weight: 600; color: #395057; }
.overlay-intro { margin: 12px 0 0; padding: 9px 11px; border-left: 3px solid #528b7e; background: rgba(33,79,77,.09); font-size: 12px; line-height: 1.6; font-weight: 750; }
.overlay-guide { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 23px 0 16px; }
.overlay-guide div { min-height: 69px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; background: rgba(33,79,77,.1); border: 1px solid rgba(33,79,77,.2); border-radius: 12px; text-align: center; }
.overlay-guide b { font-size: 17px; line-height: 1; }
.overlay-guide span { font-size: 10px; font-weight: 750; }
.stage-select { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.stage-select button { padding: 6px 10px; border: 1px solid #214f4d; border-radius: 7px; background: #fff6e8; color: #214f4d; box-shadow: 3px 3px 0 #214f4d; font: inherit; font-size: 11px; font-weight: 800; transform: skewX(-6deg); cursor: pointer; }
.stage-select button span { display: inline-block; transform: skewX(6deg); }
.stage-select button:active { box-shadow: 1px 1px 0 #214f4d; }
.overlay-stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin: 18px 0 20px; }
.overlay-stats div { padding: 10px 12px; background: #fff; border: 2px solid #ecd9b8; border-radius: 12px; }
.overlay-stats small { display: block; font-size: 10px; font-weight: 800; color: #516865; }
.overlay-stats strong { display: block; font-size: 29px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.replay-meta { margin: -12px 0 14px; color: #395057; }
.replay-meta p { margin: 0 0 8px; font-size: 11px; line-height: 1.5; font-weight: 750; white-space: pre-line; }
.replay-meta p:empty { display: none; }
.replay-meta button { min-height: 36px; padding: 5px 10px; border: 1px solid #698381; border-radius: 10px; background: transparent; color: #254f50; font: inherit; font-size: 11px; font-weight: 800; }
.replay-meta button:active { background: rgba(36,79,80,.12); }
.replay-meta input { display: block; width: 100%; margin-top: 7px; padding: 6px; border: 1px solid #698381; border-radius: 6px; color: #254f50; font-size: 11px; }
.replay-meta input[hidden] { display: none; }
.action { position: relative; overflow: hidden; width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 19px; border: 0; border-radius: 14px; background: linear-gradient(92deg, #ef7d4e, #f4b942); color: #fff; font-size: 16px; font-weight: 900; box-shadow: 0 6px 0 #8a4a26; }
.action:active { transform: translateY(3px); box-shadow: 0 3px 0 #8a4a26; }
.action-label { display: inline-block; transform: skewX(-6deg); }
.action .wind { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }
.action .wind i { display: block; width: 34px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.95); margin: 3px 0; }
.action .wind i:nth-child(2) { width: 24px; margin-left: 8px; }
.action .wind i:nth-child(3) { width: 14px; margin-left: 16px; }
.secondary-action { display: block; width: 100%; min-height: 42px; margin-top: 13px; padding: 6px 12px; border: 1px solid #698381; border-radius: 14px; background: transparent; color: #254f50; font-size: 12px; font-weight: 800; }
.secondary-action:active { background: rgba(36,79,80,.12); }
.overlay-foot { margin: 16px 0 0; font-size: 10px; line-height: 1.6; color: #526767; }
.overlay:not([hidden]) ~ .controls { pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 360px) {
  .hud-line { gap: 5px; }
  .stage-number { font-size: 9px; }
  #stage-name { font-size: 12px; }
  .icon-button { width: 34px; height: 34px; font-size: 16px; }
  .controls button { min-height: 72px; }
  .steer { min-width: 66px; font-size: 29px; }
  .call { min-width: 104px; }
  .hint { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 85px); }
}
@media (max-height: 570px) {
  .hud { padding-bottom: 4px; }
  .cue { top: 73px; }
  .road-warning { top: 101px; }
  .hint { display: none; }
  .controls button { min-height: 58px; }
  .overlay-card { padding: 20px; }
  .overlay-guide { margin: 12px 0; }
  .overlay-guide div { min-height: 50px; }
}
@media (min-width: 750px) and (pointer: fine) {
  .controls { left: 50%; right: auto; width: min(500px, 80vw); transform: translateX(-50%); opacity: .84; }
  .controls button { min-height: 62px; }
  .hint { bottom: 85px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .voice-burst .voice-glow { animation: none; opacity: .35; transform: translate(-50%, -50%) scale(.85); }
  .voice-burst .voice-wave { animation: none; opacity: .42; transform: translate(-50%, -55%) scale(.9); }
  .voice-burst .voice-phrase { animation: none; opacity: 1; transform: translate(-50%, 0); }
}

.combo-meter { display: flex; align-items: center; gap: 8px; margin-top: 5px; color: var(--mint); font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.combo-bar { display: flex; gap: 3px; }
.combo-bar i { width: 13px; height: 5px; border-radius: 2px; background: rgba(255,246,232,.25); }
.combo-meter.tier-0 .combo-bar i:nth-child(-n+1), .combo-meter.tier-1 .combo-bar i:nth-child(-n+2), .combo-meter.tier-2 .combo-bar i:nth-child(-n+3), .combo-meter.tier-3 .combo-bar i:nth-child(-n+4), .combo-meter.tier-4 .combo-bar i:nth-child(-n+5) { background: currentColor; }
.combo-meter.tier-2 { color: #afd4a4; }
.combo-meter.tier-3 { color: #d4c987; }
.combo-meter.tier-4 { color: var(--gold); }

/* Results put the measurable outcome ahead of the closing line. */
.result-overlay .overlay-card { padding: 20px 22px; }
.result-overlay .kicker { margin-bottom: 6px; }
.result-overlay h1 { font-size: clamp(27px, 7vw, 36px); }
.result-overlay .overlay-stats { gap: 5px; margin: 10px 0 0; }
.result-overlay .overlay-stats > div { padding: 5px 9px; border-width: 1px; border-radius: 8px; }
.result-overlay .overlay-stats small { font-size: 11px; }
.result-overlay .overlay-stats strong { font-size: 24px; line-height: 1.1; }
.result-overlay .overlay-stats > .result-friends { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.result-overlay .result-friends strong { font-size: 16px; }
.result-overlay .overlay-stats > .result-splits { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 3px 12px; background: transparent; border: 0; padding: 2px 0; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-overlay #result-record { grid-column: 1 / -1; margin: 0; color: #395057; font-size: 11px; line-height: 1.35; font-weight: 800; white-space: pre-line; }
.result-overlay #result-record:empty { display: none; }
.result-overlay .overlay-lead { margin: 7px 0; font-size: 12px; line-height: 1.4; font-weight: 600; }
.result-overlay .replay-meta { margin: 0 0 8px; }
.result-overlay .action { min-height: 46px; }
.result-overlay .secondary-action { min-height: 36px; margin-top: 8px; }
.finale-result { align-items: center; padding-top: max(16px, env(safe-area-inset-top)); }
.finale-result .overlay-card { margin: auto; }
@media (min-width: 760px) {
  .finale-result .overlay-card { margin: auto 2vw auto 0; }
}
