/* ============================================================================================
   Turbo Kart Rally — UI styles (canvas, overlay layering, menus, HUD, results)
   ============================================================================================ */
:root {
  --display: 'Lilita One', 'Noto Sans TC', 'PingFang TC', 'Arial Black', Impact, sans-serif;
  --body: 'Nunito', 'Noto Sans TC', 'PingFang TC', 'Segoe UI', system-ui, sans-serif;
  --ink: #14122b;
  --gold: #ffd23f;
  --orange: #ff8a1f;
  --red: #ff4757;
  --blue: #2f8bff;
  --cyan: #3de0ff;
  --panel: rgba(16, 20, 48, 0.72);
  --panel-solid: #161a3a;
  --outline: 0 3px 0 var(--ink), 0 -2px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink);
  --ui-scale: 1;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #0b1020; color: #fff;
  font-family: var(--body);
  user-select: none; -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}
#game-root { position: fixed; inset: 0; overflow: hidden; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#ui-root { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
#ui-root.no-world { background: radial-gradient(ellipse at 50% 120%, #ff9a3c 0%, #ff4f7b 30%, #5b3cc4 62%, #1a1e5a 100%); }
#ui-root.no-world::before {
  content: ''; position: absolute; inset: -50%;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,0.05) 0 40px, transparent 40px 110px);
  animation: stripes 6s linear infinite;
}
@keyframes stripes { to { transform: translateX(220px); } }

button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- generic buttons */
.btn {
  pointer-events: auto; cursor: pointer;
  font-family: var(--display); font-size: 26px; letter-spacing: 1px;
  color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.35);
  padding: 12px 28px; min-width: 200px;
  border: 3px solid rgba(255,255,255,0.9); border-radius: 16px;
  background: linear-gradient(180deg, #4a5bd8 0%, #2c35a0 100%);
  box-shadow: 0 6px 0 #161b5c, 0 10px 20px rgba(0,0,0,0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s, filter 0.15s;
}
.btn.primary { background: linear-gradient(180deg, #ffcf3a 0%, #ff8a1f 100%); color: #fff; box-shadow: 0 6px 0 #b24a00, 0 10px 20px rgba(0,0,0,0.35); }
.btn:hover, .btn.focus { transform: translateY(-3px) scale(1.04); filter: brightness(1.12); }
.btn.focus { outline: 4px solid #fff; outline-offset: 3px; animation: focusGlow 1s ease-in-out infinite alternate; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #161b5c; }
@keyframes focusGlow { from { box-shadow: 0 6px 0 rgba(0,0,0,0.45), 0 0 0 rgba(255,210,63,0); } to { box-shadow: 0 6px 0 rgba(0,0,0,0.45), 0 0 26px rgba(255,210,63,0.85); } }

.kc {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 6px; margin-right: 4px;
  font-family: var(--display); font-size: 14px; color: var(--ink);
  background: linear-gradient(180deg, #fff, #d9dcf0); border-radius: 6px;
  box-shadow: 0 3px 0 #8a8fb5;
}
.kc.wide { min-width: 52px; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: absolute; inset: 0; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.35s ease; }

/* ---- loading */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at center, rgba(26,30,90,0.85), rgba(8,10,28,0.96)); }
.spinner { width: 64px; height: 64px; border-radius: 50%; border: 8px solid rgba(255,255,255,0.18); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--display); font-size: 30px; letter-spacing: 3px; text-shadow: var(--outline); }

/* ---- title */
.title-screen { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.title-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(0,0,0,0) 30%, rgba(8,8,30,0.55) 100%),
    linear-gradient(180deg, rgba(20,18,60,0.35) 0%, rgba(0,0,0,0) 40%, rgba(10,8,30,0.6) 100%);
}
.logo {
  position: relative; z-index: 0; margin-top: 11vh; text-align: center;
  transform: rotate(-4deg) skewX(-8deg);
  animation: logoIn 1s cubic-bezier(.2,1.6,.4,1) both, logoFloat 4s ease-in-out 1s infinite;
}
@keyframes logoIn { from { transform: rotate(-4deg) skewX(-8deg) scale(0.3) translateY(-80px); opacity: 0; } to { transform: rotate(-4deg) skewX(-8deg) scale(1); opacity: 1; } }
@keyframes logoFloat { 0%,100% { transform: rotate(-4deg) skewX(-8deg) translateY(0); } 50% { transform: rotate(-3deg) skewX(-8deg) translateY(-10px); } }
.logo-line {
  position: relative; font-family: var(--display); line-height: 0.92; letter-spacing: 2px;
  color: transparent; -webkit-background-clip: text; background-clip: text;
  -webkit-text-stroke: 3px rgba(255,255,255,0.95);
  paint-order: stroke fill;
}
.logo-line::before {
  content: attr(data-text); position: absolute; left: 0; top: 0; z-index: -1;
  -webkit-text-stroke: 14px var(--ink);
  color: var(--ink);
}
.logo-line.l1 {
  font-size: clamp(72px, 15vw, 210px);
  background-image: linear-gradient(180deg, #fff6a8 0%, #ffd23f 35%, #ff9d1f 60%, #ff5a1f 100%);
}
.logo-line.l1::before {
  text-shadow: 0 4px 0 #b3260a, 0 8px 0 #9a1f08, 0 12px 0 #801906, 0 16px 0 #661304, 0 22px 24px rgba(0,0,0,0.6);
}
.logo-line.l2 {
  font-size: clamp(40px, 7.6vw, 108px); margin-top: 4px;
  background-image: linear-gradient(180deg, #e8fcff 0%, #7ee8ff 40%, #2f8bff 75%, #3b3fd8 100%);
}
.logo-line.l2::before {
  text-shadow: 0 3px 0 #1d2a8a, 0 6px 0 #18237a, 0 9px 0 #121a63, 0 14px 18px rgba(0,0,0,0.6);
}
.logo-swoosh {
  position: absolute; left: -8%; right: -8%; top: 52%; height: 22%; z-index: -2;
  background: linear-gradient(90deg, rgba(255,71,87,0) 0%, rgba(255,71,87,0.95) 20%, rgba(255,138,31,0.95) 80%, rgba(255,138,31,0) 100%);
  transform: skewX(-20deg); border-radius: 8px;
  box-shadow: 0 0 30px rgba(255,120,40,0.6);
}
.press-start {
  position: absolute; bottom: 17vh; font-family: var(--display); font-size: clamp(20px, 2.6vw, 34px);
  letter-spacing: 2px; text-shadow: var(--outline), 0 0 20px rgba(255,210,63,0.6);
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.97); } }
.title-foot { position: absolute; bottom: 18px; left: 0; right: 0; display: flex; gap: 10px; justify-content: center; align-items: center;
  font-weight: 700; font-size: 14px; opacity: 0.85; text-shadow: 0 1px 2px #000; }
.title-foot span:first-child { margin-right: 24px; }

/* ---- character select */
.select-screen {
  display: flex; flex-direction: column; padding: 22px 28px 16px;
  background: linear-gradient(90deg, rgba(12,14,44,0.82) 0%, rgba(12,14,44,0.45) 34%, rgba(12,14,44,0) 44%, rgba(12,14,44,0) 58%, rgba(12,14,44,0.55) 68%, rgba(12,14,44,0.85) 100%);
}
.sel-header { display: flex; align-items: center; justify-content: space-between; }
.sel-title {
  font-family: var(--display); font-size: clamp(30px, 3.6vw, 52px); letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 0%, #ffe27a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 var(--ink)) drop-shadow(0 0 1px var(--ink));
  transform: skewX(-6deg);
}
.sel-back { font-family: var(--display); font-size: 18px; padding: 8px 16px; border-radius: 12px; background: rgba(0,0,0,0.35); cursor: pointer; }
.sel-back:hover { background: rgba(255,255,255,0.15); }
.sel-body { flex: 1; display: flex; justify-content: space-between; align-items: stretch; gap: 24px; min-height: 0; margin-top: 14px; }
.sel-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr);
  gap: 12px; width: min(520px, 42vw); align-content: start;
}
.card {
  position: relative; cursor: pointer; display: grid; grid-template-columns: 64px 1fr; grid-template-rows: auto 1fr;
  column-gap: 10px; padding: 9px 10px 9px 9px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(40,46,110,0.92), rgba(22,26,66,0.92));
  border: 3px solid rgba(255,255,255,0.18);
  box-shadow: inset 6px 0 0 var(--kc), 0 6px 14px rgba(0,0,0,0.35);
  transition: transform 0.16s cubic-bezier(.3,1.6,.5,1), border-color 0.15s, box-shadow 0.15s, background 0.2s;
  animation: cardIn 0.45s cubic-bezier(.2,1.4,.4,1) both;
}
.card:nth-child(1) { animation-delay: 0.02s; } .card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.10s; } .card:nth-child(4) { animation-delay: 0.14s; }
.card:nth-child(5) { animation-delay: 0.18s; } .card:nth-child(6) { animation-delay: 0.22s; }
.card:nth-child(7) { animation-delay: 0.26s; } .card:nth-child(8) { animation-delay: 0.30s; }
@keyframes cardIn { from { opacity: 0; transform: translateX(-40px) scale(0.9); } to { opacity: 1; transform: none; } }
.card.selected { background: linear-gradient(135deg, color-mix(in srgb, var(--kc) 55%, #1c2160), rgba(22,26,66,0.95)); border-color: #fff; transform: scale(1.03); }
.card.focus { border-color: var(--gold); box-shadow: inset 6px 0 0 var(--kc), 0 0 0 3px rgba(255,210,63,0.5), 0 0 24px rgba(255,210,63,0.55); }
.card.picked { animation: picked 0.4s ease; }
@keyframes picked { 40% { transform: scale(1.12); } 100% { transform: scale(1.03); } }
.card-portrait {
  grid-row: 1 / span 2; width: 64px; height: 64px; border-radius: 14px; overflow: hidden; align-self: center;
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--kc) 60%, #fff), var(--kc));
  border: 3px solid #fff; display: flex; align-items: center; justify-content: center;
}
.card-portrait img { width: 100%; height: 100%; object-fit: cover; }
.card-portrait .initial, .pv-initial { font-family: var(--display); font-size: 36px; text-shadow: var(--outline); }
.card-name { font-family: var(--display); font-size: 22px; line-height: 1.1; text-shadow: 0 2px 0 var(--ink); }
.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; align-content: center; min-width: 0; }
.st { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 9px; font-weight: 900; letter-spacing: 0.5px; opacity: 0.9; }
.bar { display: flex; gap: 1.5px; }
.bar i { display: block; flex: none; width: 6px; height: 7px; border-radius: 2px; background: rgba(255,255,255,0.18); }
.bar i.on { background: linear-gradient(180deg, #fff27a, #ffb21f); box-shadow: 0 0 4px rgba(255,200,40,0.6); }
.st.big { font-size: 13px; margin: 3px 0; }
.st.big .bar { gap: 4px; }
.st.big .bar i { width: 22px; height: 11px; border-radius: 3px; }

.sel-side { width: min(380px, 34vw); display: flex; flex-direction: column; gap: 14px; }
.preview {
  padding: 16px; border-radius: 20px; background: var(--panel); border: 3px solid rgba(255,255,255,0.22);
  backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}
.pv-portrait {
  width: 124px; height: 124px; border-radius: 50%; overflow: hidden; border: 5px solid #fff;
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--kc, #888) 55%, #fff), var(--kc, #888));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 5px var(--kc, #888), 0 10px 20px rgba(0,0,0,0.4);
}
.pv-portrait.pop { animation: pvPop 0.35s cubic-bezier(.3,1.8,.5,1); }
@keyframes pvPop { from { transform: scale(0.7) rotate(-8deg); } to { transform: none; } }
.pv-portrait img { width: 100%; height: 100%; object-fit: cover; }
.pv-info { width: 100%; }
.pv-name { font-family: var(--display); font-size: 40px; text-align: center; line-height: 1; text-shadow: 0 4px 0 var(--ink); }
.pv-kart { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 900; font-size: 12px; opacity: 0.85; margin: 6px 0 8px; letter-spacing: 1px; }
.swatch { width: 34px; height: 16px; border-radius: 5px; border: 2px solid #fff; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: grid; grid-template-columns: 70px 28px 1fr 28px; align-items: center; gap: 4px;
  padding: 10px 12px; border-radius: 14px; background: var(--panel); border: 3px solid rgba(255,255,255,0.18);
  cursor: pointer; transition: all 0.15s;
}
.opt.focus { border-color: var(--gold); background: rgba(60,50,20,0.8); box-shadow: 0 0 20px rgba(255,210,63,0.35); }
.opt-lbl { font-family: var(--display); font-size: 16px; opacity: 0.8; }
.opt-val { font-family: var(--display); font-size: 21px; text-align: center; white-space: nowrap; }
.opt-val.bump { animation: bump 0.25s ease; }
@keyframes bump { 50% { transform: scale(1.18); color: var(--gold); } }
.opt-arrow { font-size: 18px; text-align: center; color: var(--gold); cursor: pointer; transition: transform 0.1s; }
.opt-arrow:hover { transform: scale(1.3); }
.race-btn { font-size: 34px; padding: 14px; margin-top: 4px; }

.controls-help {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin-top: 12px;
  padding: 10px 14px; border-radius: 14px; background: rgba(0,0,0,0.42); font-weight: 800; font-size: 13px;
}
.ctl { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.ctl .kc:last-of-type { margin-right: 8px; }

/* ---- pause */
.pause-screen { display: flex; align-items: center; justify-content: center; background: rgba(8,10,30,0.55); backdrop-filter: blur(5px); }
.pause-panel {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 26px 34px 22px; border-radius: 26px; background: linear-gradient(180deg, rgba(40,46,120,0.95), rgba(20,22,60,0.95));
  border: 4px solid #fff; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  transform: scale(0.9); transition: transform 0.25s cubic-bezier(.3,1.6,.5,1);
}
.pause-screen.active .pause-panel { transform: none; }
.pause-title { font-family: var(--display); font-size: 58px; letter-spacing: 3px; color: var(--gold); text-shadow: 0 5px 0 var(--ink); margin-bottom: 4px; }
.pause-panel .btn { width: 300px; }
.controls-help.compact { max-width: 440px; font-size: 12px; margin-top: 8px; }

/* ---- intro card */
.intro-card {
  position: absolute; left: 0; bottom: 14vh; padding: 16px 60px 16px 40px; opacity: 0;
  background: linear-gradient(90deg, rgba(255,71,87,0.95), rgba(255,138,31,0.9) 80%, rgba(255,138,31,0));
  clip-path: polygon(0 0, 100% 0, 94% 100%, 0 100%);
  transform: translateX(-110%);
}
.intro-card.show { animation: introCard 4s cubic-bezier(.2,1,.3,1) forwards; }
@keyframes introCard {
  0% { transform: translateX(-110%); opacity: 1; }
  12%, 85% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(-10%); opacity: 0; }
}
.ic-sub { font-family: var(--display); font-size: 20px; letter-spacing: 2px; opacity: 0.95; }
.ic-name { font-family: var(--display); font-size: clamp(36px, 5vw, 64px); line-height: 1; text-shadow: 0 4px 0 rgba(0,0,0,0.35); }
.ic-skip { font-weight: 900; font-size: 12px; letter-spacing: 2px; opacity: 0.8; margin-top: 6px; }

/* ================================================================ HUD */
.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--display); color: #fff; }
.hud.shake { animation: shake 0.45s ease; }
@keyframes shake { 15% { transform: translate(-7px, 3px); } 30% { transform: translate(6px, -4px); } 50% { transform: translate(-4px, 2px); } 70% { transform: translate(3px, -1px); } }

.hud-tl { position: absolute; top: 18px; left: 24px; }
.hud-lap { display: flex; align-items: baseline; gap: 6px; text-shadow: var(--outline); transform-origin: left center; }
.hud-lap .lbl { font-size: 26px; color: #bfe6ff; }
.hud-lap .val { font-size: 60px; line-height: 1; }
.hud-lap .of { font-size: 34px; opacity: 0.9; }
.hud-lap.final .val { color: var(--gold); }
.hud-lap.pulse { animation: lapPulse 0.6s ease; }
@keyframes lapPulse { 30% { transform: scale(1.3); color: var(--gold); } }
.hud-timer {
  font-family: var(--body); font-weight: 900; font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: 1px;
  text-shadow: var(--outline); margin-top: 2px;
}
.hud-splits { margin-top: 4px; font-family: var(--body); font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; }
.split { text-shadow: 0 2px 0 var(--ink), 0 0 3px var(--ink); opacity: 0.92; animation: splitIn 0.35s ease both; }
.split span { display: inline-block; width: 28px; color: #9fd3ff; }
.split.best { color: #8dff9a; }
@keyframes splitIn { from { opacity: 0; transform: translateX(-20px); } }
.hud-lappop {
  position: absolute; top: 120px; left: 24px; font-family: var(--body); font-weight: 900; font-size: 26px; color: var(--gold);
  text-shadow: var(--outline); opacity: 0;
}
.hud-lappop.show { animation: lapPop 2.2s ease forwards; }
@keyframes lapPop { 0% { opacity: 0; transform: translateY(10px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* item slot */
.hud-item { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.item-slot {
  position: relative; width: 112px; height: 112px; border-radius: 28px;
  background: radial-gradient(circle at 50% 35%, rgba(90,110,220,0.85), rgba(20,24,70,0.88));
  border: 5px solid #fff;
  box-shadow: 0 0 0 4px var(--ink), 0 8px 18px rgba(0,0,0,0.45), inset 0 -8px 16px rgba(0,0,0,0.35), inset 0 6px 10px rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
}
.item-slot::after { content: ''; position: absolute; inset: 6px; border-radius: 20px; border: 2px dashed rgba(255,255,255,0.18); }
.item-slot.filled { animation: slotGlow 1.4s ease-in-out infinite alternate; }
@keyframes slotGlow { to { box-shadow: 0 0 0 4px var(--ink), 0 0 26px rgba(255,220,90,0.75), inset 0 -8px 16px rgba(0,0,0,0.35); } }
.item-slot.spinning .item-img { animation: rouletteJitter 0.14s linear infinite; filter: blur(0.6px) brightness(1.1); }
@keyframes rouletteJitter { 0% { transform: translateY(-10px) scale(0.9); } 100% { transform: translateY(10px) scale(0.9); } }
.item-slot.got { animation: gotPop 0.4s cubic-bezier(.3,1.8,.5,1); }
@keyframes gotPop { 0% { transform: scale(0.7); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
.item-img { width: 84px; height: 84px; image-rendering: auto; filter: drop-shadow(0 4px 2px rgba(0,0,0,0.4)); }
.item-count {
  position: absolute; right: -14px; bottom: -12px; font-size: 32px; color: var(--gold); text-shadow: var(--outline);
}
.item-hint { margin-top: 6px; font-family: var(--body); font-weight: 900; font-size: 11px; letter-spacing: 1px; padding: 2px 8px; border-radius: 8px; background: rgba(0,0,0,0.45); transition: opacity 0.2s; opacity: 0; }

/* standings */
.hud-standings { position: absolute; right: 18px; top: 18px; display: flex; flex-direction: column; gap: 3px; }
.st-row {
  display: flex; align-items: center; gap: 7px; height: 25px; padding: 0 12px 0 6px; border-radius: 13px;
  background: rgba(10,12,40,0.55); font-family: var(--body); font-weight: 900; font-size: 13px;
  transition: background 0.2s, transform 0.2s;
}
.st-row.me { background: linear-gradient(90deg, rgba(255,210,63,0.95), rgba(255,138,31,0.9)); color: var(--ink); transform: translateX(-8px); }
.st-pos { width: 16px; text-align: center; font-family: var(--display); font-size: 15px; }
.st-chip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.st-name { min-width: 56px; }

/* minimap */
.hud-minimap {
  position: absolute; left: 16px; bottom: 16px; width: clamp(150px, 24vmin, 240px); height: clamp(150px, 24vmin, 240px);
  border-radius: 24px; background: radial-gradient(circle, rgba(10,14,40,0.45), rgba(10,14,40,0.2) 70%, rgba(10,14,40,0));
}
.hud-minimap canvas { width: 100%; height: 100%; display: block; }

/* speedo + place */
.hud-br { position: absolute; right: 22px; bottom: 10px; display: flex; align-items: flex-end; gap: 6px; }
.hud-speedo { position: relative; width: clamp(120px, 17vmin, 160px); height: clamp(120px, 17vmin, 160px); margin-bottom: 18px; border-radius: 50%; transition: filter 0.2s; }
.hud-speedo.boost { filter: drop-shadow(0 0 14px rgba(255,160,40,0.9)); }
.hud-speedo canvas { width: 100%; height: 100%; }
.speed-val { position: absolute; left: 0; right: 0; top: 36%; text-align: center; font-size: clamp(30px, 4.4vmin, 42px); line-height: 1; text-shadow: var(--outline); }
.speed-unit { position: absolute; left: 0; right: 0; top: 64%; text-align: center; font-family: var(--body); font-weight: 900; font-size: 12px; opacity: 0.85; text-shadow: 0 1px 2px #000; }
.drift-pill {
  position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%) scale(0.6); opacity: 0;
  padding: 3px 12px; border-radius: 10px; font-size: 15px; letter-spacing: 1px; background: #d8dbe8; color: var(--ink);
  border: 2px solid #fff; transition: transform 0.15s cubic-bezier(.3,1.8,.5,1), opacity 0.15s;
}
.drift-pill.show { opacity: 1; transform: translateX(-50%) scale(1); }
.drift-pill.lvl1 { background: #3aa0ff; color: #fff; box-shadow: 0 0 14px #3aa0ff; }
.drift-pill.lvl2 { background: #ff8a1f; color: #fff; box-shadow: 0 0 16px #ff8a1f; }
.drift-pill.lvl3 { background: #b34dff; color: #fff; box-shadow: 0 0 20px #d07bff; animation: ultra 0.25s linear infinite alternate; }
@keyframes ultra { to { filter: brightness(1.35); } }
.hud-place { --pc: #fff; display: flex; align-items: flex-start; line-height: 0.85; color: var(--pc); transform-origin: 70% 80%; }
.hud-place .num {
  font-size: clamp(90px, 16vmin, 150px);
  -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill;
  text-shadow: 0 7px 0 var(--ink), 0 10px 20px rgba(0,0,0,0.4);
}
.hud-place .suf {
  font-size: clamp(34px, 6vmin, 56px); margin-top: 6px;
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink);
}
.hud-place.bump { animation: placeBump 0.45s cubic-bezier(.3,1.8,.5,1); }
@keyframes placeBump { 0% { transform: scale(1.45) rotate(-6deg); } 100% { transform: none; } }

/* countdown */
.hud-countdown {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(120px, 26vmin, 260px); line-height: 1;
  -webkit-text-stroke: 12px var(--ink); paint-order: stroke fill; text-shadow: 0 12px 0 var(--ink), 0 0 60px rgba(255,255,255,0.4);
  opacity: 0; pointer-events: none;
}
.hud-countdown.show { animation: cdPop 0.95s cubic-bezier(.2,1.6,.4,1) forwards; }
.hud-countdown.n3 { color: #ff4757; } .hud-countdown.n2 { color: #ffa21f; } .hud-countdown.n1 { color: #ffe23f; }
.hud-countdown.go { color: #4dff7c; animation: goPop 1.1s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes cdPop { 0% { opacity: 0; transform: scale(2.6); } 25% { opacity: 1; transform: scale(1); } 75% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.6); } }
@keyframes goPop { 0% { opacity: 0; transform: scale(0.3) rotate(-10deg); } 25% { opacity: 1; transform: scale(1.15) rotate(3deg); } 70% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: scale(2.2); } }

/* banners */
.hud-banner {
  position: absolute; left: 0; right: 0; top: 24%; text-align: center; font-size: clamp(56px, 10vmin, 110px);
  color: var(--gold); -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink);
  opacity: 0; font-style: italic;
}
.hud-banner.show { animation: bannerSweep 2.8s cubic-bezier(.2,.9,.3,1) forwards; }
.hud-banner.final { background: linear-gradient(90deg, rgba(255,71,87,0), rgba(255,71,87,0.85) 20%, rgba(255,71,87,0.85) 80%, rgba(255,71,87,0)); padding: 10px 0; }
@keyframes bannerSweep {
  0% { opacity: 1; transform: translateX(100vw) skewX(-12deg); }
  15% { transform: translateX(-2vw) skewX(-12deg); }
  22%, 78% { opacity: 1; transform: translateX(0) skewX(-8deg); }
  100% { opacity: 0; transform: translateX(-100vw) skewX(-12deg); }
}
.hud-wrongway {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); display: none; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 34px 12px; border-radius: 20px; background: rgba(200,20,40,0.88); border: 5px solid #fff;
  box-shadow: 0 0 0 5px var(--ink), 0 0 40px rgba(255,40,60,0.7);
}
.hud-wrongway.show { display: flex; animation: wwBlink 0.6s steps(2, jump-none) infinite; }
@keyframes wwBlink { 50% { opacity: 0.45; } }
.ww-text { font-size: clamp(40px, 7vmin, 64px); text-shadow: 0 4px 0 var(--ink); letter-spacing: 2px; }
.ww-arrow { width: 0; height: 0; border-left: 30px solid transparent; border-right: 30px solid transparent; border-bottom: 34px solid #fff; transform: rotate(180deg); animation: wwArrow 0.6s ease-in-out infinite alternate; }
@keyframes wwArrow { to { transform: rotate(180deg) translateY(-6px); } }

.hud-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, #fffde0 0%, #fff27a 60%, #ffd23f 100%); z-index: 5; }
.hud-flash.flash { animation: flash 0.75s ease-out; }
.hud-flash.flash-soft { animation: flashSoft 0.5s ease-out; }
@keyframes flash { 0% { opacity: 0.95; } 15% { opacity: 0.4; } 25% { opacity: 0.85; } 100% { opacity: 0; } }
@keyframes flashSoft { 0% { opacity: 0.45; } 100% { opacity: 0; } }

.hud-finish { position: absolute; left: 0; right: 0; top: 20%; text-align: center; opacity: 0; }
.hud-finish.show { animation: finishIn 0.7s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes finishIn { from { opacity: 0; transform: scale(3) rotate(8deg); } to { opacity: 1; transform: none; } }
.fin-title {
  display: inline-block; font-size: clamp(80px, 15vmin, 160px); font-style: italic; padding: 0 40px;
  color: #fff; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; text-shadow: 0 10px 0 var(--ink);
  background:
    repeating-conic-gradient(rgba(0,0,0,0.85) 0 25%, rgba(255,255,255,0.85) 0 50%) 0 0 / 40px 40px;
  border: 6px solid #fff; border-radius: 20px; box-shadow: 0 0 0 6px var(--ink), 0 20px 40px rgba(0,0,0,0.45);
  transform: skewX(-8deg);
}
.fin-place { font-size: clamp(60px, 11vmin, 120px); margin-top: 18px; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); }
.fin-place small { font-size: 0.45em; vertical-align: top; }

/* toast */
.toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 8px 20px; border-radius: 20px; background: rgba(0,0,0,0.7);
  font-family: var(--display); font-size: 18px; letter-spacing: 1px; opacity: 0; z-index: 20; }
.toast.show { animation: toast 1.6s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 20px); } 15%, 75% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ================================================================ results */
.results {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto; z-index: 10;
  background: radial-gradient(ellipse at center, rgba(20,24,70,0.55), rgba(6,8,24,0.85));
  opacity: 0; transition: opacity 0.4s ease;
}
.results.show { opacity: 1; }
.res-panel {
  width: min(780px, 94vw); max-height: 94vh; display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 20px 24px 22px; border-radius: 28px; background: linear-gradient(180deg, rgba(44,52,140,0.96), rgba(18,20,58,0.96));
  border: 5px solid #fff; box-shadow: 0 0 0 5px var(--ink), 0 30px 60px rgba(0,0,0,0.55);
  transform: translateY(40px) scale(0.92); transition: transform 0.5s cubic-bezier(.2,1.5,.4,1);
}
.results.show .res-panel { transform: none; }
.res-title { text-align: center; font-family: var(--display); font-size: clamp(40px, 7vmin, 66px); line-height: 1; color: var(--gold); text-shadow: 0 5px 0 var(--ink); transform: skewX(-8deg); }
.res-sub { text-align: center; font-weight: 900; font-size: 13px; letter-spacing: 2px; opacity: 0.8; margin-bottom: 4px; }
.res-table { display: flex; flex-direction: column; gap: 5px; overflow-y: auto; min-height: 0; }
.res-row {
  display: grid; grid-template-columns: 70px 50px 1fr auto 110px; align-items: center; gap: 12px;
  padding: 4px 14px 4px 8px; border-radius: 14px; background: rgba(255,255,255,0.08);
  animation: rowIn 0.45s cubic-bezier(.2,1.4,.4,1) both; animation-delay: var(--d);
}
@keyframes rowIn { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
.res-row.me { background: linear-gradient(90deg, rgba(255,210,63,0.95), rgba(255,138,31,0.92)); color: var(--ink); box-shadow: 0 0 20px rgba(255,190,50,0.5); }
.res-row.me .res-place { -webkit-text-stroke: 5px var(--ink); }
.res-place { font-family: var(--display); font-size: 36px; line-height: 1; text-align: center; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.res-place small { font-size: 0.45em; vertical-align: top; }
.res-portrait { width: 46px; height: 46px; border-radius: 12px; overflow: hidden; border: 3px solid #fff; background: var(--kc); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 24px; }
.res-portrait img { width: 100%; height: 100%; object-fit: cover; }
.res-name { font-family: var(--display); font-size: 24px; }
.res-name em { font-style: normal; font-size: 12px; padding: 2px 7px; border-radius: 6px; background: var(--ink); color: var(--gold); vertical-align: middle; margin-left: 6px; }
.res-best { font-weight: 900; font-size: 12px; opacity: 0.75; font-variant-numeric: tabular-nums; }
.res-time { font-weight: 900; font-size: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.res-buttons { display: flex; justify-content: center; gap: 18px; margin-top: 12px; flex-wrap: wrap; }

/* ================================================================ responsive */
@media (max-width: 900px) {
  .select-screen { padding: 14px; overflow-y: auto; background: rgba(12,14,44,0.78); }
  .sel-body { flex-direction: column; }
  .sel-grid { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: auto; }
  .card { grid-template-columns: 1fr; text-align: center; }
  .card-portrait { grid-row: auto; margin: 0 auto 4px; width: 52px; height: 52px; }
  .card-stats { display: none; }
  .sel-side { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .preview { flex: 1 1 260px; }
  .opts { flex: 1 1 260px; }
  .controls-help { display: none; }
  .hud-standings { display: none; }
  .item-slot { width: 88px; height: 88px; border-radius: 22px; }
  .item-img { width: 64px; height: 64px; }
  .hud-lap .val { font-size: 44px; }
  .hud-timer { font-size: 22px; }
  .res-row { grid-template-columns: 54px 40px 1fr 90px; }
  .res-best { display: none; }
  .res-name { font-size: 18px; }
  .btn { min-width: 150px; font-size: 20px; }
}
@media (max-height: 640px) {
  .controls-help { display: none; }
  .pv-portrait { width: 84px; height: 84px; }
  .pv-name { font-size: 30px; }
  .card { padding: 5px; }
  .res-row { padding: 2px 10px 2px 6px; }
  .res-place { font-size: 28px; }
  .res-portrait { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .press-start, .btn.focus, .item-slot.filled { animation: none !important; }
}

/* ================================================================ touch controls (mobile build) */
.tc-pad { position: absolute; inset: 0; pointer-events: none; z-index: 40; font-family: var(--display); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tc-pad.hidden { display: none; }
.tc-btn { pointer-events: auto; touch-action: none; display: flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #fff; background: rgba(20,24,60,0.42); border: 3px solid rgba(255,255,255,0.75); text-shadow: 0 2px 3px rgba(0,0,0,0.6);
  box-shadow: 0 4px 0 rgba(0,0,0,0.25); transition: transform 0.06s, background 0.06s; }
.tc-btn.on { transform: scale(0.92); background: rgba(255,190,40,0.75); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }
.tc-left { position: absolute; left: calc(14px + env(safe-area-inset-left, 0px)); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tc-steer { position: relative;
  display: flex; gap: 14px; pointer-events: auto; touch-action: none; padding: 6px; }
.tc-arrow { width: 84px; height: 84px; font-size: 34px; pointer-events: none; }
.tc-right { position: absolute; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: 210px; height: 190px; }
.tc-gas { position: absolute; right: 0; bottom: 0; width: 96px; height: 96px; font-size: 22px; background: rgba(40,170,90,0.55); }
.tc-drift { position: absolute; right: 106px; bottom: 0; width: 76px; height: 76px; font-size: 18px; background: rgba(60,120,255,0.5); }
.tc-brake { position: absolute; right: 124px; bottom: 90px; width: 58px; height: 58px; font-size: 15px; background: rgba(220,60,60,0.5); }
.tc-item { position: absolute; right: 18px; bottom: 108px; width: 62px; height: 62px; font-size: 16px; background: rgba(170,80,230,0.5); }
.tc-pause { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.tc-rotate { display: none; }
@media (orientation: portrait) {
  body.touch .tc-rotate { display: flex; position: absolute; inset: 0; z-index: 60; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    background: rgba(12,14,44,0.92); color: #fff; font-family: var(--display); font-size: 24px; text-align: center; padding: 24px; }
  .tc-rot-icon { font-size: 56px; }
}
/* move the HUD out of the thumbs' way */
body.touch .hud-minimap { top: 78px; bottom: auto; left: 14px; width: 96px; height: 96px; }
body.touch .hud-br { top: 8px; bottom: auto; right: 64px; }
body.touch .hud-speedo { width: 84px; height: 84px; margin-bottom: 0; }
body.touch .hud-speedo .speed-val { font-size: 22px; }
body.touch .hud-speedo .speed-unit { font-size: 9px; }
body.touch .hud-standings { display: none; }
body.touch .hud-tl { top: 10px; left: 14px; }
@media (max-height: 380px) {
  .tc-arrow { width: 72px; height: 72px; }
  .tc-right { transform: scale(0.88); transform-origin: bottom right; }
  body.touch .hud-minimap { top: 70px; width: 80px; height: 80px; }
}
body.touch .hud-br { align-items: center; }
body.touch .hud-place .num { font-size: 48px; }
body.touch .hud-place .suf { font-size: 20px; }
body.touch .hud-place .num { -webkit-text-stroke: 5px var(--ink); } body.touch .hud-place .suf { -webkit-text-stroke: 4px var(--ink); }

.tc-rot-btn { margin-top: 10px; padding: 12px 22px; border-radius: 999px; background: #ffd23f; color: #1a1d3a; font-size: 20px; }
@media (orientation: portrait) {
  .tc-arrow { width: 64px; height: 64px; font-size: 26px; }
  .tc-steer { gap: 10px; }
  .tc-right { transform: scale(0.74); transform-origin: bottom right; }
  body.touch .hud-br { right: 60px; }
  body.touch .hud-speedo { width: 66px; height: 66px; }
  body.touch .hud-place .num { font-size: 36px; }
}
.tc-brake { flex-direction: column; line-height: 1.05; } .tc-brake small { font-size: 11px; opacity: .85; }

.tc-back { width: 84px; height: 84px; font-size: 34px; }
.tc-left { gap: 12px; }
@media (orientation: portrait) { .tc-back { width: 64px; height: 64px; font-size: 26px; } }
@media (max-height: 380px) { .tc-back { width: 60px; height: 60px; font-size: 26px; } .tc-left { gap: 4px; } }

/* dashboard + ladder throttle + back-on-track (touch) */
.tc-dash { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: 104px; height: 96px; pointer-events: none;
  background: radial-gradient(ellipse at 50% 70%, rgba(20,24,52,0.85), rgba(20,24,52,0.55)); border-radius: 52px 52px 18px 18px; border: 2px solid rgba(255,255,255,0.35); }
.tc-dash canvas { position: absolute; left: 2px; top: 2px; width: 100px; height: 62px; }
.tc-kmh { position: absolute; left: 0; right: 0; top: 34px; text-align: center; color: #fff; font-size: 22px; line-height: 1; font-family: var(--display); }
.tc-unit { position: absolute; left: 0; right: 0; top: 56px; text-align: center; color: #cfd6ff; font-size: 9px; }
.tc-ladder { position: absolute; left: 50%; transform: translateX(-50%); bottom: 6px; display: flex; align-items: flex-end; gap: 3px; }
.tc-ladder i { display: block; width: 12px; background: rgba(255,255,255,0.18); border-radius: 2px; }
.tc-ladder i.on:nth-child(1) { background: #43d17a; } .tc-ladder i.on:nth-child(2) { background: #9be15d; } .tc-ladder i.on:nth-child(3) { background: #ffd23f; }
.tc-ladder i.on:nth-child(4) { background: #ff9f1a; } .tc-ladder i.on:nth-child(5) { background: #ff4d3d; box-shadow: 0 0 8px #ff4d3d; }
.tc-reset { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); pointer-events: auto; padding: 16px 28px; border-radius: 18px;
  background: #ffb300; color: #1c2140; font-size: 24px; border: 3px solid #fff; box-shadow: 0 6px 18px rgba(0,0,0,0.4); animation: tcPulse 0.9s ease-in-out infinite; }
.tc-reset.hidden { display: none; }
@keyframes tcPulse { 0%,100% { transform: translate(-50%,-50%) scale(1); } 50% { transform: translate(-50%,-50%) scale(1.07); } }
body.touch .hud-speedo { display: none; }
@media (orientation: landscape) { .tc-dash { bottom: calc(6px + env(safe-area-inset-bottom, 0px)); } }

/* title: which real place is showing + my-driver avatar */
.title-now { position: absolute; top: 58%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.title-now .tn-text { font-family: 'Noto Sans TC', var(--display); font-weight: 900; font-size: 18px; color: #fff; background: rgba(20,24,52,0.82); border: 2px solid #ffd23f; border-radius: 14px; padding: 6px 16px; white-space: nowrap; }
.title-now .tn-dots { display: flex; gap: 8px; } .title-now .tn-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.6); } .title-now .tn-dots i.on { background: #ffd23f; box-shadow: 0 0 8px #ffd23f; }
.title-now.swap .tn-text { animation: tnSwap 0.6s ease; } @keyframes tnSwap { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: none; } }
.title-avatar { position: absolute; top: calc(70px + env(safe-area-inset-top, 0px)); right: 16px; width: 54px; height: 54px; border-radius: 50%; border: 3px solid #fff; background: #e8322f; overflow: hidden; display: flex; align-items: center; justify-content: center; font-family: 'Noto Sans TC', sans-serif; font-weight: 900; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.35); z-index: 3; }
.title-avatar img { width: 100%; height: 100%; object-fit: cover; display: none; } .title-avatar.has img { display: block; } .title-avatar.has span { display: none; }

/* track cards (real route maps) */
.opt.opt-tracks { display: block; padding: 8px 8px 10px; cursor: default; }
.opt-tracks .opt-lbl { display: block; margin: 0 0 6px 4px; }
.track-cards { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 4px; -webkit-overflow-scrolling: touch; }
.track-card { flex: 0 0 132px; scroll-snap-align: center; border-radius: 12px; background: rgba(40,46,96,0.9); border: 3px solid rgba(255,255,255,0.2); padding: 5px; cursor: pointer; transition: transform 0.15s, border-color 0.15s; }
.track-card canvas { width: 100%; height: auto; border-radius: 8px; display: block; }
.track-card .tcd-name { font-family: 'Noto Sans TC', var(--display); font-weight: 900; font-size: 15px; margin-top: 4px; white-space: nowrap; }
.track-card .tcd-country { font-size: 11px; color: #ffd23f; font-weight: 700; }
.track-card.sel { border-color: #ffd23f; box-shadow: 0 0 16px rgba(255,210,63,0.6); transform: translateY(-2px); }
.track-card.bump { animation: cardPop 0.45s ease; } @keyframes cardPop { 40% { transform: scale(1.08); box-shadow: 0 0 26px #ffd23f; } }

/* profile setup */
.profile-screen { display: flex; align-items: center; justify-content: center; background: rgba(12,14,34,0.92); }
.pf-panel { width: min(360px, 90vw); display: flex; flex-direction: column; align-items: center; gap: 12px; font-family: 'Noto Sans TC', sans-serif; color: #fff; }
.pf-title { font-size: 26px; font-weight: 900; } .pf-sub { font-size: 13px; opacity: 0.8; margin-top: -6px; }
.pf-photo { width: 150px; height: 150px; border-radius: 50%; background: #3a3f6a; border: 4px solid #fff; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #bbb; }
.pf-photo img { width: 100%; height: 100%; object-fit: cover; }
.pf-btns { display: flex; gap: 10px; } .pf-btn { font-size: 17px; padding: 10px 18px; cursor: pointer; }
.pf-name { width: 100%; box-sizing: border-box; font-size: 20px; padding: 12px 14px; border-radius: 12px; border: 2px solid #ccc; font-family: inherit; }
.pf-note { font-size: 12px; opacity: 0.7; } .pf-done { width: 100%; font-size: 24px; padding: 12px; } .pf-skip { font-size: 13px; opacity: 0.7; text-decoration: underline; cursor: pointer; }
.pf-magic { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: radial-gradient(circle, rgba(255,230,120,0.35), rgba(12,14,34,0.95) 60%); }
.pf-magic.go { display: flex; }
.pf-magic-photo { width: 180px; height: 180px; border-radius: 50%; overflow: hidden; background: #e8322f; border: 5px solid #fff3b0; animation: pfBurst 1.2s ease; box-shadow: 0 0 0 0 rgba(255,220,100,0.9); }
.pf-magic-photo img { width: 100%; height: 100%; object-fit: cover; }
@keyframes pfBurst { 0% { transform: scale(0.3) rotateY(0); } 45% { transform: scale(1.15) rotateY(360deg); box-shadow: 0 0 60px 30px rgba(255,220,100,0.8); } 100% { transform: scale(1) rotateY(360deg); box-shadow: 0 0 30px 8px rgba(255,220,100,0.5); } }
.pf-magic-name { font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 40px; color: #fff; text-shadow: 0 0 16px #ffd23f; }
.pf-magic-name b { display: inline-block; opacity: 0; animation: pfLetter 0.35s ease forwards; } @keyframes pfLetter { 0% { opacity: 0; transform: scale(2); } 100% { opacity: 1; transform: none; } }
#ui-root.title-fade::after { content: ''; position: absolute; inset: 0; background: #0b0e20; opacity: 1; pointer-events: none; animation: tfade 0.4s ease; z-index: 1; }
@keyframes tfade { from { opacity: 0; } to { opacity: 1; } }
.pf-btn { text-align: center; flex: 1; }
/* inside the Claude app (framed): keep the top HUD below the app's floating header */
body.touch.framed .hud-tl { top: 74px; } body.touch.framed .hud-item { top: 70px; } body.touch.framed .hud-br { top: 66px; }
body.touch.framed .hud-minimap { top: 150px; } body.touch.framed .tc-pause { top: 70px; }
/* dashboard sits above the steering arrows (free grass area), not between the buttons */
.tc-dash { left: calc(14px + env(safe-area-inset-left, 0px)); transform: none; bottom: calc(206px + env(safe-area-inset-bottom, 0px)); }
@media (orientation: landscape) { .tc-dash { left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom, 0px)); } }
.title-avatar { top: auto; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); right: auto; left: 16px; }
/* results + pause always on the top layer, above the touch pad and dashboard */
.results, .screen { z-index: 60; }
body.touch.framed .results { padding-top: 64px; box-sizing: border-box; }
.hud-item { transition: opacity 0.2s ease, transform 0.25s cubic-bezier(.3,1.6,.5,1); }
.hud-item.empty { opacity: 0; transform: translateX(-50%) scale(0.4); pointer-events: none; }

/* PM #20: bigger minimap on phones (was 80–96 px) */
body.touch .hud-minimap { width: 150px; height: 150px; background: rgba(10,18,40,0.35); border-radius: 18px; }
@media (orientation: landscape) { body.touch .hud-minimap { width: 128px; height: 128px; } }

/* PM #16: 1st-place victory close-up */
.hud-victory { position: absolute; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.vic-confetti i { position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 2px; animation: vicFall linear infinite; opacity: 0.95; }
@keyframes vicFall { 0% { transform: translateY(-20px) rotate(0); } 100% { transform: translateY(110vh) rotate(720deg); } }
.vic-card { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); text-align: center; animation: vicPop 0.7s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes vicPop { 0% { transform: translateX(-50%) scale(0.2); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
.vic-crown { font-size: 34px; margin-bottom: -12px; animation: vicBob 1s ease-in-out infinite; }
.vic-face { position: relative; width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; border: 6px solid #ffd600; box-shadow: 0 0 0 4px #fff, 0 0 40px rgba(255,214,0,0.9); background: #1c2b6b; overflow: visible; }
.vic-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.vic-v { position: absolute; right: -34px; top: -10px; font-size: 46px; animation: vicWave 0.6s ease-in-out infinite alternate; transform-origin: 30% 90%; }
@keyframes vicWave { 0% { transform: rotate(-14deg); } 100% { transform: rotate(14deg) scale(1.08); } }
@keyframes vicBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.vic-title { font-family: var(--display); font-size: 44px; color: #ffd600; text-shadow: 0 3px 0 #1c2b6b, 0 0 12px rgba(0,0,0,0.6); margin-top: 4px; line-height: 1; }
.vic-name { font-family: var(--display); font-size: 24px; color: #fff; text-shadow: 0 2px 4px #000; }

body.framed .vic-card { top: 150px; }

/* PM #24: the "my driver" entry must look like a button (was a bare red circle) */
.title-avatar { width: auto; height: 48px; padding: 0 16px 0 4px; border-radius: 26px; gap: 8px; justify-content: flex-start; overflow: visible; cursor: pointer;
  background: linear-gradient(#ff5a4f, #d9261f); border: 3px solid #fff; box-shadow: 0 5px 0 #8e1510, 0 8px 16px rgba(0,0,0,0.35); }
.title-avatar:active { transform: translateY(3px); box-shadow: 0 2px 0 #8e1510, 0 4px 10px rgba(0,0,0,0.35); }
.title-avatar .ta-face { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; background: #fff; color: #d9261f; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 16px; flex: none; }
.title-avatar .ta-face img { width: 100%; height: 100%; object-fit: cover; }
.title-avatar .ta-label { font-size: 17px; font-weight: 900; white-space: nowrap; letter-spacing: 1px; }
.title-avatar .ta-label em { font-style: normal; margin-left: 6px; background: #fff; color: #d9261f; border-radius: 10px; padding: 1px 8px; font-size: 14px; }
.title-avatar { animation: taPulse 2.4s ease-in-out infinite; }
@keyframes taPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* phone: lap-split list sat under the (now bigger) minimap — hide it on touch screens */
body.touch .hud-splits { display: none; }

/* PM #6: local item name pop under the item slot */
.item-name { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px) scale(0.6); opacity: 0; white-space: nowrap; pointer-events: none;
  font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 20px; color: #ffd600; background: #1c2b6b; border: 2px solid #ffd600; border-radius: 12px; padding: 2px 12px; }
.item-name.show { animation: itemNamePop 1.1s ease-out both; }
@keyframes itemNamePop { 0% { opacity: 0; transform: translate(-50%, 6px) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, 6px) scale(1.12); } 25% { transform: translate(-50%, 6px) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 0) scale(1); } }

/* PM #6: souvenir counter (top-right, under the place) */
.hud-souv { position: absolute; right: 14px; top: 104px; z-index: 6; pointer-events: none; font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 15px; color: #fff;
  background: linear-gradient(#c9961a, #9c7210); border: 2px solid #fff3b0; border-radius: 14px; padding: 3px 10px; box-shadow: 0 3px 8px rgba(0,0,0,0.35); }
.hud-souv b { font-size: 18px; color: #fff6c8; } .hud-souv .sv-ic { margin-right: 4px; }
.hud-souv.hidden { display: none; }
.hud-souv.bump { animation: souvBump 0.6s ease-out; }
@keyframes souvBump { 0% { transform: scale(1); } 30% { transform: scale(1.35); box-shadow: 0 0 24px #ffe066; } 100% { transform: scale(1); } }
body.touch.framed .hud-souv { top: 156px; }

/* PM #6: souvenir pick-up magic (about 1.5 s, the race keeps running) */
.hud-souv-pop { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); z-index: 38; pointer-events: none; text-align: center; width: 88%; max-width: 420px; }
.svp-coin { position: relative; width: 116px; height: 116px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 40% 35%, #fff3b0, #f2c230 60%, #b8860b); border: 5px solid #fff3b0; box-shadow: 0 0 0 6px rgba(255,224,102,0.35), 0 0 50px 12px rgba(255,214,0,0.8);
  animation: svpBurst 0.6s cubic-bezier(.2,1.6,.4,1) both; }
.svp-coin span { font-size: 62px; }
.svp-coin i { position: absolute; left: 50%; top: 50%; font-style: normal; color: #fff6a0; font-size: 22px; text-shadow: 0 0 8px #ffd600; animation: svpStar 0.9s ease-out both; }
@keyframes svpStar { 0% { transform: translate(-50%, -50%) rotate(var(--a)) translateY(0) scale(0.3); opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(var(--a)) translateY(-110px) scale(1); opacity: 0; } }
@keyframes svpBurst { 0% { transform: scale(0.1) rotate(-40deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.svp-title { margin-top: 12px; font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 26px; color: #ffd600; text-shadow: 0 3px 0 #1c2b6b, 0 0 10px rgba(0,0,0,0.7); animation: svpBurst 0.5s 0.15s both; }
.svp-line { margin-top: 6px; font-family: 'Noto Sans TC', sans-serif; font-weight: 700; font-size: 15px; color: #fff; background: rgba(12,20,50,0.72); border-radius: 12px; padding: 6px 12px; display: inline-block; animation: svpBurst 0.5s 0.25s both; }
.hud-souv-pop.fly .svp-coin { transition: transform 0.5s ease-in, opacity 0.5s ease-in; transform: translate(40vw, -30vh) scale(0.2); opacity: 0.2; animation: none; }
.hud-souv-pop.fly .svp-title, .hud-souv-pop.fly .svp-line { transition: opacity 0.3s; opacity: 0; animation: none; }

/* PM #6: 旅行收藏冊 */
.sel-btns { display: flex; gap: 8px; align-items: center; }
.sel-book { font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 16px; padding: 8px 14px; border-radius: 12px; cursor: pointer; color: #3b2a00;
  background: linear-gradient(#ffe27a, #f2b90f); box-shadow: 0 4px 0 #a07200; }
.sel-book:active { transform: translateY(3px); box-shadow: 0 1px 0 #a07200; }
.book-screen { background: #f6f0e2; color: #1d1d1f; overflow-y: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 24px; font-family: 'Noto Sans TC', sans-serif; }
body.framed .book-screen { padding-top: 76px; }
.bk-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.bk-back { color: #1c5fd6; font-weight: 700; font-size: 17px; cursor: pointer; padding: 6px 0; }
.bk-title { font-weight: 900; font-size: 22px; }
.bk-count { text-align: center; color: #666; margin: 4px 0 12px; font-weight: 700; }
.bk-card { background: #fff; border-radius: 16px; padding: 12px 14px 10px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.bk-place { font-weight: 900; font-size: 16px; margin-bottom: 8px; }
.bk-row { display: flex; justify-content: space-around; }
.bk-item { text-align: center; width: 30%; }
.bk-coin { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 900;
  background: #cfcfcf; color: #fff; border: 3px solid #b5b5b5; }
.bk-coin.got { background: radial-gradient(circle at 40% 35%, #fff3b0, #f2c230 60%, #c99a14); border-color: #b8860b; cursor: pointer; box-shadow: 0 0 12px rgba(242,194,48,0.6); }
.bk-name { font-size: 13px; margin-top: 4px; color: #333; font-weight: 700; }
.bk-coin:not(.got) + .bk-name { color: #999; }
.bk-line { margin: 6px auto 8px; text-align: center; color: #555; font-size: 14px; max-width: 420px; min-height: 40px; }
.bk-line.show { color: #1d1d1f; font-weight: 700; animation: svpBurst 0.4s both; }
.bk-note { text-align: center; color: #999; font-size: 12px; }

/* select header: keep title + 收藏冊 + 返回 on one line on phones */
.sel-btns > div { white-space: nowrap; }
@media (max-width: 480px) { .sel-title { font-size: 24px; white-space: nowrap; } .sel-book, .sel-back { font-size: 14px; padding: 7px 10px; } }
/* the local item name sits below the 道具 hint */
.item-name { top: calc(100% + 4px); z-index: 7; }

/* PM phone: inside the Claude app the top bar (✕ Turbo Kart Rally) covers the top ~70 px —
   push the select screen's header (title, 📖 收藏冊, 返回) below it */
body.framed .select-screen { padding-top: 76px; }

/* PM #10: roadside photo-point toast ("喀嚓！拍到了…") + white camera flash */
@keyframes camFlashKF { 0% { opacity: 0; } 8% { opacity: 0.9; } 100% { opacity: 0; } }
.hud.camflash::after { content: ''; position: absolute; inset: 0; background: #fff; pointer-events: none; z-index: 50; opacity: 0; animation: camFlashKF 0.35s ease-out forwards; }
.photo-toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, -12px); z-index: 40; pointer-events: none;
  display: flex; align-items: center; gap: 8px; background: rgba(12,23,48,0.88); border: 2px solid #ffd23f; border-radius: 14px;
  padding: 10px 18px; font-family: 'Noto Sans TC', sans-serif; font-weight: 800; font-size: 15px; color: #fff;
  opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease; }
.photo-toast.show { opacity: 1; transform: translate(-50%, 0); }
.photo-toast .pt-ic { font-size: 20px; }

/* PM #10: 「到此一遊」明信片檢視器（成績畫面之後） */
.btn.postcard { background: linear-gradient(180deg, #4c6ef5 0%, #2b3e9c 100%); color: #fff; }
.postcard-screen { position: absolute; inset: 0; z-index: 70; background: rgba(6,12,28,0.97); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease; font-family: 'Noto Sans TC', sans-serif; }
.postcard-screen.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.25s ease; }   /* v27: .screen 預設 visibility:hidden，這裡要打開，否則明信片開了也看不到 */
.postcard-screen.hidden { display: none; }
.pc-wrap { width: min(92vw, 420px); display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 94vh; padding: calc(10px + env(safe-area-inset-top, 0px)) 0 10px; }
.pc-img-wrap { position: relative; width: 100%; aspect-ratio: 5/4; border-radius: 18px; overflow: hidden; background: #0c1730; box-shadow: 0 12px 32px rgba(0,0,0,0.5); }
.pc-img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s ease; }
.pc-img.show { opacity: 1; }
.pc-spinner { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; color: #ffe9a8; font-weight: 700; font-size: 15px; }
.pc-spinner.show { display: flex; }
.pc-thumbs { display: flex; gap: 8px; width: 100%; overflow-x: auto; padding-bottom: 2px; }
.pc-th { flex: none; padding: 8px 14px; border-radius: 12px; background: rgba(255,255,255,0.08); color: #cfe0ff; font-size: 13px; font-weight: 700; cursor: pointer; border: 2px solid transparent; }
.pc-th.cur { background: rgba(255,210,63,0.18); border-color: #ffd23f; color: #ffe9a8; }
.pc-buttons { display: flex; gap: 12px; width: 100%; }
.pc-buttons .btn { flex: 1; }
.pc-back { color: #8ea3cc; font-size: 14px; font-weight: 700; cursor: pointer; padding: 4px 0; }


/* v30 (PM 2026-09-28): landscape — minimap sat on top of the ◀ ▶ arrows; move it right of the lap / timer, above the arrows */
@media (orientation: landscape) {
  body.touch .hud-minimap { left: calc(116px + env(safe-area-inset-left, 0px)); top: 10px; width: 118px; height: 118px; }
  body.touch.framed .hud-minimap { top: 70px; }
}

/* PM #7 (cut 5): 導遊小卡 — top of the screen, between minimap and place; closes itself after 4 s */
.hud-guide { position: absolute; z-index: 35; pointer-events: none; background: rgba(12,23,48,0.9); border: 3px solid #ffc928; border-radius: 14px;
  padding: 8px 12px 10px; color: #fff; font-family: 'Noto Sans TC', 'PingFang TC', sans-serif; line-height: 1.4; box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  left: calc(176px + env(safe-area-inset-left, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); top: calc(150px + env(safe-area-inset-top, 0px));
  opacity: 0; transform: translateY(-10px) scale(0.96); transition: opacity 0.25s ease, transform 0.3s cubic-bezier(.3,1.5,.5,1); }
.hud-guide.show { opacity: 1; transform: none; }
.hud-guide .g-zh { color: #ffc928; font-weight: 900; font-size: 16px; }
.hud-guide .g-orig { color: #9fb2e6; font-size: 11px; font-weight: 700; }
.hud-guide .g-line { font-size: 13px; font-weight: 700; margin-top: 2px; }
.hud-guide .g-bar { height: 4px; border-radius: 2px; background: #2c3f63; margin-top: 7px; overflow: hidden; }
.hud-guide .g-bar i { display: block; height: 100%; width: 100%; background: #ffc928; transform-origin: left; }
.hud-guide.show .g-bar i { animation: gBar 4s linear forwards; }
@keyframes gBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
body.touch.framed .hud-guide { top: calc(204px + env(safe-area-inset-top, 0px)); }
/* landscape: top row, between the item slot (centre) and the place / pause (right) */
@media (orientation: landscape) {
  .hud-guide, body.touch.framed .hud-guide { left: calc(50% + 58px); right: calc(150px + env(safe-area-inset-right, 0px)); top: calc(10px + env(safe-area-inset-top, 0px)); }
  body.touch.framed .hud-guide { top: 70px; }
}
.hud-banner.fly { background: linear-gradient(90deg, rgba(232,89,12,0), rgba(232,89,12,0.9) 20%, rgba(232,89,12,0.9) 80%, rgba(232,89,12,0)); padding: 10px 0; }
.hud-banner.water { background: linear-gradient(90deg, rgba(31,127,209,0), rgba(31,127,209,0.9) 20%, rgba(31,127,209,0.9) 80%, rgba(31,127,209,0)); padding: 10px 0; }

/* 收藏冊: guide cards seen on each track */
.bk-guides { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; padding-top: 8px; border-top: 1px dashed #e3e3ea; }
.bk-guide { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; background: #eef1f8; color: #9aa0b4; }
.bk-guide.got { background: #0c1730; color: #ffc928; cursor: pointer; }

/* PM #7 v2: sky / dive — D-pad ▲ appears, speedo hides, mission pill + photo frame + underwater tint */
.tc-up { display: none; }
body.adv .tc-up { display: flex; width: 64px; height: 64px; font-size: 26px; background: rgba(232,89,12,0.85); border-color: #fff; }
body.adv .tc-back { background: rgba(232,89,12,0.85); border-color: #fff; }
body.adv .tc-dash { display: none; }
body.adv-drop .tc-item { background: rgba(224,49,49,0.9); font-size: 15px; }
.hud-mission { position: absolute; left: 50%; top: calc(118px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -8px); z-index: 36; pointer-events: none;
  background: rgba(12,23,48,0.88); color: #fff; border: 2px solid #ffc928; border-radius: 999px; padding: 6px 14px; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
  font-family: 'Noto Sans TC', 'PingFang TC', sans-serif; font-weight: 900; font-size: 14px; opacity: 0; transition: opacity 0.2s, transform 0.25s; }
.hud-mission.show { opacity: 1; transform: translate(-50%, 0); }
body.touch.framed .hud-mission { top: 176px; }
@media (orientation: landscape) { .hud-mission, body.touch.framed .hud-mission { top: auto; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); } }
.hud-frame { position: absolute; left: 50%; top: 44%; width: min(46vw, 230px); aspect-ratio: 1; transform: translate(-50%, -50%); z-index: 34; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.hud-frame.show { opacity: 1; }
.hud-frame .c { position: absolute; width: 22%; height: 22%; border: 4px solid #ffc928; }
.hud-frame .tl { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.hud-frame .tr { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.hud-frame .bl { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.hud-frame .br { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.hud-frame svg { position: absolute; inset: 14%; transform: rotate(-90deg); }
.hud-frame circle { fill: none; stroke-width: 5; }
.hud-frame .bg { stroke: rgba(255,255,255,0.25); }
.hud-frame .fg { stroke: #ffc928; stroke-dasharray: 276.5; stroke-dashoffset: 276.5; stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.hud-frame.lock .c { border-color: #69db7c; }
.hud-underwater { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 0.4s;
  background: radial-gradient(ellipse at 50% 0%, rgba(190,245,255,0.18), rgba(10,90,140,0.08) 60%, rgba(5,50,90,0.3)),
    repeating-linear-gradient(100deg, rgba(255,255,255,0.07) 0 18px, rgba(255,255,255,0) 18px 60px);
  background-size: 100% 100%, 220% 100%; animation: uwRays 6s linear infinite; }
.hud-underwater.show { opacity: 1; }
@keyframes uwRays { from { background-position: 0 0, 0 0; } to { background-position: 0 0, 120% 0; } }
@media (prefers-reduced-motion: reduce) { .hud-underwater { animation: none; } }
body.adv .hud-minimap { display: none; }   /* PM #7 v2: minimap not needed during the 8 s dive / flight; frees the top for the mission */
@media (orientation: landscape) {
  body.adv .tc-left { gap: 4px; }
  body.adv .tc-up, body.adv .tc-back { width: 54px; height: 54px; font-size: 22px; }
  body.adv .tc-arrow { width: 62px; height: 62px; }
}

/* PM #8 (cut 6): 🏔 天空冒險 */
.tcd-sky { margin: 6px auto 2px; background: #2f7d5b; color: #fff; border-radius: 10px; padding: 4px 8px; font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 13px; text-align: center; cursor: pointer; box-shadow: 0 3px 0 #1d5a3f; }
.tcd-sky:active { transform: translateY(2px); box-shadow: 0 1px 0 #1d5a3f; }
body.first .hud-tl, body.first .hud-br, body.first .hud-minimap, body.first .hud-item, body.first .hud-standings, body.first .hud-splits { display: none !important; }
body.first .tc-item, body.first .tc-drift, body.first .tc-back, body.first .tc-up, body.first .tc-pause { display: none !important; }
body.first-s1 .tc-gas, body.first-s1 .tc-brake, body.first-s3 .tc-gas, body.first-s3 .tc-brake, body.first-s2 .tc-brake, body.first-s4 .tc-gas { display: none !important; }
body.first .hud-mission { top: calc(62px + env(safe-area-inset-top, 0px)); }
body.touch.framed.first .hud-mission { top: 120px; }
.first-exit { position: absolute; left: calc(12px + env(safe-area-inset-left, 0px)); top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 50; background: rgba(12,23,48,0.8); color: #fff; border: 2px solid rgba(255,255,255,0.7); border-radius: 999px; padding: 5px 12px; font-family: 'Noto Sans TC', sans-serif; font-weight: 900; font-size: 14px; cursor: pointer; pointer-events: auto; }
body.touch.framed .first-exit { top: 70px; }
.first-results { display: flex; align-items: center; justify-content: center; background: rgba(8,20,30,0.72); z-index: 65; font-family: 'Noto Sans TC', sans-serif; }
.fr-panel { width: min(92vw, 440px); background: #fff; color: #15213a; border-radius: 20px; padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; max-height: 92vh; overflow-y: auto; }
.fr-title { font-weight: 900; font-size: 24px; text-align: center; }
.fr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.fr-stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.fr-stats span { font-size: 12px; color: #5a6477; }
.fr-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.fr-sv { text-align: center; }
.fr-coin { width: 48px; height: 48px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; background: #e2e5ee; color: #9aa0b4; font-weight: 900; border: 3px solid #cfd3de; }
.fr-sv.got .fr-coin { background: radial-gradient(circle at 40% 35%, #fff3b0, #f2c230 60%, #c99a14); border-color: #b8860b; }
.fr-nm { font-size: 11px; margin-top: 3px; font-weight: 700; color: #333; }
.fr-sv:not(.got) .fr-nm { color: #9aa0b4; }
.fr-btns { display: flex; flex-direction: column; gap: 8px; }
.pc-hint { color: #cfe0ff; font-size: 12px; text-align: center; font-family: 'Noto Sans TC', sans-serif; max-width: 90%; }
@media (orientation: landscape) {
  body.first .hud-mission { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }
  body.touch.framed.first .hud-mission { bottom: auto; top: 72px; }
}

/* PM (2026-09-30): way back to WatchWorld when the game runs on navcorx.com/world/kart/ */
.ww-back { position: fixed; z-index: 400; display: none; left: calc(12px + env(safe-area-inset-left, 0px)); top: calc(10px + env(safe-area-inset-top, 0px));
  padding: 7px 14px; border-radius: 999px; background: rgba(15,17,21,0.82); color: #fff; font: 700 14px "Noto Sans TC", system-ui, sans-serif;
  text-decoration: none; border: 1.5px solid rgba(255,255,255,0.55); box-shadow: 0 3px 10px rgba(0,0,0,0.35); -webkit-tap-highlight-color: transparent; }
.ww-back:active { transform: scale(0.95); }
body.ww[data-state="title"] .ww-back, body.ww[data-state="paused"] .ww-back { display: block; }
body.ww .select-screen, body.ww .book-screen { padding-top: 56px; }
