:root {
  --navy: #08122d;
  --navy-2: #101f46;
  --red: #ec3b32;
  --red-dark: #a51b17;
  --yellow: #ffd33d;
  --yellow-deep: #f0a400;
  --blue: #2f65dd;
  --ink: #11172b;
  --cream: #fff9e8;
  --glass: rgba(10, 18, 41, 0.72);
  --glass-light: rgba(255, 255, 255, 0.08);
  --display: "Arial Black", "Avenir Next Condensed", Impact, "Haettenschweiler", sans-serif;
  --body: "Avenir Next", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #071025;
  color: var(--cream);
  font-family: var(--body);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior: none; }

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  outline: none;
}
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 4px; }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 3px solid #aeb6c7;
  color: #1a2140;
  font-family: var(--body);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24);
}

.hidden { display: none !important; }

#app {
  position: fixed;
  inset: 0;
  isolation: isolate;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.screen-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0) 40%, rgba(3, 8, 22, 0.24) 100%),
    linear-gradient(180deg, rgba(6, 12, 28, 0.35) 0%, rgba(6, 12, 28, 0) 18%, rgba(6, 12, 28, 0) 70%, rgba(6, 12, 28, 0.5) 100%);
}

/* ==========================================================================
   Loader
   ========================================================================== */
#loader {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background:
    radial-gradient(circle at 50% 40%, #19346d 0%, #0a132f 52%, #050a18 100%);
  transition: opacity 0.6s ease, visibility 0.6s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-logo {
  font-family: var(--display);
  font-size: clamp(44px, 8vw, 96px);
  font-style: italic;
  color: var(--red);
  letter-spacing: -0.04em;
  -webkit-text-stroke: 3px #fff;
  text-shadow: 0 7px 0 #78100c, 0 14px 25px rgba(0, 0, 0, 0.5);
}
.loader-logo span { color: var(--yellow); }
.loader-track {
  width: min(330px, 66vw);
  height: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.loader-track i {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--yellow), #ff7a36, var(--red));
  animation: loaderMove 1.1s ease-in-out infinite;
}
.loader-text {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.55);
}
@keyframes loaderMove {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

/* ==========================================================================
   System buttons
   ========================================================================== */
#system-buttons {
  position: absolute;
  z-index: 110;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(8, 17, 40, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, background 0.16s ease;
}
.icon-button:hover { transform: translateY(-2px); background: rgba(30, 54, 105, 0.82); }
.icon-button.muted { opacity: 0.55; }
#pause-button { display: none; }
body[data-screen="race"] #pause-button,
body[data-screen="paused"] #pause-button { display: grid; }

/* ==========================================================================
   Title
   ========================================================================== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  animation: screenIn 0.5s ease both;
}
@keyframes screenIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#title-screen {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(22px, 4vw, 52px) clamp(22px, 5vw, 80px) clamp(18px, 3vw, 38px);
  background:
    radial-gradient(ellipse at 50% 58%, rgba(10, 17, 40, 0.06) 0%, rgba(7, 12, 29, 0.4) 68%, rgba(5, 9, 21, 0.72) 100%),
    linear-gradient(180deg, rgba(5, 9, 22, 0.66) 0%, rgba(5, 9, 22, 0.02) 30%, rgba(5, 9, 22, 0.06) 67%, rgba(4, 8, 18, 0.92) 100%);
}

.title-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.76);
  text-transform: uppercase;
}
.brand-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  background: rgba(6, 14, 34, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  backdrop-filter: blur(9px);
}
.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 12px var(--yellow);
}
.title-top-right { opacity: 0.62; }

.title-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: -2vh;
  text-align: center;
}

.logo-lockup {
  position: relative;
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.5));
  animation: logoFloat 4.4s ease-in-out infinite;
}
@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50% { transform: translateY(-9px) rotate(0.4deg); }
}
.logo-kicker {
  font-family: var(--display);
  font-size: clamp(12px, 1.6vw, 23px);
  letter-spacing: 0.65em;
  color: #fff5c9;
  text-shadow: 0 3px 0 #153065;
  transform: translateX(0.32em);
  margin-bottom: -0.1em;
}
.logo-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.08em;
  font-family: var(--display);
  font-size: clamp(66px, 12.2vw, 182px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.88;
  letter-spacing: -0.055em;
  transform: skew(-4deg);
}
.logo-mario {
  color: #f3392f;
  -webkit-text-stroke: clamp(2px, 0.34vw, 6px) #fffdf3;
  paint-order: stroke fill;
  text-shadow:
    0 0.032em 0 #b91f18,
    0 0.062em 0 #7b100c,
    0 0.1em 0 #101b46,
    0 0.145em 0.16em rgba(0, 0, 0, 0.45);
}
.logo-kart {
  color: var(--yellow);
  -webkit-text-stroke: clamp(2px, 0.34vw, 6px) #fffdf3;
  paint-order: stroke fill;
  text-shadow:
    0 0.032em 0 #e28e00,
    0 0.062em 0 #b55b00,
    0 0.1em 0 #101b46,
    0 0.145em 0.16em rgba(0, 0, 0, 0.45);
}
.logo-ribbon {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  margin-top: 9px;
}
.logo-ribbon span {
  height: 2px;
  width: clamp(38px, 8vw, 110px);
  background: linear-gradient(90deg, transparent, var(--yellow));
}
.logo-ribbon span:last-child { background: linear-gradient(90deg, var(--yellow), transparent); }
.logo-ribbon b {
  font-family: var(--display);
  font-size: clamp(10px, 1.35vw, 17px);
  letter-spacing: 0.35em;
  padding: 6px 17px 5px;
  color: #10204a;
  background: linear-gradient(180deg, #ffe45f, #f3b51e);
  border-radius: 4px;
  border-bottom: 3px solid #9b5d00;
  transform: skew(-4deg);
}
.title-tagline {
  margin: clamp(14px, 2vw, 26px) 0 clamp(22px, 3.2vw, 38px);
  font-family: var(--display);
  font-size: clamp(9px, 1.1vw, 13px);
  letter-spacing: 0.28em;
  color: rgba(255, 255, 255, 0.76);
  text-shadow: 0 2px 9px rgba(0, 0, 0, 0.6);
}
.title-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.big-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  min-width: 250px;
  padding: 17px 30px;
  font-family: var(--display);
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fffdf2;
  text-transform: uppercase;
  border-radius: 12px;
  border: 3px solid #fff8d7;
  background: linear-gradient(180deg, #ff6556 0%, #ed372e 45%, #bf1d18 100%);
  box-shadow:
    0 7px 0 #7b100d,
    0 13px 24px rgba(0, 0, 0, 0.38),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 2px 0 #8c1511;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
  overflow: hidden;
}
.big-button:hover {
  transform: translateY(-3px);
  filter: brightness(1.06);
  box-shadow:
    0 10px 0 #7b100d,
    0 18px 28px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}
.big-button:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #7b100d, 0 6px 12px rgba(0, 0, 0, 0.3);
}
.big-button em {
  font-style: normal;
  font-size: 1.2em;
  transform: translateY(-1px);
}
.btn-shine {
  position: absolute;
  top: -60%;
  left: -45%;
  width: 38%;
  height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  transform: rotate(17deg);
  animation: shineSweep 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes shineSweep {
  0%, 58% { left: -55%; }
  78%, 100% { left: 125%; }
}
.ghost-button {
  padding: 14px 24px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 255, 255, 0.34);
  background: rgba(7, 15, 36, 0.5);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  transition: background 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.62);
  transform: translateY(-2px);
}

.control-strip {
  display: flex;
  gap: clamp(13px, 2.4vw, 30px);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: clamp(26px, 4vw, 46px);
  padding: 10px 17px;
  border-radius: 12px;
  background: rgba(5, 12, 30, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}
.control-strip > div { display: flex; align-items: center; gap: 5px; }
.control-strip span {
  margin-left: 4px;
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.58);
  font-weight: 700;
}
.title-bottom {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.19em;
  color: rgba(255, 255, 255, 0.48);
}
.title-bottom i { width: 4px; height: 4px; border-radius: 50%; background: var(--yellow); opacity: 0.65; }
.title-tip { margin-left: auto; color: rgba(255, 255, 255, 0.63); }

/* ==========================================================================
   Character select
   ========================================================================== */
#select-screen {
  padding: clamp(12px, 2.4vw, 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(13, 29, 67, 0.38), rgba(4, 9, 23, 0.9) 80%),
    linear-gradient(180deg, rgba(4, 9, 22, 0.7), rgba(4, 9, 22, 0.92));
  backdrop-filter: blur(6px);
}
.select-shell {
  width: min(1180px, 100%);
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  padding: clamp(16px, 2.2vw, 28px);
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(24, 42, 88, 0.93), rgba(8, 16, 38, 0.96) 62%),
    radial-gradient(circle at 0 0, rgba(255, 211, 61, 0.14), transparent 40%);
  border: 1px solid rgba(255, 255, 255, 0.17);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.17);
  overflow: hidden;
}
.select-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}
.back-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
  font-size: 21px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.back-button:hover { background: rgba(255, 255, 255, 0.14); transform: translateX(-2px); }
.select-title { flex: 1; }
.eyebrow {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.27em;
  color: var(--yellow);
  text-transform: uppercase;
}
.select-title h1 {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(22px, 2.8vw, 35px);
  line-height: 1;
  letter-spacing: -0.02em;
  transform: skew(-3deg);
  text-shadow: 0 3px 0 #101a38;
}
.select-best {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 14px;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.select-best span {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.42);
}
.select-best b { font-family: var(--display); font-size: 15px; color: var(--yellow); }

.character-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 14px);
  padding: clamp(13px, 1.7vw, 21px) 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.character-grid::-webkit-scrollbar { width: 6px; }
.character-grid::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 9px; }

.char-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 15px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.13);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.095), rgba(255, 255, 255, 0.025));
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  text-align: left;
}
.char-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.34);
}
.char-card.selected {
  border-color: var(--yellow);
  transform: translateY(-5px) scale(1.012);
  box-shadow: 0 0 0 3px rgba(255, 211, 61, 0.18), 0 16px 34px rgba(0, 0, 0, 0.42), 0 0 30px rgba(255, 211, 61, 0.24);
}
.char-card.selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--yellow);
  color: #172249;
  font-family: var(--display);
  font-size: 15px;
  box-shadow: 0 3px 0 #b47d00;
  z-index: 3;
}
.char-portrait {
  position: relative;
  width: 100%;
  aspect-ratio: 1.35 / 1;
  overflow: hidden;
  background: #1a2b58;
}
.char-portrait canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
.char-portrait::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 44%;
  background: linear-gradient(180deg, transparent, rgba(7, 13, 30, 0.9));
}
.char-meta {
  position: relative;
  padding: 8px 11px 10px;
  margin-top: -27px;
  z-index: 2;
}
.char-name-row { display: flex; align-items: baseline; gap: 6px; }
.char-name {
  font-family: var(--display);
  font-size: clamp(13px, 1.3vw, 17px);
  font-style: italic;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-title {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.48);
  text-transform: uppercase;
  white-space: nowrap;
}
.char-stats { display: flex; flex-direction: column; gap: 4px; margin-top: 7px; }
.char-stat { display: flex; align-items: center; gap: 6px; }
.char-stat span {
  width: 31px;
  font-family: var(--display);
  font-size: 7px;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.46);
}
.stat-pips { display: flex; gap: 3px; flex: 1; }
.stat-pips i {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.13);
}
.stat-pips i.on { background: linear-gradient(90deg, var(--yellow), #ff9b2f); box-shadow: 0 0 6px rgba(255, 211, 61, 0.4); }

.select-footer {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2vw, 26px);
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}
.driver-quote {
  flex: 1;
  min-width: 130px;
  position: relative;
  padding-left: 24px;
}
.quote-mark {
  position: absolute;
  left: 0;
  top: -10px;
  font-family: Georgia, serif;
  font-size: 38px;
  color: var(--yellow);
  opacity: 0.7;
  line-height: 1;
}
.driver-quote p {
  margin: 0 0 3px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  font-style: italic;
}
.driver-quote > span {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.38);
  text-transform: uppercase;
}
.engine-class { display: flex; flex-direction: column; gap: 6px; }
.engine-label {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.21em;
  color: rgba(255, 255, 255, 0.44);
}
.cc-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.cc-tabs button {
  display: flex;
  align-items: baseline;
  gap: 1px;
  padding: 7px 10px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.5);
  transition: background 0.15s ease, color 0.15s ease;
}
.cc-tabs button b { font-family: var(--display); font-size: 15px; }
.cc-tabs button small { font-size: 7px; font-weight: 800; letter-spacing: 0.04em; }
.cc-tabs button:hover { color: #fff; }
.cc-tabs button.active {
  background: linear-gradient(180deg, #ffe069, #f0b31f);
  color: #1b2550;
  box-shadow: 0 3px 0 #a06c00;
}
.race-button { min-width: 225px; }

/* ==========================================================================
   HUD
   ========================================================================== */
#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  font-family: var(--body);
}
.hud-left {
  position: absolute;
  top: clamp(14px, 2.2vw, 26px);
  left: clamp(14px, 2.2vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.position-box {
  min-width: 158px;
  padding: 6px 14px 8px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16, 27, 58, 0.88), rgba(7, 14, 34, 0.68));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}
.hud-caption {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.28em;
  color: rgba(255, 255, 255, 0.47);
}
.position-line {
  display: flex;
  align-items: baseline;
  gap: 3px;
  line-height: 0.94;
  color: #fff;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(54px, 6.7vw, 82px);
  letter-spacing: -0.05em;
  -webkit-text-stroke: 2px rgba(8, 13, 29, 0.75);
  text-shadow:
    0 4px 0 #18234a,
    0 8px 17px rgba(0, 0, 0, 0.36),
    0 0 24px rgba(255, 211, 61, 0.18);
}
#position-suffix {
  font-size: 0.42em;
  color: var(--yellow);
  letter-spacing: 0;
  text-shadow: 0 2px 0 #8a5a00;
}
.chip-row { display: flex; gap: 6px; }
.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 10px;
  border-radius: 9px;
  background: rgba(8, 16, 37, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(7px);
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.43);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.stat-chip b {
  font-size: 12px;
  letter-spacing: 0.03em;
  color: #fff;
  white-space: nowrap;
}
.stat-chip b small { opacity: 0.45; font-size: 0.8em; }
.chip-icon { width: 12px; height: 12px; display: inline-block; opacity: 0.67; }
.lap-icon { border: 2px solid #fff; border-radius: 50%; border-left-color: transparent; transform: rotate(-35deg); }
.clock-icon { border: 2px solid #fff; border-radius: 50%; position: relative; }
.clock-icon::after {
  content: ""; position: absolute; left: 4px; top: 1px; width: 1.5px; height: 4px;
  background: #fff; transform-origin: bottom center; transform: rotate(25deg);
}

.hud-right {
  position: absolute;
  top: clamp(14px, 2.2vw, 26px);
  right: clamp(14px, 2.2vw, 28px);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.item-column { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#item-slot {
  position: relative;
  width: clamp(88px, 9.5vw, 118px);
  height: clamp(88px, 9.5vw, 118px);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.13), transparent 52%),
    linear-gradient(155deg, rgba(28, 44, 88, 0.9), rgba(7, 14, 34, 0.88));
  border: 2.5px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.19);
  backdrop-filter: blur(10px);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}
#item-slot:not(.empty) {
  border-color: var(--yellow);
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 224, 90, 0.25), transparent 57%),
    linear-gradient(155deg, rgba(57, 50, 71, 0.94), rgba(16, 21, 45, 0.9));
  box-shadow: 0 0 0 3px rgba(255, 211, 61, 0.12), 0 12px 30px rgba(0, 0, 0, 0.32), 0 0 28px rgba(255, 211, 61, 0.26);
}
#item-slot.rolling { animation: itemRoulette 0.16s linear infinite; }
@keyframes itemRoulette {
  0% { transform: rotate(-1.8deg) scale(0.98); }
  50% { transform: rotate(1.8deg) scale(1.03); }
  100% { transform: rotate(-1.8deg) scale(0.98); }
}
#item-icon {
  font-size: clamp(31px, 3.6vw, 46px);
  line-height: 1.05;
  filter: drop-shadow(0 4px 7px rgba(0, 0, 0, 0.4));
  z-index: 1;
}
#item-slot.empty #item-icon { opacity: 0.27; font-family: var(--display); color: #fff; font-size: 42px; }
#item-name {
  font-family: var(--display);
  font-size: 7px;
  letter-spacing: 0.13em;
  color: rgba(255, 255, 255, 0.48);
  text-transform: uppercase;
  z-index: 1;
}
#item-slot:not(.empty) #item-name { color: var(--yellow); }
.item-glow {
  position: absolute;
  inset: 8%;
  border-radius: 18px;
  background: conic-gradient(from 0deg, transparent, rgba(255, 211, 61, 0.16), transparent 30%);
  opacity: 0;
  transition: opacity 0.2s ease;
}
#item-slot:not(.empty) .item-glow { opacity: 1; animation: rotateGlow 4s linear infinite; }
@keyframes rotateGlow { to { transform: rotate(360deg); } }
.item-key {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f5f1e4;
  border-bottom: 3px solid #9ea5b6;
  color: #1a2341;
  font-family: var(--display);
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.coin-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px 4px 6px;
  border-radius: 999px;
  background: rgba(8, 16, 37, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-family: var(--display);
  font-size: 13px;
  backdrop-filter: blur(7px);
}
.coin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #fff4ae, #ffc928 42%, #c17b00 100%);
  border: 2px solid #fff2a0;
  box-shadow: 0 0 8px rgba(255, 200, 40, 0.45);
}
.coin-max { font-size: 9px; color: rgba(255, 255, 255, 0.38); }
#coins { color: var(--yellow); }

.minimap-wrap {
  position: relative;
  width: clamp(148px, 15vw, 196px);
  height: clamp(148px, 15vw, 196px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(23, 43, 86, 0.8), rgba(5, 11, 27, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.21);
  box-shadow: 0 13px 34px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(9px);
  overflow: hidden;
}
#minimap { width: 100%; height: 100%; display: block; }
.minimap-tag {
  position: absolute;
  left: 50%;
  bottom: 9px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--display);
  font-size: 6px;
  letter-spacing: 0.17em;
  color: rgba(255, 255, 255, 0.43);
}

#speedo {
  position: absolute;
  right: clamp(18px, 3vw, 38px);
  bottom: clamp(17px, 2.5vw, 31px);
  text-align: right;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.38));
}
.speed-number { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
#speed {
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(45px, 6vw, 74px);
  line-height: 0.86;
  letter-spacing: -0.04em;
  color: #fff;
  -webkit-text-stroke: 1.5px #1a2348;
  text-shadow: 0 4px 0 #1b2852, 0 7px 18px rgba(0, 0, 0, 0.4);
}
.speed-number small {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.56);
}
.speed-bar {
  margin-top: 7px;
  width: clamp(150px, 17vw, 210px);
  height: 7px;
  border-radius: 99px;
  background: rgba(7, 13, 31, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.17);
  overflow: hidden;
}
.speed-bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #5ddcff, #ffe348 62%, #ff5044);
  box-shadow: 0 0 12px rgba(255, 211, 61, 0.55);
  transition: width 0.1s linear;
}

#drift-charge {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 3vw, 34px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(7, 14, 33, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.17);
  backdrop-filter: blur(7px);
}
#drift-charge > span {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.58);
}
.drift-bars { display: flex; gap: 4px; }
.drift-bars i {
  width: 25px;
  height: 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
#drift-charge.tier1 .drift-bars i:nth-child(1) { background: #5ad8ff; box-shadow: 0 0 9px #5ad8ff; }
#drift-charge.tier2 .drift-bars i:nth-child(-n+2) { background: #ffa62e; box-shadow: 0 0 9px #ffa62e; }
#drift-charge.tier3 .drift-bars i { background: #c76bff; box-shadow: 0 0 11px #c76bff; }

#wrong-way {
  position: absolute;
  top: 19%;
  left: 50%;
  transform: translateX(-50%);
  padding: 11px 25px;
  border-radius: 9px;
  background: rgba(180, 22, 20, 0.87);
  border: 2px solid #ffb4a8;
  font-family: var(--display);
  font-size: clamp(18px, 2.4vw, 28px);
  font-style: italic;
  letter-spacing: 0.06em;
  text-shadow: 0 3px 0 #620907;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  animation: wrongPulse 0.8s ease-in-out infinite;
  z-index: 4;
}
@keyframes wrongPulse {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.045); opacity: 0.8; }
}

#announce {
  position: absolute;
  top: 17%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(28px, 4.2vw, 52px);
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 2px #11204a;
  text-shadow: 0 5px 0 #11204a, 0 10px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
#announce.show { animation: announcePop 1.7s cubic-bezier(0.15, 0.9, 0.22, 1) both; }
#announce.gold { color: var(--yellow); }
#announce.red { color: #ff6f5c; }
#announce.blue { color: #85e7ff; }
@keyframes announcePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55) skew(-7deg); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) skew(-7deg); }
  24% { transform: translate(-50%, -50%) scale(1) skew(-7deg); }
  76% { opacity: 1; transform: translate(-50%, -50%) scale(1) skew(-7deg); }
  100% { opacity: 0; transform: translate(-50%, -68%) scale(0.94) skew(-7deg); }
}

#mini-turbo {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%) scale(0.6);
  font-family: var(--display);
  font-size: 16px;
  font-style: italic;
  letter-spacing: 0.04em;
  color: #9feaff;
  text-shadow: 0 0 18px #4ddcff, 0 3px 0 #12325a;
  opacity: 0;
  pointer-events: none;
}
#mini-turbo.show { animation: miniTurboPop 1s ease-out both; }
#mini-turbo.tier2 { color: #ffcc62; text-shadow: 0 0 18px #ff9b28, 0 3px 0 #573000; }
#mini-turbo.tier3 { color: #e0a2ff; text-shadow: 0 0 22px #b954ff, 0 3px 0 #39125a; }
@keyframes miniTurboPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(18px) scale(0.65); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.12); }
  65% { opacity: 1; transform: translateX(-50%) translateY(-3px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-24px) scale(0.98); }
}

#countdown {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(110px, 19vw, 230px);
  line-height: 0.8;
  color: var(--yellow);
  -webkit-text-stroke: clamp(3px, 0.5vw, 7px) #fff8da;
  text-shadow:
    0 9px 0 #a54900,
    0 18px 0 #101d44,
    0 28px 48px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  z-index: 8;
}
#countdown.tick { animation: countdownPop 0.9s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
#countdown.go { color: #fff; -webkit-text-stroke: 5px #2b6bd8; text-shadow: 0 9px 0 #0a3da1, 0 18px 0 #071b48, 0 28px 45px rgba(0, 0, 0, 0.4); }
@keyframes countdownPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(2.1); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(0.92); }
  24% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.78); }
}
#item-toast {
  position: absolute;
  left: 50%;
  top: 64%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 2px 0 #17214a, 0 0 14px rgba(255, 211, 61, 0.7);
  opacity: 0;
}
#item-toast.show { animation: itemToast 1.2s ease both; }
@keyframes itemToast {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  20% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
}

#damage-flash, #lightning-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 14;
  opacity: 0;
}
#damage-flash {
  background: radial-gradient(ellipse at center, transparent 30%, rgba(220, 35, 28, 0.55) 100%);
  mix-blend-mode: screen;
}
#damage-flash.hit { animation: damageFlash 0.5s ease-out; }
@keyframes damageFlash {
  0% { opacity: 0; }
  12% { opacity: 1; }
  100% { opacity: 0; }
}
#lightning-flash {
  background: linear-gradient(180deg, rgba(215, 242, 255, 0.97), rgba(92, 163, 255, 0.7));
  mix-blend-mode: screen;
}
#lightning-flash.flash { animation: lightningFlash 0.65s ease-out; }
@keyframes lightningFlash {
  0% { opacity: 0; }
  5% { opacity: 1; }
  16% { opacity: 0.2; }
  25% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 8, 20, 0.7);
  backdrop-filter: blur(10px);
  animation: screenIn 0.25s ease both;
}
.modal-card {
  position: relative;
  width: min(780px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: clamp(22px, 3.2vw, 40px);
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0, rgba(74, 112, 205, 0.25), transparent 42%),
    linear-gradient(155deg, #1b2f5e, #0a1432 70%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.55);
}
.modal-card h2 {
  margin: 0 0 19px;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(28px, 4vw, 45px);
  letter-spacing: -0.02em;
  text-shadow: 0 4px 0 #091127;
}
.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  font-size: 15px;
  transition: background 0.15s ease;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.16); }
.how-grid {
  display: grid;
  grid-template-columns: 1.08fr 1fr 1fr;
  gap: 22px;
  margin-bottom: 26px;
}
.how-block h3 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--yellow);
}
.how-row { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; }
.how-row span {
  margin-left: 7px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.67);
}
.how-block p {
  margin: 0 0 10px;
  font-size: 11px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.61);
}
.how-block p b { color: #fff; }
.item-legend {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  font-size: 10px;
}
.item-legend span { font-size: 17px; }
.item-legend b { color: rgba(255, 255, 255, 0.85); }
.item-legend small { font-size: 8px; color: rgba(255, 255, 255, 0.4); }
.modal-ok { display: flex; min-width: 210px; padding: 14px 20px; font-size: 14px; margin: 0 auto; }

.pause-card { width: min(430px, 94vw); text-align: center; }
.pause-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.pause-actions .big-button { min-width: 260px; }
.pause-actions .ghost-button { min-width: 180px; }
.pause-hint {
  margin: 22px 0 0;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.42);
}

/* ==========================================================================
   Results
   ========================================================================== */
#results-screen {
  padding: clamp(12px, 2.4vw, 28px);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(38, 72, 145, 0.5), rgba(4, 9, 22, 0.92) 68%),
    linear-gradient(180deg, rgba(3, 8, 20, 0.78), rgba(3, 8, 20, 0.95));
  backdrop-filter: blur(6px);
  overflow-y: auto;
}
.results-shell {
  width: min(980px, 100%);
  max-height: 95vh;
  overflow-y: auto;
  padding: clamp(18px, 3vw, 32px);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(22, 39, 80, 0.95), rgba(7, 14, 34, 0.97) 66%);
  border: 1px solid rgba(255, 255, 255, 0.17);
  box-shadow: 0 36px 90px rgba(0, 0, 0, 0.55);
}
.results-head { text-align: center; position: relative; padding-bottom: 15px; }
.results-head h1 {
  margin: 0;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(26px, 4.4vw, 50px);
  letter-spacing: -0.03em;
  text-shadow: 0 5px 0 #0a1330, 0 9px 25px rgba(0, 0, 0, 0.4);
}
.results-place {
  position: absolute;
  right: 4%;
  top: 0;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(56px, 8vw, 94px);
  color: var(--yellow);
  line-height: 0.85;
  -webkit-text-stroke: 2px #fff7d0;
  text-shadow: 0 5px 0 #9c6100, 0 10px 0 #10204a;
  transform: rotate(-4deg);
}
.results-place small { font-size: 0.32em; color: #fff; -webkit-text-stroke: 0; text-shadow: 0 3px 0 #10204a; }
#results-subtitle {
  margin: 8px 0 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.57);
  font-style: italic;
  letter-spacing: 0.03em;
}
.results-body {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  margin: 10px 0 17px;
}
.standings {
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(0, 0, 0, 0.16);
}
.standings-head {
  display: grid;
  grid-template-columns: 30px 34px 1fr auto;
  gap: 8px;
  padding: 6px 11px;
  background: rgba(255, 255, 255, 0.045);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--display);
  font-size: 7px;
  letter-spacing: 0.13em;
  color: rgba(255, 255, 255, 0.35);
}
.standings-head span:last-child { text-align: right; }
.standing-row {
  display: grid;
  grid-template-columns: 30px 34px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 41px;
  padding: 5px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  font-size: 11px;
  animation: rowIn 0.4s ease both;
}
.standing-row:last-child { border-bottom: 0; }
.standing-row.player {
  background: linear-gradient(90deg, rgba(255, 211, 61, 0.17), rgba(255, 211, 61, 0.05));
  box-shadow: inset 3px 0 0 var(--yellow);
}
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}
.standing-pos {
  font-family: var(--display);
  font-style: italic;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.48);
}
.standing-row:nth-child(1) .standing-pos { color: #ffd33d; }
.standing-row:nth-child(2) .standing-pos { color: #d5dded; }
.standing-row:nth-child(3) .standing-pos { color: #d59255; }
.standing-avatar {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 10px;
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.standing-name { font-weight: 800; letter-spacing: 0.02em; color: rgba(255, 255, 255, 0.87); }
.standing-name small {
  margin-left: 5px;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--yellow);
}
.standing-time { font-family: var(--display); font-size: 10px; color: rgba(255, 255, 255, 0.48); }
.results-stats { display: flex; flex-direction: column; gap: 6px; }
.result-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 12px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.075);
}
.result-stat span {
  font-family: var(--display);
  font-size: 7px;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.42);
}
.result-stat b { font-family: var(--display); font-size: 13px; color: #fff; }
.result-stat b small { font-size: 0.7em; opacity: 0.5; }
.trophy-card {
  flex: 1;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 212, 61, 0.22), transparent 60%),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 211, 61, 0.26);
}
.trophy-card.hidden-card { opacity: 0.38; filter: grayscale(1); }
.trophy { font-size: 33px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35)); }
.trophy-card strong { font-family: var(--display); font-size: 10px; letter-spacing: 0.12em; color: var(--yellow); }
.trophy-card span { font-size: 7px; letter-spacing: 0.16em; color: rgba(255, 255, 255, 0.36); }
.results-actions { display: flex; justify-content: center; gap: 13px; flex-wrap: wrap; }
.results-actions .big-button { min-width: 235px; padding: 14px 24px; font-size: 15px; }

/* ==========================================================================
   Mobile controls
   ========================================================================== */
#mobile-controls {
  position: absolute;
  inset: auto 0 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 17px calc(17px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.touch-cluster { display: flex; align-items: flex-end; gap: 9px; pointer-events: auto; }
.touch-button {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(10, 20, 43, 0.63);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-family: var(--display);
  font-size: 18px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  touch-action: none;
  transition: transform 0.08s ease, background 0.08s ease;
}
.touch-button.pressed {
  transform: scale(0.93);
  background: rgba(255, 211, 61, 0.35);
  border-color: var(--yellow);
}
.touch-button.gas {
  width: 82px;
  height: 82px;
  background: rgba(225, 55, 47, 0.7);
  border-color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  letter-spacing: 0.06em;
}
.touch-button.steer { font-size: 20px; }
.touch-button.small { width: 55px; height: 55px; font-size: 9px; letter-spacing: 0.06em; }
.touch-button.drift { background: rgba(46, 95, 197, 0.7); }
.touch-button.item { font-size: 8px; letter-spacing: 0.01em; padding: 0; overflow: hidden; background: rgba(163, 83, 198, 0.68); }
.touch-button.item.has-item { font-size: 24px; }
.touch-button[data-control="brake"] { font-size: 8px; }
.touch-right { display: grid; grid-template-columns: 55px 82px; grid-template-rows: 55px 55px 82px; gap: 8px; }
.touch-right .small[data-control="brake"] { grid-column: 2; grid-row: 1; }
.touch-right .small[data-control="drift"] { grid-column: 1; grid-row: 2; }
.touch-right .small[data-control="item"] { grid-column: 1; grid-row: 3; }
.touch-right .gas { grid-column: 2; grid-row: 2 / span 2; }

#rotate-hint {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 100;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(5, 12, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.58);
  pointer-events: none;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 980px) {
  .how-grid { grid-template-columns: 1fr 1fr; }
  .how-block:last-child { grid-column: span 2; }
  .character-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .char-title { display: none; }
  .driver-quote { display: none; }
  .select-footer { justify-content: space-between; }
}

@media (max-width: 760px), (pointer: coarse) {
  .title-top-right, .title-tip { display: none; }
  .title-bottom { justify-content: center; }
  .title-core { margin-top: -5vh; }
  .control-strip { display: none; }
  .title-actions { flex-direction: column; gap: 11px; }
  .big-button { min-width: 230px; padding: 15px 24px; }
  .title-tagline { letter-spacing: 0.14em; }
  .logo-main { font-size: clamp(38px, 11.2vw, 58px); }
  .brand-chip { font-size: 8px; letter-spacing: 0.15em; padding: 6px 10px; }
  #system-buttons { top: calc(9px + env(safe-area-inset-top)); right: 9px; left: auto; transform: none; }
  body[data-screen="select"] #system-buttons,
  body[data-screen="results"] #system-buttons { display: none; }
  .hud-left { top: calc(10px + env(safe-area-inset-top)); }
  .hud-right { top: calc(48px + env(safe-area-inset-top)); }
  .item-key { display: none; }

  .select-shell { max-height: 97vh; padding: 12px; border-radius: 17px; }
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 11px 2px; }
  .select-title h1 { font-size: 20px; }
  .select-best { display: none; }
  .select-footer { flex-wrap: wrap; gap: 10px; padding-top: 11px; }
  .engine-class { flex: 1; }
  .race-button { width: 100%; min-width: 0; }
  .char-portrait { aspect-ratio: 1.25 / 1; }

  .hud-left { top: calc(10px + env(safe-area-inset-top)); left: 10px; gap: 6px; }
  .position-box { min-width: 120px; padding: 4px 10px 6px; border-radius: 12px; }
  .hud-caption { font-size: 6px; }
  .position-line { font-size: 48px; }
  .stat-chip { height: 25px; padding: 0 7px; gap: 4px; font-size: 7px; }
  .stat-chip b { font-size: 10px; }
  .chip-icon { width: 10px; height: 10px; }
  .hud-right { top: calc(48px + env(safe-area-inset-top)); right: 10px; gap: 5px; }
  #item-slot { width: 76px; height: 76px; border-radius: 18px; border-width: 2px; }
  #item-icon { font-size: 29px; }
  #item-name { font-size: 5px; }
  .item-key { width: 22px; height: 22px; font-size: 10px; right: -5px; bottom: -5px; }
  .coin-pill { font-size: 11px; padding: 2px 8px 2px 4px; }
  .coin-dot { width: 15px; height: 15px; }
  .minimap-wrap { width: 112px; height: 112px; }
  .minimap-tag { display: none; }
  #speedo { right: 14px; bottom: 110px; }
  #speed { font-size: 44px; }
  .speed-bar { width: 125px; }
  #drift-charge { bottom: 108px; left: auto; right: 14px; transform: none; }
  #announce { top: 21%; font-size: 29px; }
  #countdown { font-size: 120px; }

  #mobile-controls:not(.hidden) { display: flex; }
  .icon-button { width: 32px; height: 32px; font-size: 14px; }

  .results-shell { padding: 15px; max-height: 97vh; }
  .results-body { grid-template-columns: 1fr; }
  .results-place { position: static; margin-top: 6px; transform: none; font-size: 52px; }
  .results-stats { display: grid; grid-template-columns: 1fr 1fr; }
  .trophy-card { grid-column: span 2; min-height: 84px; }
  .standing-row { min-height: 37px; font-size: 10px; grid-template-columns: 26px 30px 1fr auto; }
  .standing-avatar { width: 24px; height: 24px; font-size: 8px; }
  .results-actions .big-button { width: 100%; min-width: 0; }
  .results-actions { flex-direction: column; }
  .pause-card { padding: 25px 18px; }
  .how-grid { grid-template-columns: 1fr; }
  .how-block:last-child { grid-column: auto; }
  .modal-card { padding: 23px 18px; }
}

@media (max-height: 540px) and (orientation: landscape) {
  .title-core { margin-top: -8vh; }
  .logo-main { font-size: 52px; }
  .logo-kicker, .logo-ribbon { display: none; }
  .title-tagline { margin: 8px 0 12px; }
  .control-strip { display: none; }
  .title-actions { flex-direction: row; }
  .big-button { padding: 11px 20px; min-width: 200px; font-size: 13px; }
  .title-bottom { display: none; }
  #mobile-controls { padding-bottom: 9px; }
  .touch-button { width: 51px; height: 51px; }
  .touch-button.gas { width: 69px; height: 69px; }
  .touch-right { grid-template-columns: 48px 69px; grid-template-rows: 48px 48px 69px; }
  .touch-button.small { width: 48px; height: 48px; }
  .hud-right .minimap-wrap { display: none; }
  .hud-right { top: 46px; }
  #system-buttons { top: calc(7px + env(safe-area-inset-top)); right: 8px; left: auto; transform: none; }
  #speedo { right: auto; left: 50%; bottom: 12px; transform: translateX(-50%); text-align: center; }
  .speed-number { justify-content: center; }
  .speed-bar { margin-left: auto; margin-right: auto; }
  #drift-charge { display: none; }
  #announce { top: 18%; }
}

@media (hover: hover) and (pointer: fine) {
  #mobile-controls { display: none !important; }
}

@media (max-width: 390px) {
  .char-name { font-size: 12px; }
  .char-stats { display: none; }
  .char-meta { padding-bottom: 4px; margin-top: -18px; }
  .minimap-wrap { width: 96px; height: 96px; }
  #item-slot { width: 68px; height: 68px; }
  #speedo { bottom: 103px; }
}


.loader-error {
  max-width: 430px;
  padding: 0 24px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.65);
}
.loader-error b { display: block; margin-bottom: 5px; color: #ffd33d; font-family: var(--display); letter-spacing: 0.12em; }
