/* ============================================================================================
   军哥卡丁车 — UI styles (canvas, overlay layering, menus, HUD, results)
   ============================================================================================ */
:root {
  --display: 'Lilita One', 'Arial Black', Impact, sans-serif;
  --body: 'Nunito', '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; }
}

/* 军哥卡丁车 · 原创海湾街机界面。比赛层只使用轻量 CSS，不绘制主视觉。 */
:root {
  --display: 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --body: 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  --ink: #133b56; --gold: #ffd568; --orange: #ff672b; --blue: #179bd0; --cyan: #d8f3ff;
  --panel: rgba(248,253,255,.94); --panel-solid: #f8fdff;
  --jg-hero: url('assets/ui/harbor-hero.webp');
}
html, body { background:#133b56; overscroll-behavior:none; -webkit-touch-callout:none; }
#game-root { height:100%; height:100dvh; }
#game-canvas { touch-action:none; }
#ui-root.no-world { background:linear-gradient(155deg,#d8f3ff,#8bd8ee 65%,#f8eac2); }
#ui-root.no-world::before { background:repeating-linear-gradient(115deg,#ffffff18 0 40px,transparent 40px 110px); }
/* The hub covers the game controls; also remove those controls from keyboard/AT navigation. */
#ui-root:has(.jg-hub:not([hidden])) .jg-touch-ui { visibility:hidden; }
button, .logo-line, .sel-title, .hud, .pv-name, .card-name { font-weight:900; }
button { -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
button:focus-visible { outline:3px solid var(--ink); outline-offset:4px; }
.screen { padding-left:max(18px,env(safe-area-inset-left)); padding-right:max(18px,env(safe-area-inset-right)); }
.btn {
  min-height:48px; border:3px solid #fff; border-radius:17px; letter-spacing:1px;
  background:linear-gradient(180deg,#269dc9,#147ba6); color:#fff;
  box-shadow:0 5px 0 #133b56,0 9px 16px #133b5630; text-shadow:0 1px 0 #133b5660;
}
.btn.primary { background:linear-gradient(180deg,#ff8540,#ff672b); color:#fff; text-shadow:0 1px 0 #a63c20; box-shadow:0 5px 0 #ba4723,0 9px 16px #133b5630; }
.btn:hover, .btn.focus { transform:translateY(-2px); filter:brightness(1.06); }
.btn.focus { outline:3px solid var(--gold); outline-offset:3px; animation:none; }
.btn:active { transform:translateY(3px); box-shadow:0 2px 0 var(--ink); }
.btn.primary:active { box-shadow:0 2px 0 #ba4723; }
.kc { color:var(--ink); background:linear-gradient(#fff,#d8f3ff); box-shadow:0 2px 0 #a4ccdc; }

/* 启动与标题：游戏世界的主视觉只出现在非驾驶界面。 */
.title-screen { padding-top:env(safe-area-inset-top); background:var(--jg-hero) center 55%/cover no-repeat,#d8f3ff; }
.title-vignette { background:linear-gradient(180deg,#133b561f,transparent 38%,#133b5659 75%,#133b56c9); }
.logo { margin-top:clamp(62px,9vh,102px); transform:rotate(-3deg); }
.brand-kicker { display:inline-block; color:var(--ink); background:#fff7da; border:2px solid #fff; border-radius:999px; padding:8px 18px; font-size:clamp(12px,1.5vw,17px); font-weight:900; letter-spacing:3px; margin-bottom:14px; box-shadow:0 4px 0 #133b5630; text-shadow:none; }
.logo-line { font-weight:950; letter-spacing:.06em; line-height:1.14; -webkit-text-stroke:2px #fff; }
.logo-line::before { -webkit-text-stroke:9px var(--ink); }
.logo-line.l1 { font-size:clamp(72px,10vw,144px); background-image:linear-gradient(#fff7d6,#ffd568 55%,#ff8540); }
.logo-line.l1::before { text-shadow:0 6px 0 #b74723,0 13px 18px #133b5640; }
.logo-line.l2 { font-size:clamp(48px,7.5vw,100px); margin-top:0; background-image:linear-gradient(#fff,#d8f3ff 40%,#42b0d7); }
.logo-line.l2::before { text-shadow:0 5px 0 #126f98,0 10px 18px #133b5650; }
.logo-swoosh { top:55%; height:20%; background:linear-gradient(90deg,transparent,#ff672b 18%,#ff8540 82%,transparent); box-shadow:none; }
.press-start { bottom:14vh; border:3px solid #fff; border-radius:20px; padding:14px 34px; background:linear-gradient(180deg,#ff8540,#ff672b); color:#fff; font-size:clamp(20px,2.5vw,30px); box-shadow:0 6px 0 #b74723,0 14px 26px #133b5640; letter-spacing:2px; cursor:pointer; animation:none; text-shadow:0 1px 0 #b74723; }
.press-start:hover { filter:brightness(1.08); }
.press-start:active { transform:translateY(3px); box-shadow:0 3px 0 #b74723; }
.press-start span { display:block; font-size:12px; font-weight:700; margin-top:5px; letter-spacing:1px; opacity:.95; }
.title-tagline { position:absolute; bottom:28vh; color:#fff; font-size:clamp(14px,1.8vw,22px); letter-spacing:2px; font-weight:900; text-shadow:0 2px 5px #133b56; }
.title-foot { bottom:max(18px,env(safe-area-inset-bottom)); flex-wrap:wrap; font-size:12px; color:#fff; text-shadow:0 1px 3px #133b56; }
.title-foot span:first-child { margin-right:12px; }
.loading-screen { background:linear-gradient(#d8f3ffeb,#fff7dae8),var(--jg-hero) center/cover; color:var(--ink); }
.spinner { border-color:#133b561a; border-top-color:var(--orange); box-shadow:0 0 0 4px #fff; }
.loading-mark { display:grid; place-items:center; width:58px; height:58px; border:3px solid #fff; border-radius:17px; background:var(--orange); color:#fff; font-size:36px; font-weight:950; box-shadow:0 5px 0 #ba4723; transform:rotate(-6deg); }
.loading-text { font-size:clamp(20px,4vw,30px); letter-spacing:1px; text-shadow:none; }
#boot-screen { position:absolute; inset:0; z-index:90; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; background:linear-gradient(#d8f3ffdf,#fff7daeb),var(--jg-hero) center/cover; color:var(--ink); text-align:center; padding:24px; }
.boot-mark { display:grid; place-items:center; width:84px; height:84px; color:#fff; background:var(--orange); border:4px solid #fff; border-radius:24px; font-size:58px; font-weight:900; transform:rotate(-8deg); box-shadow:0 6px 0 #ba4723; }
#boot-screen h1 { font-size:32px; margin:12px 0 0; }
#boot-message { color:#365a6f; line-height:1.6; }
#boot-retry { min-height:48px; padding:12px 24px; border:3px solid #fff; background:var(--orange); color:#fff; border-radius:15px; font-weight:900; box-shadow:0 4px 0 #ba4723; }

/* 海湾车库：白色卡片、橙色选择态与可触控设置。 */
.select-screen { background:linear-gradient(90deg,#d8f3fff2 0%,#d8f3ffe0 32%,#d8f3ff22 46%,#d8f3ff22 54%,#d8f3ffe0 68%,#d8f3fff2 100%); color:var(--ink); padding-top:max(22px,env(safe-area-inset-top)); padding-bottom:max(16px,env(safe-area-inset-bottom)); }
.selection-brand { display:block; color:#147ba6; font-size:12px; font-weight:900; letter-spacing:2px; margin-bottom:5px; }
.sel-header { gap:12px; padding-right:165px; flex:none; }
.sel-title { font-size:clamp(23px,3vw,42px); background:none; color:var(--ink); filter:none; transform:none; line-height:1.2; letter-spacing:1px; }
.sel-back { border:3px solid #fff; min-height:44px; color:var(--ink); background:#f8fdff; font-size:15px; font-weight:900; white-space:nowrap; box-shadow:0 3px 0 #99c7d9; }
.sel-back:hover { background:#fff7da; }
.card { text-align:left; color:var(--ink); font-family:var(--body); background:linear-gradient(145deg,#fff,#eaf8ff); border:3px solid #fff; box-shadow:inset 5px 0 0 var(--kc),0 5px 0 #aacedd,0 9px 14px #133b561a; padding-right:12px; }
.card:hover { background:#fff7da; }
.card.selected { background:linear-gradient(135deg,#fff7da,#ffe5ab); border-color:var(--orange); transform:translateY(-2px); box-shadow:inset 5px 0 0 var(--kc),0 5px 0 #e8a34e,0 0 0 2px #fff; }
.card.focus { border-color:var(--orange); box-shadow:inset 5px 0 0 var(--kc),0 5px 0 #e8a34e,0 0 0 3px #fff; }
.card-name { font-size:clamp(17px,1.6vw,23px); text-shadow:none; padding-right:18px; }
.card-number { position:absolute; right:8px; top:7px; font-size:10px; font-weight:900; color:#53778c; font-variant-numeric:tabular-nums; }
.card-portrait { box-shadow:0 3px 0 #133b5620; }
.card-portrait .initial, .pv-initial { color:#fff; }
.card-stats .st { font-size:10px; }
.bar i { background:#c6dce5; }
.bar i.on { background:linear-gradient(#ffad5a,#ff672b); box-shadow:none; }
.sel-side { gap:12px; }
.preview { color:var(--ink); background:linear-gradient(145deg,#fffffff2,#eaf8fff2); border:3px solid #fff; backdrop-filter:none; box-shadow:0 6px 0 #99c7d9,0 12px 22px #133b561f; }
.pv-portrait { box-shadow:0 0 0 4px var(--kc,#99c7d9),0 7px 0 #133b5620; }
.pv-name { font-size:36px; text-shadow:none; line-height:1.18; }
.pv-kart { color:#53778c; opacity:1; }
.opt { grid-template-columns:50px 44px 1fr 44px; padding:6px 9px; color:var(--ink); background:#f8fdff; border:3px solid #fff; box-shadow:0 4px 0 #99c7d9; }
.opt.focus { border-color:var(--orange); background:#fff7da; box-shadow:0 4px 0 #e8a34e; }
.opt-arrow { min-width:44px; height:44px; padding:0; border:0; border-radius:11px; background:#d8f3ff; color:#147ba6; font-size:17px; }
.opt-arrow:hover { transform:none; background:#bce8fa; }
.opt-arrow:active { background:#ffd568; }
.opt-val { font-size:18px; }
.opt-lbl { font-size:14px; opacity:1; color:#53778c; }
.race-btn { font-size:26px; min-height:54px; padding:9px; }
.controls-help { color:var(--ink); background:#f8fdffed; border:2px solid #fff; box-shadow:0 3px 0 #99c7d9; }

/* 维修站与终点成绩使用同一套厚边卡片。 */
.pause-screen { background:#133b565e; backdrop-filter:blur(3px); }
.pause-panel { color:var(--ink); background:linear-gradient(150deg,#fff,#eaf8ff); max-height:90dvh; overflow-y:auto; max-width:94vw; border:4px solid #fff; box-shadow:0 8px 0 #99c7d9,0 20px 45px #133b5650; }
.pause-kicker { font-size:12px; font-weight:900; color:#147ba6; letter-spacing:2px; }
.pause-title { font-size:clamp(26px,5vw,44px); letter-spacing:1px; color:var(--ink); text-shadow:none; }
.intro-card { background:linear-gradient(90deg,#ff672bf2,#ff8540eb 82%,transparent); }
.results { background:linear-gradient(#133b5675,#133b56c4); }
.res-panel { color:var(--ink); background:linear-gradient(150deg,#fff,#eaf8ff); max-height:90dvh; border:4px solid #fff; box-shadow:0 8px 0 #99c7d9,0 25px 45px #133b5650; }
.res-title { font-size:clamp(28px,5vmin,46px); line-height:1.25; color:var(--ink); text-shadow:none; transform:none; }
.res-sub { color:#53778c; font-size:12px; letter-spacing:1px; opacity:1; }
.res-row { grid-template-columns:60px 48px minmax(0,1fr) auto 105px; background:#d8f3ff; border:2px solid #fff; }
.res-row.me { color:var(--ink); background:linear-gradient(90deg,#ffd568,#ffe6ad); box-shadow:0 3px 0 #e8ba5f; }
.res-name { font-size:20px; overflow-wrap:anywhere; }
.res-time { font-size:20px; }
.res-place { font-size:28px; -webkit-text-stroke:3px var(--ink); }
.res-row.me .res-place { -webkit-text-stroke:3px var(--ink); }
.res-buttons { flex:none; }

/* 驾驶界面保持小尺寸，跑道中央不增加图片或遮罩。 */
.hud-tl { top:max(14px,env(safe-area-inset-top)); left:max(18px,env(safe-area-inset-left)); padding:9px 12px; border:2px solid #fff; border-radius:17px; background:#f8fdffe8; color:var(--ink); box-shadow:0 4px 0 #133b5640; }
.hud-brand { display:flex; align-items:center; gap:7px; margin-bottom:6px; text-shadow:none; }
.hud-brand-mark { display:grid; place-items:center; font-size:21px; width:34px; height:34px; border:2px solid #fff; background:var(--orange); border-radius:10px; color:#fff; box-shadow:0 2px 0 #ba4723; }
.hud-brand strong { display:block; font-size:16px; }
.hud-brand small { display:block; color:#53778c; font-size:9px; letter-spacing:1px; margin-top:2px; }
.hud-lap { text-shadow:none; }
.hud-lap .lbl { font-size:16px; color:#53778c; }
.hud-lap .val { font-size:40px; }
.hud-lap .of { font-size:24px; }
.hud-lap.final .val { color:#bd4b23; }
.hud-timer { font-size:23px; text-shadow:none; }
.hud-splits { max-height:75px; overflow:hidden; font-size:12px; }
.split { text-shadow:none; }
.split span { width:54px; color:#147ba6; }
.split.best { color:#16846d; }
.hud-standings { top:max(72px,calc(env(safe-area-inset-top) + 62px)); right:max(18px,env(safe-area-inset-right)); }
.st-row { background:#f8fdffe3; color:var(--ink); border:1px solid #fff; box-shadow:0 2px 0 #133b5620; }
.st-row.me { background:linear-gradient(90deg,#ffd568,#ffaf58); }
.st-name { max-width:145px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hud-minimap { background:#133b5659; border:2px solid #ffffffa3; border-radius:22px; }
.hud-speedo { background:#f8fdffe0; border:2px solid #fff; box-shadow:0 4px 0 #133b5640; }
.speed-val { color:var(--ink); text-shadow:none; }
.speed-unit { color:#53778c; opacity:1; text-shadow:none; }
.item-slot { background:radial-gradient(circle at 50% 30%,#d8f3ff,#86c9e3); box-shadow:0 4px 0 #133b5640,inset 0 -6px 0 #133b5615; }
.item-slot::after { border-color:#fff9; }
.item-hint { max-width:180px; color:#fff; background:#133b56d9; text-align:center; letter-spacing:0; }
.drift-pill { white-space:nowrap; font-size:12px; }
.drift-pill.lvl3 { background:var(--orange); box-shadow:0 0 16px #ffd568; }
.hud-place .num { font-size:clamp(65px,12vmin,115px); -webkit-text-stroke:5px var(--ink); }
.hud-place .suf { font-size:clamp(24px,4vmin,36px); -webkit-text-stroke:3px var(--ink); }
.hud-countdown { font-weight:950; -webkit-text-stroke:6px var(--ink); }
.hud-countdown.n3 { color:var(--orange); } .hud-countdown.n2 { color:#ffad5a; } .hud-countdown.n1 { color:var(--gold); }
.hud-countdown.go { color:#d8f3ff; }
.hud-banner { font-size:clamp(30px,6vmin,70px); -webkit-text-stroke:4px var(--ink); }
.hud-banner.final { background:linear-gradient(90deg,transparent,#ff672be3 24%,#ff672be3 76%,transparent); }
.hud-wrongway { max-width:90vw; background:#ff672bf2; box-shadow:0 5px 0 #ba4723; border-width:3px; padding:10px 18px; }
.ww-text { font-size:clamp(22px,4vmin,42px); letter-spacing:1px; }
.fin-title { font-size:clamp(45px,10vmin,100px); -webkit-text-stroke:4px var(--ink); padding:8px 22px; }
.fin-place { font-size:clamp(46px,8vmin,90px); -webkit-text-stroke:4px var(--ink); }
.toast { max-width:90vw; width:max-content; color:#fff; background:#133b56eb; border:2px solid #fff; text-align:center; box-shadow:0 3px 0 #133b5640; }
body.jg-has-touch .hud-minimap { left:max(16px,env(safe-area-inset-left)); bottom:max(125px,calc(env(safe-area-inset-bottom) + 125px)); width:105px; height:105px; }
body.jg-has-touch .hud-br { bottom:max(190px,calc(env(safe-area-inset-bottom) + 190px)); right:max(18px,env(safe-area-inset-right)); gap:4px; }
body.jg-has-touch .hud-speedo { width:92px; height:92px; margin-bottom:0; }
body.jg-has-touch .speed-val { font-size:25px; }
body.jg-has-touch .speed-unit { font-size:9px; }
body.jg-has-touch .hud-place .num { font-size:65px; }
body.jg-has-touch .hud-place .suf { font-size:24px; }
body.jg-has-touch .toast { bottom:180px; font-size:14px; }
body.jg-has-touch .hud-brand small, body.jg-has-touch .hud-standings, body.jg-has-touch .controls-help { display:none; }

@media (max-width:950px) {
  .select-screen { padding-top:max(66px,calc(env(safe-area-inset-top) + 62px)); padding-bottom:max(14px,env(safe-area-inset-bottom)); background:#d8f3fff2; overflow-y:auto; overscroll-behavior:contain; }
  .sel-header { padding-right:0; }
  .sel-body { flex:none; flex-direction:column; margin-top:12px; gap:14px; }
  .sel-grid { width:100%; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; grid-auto-rows:auto; }
  .card { min-height:106px; grid-template-columns:1fr; text-align:center; }
  .card-name { padding-right:0; font-size:16px; }
  .card-portrait { grid-row:auto; margin:0 auto 4px; width:52px; height:52px; }
  .card-stats { display:none; }
  .sel-side { width:100%; flex-direction:row; align-items:stretch; }
  .preview { flex:1 1 220px; }
  .opts { flex:1 1 230px; }
  .pv-portrait { width:80px; height:80px; }
  .pv-name { font-size:26px; }
  .st.big .bar i { width:17px; }
  .controls-help, .hud-standings { display:none; }
  .res-row { grid-template-columns:54px 40px minmax(0,1fr) 90px; }
  .res-best { display:none; }
}
@media (max-width:560px) {
  .logo { margin-top:max(94px,calc(env(safe-area-inset-top) + 78px)); }
  .brand-kicker { font-size:11px; letter-spacing:2px; padding:7px 12px; }
  .logo-line.l1 { font-size:82px; } .logo-line.l2 { font-size:56px; }
  .title-tagline { bottom:30vh; font-size:13px; letter-spacing:1px; }
  .press-start { bottom:16vh; padding:12px 28px; }
  .title-foot { padding:0 12px; font-size:10px; }
  .select-screen { padding-left:max(10px,env(safe-area-inset-left)); padding-right:max(10px,env(safe-area-inset-right)); }
  .sel-title { font-size:22px; }
  .selection-brand { font-size:10px; letter-spacing:1px; }
  .sel-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
  .card { min-height:94px; }
  .sel-side { flex-direction:column; }
  .preview { flex:none; flex-direction:row; align-items:center; padding:14px; gap:16px; }
  .pv-portrait { flex:none; width:76px; height:76px; }
  .pv-name { text-align:left; font-size:24px; }
  .pv-kart { justify-content:flex-start; font-size:10px; margin:5px 0; letter-spacing:0; }
  .st.big { font-size:10px; margin:2px 0; }
  .st.big .bar { gap:3px; } .st.big .bar i { width:14px; height:8px; }
  .opts { flex:none; }
  .hud-brand strong { font-size:11px; } .hud-brand small { font-size:8px; }
  .hud-brand-mark { width:25px; height:25px; font-size:16px; border-radius:7px; }
  .hud-brand { gap:5px; margin-bottom:5px; }
  .hud-tl { left:max(10px,env(safe-area-inset-left)); top:max(64px,calc(env(safe-area-inset-top) + 60px)); padding:7px 9px; border-radius:14px; }
  .hud-item { top:max(65px,calc(env(safe-area-inset-top) + 61px)); left:auto; right:max(15px,env(safe-area-inset-right)); transform:none; }
  .item-slot { width:68px; height:68px; border-radius:18px; border-width:3px; } .item-slot::after { border-radius:12px; }
  .item-img { width:50px; height:50px; }
  .item-count { font-size:22px; right:-7px; bottom:-8px; }
  .item-hint { font-size:9px; max-width:95px; padding:3px 5px; }
  .hud-lap .val { font-size:28px; } .hud-lap .lbl { font-size:12px; } .hud-lap .of { font-size:18px; }
  .hud-timer { font-size:17px; }
  .hud-splits { font-size:10px; max-height:38px; } .split span { width:44px; }
  .res-panel { padding:15px 10px; gap:7px; border-width:3px; width:94vw; }
  .res-row { gap:5px; padding:5px; grid-template-columns:34px 29px minmax(0,1fr) 74px; }
  .res-name { font-size:13px; } .res-portrait { width:29px; height:29px; border-radius:8px; }
  .res-place { font-size:22px; } .res-name em { display:block; width:max-content; margin:2px 0 0; padding:1px 4px; font-size:9px; }
  .res-time { font-size:14px; }
  .res-buttons { gap:10px; } .res-buttons .btn { min-width:120px; font-size:17px; padding:10px 12px; }
  .pause-panel { padding:22px 18px; } .pause-panel .btn { width:min(270px,75vw); }
  .intro-card { max-width:100vw; padding:16px 25px 16px 18px; bottom:22vh; }
  .ic-name { font-size:30px; } .ic-sub { font-size:14px; } .ic-skip { font-size:10px; letter-spacing:0; }
}
@media (orientation:landscape) and (max-height:520px) {
  .logo { margin-top:32px; }
  .brand-kicker { margin-bottom:7px; font-size:10px; padding:4px 12px; }
  .logo-line.l1 { font-size:58px; } .logo-line.l2 { font-size:40px; }
  .title-tagline { bottom:26%; font-size:12px; }
  .press-start { bottom:7%; font-size:18px; padding:7px 25px; }
  .press-start span { font-size:10px; margin-top:2px; } .title-foot { display:none; }
  .select-screen { padding-top:max(10px,env(safe-area-inset-top)); }
  .sel-header { padding-right:152px; } .selection-brand { font-size:9px; margin-bottom:2px; }
  .sel-title { font-size:22px; }
  .sel-body { flex-direction:row; gap:16px; }
  .sel-grid { width:60%; gap:8px; grid-template-columns:repeat(4,minmax(0,1fr)); }
  .card { min-height:80px; padding:5px; } .card-portrait { width:42px; height:42px; }
  .card-name { font-size:13px; } .card-number { font-size:8px; right:5px; }
  .sel-side { width:40%; flex-direction:column; } .preview { display:none; } .opts { flex:none; }
  .opt { grid-template-columns:28px 44px minmax(0,1fr) 44px; gap:2px; padding:2px 4px; } .opt-val { font-size:14px; }
  .race-btn { font-size:21px; min-height:48px; }
  .hud-tl { top:max(9px,env(safe-area-inset-top)); left:max(12px,env(safe-area-inset-left)); padding:5px 8px; }
  .hud-brand { margin-bottom:3px; } .hud-brand strong { font-size:12px; } .hud-brand-mark { width:24px; height:24px; font-size:16px; }
  .hud-lap .lbl { font-size:12px; } .hud-lap .val { font-size:26px; } .hud-lap .of { font-size:18px; }
  .hud-timer { font-size:15px; } .hud-splits { display:none; }
  .hud-item { top:10px; left:50%; right:auto; transform:translateX(-50%); }
  .item-slot { width:58px; height:58px; border-width:3px; border-radius:15px; } .item-img { width:44px; height:44px; }
  .item-hint { font-size:9px; padding:2px 5px; }
  body.jg-has-touch .hud-minimap { width:78px; height:78px; bottom:max(106px,calc(env(safe-area-inset-bottom) + 106px)); }
  body.jg-has-touch .hud-br { bottom:max(130px,calc(env(safe-area-inset-bottom) + 130px)); right:max(12px,env(safe-area-inset-right)); }
  body.jg-has-touch .hud-speedo { width:68px; height:68px; } body.jg-has-touch .speed-val { font-size:20px; } body.jg-has-touch .speed-unit { font-size:7px; }
  body.jg-has-touch .hud-place .num { font-size:48px; } body.jg-has-touch .hud-place .suf { font-size:18px; } body.jg-has-touch .toast { bottom:130px; }
  .res-panel { max-height:92dvh; padding:10px 14px; gap:4px; width:min(600px,94vw); } .res-title { font-size:26px; }
  .res-sub { font-size:10px; margin-bottom:0; } .res-row { padding:3px 7px; } .res-portrait { width:26px; height:26px; }
  .res-name { font-size:13px; } .res-place { font-size:21px; } .res-time { font-size:14px; }
  .res-buttons { margin-top:5px; } .res-buttons .btn { min-width:120px; padding:8px 15px; font-size:16px; }
  .pause-panel { gap:8px; padding:16px 22px; } .pause-title { font-size:27px; margin:0; } .pause-panel .btn { padding:9px 25px; }
  .ic-name { font-size:30px; } .ic-sub { font-size:13px; } .intro-card { bottom:22%; padding:12px 35px 12px 18px; }
}
@media (max-width:350px) {
  .logo-line.l1 { font-size:73px; } .logo-line.l2 { font-size:49px; }
  .card-name { font-size:13px; } .res-buttons .btn { min-width:105px; }
}
@media (prefers-reduced-motion:reduce) {
  #ui-root.no-world::before, .logo, .card, .press-start, .btn.focus, .item-slot.filled, .hud-wrongway, .ww-arrow { animation:none!important; }
  .card, .btn, .screen { transition:none; }
}
