/* 港城飛馳 v2 — 鮮色卡通、大字、圓角，6 歲啱用 */
:root {
  --pink: #ff4fb0;
  --blue: #3ab0ff;
  --yellow: #ffd23a;
  --green: #4fd16a;
  --purple: #8a5aff;
  --ink: #2a1a4a;
  --cream: #fff8e8;
  --radius: 22px;
  font-family: "Nunito", "Baloo 2", "Arial Rounded MT Bold", "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", "Noto Color Emoji", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: #7fd4ff; color: var(--ink); overflow: hidden;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#app { position: fixed; inset: 0; }
#race-canvas, .overlay-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; touch-action: none; }
.overlay-canvas { pointer-events: none; z-index: 6; }
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 7; overflow: hidden; }
.fx-star { position: absolute; font-size: 34px; transform: translate(-50%, -50%); animation: star-fly .9s ease-out forwards; }
@keyframes star-fly { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.4); opacity: 0; } }

.screen {
  position: absolute; inset: 0; z-index: 2;
  display: none; flex-direction: column; align-items: center; justify-content: safe center;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px; gap: 12px; overflow: auto;
  background: radial-gradient(circle at 20% 10%, #fff7 0 8%, transparent 9%), radial-gradient(circle at 80% 18%, #fff6 0 6%, transparent 7%),
    linear-gradient(180deg, #6cc8ff 0%, #b8ecff 55%, #ffe9b0 100%);
}
.screen.active { display: flex; }
.screen.race { background: transparent; justify-content: flex-start; padding: 0; touch-action: none; pointer-events: auto; }

h2 { margin: 0; font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 900; color: var(--ink); text-shadow: 0 3px 0 #fff; }
h3 { margin: 10px 0 4px; font-size: 1.1rem; }

.logo { text-align: center; }
.logo h1 {
  margin: 0; font-size: clamp(3rem, 12vw, 5.5rem); font-weight: 900; letter-spacing: .08em;
  color: #fff; -webkit-text-stroke: 3px var(--pink);
  text-shadow: 0 6px 0 var(--pink), 0 10px 18px rgba(0,0,0,.2);
  animation: wobble 3s ease-in-out infinite;
}
@keyframes wobble { 0%,100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg) scale(1.03); } }
.logo .sub { margin: 6px 0 0; font-weight: 900; font-size: clamp(1rem, 4vw, 1.5rem); color: var(--purple); }
.boot-cloud { font-size: clamp(4rem, 16vw, 7rem); position: relative; animation: float 3s ease-in-out infinite; line-height: 1; }
.boot-cloud span { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); font-size: .38em; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.story { max-width: 36rem; text-align: center; font-size: clamp(1rem, 3.6vw, 1.25rem); line-height: 1.7; background: #fffc; padding: 12px 18px; border-radius: var(--radius); }
.tip { color: #b0306a; font-size: .95rem; font-weight: 700; margin: 0; }
.osm { font-size: .9rem; margin: 0; }
.osm a { color: #1a5fbf; font-weight: 700; }
.hint { color: #3a3060; font-size: 1rem; text-align: center; margin: 0; }

.btn {
  appearance: none; border: 0; cursor: pointer; background: #fff; color: var(--ink);
  padding: 12px 22px; border-radius: 999px; font-size: 1.1rem; font-weight: 900; text-decoration: none;
  box-shadow: 0 5px 0 #c9b8ff, 0 8px 18px rgba(0,0,0,.12); font-family: inherit;
  transition: transform .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #c9b8ff; }
.btn.primary { background: var(--pink); color: #fff; box-shadow: 0 6px 0 #c02a80, 0 10px 20px rgba(255,79,176,.35); }
.btn.big { font-size: clamp(1.4rem, 5vw, 2rem); padding: 16px 40px; }
.btn.small { padding: 8px 16px; font-size: 1rem; }
.btn.ghost { background: #ffffffaa; }
.btn.danger { background: #ff6a6a; color: #fff; box-shadow: 0 5px 0 #b03030; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.boot-links { display: flex; gap: 10px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.topbar { width: min(100%, 980px); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar h2 { flex: 1; }
.stat { background: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 900; font-size: 1.2rem; }
.coin-ic { display: inline-block; width: 1em; height: 1em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6b0, #ffc83a 50%, #e09a10); vertical-align: -0.12em; }

/* partners */
.driver-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; width: min(100%, 900px); }
.driver-card { border: 0; border-radius: var(--radius); background: #fff; padding: 14px; cursor: pointer; font-family: inherit; box-shadow: 0 6px 0 #d8ccff; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.driver-card .mono { font-size: 3.6rem; animation: float 2.5s ease-in-out infinite; }
.driver-card b { font-size: 1.4rem; }
.driver-card p { margin: 0; font-size: .95rem; color: #5a4a80; }
.driver-card.selected { outline: 6px solid var(--c, var(--pink)); transform: scale(1.04); }
.driver-card.locked { filter: grayscale(1); opacity: .55; }

/* map */
.hk-map { position: relative; width: min(100%, 980px); aspect-ratio: 16 / 10; max-height: 72vh; border-radius: 28px; overflow: hidden; box-shadow: 0 10px 0 #2a8fc0, 0 14px 30px rgba(0,0,0,.2); }
.map-art, .map-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-ferry { animation: ferry 14s linear infinite; }
@keyframes ferry { 0% { transform: translate(0, 0); } 50% { transform: translate(120px, 12px); } 100% { transform: translate(0, 0); } }
.map-node {
  position: absolute; transform: translate(-50%, -50%); border: 0; cursor: pointer; font-family: inherit;
  width: clamp(50px, 7.4vw, 78px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--c, #ffd23a) 60%);
  box-shadow: 0 6px 0 rgba(0,0,0,.25); display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: bounce 1.6s ease-in-out infinite; animation-delay: var(--dl, 0s);
}
@keyframes bounce { 0%,100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, -60%); } }
.map-node .num { font-size: clamp(1.1rem, 2.6vw, 1.7rem); font-weight: 900; line-height: 1; }
.map-node .emo { font-size: clamp(.8rem, 1.8vw, 1.2rem); line-height: 1; }
.map-node .name { position: absolute; top: 100%; margin-top: 6px; white-space: nowrap; font-size: clamp(.62rem, 1.4vw, .9rem); font-weight: 900; background: #fff; padding: 2px 8px; border-radius: 999px; }
.map-node .type { position: absolute; top: calc(100% + 26px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: clamp(.48rem, 1.05vw, .7rem); font-weight: 800; color: #4a2a80; background: #efe8ff; padding: 1px 7px; border-radius: 999px; border: 1.5px solid #c9b8ff; max-width: 18vw; overflow: hidden; text-overflow: ellipsis; }
.map-node .stars { position: absolute; bottom: -4px; font-size: clamp(.7rem, 1.6vw, .95rem); letter-spacing: -2px; }
.map-node .eater { position: absolute; top: -14px; right: -12px; font-size: clamp(.9rem, 2vw, 1.4rem); animation: float 2s ease-in-out infinite; }
.map-node.locked { filter: grayscale(.9) brightness(1.08); opacity: .82; animation: none; cursor: default; }
.map-node.unsaved { --c: #d8d0ff; }
.map-node.saved { --c: #ffd23a; }
.map-hint { background: #fffc; padding: 6px 14px; border-radius: 999px; }

/* garage */
.garage-stage { position: relative; width: min(100%, 700px); height: min(38vh, 320px); border-radius: 28px; overflow: hidden; background: radial-gradient(circle at 50% 80%, #fff 0 20%, #ffd8f0 21% 40%, #bde8ff 41%); box-shadow: 0 8px 0 #c9b8ff; flex-shrink: 0; }
#garage-canvas { width: 100%; height: 100%; display: block; cursor: pointer; }
.stage-hint { position: absolute; bottom: 8px; left: 0; right: 0; }
.garage-tabs { width: min(100%, 900px); }
.garage-row { display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 12px; }
.garage-item { border: 0; flex: 0 0 auto; min-width: 110px; padding: 10px 12px; border-radius: 18px; background: #fff; font-family: inherit; font-size: 1rem; font-weight: 900; cursor: pointer; box-shadow: 0 5px 0 #d8ccff; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.garage-item .big-emo { font-size: 2.2rem; }
.garage-item.selected { outline: 5px solid var(--pink); }
.garage-item.locked { filter: grayscale(1); opacity: .5; }
.garage-item i { font-style: normal; font-size: .8rem; color: #806aa0; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #0002; }
.dex-row { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 20px; }
.dex-row span { background: #2a1050; color: #fff4a0; padding: 6px 12px; border-radius: 12px; font-weight: 900; text-shadow: 0 0 8px #ff4fd0; box-shadow: 0 0 0 3px #ff4fd0; }
.dex-row em { color: #806aa0; }

/* settings */
.opts { width: min(100%, 640px); display: flex; flex-direction: column; gap: 10px; }
.opt { background: #fff; padding: 12px 16px; border-radius: 16px; font-weight: 700; font-size: 1.05rem; display: flex; gap: 10px; align-items: center; }
.opt input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--pink); flex-shrink: 0; }
.opt select { font-size: 1rem; padding: 4px; border-radius: 8px; }

/* ---------------- RACE HUD ---------------- */
.race .hud-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; align-items: center; gap: 8px; z-index: 4; }
.hud-btn { pointer-events: auto; width: 46px; height: 46px; border-radius: 50%; border: 0; background: #fff; font-size: 1.3rem; font-weight: 900; box-shadow: 0 4px 0 #0002; cursor: pointer; flex-shrink: 0; }
.hud-progress { flex: 1; min-width: 0; }
.progress-bar { position: relative; height: 14px; background: #ffffffaa; border-radius: 999px; overflow: visible; }
.progress-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--yellow), var(--pink)); }
.progress-bar b { position: absolute; top: -8px; left: 0; font-size: 22px; transform: translateX(-50%) scaleX(-1); }
.street-sign { margin-top: 6px; display: inline-block; background: #1f8a4c; color: #fff; font-weight: 900; font-size: .85rem; padding: 2px 10px; border-radius: 6px; border: 2px solid #fff; }
.hud-gold { background: #fff; border-radius: 999px; padding: 4px 12px 4px 4px; display: flex; align-items: center; gap: 6px; font-size: 1.3rem; font-weight: 900; box-shadow: 0 4px 0 #0002; }
.gold-ic { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #fff6b0, #ffc83a 55%, #e09a10); color: #8a4a00; font-size: 1.1rem; }
.hud-stars { display: flex; gap: 2px; font-size: 1.6rem; }
.hud-stars i { font-style: normal; filter: grayscale(1) opacity(.45); transition: filter .3s, transform .3s; }
.hud-stars i.on { filter: none; transform: scale(1.2); }

.quiz-wrap { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 70px); left: 2vw; right: 2vw; display: none; flex-direction: column; align-items: center; gap: 1vh; z-index: 3; pointer-events: none; }
.quiz-wrap.show { display: flex; animation: drop-in .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes drop-in { from { transform: translateY(-40px) scale(.8); opacity: 0; } }
.quiz-mech { font-weight: 900; font-size: clamp(.9rem, 2.2vh, 1.3rem); background: var(--purple); color: #fff; padding: 3px 14px; border-radius: 999px; }
.quiz-banner {
  max-width: 96vw; background: #fff; color: var(--ink); border-radius: 26px; padding: .25em .6em;
  font-weight: 900; line-height: 1.25; text-align: center; font-size: 8vh;
  box-shadow: 0 7px 0 var(--pink), 0 12px 24px rgba(0,0,0,.18); border: 5px solid var(--pink);
}
.quiz-banner .blank { display: inline-block; min-width: 1.8em; margin: 0 .1em; padding: 0 .15em; border-radius: 12px; background: #fff3a8; box-shadow: inset 0 0 0 4px #ffc83a; color: #c02a80; animation: glowblank 1.2s ease-in-out infinite; }
.quiz-banner .blank.small { min-width: 1.1em; font-size: .7em; vertical-align: middle; }
.quiz-banner .chip { font-size: .8em; }
.quiz-banner .brk { display: block; height: .15em; }
.quiz-banner .blank.cur { box-shadow: inset 0 0 0 5px var(--pink), 0 0 18px #ffb0e0; }
.quiz-banner .blank.filled { background: #c8ffd8; box-shadow: inset 0 0 0 4px var(--green); animation: none; color: #106a30; }
.quiz-banner .blank.flash { animation: blankflash .25s ease-in-out 4; }
@keyframes glowblank { 50% { background: #fffbd8; } }
@keyframes blankflash { 50% { background: #ff4fb0; transform: scale(1.15); } }
.quiz-banner .chip { display: inline-block; background: #ffe0b0; border-radius: 10px; padding: 0 .15em; margin: 0 .08em; }
.quiz-banner .glow { color: #ff2e9a; text-shadow: 0 0 14px #ffb0e0; font-size: 1.15em; transition: all .3s; }
.quiz-sub { font-weight: 900; background: #fffd; padding: 2px 12px; border-radius: 999px; font-size: clamp(.9rem, 2.6vh, 1.5rem); max-width: 94vw; text-align: center; display: none; }
.quiz-sub.show { display: block; }
.quiz-wrap .hint-pic { display: none; position: absolute; right: -1vw; top: -4vh; font-size: clamp(40px, 9vh, 88px) !important; line-height: 1.1; background: #fff; border-radius: 24px; padding: 6px 16px; box-shadow: 0 6px 0 var(--yellow); animation: pop .4s cubic-bezier(.3,1.8,.5,1); z-index: 3; transform: rotate(5deg); }
.quiz-wrap .hint-pic.show { display: block; }
.quiz-wrap .hint-pic.sentence { position: relative; right: auto; top: auto; transform: none; font-size: clamp(1.1rem, 3.6vh, 2rem) !important; font-weight: 900; max-width: 92vw; text-align: center; }
.hint-pic .glow { background: #fff3a8; color: #c02a80; border-radius: 8px; padding: 0 4px; box-shadow: 0 0 16px #ffd23a; }
@keyframes pop { from { transform: scale(.3); } }
.lane-strip { width: min(96vw, 900px); display: grid; grid-template-columns: repeat(var(--lanes, 3), 1fr); gap: 1.2vw; }
.lane-cell { min-height: 1em; background: #1f8a4c; color: #fff; border: 4px solid #fff; border-radius: 16px; text-align: center; font-weight: 900; padding: .1em .15em; font-size: 10vh; line-height: 1.15; box-shadow: 0 5px 0 #0003; transition: transform .15s; word-break: keep-all; overflow-wrap: anywhere; }
.lane-cell.empty { background: transparent; border-color: transparent; box-shadow: none; }
.lane-cell.off { background: #9aa0aa; color: #e8e8ee; transform: scale(.78); opacity: .6; }
.lane-cell.flash { transform: scale(1.1); background: var(--blue); }
.lane-cell.me { outline: 5px dashed var(--yellow); outline-offset: 3px; }
.lane-cell.ok { background: var(--green); }
.lane-cell.nope { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.scene-card { position: absolute; left: 4vw; right: 4vw; top: calc(max(8px, env(safe-area-inset-top)) + 70px); display: none; background: linear-gradient(180deg, #2a1a6a, #6a3aa0); color: #fff; border-radius: 26px; border: 5px solid var(--yellow); padding: 12px 18px; text-align: center; z-index: 3; box-shadow: 0 0 30px #a04ac0; }
.scene-card.show { display: block; animation: drop-in .4s; }
.scene-pic { font-size: clamp(2.4rem, 8vh, 4.5rem); }
.scene-text { margin: 4px 0 0; font-weight: 900; font-size: clamp(1.05rem, 3.4vh, 1.9rem); line-height: 1.45; }
.scene-text .glow { background: var(--yellow); color: var(--ink); border-radius: 8px; padding: 0 4px; }
.scene-replay { position: absolute; left: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 58px); display: none; z-index: 4; }
.scene-replay.show { display: block; }
.scene-list { display: none; gap: 6px; margin-top: 6px; }
.scene-list.open { display: flex; }
.scene-list button { font-size: 1.2rem; }

.combo { position: absolute; right: 2vw; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 120px); font-size: clamp(1.4rem, 5vh, 2.6rem); font-weight: 900; color: #fff; -webkit-text-stroke: 2px var(--pink); text-shadow: 0 5px 0 var(--pink); opacity: 0; transform: scale(.5) rotate(-8deg); transition: all .3s cubic-bezier(.3,1.8,.5,1); z-index: 4; pointer-events: none; }
.combo.show { opacity: 1; transform: scale(1) rotate(-8deg); }
.countdown { position: absolute; inset: 0; display: none; place-items: center; font-size: 30vh; font-weight: 900; color: #fff; -webkit-text-stroke: 6px var(--pink); text-shadow: 0 10px 0 var(--pink); z-index: 5; pointer-events: none; }
.countdown.show { display: grid; animation: pop .5s; }
.toast { position: absolute; left: 50%; top: 84%; transform: translate(-50%, -50%) scale(.6); font-size: clamp(1.1rem, 4.2vh, 2.3rem); font-weight: 900; background: #fff; color: var(--pink); padding: 8px 26px; border-radius: 999px; box-shadow: 0 6px 0 var(--pink); opacity: 0; transition: all .25s cubic-bezier(.3,1.8,.5,1); z-index: 5; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.street-toast { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: calc(max(8px, env(safe-area-inset-bottom)) + 220px); background: #1f8a4c; color: #fff; border: 3px solid #fff; border-radius: 10px; padding: 4px 16px; font-weight: 900; font-size: 1.3rem; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 3; }
.street-toast.show { opacity: 1; }
.speedlines { position: absolute; inset: 0; pointer-events: none; z-index: 1; opacity: 0; transition: opacity .3s;
  background: repeating-conic-gradient(from 0deg at 50% 45%, transparent 0 4deg, rgba(255,255,255,.55) 4deg 5deg);
  -webkit-mask: radial-gradient(circle at 50% 45%, transparent 0 30%, #000 70%); mask: radial-gradient(circle at 50% 45%, transparent 0 30%, #000 70%); }
.speedlines.on { opacity: .8; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(6deg); } }

.partner-box { position: absolute; left: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 118px); display: flex; align-items: flex-end; gap: 8px; z-index: 4; max-width: 58vw; pointer-events: none; }
.partner-face { width: 74px; height: 74px; flex-shrink: 0; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 44px; box-shadow: 0 5px 0 #0003; border: 4px solid var(--pink); }
.partner-face.hop { animation: hop .5s; }
@keyframes hop { 50% { transform: translateY(-18px) scale(1.1); } }
.partner-bubble { background: #fff; border-radius: 18px 18px 18px 4px; padding: 8px 14px; font-weight: 900; font-size: clamp(1rem, 2.6vh, 1.5rem); box-shadow: 0 4px 0 #0002; opacity: 0; transform: scale(.7); transform-origin: bottom left; transition: all .2s; }
.partner-bubble.show { opacity: 1; transform: scale(1); }
.speedo { position: absolute; right: 118px; bottom: max(8px, env(safe-area-inset-bottom)); width: 150px; z-index: 4; text-align: center; pointer-events: none; }
.speedo svg { width: 100%; }
.arc-bg { fill: none; stroke: #ffffffcc; stroke-width: 20; stroke-linecap: round; }
.arc-fg { fill: none; stroke: url(#none); stroke: var(--pink); stroke-width: 20; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .15s; }
.speed { position: absolute; left: 0; right: 0; top: 34%; font-family: 'Nunito', 'Arial Rounded MT Bold', 'Helvetica Neue', Arial, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: 0; font-size: 2.2rem; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px var(--ink); }
.speed small { font-size: .9rem; -webkit-text-stroke: 0; color: var(--ink); margin-left: 2px; }
.flame { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); font-size: 40px; opacity: 0; transition: opacity .2s; }
.flame.on { opacity: 1; animation: flick .15s infinite alternate; }
@keyframes flick { to { transform: translateX(-50%) scale(1.25); } }
.coins-mini { position: absolute; left: 0; right: 0; bottom: -2px; font-weight: 900; font-size: 1.1rem; }
.coins-mini em { font-style: normal; color: var(--pink); margin-left: 4px; }
.rocket { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: 96px; height: 96px; border-radius: 50%; border: 5px solid #fff; background: radial-gradient(circle at 35% 30%, #ffb0e0, var(--pink)); font-size: 46px; box-shadow: 0 7px 0 #c02a80; z-index: 4; cursor: pointer; }
.rocket:active { transform: translateY(5px); box-shadow: 0 2px 0 #c02a80; }
.rocket.disabled { filter: grayscale(.8); }
.nitro-pips { position: absolute; left: 0; right: 0; bottom: -16px; display: flex; justify-content: center; gap: 4px; }
.nitro-pips i { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--pink); }
.nitro-pips i.on { background: var(--yellow); }
.kbd-hint { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); font-size: .75rem; color: #fff; background: #0006; padding: 2px 10px; border-radius: 999px; display: none; z-index: 4; pointer-events: none; white-space: nowrap; }
.race.kbd .kbd-hint { display: block; }
.tap-hint { position: absolute; top: 55%; font-size: 3.2rem; color: #fff; opacity: .0; z-index: 1; pointer-events: none; text-align: center; text-shadow: 0 3px 0 #0003; transition: opacity .5s; }
.tap-hint small { display: block; font-size: 1rem; font-weight: 900; }
.tap-hint.left { left: 6vw; } .tap-hint.right { right: 6vw; }
.race.teach .tap-hint { opacity: .85; animation: pulse 1s infinite; }
.tap-ripple { position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; border-radius: 50%; background: #ffffff88; display: grid; place-items: center; font-size: 40px; color: var(--pink); pointer-events: none; animation: ripple .5s ease-out forwards; z-index: 4; }
@keyframes ripple { from { transform: scale(.4); } to { transform: scale(1.4); opacity: 0; } }

/* result */
.result-stars { font-size: clamp(3rem, 12vw, 5rem); letter-spacing: .1em; }
.result-stars .dim { filter: grayscale(1) opacity(.35); }
.result-gold { font-size: 1.4rem; font-weight: 900; background: #fff; padding: 8px 20px; border-radius: 999px; margin: 0; }
.result-unlock { font-weight: 900; color: var(--pink); font-size: 1.2rem; margin: 0; }
.parent { background: #fff; border-radius: 16px; padding: 8px 14px; width: min(100%, 560px); }
.parent summary { font-weight: 900; cursor: pointer; }
.parent table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .95rem; }
.parent td, .parent th { border-bottom: 1px solid #eee; padding: 4px; text-align: left; }

/* phones */
@media (max-width: 560px) {
  .rocket { width: 84px; height: 84px; font-size: 40px; }
  .hud-stars { font-size: 1.2rem; }
  .hud-gold { font-size: 1.05rem; }
  .gold-ic { width: 28px; height: 28px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; } }

#screen-garage .topbar, #screen-settings .topbar, #screen-credits .topbar { position: sticky; top: 0; z-index: 5; }

@media (max-aspect-ratio: 3/4) { .street-toast { display: none; } }

/* v3：古字石磚（橫額入面）、連擊發燒 */
.quiz-banner img.glyph { height: 1.5em; width: 1.5em; vertical-align: middle; border-radius: .2em; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
#screen-race.fever::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, rgba(255,140,40,0) 55%, rgba(255,90,40,.28) 100%); animation: feverPulse .6s ease-in-out infinite alternate; }
@keyframes feverPulse { from { opacity: .6; } to { opacity: 1; } }
#screen-race.fever #speedlines { opacity: 1; filter: hue-rotate(-30deg) saturate(1.4); }

/* v3 獨立產品標記 */
.logo .v3-badge { display: inline-block; font-size: 0.45em; vertical-align: super; padding: 0.1em 0.45em; border-radius: 0.6em; background: #ff4fd0; color: #fff; }
.logo .v3-sub { margin-top: 0.1em; font-weight: 700; color: #ffe36a; }


/* ➕➖ 加速／減速（設計稿 v3-speed-ctrl）：左下大掣 ≥96px，綠加速／藍減速 */
.speed-ctrl { position: absolute; left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 6; display: flex; align-items: center; gap: 8px; }
.speed-btn { width: 104px; height: 104px; border-radius: 50%; border: 6px solid #fff; color: #fff; box-shadow: 0 7px 0 #0004; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; line-height: 1; padding: 0; }
.speed-btn b { font-size: 42px; margin-top: 2px; }
.speed-btn span { font-size: 1.05rem; text-shadow: 0 2px 0 #0005; }
.speed-btn.accel { background: radial-gradient(circle at 35% 30%, #9dffb0, #1fb84a); box-shadow: 0 7px 0 #0c7a2c; }
.speed-btn.decel { background: radial-gradient(circle at 35% 30%, #9ecbff, #1a6fd4); box-shadow: 0 7px 0 #0a3f8a; }
.speed-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 #0004; }
.speed-btn:disabled { filter: grayscale(.55); opacity: .7; }
.gear-pill { min-width: 64px; padding: 8px 10px; border-radius: 999px; background: #fff; border: 4px solid var(--pink); font-weight: 900; font-size: 1.15rem; text-align: center; box-shadow: 0 4px 0 #0003; color: var(--ink); }
.race.paused .speed-ctrl { visibility: hidden; }
.race.paused .partner-box { visibility: hidden; } /* 暫停時用卡面提示，唔好再叠一條對白 */

/* 🛑 煞停掣（設計稿 v3-brake）：右下大紅掣（≥96px），🚀 移上佢上面 */
.brake-btn { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 50%; border: 6px solid #fff; background: radial-gradient(circle at 35% 30%, #ff8a8a, #e0182a); color: #fff; box-shadow: 0 7px 0 #8a0a14; z-index: 6; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; line-height: 1; padding: 0; }
.brake-btn b { font-size: 38px; }
.brake-btn span { font-size: 1.25rem; margin-top: 2px; text-shadow: 0 2px 0 #8a0a14; }
.brake-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 #8a0a14; }
.race .rocket { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 124px); }
.race.paused .brake-btn,
.race.paused .rocket,
.race.paused .speedo { visibility: hidden; }
/* 煞停碼頭：底部細條，冇全屏遮罩／大白卡，唔擋題目橫額同路中選項 */
.pause-dock { position: absolute; left: 8px; right: 8px; bottom: max(10px, env(safe-area-inset-bottom)); top: auto; z-index: 9; display: none; align-items: flex-end; gap: 8px; background: none; pointer-events: none; }
.race.paused .pause-dock { display: flex; }
.pause-hint-bar { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; background: #fff; border: 4px solid var(--pink); border-radius: 20px; padding: 8px 10px; box-shadow: 0 5px 0 #0003; pointer-events: none; }
.pause-hint-bar .partner-face { width: 56px; height: 56px; font-size: 32px; flex-shrink: 0; }
.pause-copy { min-width: 0; flex: 1; text-align: left; }
.pause-hint { margin: 0; font-weight: 900; font-size: clamp(0.95rem, 2.4vh, 1.35rem); line-height: 1.3; }
.pause-cheer { margin: 4px 0 0; font-weight: 900; color: var(--pink); font-size: clamp(0.85rem, 2vh, 1.1rem); line-height: 1.3; }
.resume-btn { pointer-events: auto; flex-shrink: 0; font-size: clamp(1.4rem, 4vh, 2.2rem) !important; min-width: 148px; min-height: 96px; border-radius: 999px !important; background: radial-gradient(circle at 35% 30%, #8affa0, #1fb84a) !important; color: #fff !important; border: 6px solid #fff !important; box-shadow: 0 8px 0 #0c7a2c !important; font-weight: 900; text-shadow: 0 3px 0 #0c7a2c; }
@media (max-width: 600px) {
  .brake-btn { width: 96px; height: 96px; }
  .race .rocket { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 112px); }
  /* 直向疊：唔同右邊速度錶爭位 */
  .speed-ctrl { flex-direction: column-reverse; align-items: stretch; gap: 6px; width: 96px; }
  .speed-btn { width: 96px; height: 96px; }
  .speed-btn b { font-size: 36px; }
  .speed-btn span { font-size: .95rem; }
  .gear-pill { min-width: 0; width: 100%; font-size: .95rem; padding: 6px 4px; }
  .speedo { right: 112px; width: 100px; }
  /* 夥伴對白：短橫條放喺加速掣上面、靠左，唔好變成路中間一條長直欄遮住車同路牌 */
  .partner-box {
    left: 10px;
    right: auto;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 264px);
    max-width: 186px;
    width: max-content;
    flex-direction: row;
    align-items: flex-end;
    gap: 6px;
  }
  .partner-box > .partner-face { display: none; } /* 暫停畫面仍然有大頭像 */
  .partner-bubble {
    font-size: 0.95rem;
    line-height: 1.25;
    padding: 7px 10px;
    max-width: 100%;
    max-height: 3.9em;
    overflow: hidden;
    border-radius: 14px;
  }
  .pause-hint-bar .partner-face { width: 44px; height: 44px; font-size: 26px; }
  .pause-hint { font-size: 0.95rem; }
  .pause-cheer { font-size: 0.85rem; }
  .resume-btn { min-width: 120px; min-height: 96px; font-size: 1.45rem !important; }
}


