/* ============================================================================================
   CyberKart — 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: #0a1124;
  --navy: #101a36;
  --emerald: #2fd6a0;
  --emerald-deep: #0f7a5a;
  --cape: #e0412f;
  --cape-deep: #8a1f14;
  --gold: #ffd23f;
  --orange: #ff8a1f;
  --red: #e0412f;
  --blue: #2f8bff;
  --cyan: #3de0ff;
  --panel: rgba(12, 22, 44, 0.78);
  --panel-solid: #101a36;
  --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: #070d1c; 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%, #2fd6a0 0%, #0f7a5a 26%, #122a4a 58%, #070d1c 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, #24365e 0%, #142246 100%);
  box-shadow: 0 6px 0 #070d1c, 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, #5cf0c0 0%, #2fd6a0 45%, #13a079 100%); color: #fff; box-shadow: 0 6px 0 #0a5a42, 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 #070d1c; }
@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(16,30,58,0.88), rgba(7,13,28,0.97)); }
.spinner { width: 64px; height: 64px; border-radius: 50%; border: 8px solid rgba(255,255,255,0.18); border-top-color: var(--emerald); 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(7,13,28,0.6) 100%),
    linear-gradient(180deg, rgba(10,17,36,0.45) 0%, rgba(0,0,0,0) 40%, rgba(7,13,28,0.7) 100%);
}
.title-vignette::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background: repeating-linear-gradient(0deg, rgba(47,214,160,0.08) 0 1px, transparent 1px 4px);
  mix-blend-mode: screen;
}
.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;
  filter: drop-shadow(0 0 18px rgba(47,214,160,0.45));
}
@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; right: 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, #e6fff5 0%, #8af5cf 30%, #2fd6a0 60%, #129a72 100%);
}
.logo-line.l1::before {
  text-shadow: 0 4px 0 #0f7a5a, 0 8px 0 #0c654a, 0 12px 0 #09503b, 0 16px 0 #063b2b, 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, #fff8d0 0%, #ffe27a 40%, #ffd23f 70%, #e0a51f 100%);
}
.logo-line.l2::before {
  text-shadow: 0 3px 0 #8a1f14, 0 6px 0 #741a11, 0 9px 0 #5e150e, 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(224,65,47,0) 0%, rgba(224,65,47,0.95) 20%, rgba(176,40,30,0.95) 80%, rgba(176,40,30,0) 100%);
  transform: skewX(-20deg); border-radius: 8px;
  box-shadow: 0 0 30px rgba(224,65,47,0.55);
}
.tagline {
  position: relative; margin-top: 3vh; padding: 6px 22px; border-radius: 999px;
  font-family: var(--display); font-size: clamp(18px, 2.2vw, 30px); letter-spacing: 4px; color: var(--emerald);
  background: rgba(10,17,36,0.7); border: 2px solid rgba(47,214,160,0.55);
  text-shadow: 0 2px 0 var(--ink), 0 0 16px rgba(47,214,160,0.75);
  box-shadow: 0 0 18px rgba(47,214,160,0.35), inset 0 0 10px rgba(47,214,160,0.2);
  animation: taglineIn 0.8s ease 0.6s both;
}
@keyframes taglineIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.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); color: var(--gold);
  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(7,13,28,0.86) 0%, rgba(7,13,28,0.5) 34%, rgba(7,13,28,0) 44%, rgba(7,13,28,0) 58%, rgba(7,13,28,0.6) 68%, rgba(7,13,28,0.88) 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%, #8af5cf 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 auto 1fr;
  column-gap: 10px; padding: 9px 10px 9px 9px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(26,42,78,0.92), rgba(12,20,42,0.92));
  border: 3px solid rgba(47,214,160,0.2);
  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%, #101a36), rgba(12,20,42,0.95)); border-color: var(--emerald); 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), 0 0 40px rgba(47,214,160,0.25); }
.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 3; 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 { grid-column: 2; 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(47,214,160,0.35);
  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; color: var(--emerald); 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(40,40,30,0.85); 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); }
.opt-track .opt-val { font-size: 16px; letter-spacing: 0.5px; }
.opt-track.night .opt-val { color: #ff6be6; text-shadow: 0 0 8px rgba(255,43,214,0.8), 0 0 18px rgba(34,230,255,0.45); }
.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(7,13,28,0.6); 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(24,38,72,0.96), rgba(10,17,36,0.96));
  border: 4px solid var(--emerald); 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(224,65,47,0.95), rgba(176,40,30,0.9) 80%, rgba(176,40,30,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; }
body[data-state="finished"] .hud-item { opacity: 0; transition: opacity 0.4s; } /* clear the view for the finish celebration */
.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; }
/* pops in, holds ~1.2 s, then clears so the finish-camera swing shows the driver's celebration */
.hud-finish.show { animation: finishIn 0.7s cubic-bezier(.2,1.6,.4,1) forwards, finishOut 0.45s ease-in 1.9s forwards; }
@keyframes finishIn { from { opacity: 0; transform: scale(3) rotate(8deg); } to { opacity: 1; transform: none; } }
@keyframes finishOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-60px) scale(0.7); } }
.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; }
@keyframes rowIn { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
.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(7,13,28,0.82); }
  .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; }
  .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; }
}
/* short desktop windows (e.g. 1280x720): fit the select screen without the controls strip */
@media (max-height: 800px) and (min-width: 901px) {
  .select-screen .controls-help { display: none; }
  .select-screen .pv-portrait { width: 92px; height: 92px; }
  .select-screen .pv-name { font-size: 32px; }
  .select-screen .preview { padding: 12px; gap: 6px; }
  .select-screen .pv-kart { margin: 2px 0 4px; }
  .select-screen .st.big { margin: 1px 0; }
  .select-screen .opt { padding: 7px 12px; }
  .select-screen .race-btn { font-size: 28px; padding: 10px; }
}
@media (max-height: 640px) and (min-width: 901px) {
  .select-screen { overflow-y: auto; }
  .select-screen .pv-stats { display: none; } /* the cards already show the stat bars */
}
@media (max-width: 500px) {
  .sel-title { font-size: 26px; }
  .sel-back { white-space: nowrap; font-size: 14px; padding: 6px 10px; }
  .sel-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-name { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .tagline, .press-start, .btn.focus, .item-slot.filled { animation: none !important; }
}

.card-company { font-size: 0.68em; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; margin-top: -2px; }

/* ================================================================ announcer toasts */
.toast.announce {
  bottom: max(110px, 16vh); display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 92vw; text-align: center;
  padding: 8px 22px 9px; border-radius: 14px; background: rgba(6,20,16,0.82); border: 2px solid rgba(47,214,160,0.75);
  box-shadow: 0 0 22px rgba(47,214,160,0.35); font-size: clamp(18px, 3.2vmin, 28px); color: #fff; pointer-events: none;
}
.toast.announce b { font-weight: normal; text-shadow: 0 2px 0 rgba(0,0,0,0.6); }
.toast.announce small { font-family: var(--body); font-weight: 900; font-size: 12px; letter-spacing: 1.5px; color: #8ff5cf; text-transform: uppercase; }
.toast.announce.bad { border-color: rgba(255,71,87,0.85); background: rgba(40,6,12,0.85); box-shadow: 0 0 22px rgba(255,71,87,0.4); }
.toast.announce.bad small { color: #ffb3bb; }
.toast.announce.warn { border-color: rgba(255,190,50,0.9); box-shadow: 0 0 22px rgba(255,190,50,0.35); }
.toast.announce.warn small { color: #ffe08a; }
.toast.announce.good b { color: #7dffc0; }
.toast.announce.show { animation: announce 2.2s ease forwards; }
@keyframes announce { 0% { opacity: 0; transform: translate(-50%, 12px) scale(0.9); } 10%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -8px); } }

/* ================================================================ scan report (results) */
.res-panel.scan { width: min(900px, 96vw); background: linear-gradient(180deg, rgba(14,30,40,0.97), rgba(8,12,24,0.97)); border-color: #2fd6a0; gap: 6px; }
.sr-head { align-self: center; display: flex; align-items: center; gap: 8px; padding: 3px 14px; border-radius: 8px; background: rgba(47,214,160,0.14);
  border: 1px solid rgba(47,214,160,0.5); font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; font-size: 13px; letter-spacing: 2px; color: #8ff5cf; }
.sr-dot { width: 8px; height: 8px; border-radius: 50%; background: #2fd6a0; box-shadow: 0 0 8px #2fd6a0; animation: wwBlink 1s steps(2, jump-none) infinite; }
.sr-posture { align-self: center; display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 4px 10px; padding: 4px 14px; border-radius: 12px;
  background: rgba(255,255,255,0.07); font-family: var(--display); font-size: 16px; letter-spacing: 1px; }
.sr-posture > span:last-child { font-family: var(--body); font-weight: 900; font-size: 13px; opacity: 0.85; }
.sr-posture .sr-grade { width: 40px; height: 34px; font-size: 22px; }
.sr-cols, .sr-row { display: grid; grid-template-columns: 52px 44px minmax(0, 1fr) auto 92px 46px; align-items: center; gap: 10px; }
.sr-cols { padding: 0 12px 0 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 10px; letter-spacing: 1.5px; opacity: 0.6; }
.sr-cols span:nth-child(4) { text-align: center; } .sr-cols span:nth-child(5) { text-align: right; } .sr-cols span:nth-child(6) { text-align: center; }
.sr-row { padding: 4px 12px 4px 8px; border-radius: 12px; background: rgba(255,255,255,0.06); border-left: 4px solid transparent;
  animation: rowIn 0.45s cubic-bezier(.2,1.4,.4,1) both; animation-delay: var(--d); }
.sr-row.guardian { border-left-color: #2fd6a0; background: linear-gradient(90deg, rgba(47,214,160,0.28), rgba(47,214,160,0.06)); }
.sr-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.45); }
.sr-row.me.guardian { border-left-color: #2fd6a0; }
.sr-place { font-family: var(--display); font-size: 32px; line-height: 1; text-align: center; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.sr-place small { font-size: 0.45em; vertical-align: top; }
.sr-portrait { width: 42px; height: 42px; border-radius: 11px; overflow: hidden; border: 3px solid #fff; background: var(--kc); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 22px; }
.sr-portrait img { width: 100%; height: 100%; object-fit: cover; }
.sr-name { font-family: var(--display); font-size: 22px; line-height: 1.05; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-name small { display: block; font-family: var(--body); font-weight: 900; font-size: 11px; letter-spacing: 1px; opacity: 0.7; text-transform: uppercase; }
.sr-name em { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--ink); color: var(--gold); vertical-align: middle; margin-left: 4px; }
.sr-name em.g { color: #2fd6a0; }
.sr-stats { display: flex; gap: 6px; }
.sr-stat { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: 2px 4px; border-radius: 8px; background: rgba(0,0,0,0.28); }
.sr-stat b { font-family: var(--display); font-weight: normal; font-size: 18px; line-height: 1.1; }
.sr-stat i { font-style: normal; font-family: var(--body); font-weight: 900; font-size: 8px; letter-spacing: 1px; opacity: 0.75; }
.sr-stat.f b { color: #ff8a8a; } .sr-stat.p b { color: #7dffc0; } .sr-stat.x b { color: #ffd23f; }
.sr-row.me .sr-stat { background: rgba(20,12,0,0.72); color: #fff; }
.sr-time { text-align: right; font-weight: 900; font-size: 19px; font-variant-numeric: tabular-nums; line-height: 1.05; }
.sr-time i { display: block; font-style: normal; font-size: 9px; letter-spacing: 1.5px; opacity: 0.65; }
.sr-grade { width: 44px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 9px; font-family: var(--display); font-size: 22px;
  color: var(--ink); background: #ccc; border: 2px solid rgba(0,0,0,0.35); }
.sr-grade.g-A { background: #2fd6a0; } .sr-grade.g-A.plus { background: #7dffc0; box-shadow: 0 0 12px rgba(125,255,192,0.8); }
.sr-grade.g-B { background: #b8f04a; } .sr-grade.g-C { background: #ffd23f; } .sr-grade.g-D { background: #ff9f43; } .sr-grade.g-F { background: #ff4757; color: #fff; }
@media (max-width: 700px) {
  .res-panel.scan { padding: 14px 10px 16px; border-radius: 20px; }
  .res-panel.scan .res-title { font-size: 34px; }
  .sr-head { font-size: 10px; letter-spacing: 1px; text-align: center; }
  .sr-cols { display: none; }
  .sr-row { grid-template-columns: 34px 34px minmax(0, 1fr) auto 38px; grid-template-areas: "pl po nm tm gr" "pl po st st gr"; gap: 3px 7px; padding: 4px 8px 5px 4px; }
  .sr-place { grid-area: pl; font-size: 24px; -webkit-text-stroke: 4px var(--ink); }
  .sr-portrait { grid-area: po; width: 32px; height: 32px; border-width: 2px; border-radius: 8px; }
  .sr-name { grid-area: nm; font-size: 16px; }
  .sr-name small { display: none; }
  .sr-stats { grid-area: st; gap: 4px; }
  .sr-stat { flex-direction: row; gap: 3px; min-width: 0; padding: 1px 5px; align-items: baseline; }
  .sr-stat b { font-size: 13px; }
  .sr-time { grid-area: tm; font-size: 14px; }
  .sr-time i { display: inline; margin-right: 4px; }
  .sr-grade { grid-area: gr; width: 36px; height: 32px; font-size: 18px; }
  .sr-posture { font-size: 13px; }
}
@media (max-height: 820px) and (min-width: 701px) {
  .res-panel.scan { padding: 12px 20px 14px; gap: 4px; }
  .res-panel.scan .res-title { font-size: 40px; }
  .res-panel.scan .res-sub { margin-bottom: 0; }
  .res-panel.scan .res-buttons { margin-top: 6px; }
  .sr-row { padding: 2px 12px 2px 8px; }
  .sr-place { font-size: 26px; }
  .sr-portrait { width: 34px; height: 34px; border-width: 2px; border-radius: 9px; }
  .sr-name { font-size: 19px; }
  .sr-name small { font-size: 10px; }
  .sr-stat { flex-direction: row; align-items: baseline; gap: 4px; padding: 1px 6px; }
  .sr-stat b { font-size: 15px; }
  .sr-grade { height: 30px; font-size: 19px; }
  .sr-posture { padding: 2px 12px; }
}

/* ================================================================ signature powers */
.hud-power {
  --pw: #2fd6a0;
  margin-top: 8px; display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 5px; border-radius: 14px;
  background: rgba(6,12,30,0.78); border: 2px solid rgba(255,255,255,0.25); font-family: var(--body, sans-serif); font-weight: 900;
}
.hud-power .pw-icon {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 17px;
  color: #fff; background: color-mix(in srgb, var(--pw) 45%, #0b1430); border: 2px solid var(--pw);
}
.hud-power .pw-body { display: flex; flex-direction: column; gap: 3px; min-width: 112px; }
.hud-power .pw-name { font-size: 11px; letter-spacing: 1.2px; color: #e6f0ff; white-space: nowrap; }
.hud-power .pw-bar { display: block; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.14); overflow: hidden; }
.hud-power .pw-bar i { display: block; height: 100%; width: 0; background: var(--pw); border-radius: 4px; transition: width 0.12s linear; }
.hud-power .pw-key { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,0.15); opacity: 0.5; }
.hud-power.ready { border-color: var(--pw); animation: pwGlow 0.7s ease-in-out infinite alternate; }
.hud-power.ready .pw-name { color: var(--pw); }
.hud-power.ready .pw-key { opacity: 1; background: var(--pw); color: #061020; }
.hud-power.fired { animation: pwFired 0.45s ease-out; }
@keyframes pwGlow { from { box-shadow: 0 0 6px color-mix(in srgb, var(--pw) 50%, transparent); } to { box-shadow: 0 0 20px var(--pw), inset 0 0 8px color-mix(in srgb, var(--pw) 40%, transparent); } }
@keyframes pwFired { 0% { transform: scale(1.15); filter: brightness(2); } 100% { transform: none; filter: none; } }

.card-power { grid-column: 1 / -1; font-size: 10px; font-weight: 900; letter-spacing: 0.6px; color: var(--pwc, var(--emerald)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.pv-power { margin-top: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,0.06); border: 2px solid var(--pwc, var(--emerald)); text-align: left; }
.pv-power .pp-name { font-family: var(--display); font-size: 18px; color: var(--pwc, var(--emerald)); letter-spacing: 0.5px; }
.pv-power .pp-name em { font-style: normal; margin-right: 6px; }
.pv-power .pp-desc { font-size: 12px; font-weight: 700; opacity: 0.88; margin-top: 2px; }
@media (max-width: 900px) { .card-power { font-size: 9px; } .hud-power .pw-body { min-width: 84px; } }

.sound-ctl { position: fixed; right: 14px; bottom: 14px; z-index: 50; display: flex; gap: 8px; }
.sound-ctl button { width: 40px; height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,.35); background: rgba(14,20,34,.72); color: #fff; font-size: 18px; cursor: pointer; display: grid; place-items: center; }
.sound-ctl button:hover { border-color: #2fd6a0; }
.sound-ctl button.off { opacity: .45; text-decoration: line-through; }
/* select screen: the RACE! button sits in the bottom-right corner, so the buttons move up beside ESC · BACK */
body[data-state="select"] .sound-ctl { top: 26px; bottom: auto; right: 168px; }
@media (max-width: 900px) { body[data-state="select"] .sound-ctl { top: auto; bottom: 14px; right: 14px; } }
@media (max-width: 700px) {
  .title-foot { bottom: 66px; flex-wrap: wrap; gap: 4px 8px; padding: 0 12px; font-size: 12px; }
  .title-foot span:first-child { flex-basis: 100%; margin-right: 0; text-align: center; }
}
body[data-state="intro"] .sound-ctl, body[data-state="countdown"] .sound-ctl,
body[data-state="racing"] .sound-ctl, body[data-state="finished"] .sound-ctl { display: none; }
body[data-state="finished"][data-results] .sound-ctl { display: flex; }

/* touch-only hints (shown by touch.js styles when ?touch=1) */
.kb-hint { display: contents; }
.tc-hint, .touch-help { display: none; }
