:root {
  color-scheme: dark;
  --ink: #f6fbff;
  --muted: #c1cfdd;
  --hot: #ff6540;
  --heat: #ffcf67;
  --cool: #56e9ff;
  --bg: #05090f;
  --panel: rgba(8, 14, 24, 0.86);
  --glass: rgba(255, 255, 255, 0.13);
  --stroke: rgba(146, 202, 255, 0.34);
  --glow: 0 0 28px rgba(86, 233, 255, 0.26);
  --progress-top: 24px;
  --progress-height: 10px;
  --stack-gap: 24px;
  --hud-top: calc(
    var(--progress-top) + var(--progress-height) + var(--stack-gap)
  );
  --minimap-top: calc(var(--hud-top) + 64px);
  --minimap-size: 194px;
  --touch-scale: 1;
  --touch-stick-size: 132px;
  --touch-knob-size: 56px;
  --touch-button-size: 1;
  --touch-button-padding-y: 12px;
  --touch-button-padding-x: 18px;
  --touch-button-font-size: 0.9rem;
  --touch-controls-left: 20px;
  --touch-controls-right: 20px;
  --touch-controls-bottom: 20px;
  --touch-stick-offset-x: 0px;
  --touch-stick-offset-y: 0px;
  --hud-scale: 1;
  --hud-pill-padding-y: 7px;
  --hud-pill-padding-x: 10px;
  --hud-font-size: 0.9rem;
  --hud-label-size: 0.7rem;
  --overlay-panel-scale: 1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Rajdhani", system-ui, sans-serif;
  background:
    radial-gradient(
      circle at 20% 18%,
      rgba(91, 156, 228, 0.3) 0%,
      rgba(11, 19, 32, 0) 34%
    ),
    radial-gradient(
      circle at 78% 12%,
      rgba(255, 140, 84, 0.18) 0%,
      rgba(5, 9, 15, 0) 28%
    ),
    radial-gradient(circle at 50% 100%, #162336 0%, #0b1320 46%, #05090f 100%);
  color: var(--ink);
  overflow: hidden;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.remote-name-layer {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
}

.remote-name-tag {
  position: absolute;
  left: 0;
  top: 0;
  max-width: min(170px, 32vw);
  padding: 4px 8px 5px;
  border: 1px solid rgba(126, 255, 255, 0.35);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(6, 13, 22, 0.82),
    rgba(5, 9, 15, 0.64)
  );
  box-shadow: 0 0 18px rgba(86, 233, 255, 0.18);
  color: #eaffff;
  font-size: clamp(0.68rem, 1.2vw, 0.82rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  will-change: transform, opacity;
}

.remote-name-tag .moderation-menu-btn {
  pointer-events: auto;
}

.remote-name-tag::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 7px;
  height: 7px;
  border-right: 1px solid rgba(126, 255, 255, 0.34);
  border-bottom: 1px solid rgba(126, 255, 255, 0.34);
  background: rgba(5, 9, 15, 0.7);
  transform: translateX(-50%) rotate(45deg);
}

.remote-name-tag.team-red {
  border-color: rgba(255, 127, 127, 0.42);
  box-shadow: 0 0 18px rgba(255, 108, 108, 0.18);
  color: #ffecec;
}

.remote-name-tag.team-neutral {
  border-color: rgba(255, 209, 122, 0.4);
  box-shadow: 0 0 18px rgba(255, 184, 91, 0.16);
  color: #fff3db;
}

.hud {
  position: absolute;
  left: 24px;
  right: 24px;
  top: var(--hud-top);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 8px;
  text-align: left;
  z-index: 5;
  font-size: 0.9rem;
  transform: scale(var(--hud-scale));
  transform-origin: top left;
}

.hud-cluster {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  min-width: 0;
}

.hud-cluster-run {
  justify-content: flex-start;
  max-width: min(62vw, 760px);
}

.hud-cluster-drive {
  justify-content: flex-end;
  max-width: min(54vw, 660px);
}

.hud .pill {
  padding: var(--hud-pill-padding-y) var(--hud-pill-padding-x);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(10, 17, 28, 0.92),
    rgba(7, 12, 20, 0.82)
  );
  backdrop-filter: blur(10px);
  box-shadow:
    0 0 16px rgba(86, 233, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.hud .status {
  display: inline-flex;
  gap: 8px;
  align-items: stretch;
  transform: none;
}

.hud .status .pill {
  display: grid;
  gap: 4px;
  min-width: 92px;
  padding: max(5px, calc(var(--hud-pill-padding-y) - 1px))
    var(--hud-pill-padding-x);
  border-radius: 999px;
}

body.playing .hud .pill {
  background: linear-gradient(
    180deg,
    rgba(10, 17, 28, 0.74),
    rgba(7, 12, 20, 0.6)
  );
  box-shadow:
    0 0 12px rgba(86, 233, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  border-color: rgba(126, 255, 255, 0.14);
  padding-block: max(4px, calc(var(--hud-pill-padding-y) - 2px));
}

body.playing .hud .label {
  opacity: 0.62;
}

body.playing .hud {
  opacity: 0.94;
}

.hud .menu-btn {
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  background: linear-gradient(
    120deg,
    rgba(32, 212, 255, 0.2),
    rgba(255, 122, 69, 0.25)
  );
}

.hud .label {
  color: var(--muted);
  font-size: var(--hud-label-size);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud strong {
  font-size: var(--hud-font-size);
}

.progress {
  position: absolute;
  left: 24px;
  right: 24px;
  top: var(--progress-top);
  height: var(--progress-height);
  border-radius: 999px;
  background: rgba(191, 217, 239, 0.22);
  overflow: hidden;
  z-index: 6;
}

.progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cool), var(--heat));
  box-shadow: 0 0 14px rgba(86, 233, 255, 0.9);
  transition: width 0.2s ease;
}

.debug-hud {
  position: absolute;
  left: 24px;
  bottom: 22px;
  z-index: 7;
  min-width: 220px;
  max-width: min(38vw, 360px);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(126, 255, 255, 0.22);
  background: rgba(7, 14, 24, 0.82);
  color: #e9f7ff;
  font-size: 0.74rem;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
  white-space: pre-line;
}

.effect-toast {
  position: absolute;
  left: 50%;
  top: calc(var(--hud-top) + 46px);
  z-index: 7;
  max-width: min(44vw, 420px);
  padding: 8px 14px;
  border: 1px solid rgba(255, 209, 122, 0.24);
  border-radius: 999px;
  background: rgba(7, 13, 22, 0.58);
  color: #fff2ca;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px) scale(0.98);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.effect-toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.daily-gift {
  position: absolute;
  right: 24px;
  top: calc(var(--hud-top) + 88px);
  z-index: 8;
  min-width: 178px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 224, 132, 0.5);
  border-radius: 18px;
  background:
    radial-gradient(
      circle at 20% 18%,
      rgba(255, 244, 183, 0.34),
      transparent 38%
    ),
    linear-gradient(135deg, rgba(26, 17, 8, 0.9), rgba(112, 37, 12, 0.82));
  color: #fff5cf;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.28),
    0 0 28px rgba(255, 153, 48, 0.24);
  transform: translateY(0) scale(1);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.daily-gift[hidden] {
  display: none;
}

.daily-gift::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.daily-gift:hover,
.daily-gift:focus-visible {
  border-color: rgba(255, 239, 160, 0.9);
  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.32),
    0 0 36px rgba(255, 181, 61, 0.38);
  transform: translateY(-2px) scale(1.01);
  outline: none;
}

.daily-gift-kicker {
  display: block;
  color: rgba(255, 235, 166, 0.82);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.daily-gift strong {
  display: block;
  margin-top: 2px;
  color: #ffffff;
  font-size: 1.15rem;
  line-height: 1.05;
}

.daily-gift span:last-child {
  display: block;
  margin-top: 3px;
  color: rgba(255, 241, 203, 0.82);
  font-size: 0.72rem;
}

.match-panel {
  position: absolute;
  right: 24px;
  top: calc(var(--hud-top) + 56px);
  width: min(22vw, 220px);
  z-index: 6;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(126, 178, 255, 0.18);
  background: rgba(8, 14, 24, 0.48);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18);
}

.match-panel.compact {
  width: min(18vw, 176px);
  padding: 7px 9px;
  background: rgba(8, 14, 24, 0.34);
}

.match-panel-header {
  display: grid;
  gap: 2px;
  margin-bottom: 6px;
}

.match-panel .eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.62rem;
}

.match-panel-body {
  display: grid;
  gap: 8px;
}

.match-panel-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.match-stat {
  padding: 7px 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(126, 178, 255, 0.1);
  display: grid;
  gap: 3px;
}

.match-stat strong {
  font-size: 1rem;
}

.match-stat span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.match-panel-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.match-panel.compact .match-panel-stats {
  display: none;
}

.match-panel.compact .eyebrow {
  display: none;
}

.match-panel.compact .match-panel-header {
  margin-bottom: 2px;
}

.match-panel.compact #match-panel-score {
  letter-spacing: 0.02em;
}

.battle-scope {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  pointer-events: none;
  background:
    radial-gradient(
      circle at center,
      transparent 0 26%,
      rgba(3, 8, 13, 0.2) 37%,
      rgba(2, 4, 8, 0.55) 100%
    ),
    linear-gradient(
      90deg,
      rgba(86, 233, 255, 0.08),
      transparent 18% 82%,
      rgba(255, 81, 77, 0.08)
    );
}

body.battle-cockpit .battle-scope {
  display: block;
}

.scope-ring,
.scope-line,
.scope-dot,
.scope-readout {
  position: absolute;
  left: 50%;
  top: 50%;
}

.scope-ring {
  width: min(34vw, 280px);
  aspect-ratio: 1;
  border: 2px solid rgba(113, 244, 255, 0.76);
  border-radius: 50%;
  box-shadow:
    0 0 18px rgba(86, 233, 255, 0.45),
    inset 0 0 22px rgba(86, 233, 255, 0.18);
  transform: translate(-50%, -50%);
}

.scope-line {
  background: rgba(119, 246, 255, 0.74);
  box-shadow: 0 0 12px rgba(86, 233, 255, 0.65);
  transform: translate(-50%, -50%);
}

.scope-line-x {
  width: min(42vw, 360px);
  height: 1px;
}

.scope-line-y {
  width: 1px;
  height: min(42vw, 360px);
}

.scope-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff8d8;
  box-shadow: 0 0 14px rgba(255, 244, 190, 0.9);
  transform: translate(-50%, -50%);
}

.scope-readout {
  transform: translate(-50%, -50%);
  color: #dffbff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-shadow: 0 0 10px rgba(86, 233, 255, 0.8);
}

.scope-readout-left {
  margin-left: min(-23vw, -170px);
  margin-top: min(17vw, 130px);
}

.scope-readout-right {
  margin-left: min(23vw, 170px);
  margin-top: min(17vw, 130px);
}

body.max-mode .hud {
  gap: 6px;
}

body.max-mode .hud .pill {
  padding: 5px 8px;
  background: linear-gradient(
    180deg,
    rgba(10, 17, 28, 0.78),
    rgba(7, 12, 20, 0.66)
  );
}

body.max-mode .hud .label {
  font-size: 0.58rem;
  letter-spacing: 0.12em;
}

body.max-mode .hud strong {
  font-size: 0.84rem;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(
    circle at 30% 20%,
    rgba(87, 172, 255, 0.2),
    rgba(6, 10, 17, 0.94)
  );
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

body:has(#message.show) .hud,
body:has(#message.show) .progress,
body:has(#message.show) .minimap-wrap,
body:has(#message.show) .match-panel,
body:has(#message.show) .remote-name-layer {
  opacity: 0.18;
}

body:has(#overlay.show) .hud,
body:has(#overlay.show) .progress,
body:has(#overlay.show) .status,
body:has(#overlay.show) .minimap-wrap,
body:has(#overlay.show) .match-panel,
body:has(#overlay.show) .resources,
body:has(#overlay.show) .debug-hud,
body:has(#overlay.show) .remote-name-layer {
  opacity: 0;
  pointer-events: none;
}

.overlay .panel {
  transform: scale(var(--overlay-panel-scale));
  transform-origin: center;
}

.panel {
  max-width: 560px;
  width: min(90vw, 560px);
  padding: 34px 32px 30px;
  border-radius: 30px;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(10, 16, 26, 0.96), rgba(7, 11, 18, 0.9)),
    radial-gradient(circle at top, rgba(91, 156, 228, 0.16), transparent 54%);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.72);
  text-align: center;
}

.overlay-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(126, 178, 255, 0.24);
  background: rgba(255, 255, 255, 0.04);
  color: var(--cool);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.lives-pill {
  gap: 10px;
}

.hearts {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.heart {
  font-size: 1.08rem;
  line-height: 1;
  color: #ff6f86;
  text-shadow: 0 0 8px rgba(255, 58, 94, 0.65);
  transform-origin: center;
}

.heart.off {
  color: rgba(196, 214, 232, 0.32);
  text-shadow: none;
}

.heart.lost {
  animation: heart-loss 420ms ease;
}

.heart.gained {
  animation: heart-gain 420ms ease;
}

.lives-count {
  min-width: 2.7rem;
}

@keyframes heart-loss {
  0% {
    transform: scale(1.2);
    opacity: 1;
  }
  70% {
    transform: scale(0.55);
    opacity: 0.35;
  }
  100% {
    transform: scale(1);
    opacity: 0.25;
  }
}

@keyframes heart-gain {
  0% {
    transform: scale(0.4);
    opacity: 0.4;
  }
  70% {
    transform: scale(1.3);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.menu-panel {
  max-width: 860px;
  width: min(94vw, 860px);
  text-align: left;
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.menu-header h2 {
  margin-bottom: 0;
}

.menu-header .overlay-kicker {
  margin: 0 0 8px;
}

.menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 4px;
  padding: 10px;
  border: 1px solid rgba(126, 178, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.menu-tabs {
  display: flex;
  gap: 10px;
  margin: 20px 0 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.menu-content {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 10px 18px 0;
  min-height: 0;
  scrollbar-width: thin;
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 16px,
    #000 calc(100% - 18px),
    transparent 100%
  );
}

.menu-content::-webkit-scrollbar {
  width: 10px;
}

.menu-content::-webkit-scrollbar-thumb {
  background: rgba(126, 178, 255, 0.28);
  border-radius: 999px;
}

.tab-btn {
  border-radius: 999px;
  padding: 8px 16px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.tab-btn.active {
  background: linear-gradient(120deg, var(--hot), var(--heat));
  color: #0d0f14;
  box-shadow: 0 10px 20px rgba(255, 77, 45, 0.3);
}

.tab-panel {
  display: none;
  gap: 14px;
}

.tab-panel.active {
  display: grid;
}

.mode-brief,
.garage-class-summary,
.controller-card {
  padding: 12px 14px;
  border: 1px solid rgba(126, 178, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  line-height: 1.38;
}

.mode-brief strong,
.garage-class-summary strong {
  display: block;
  color: var(--ink);
  margin-bottom: 3px;
}

.mode-brief span,
.garage-class-summary span {
  color: var(--muted);
}

.mode-brief em,
.game-card-copy em,
.game-card-copy small {
  color: var(--heat);
  font-style: normal;
  font-weight: 700;
  line-height: 1.25;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.field select,
.field input,
.field textarea,
.join-code-row input,
.chat-compose input {
  margin-top: 4px;
}

.field select,
.field input:not([type="checkbox"]),
.field textarea,
.join-code-row input,
.chat-compose input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(9, 12, 18, 0.8);
  color: var(--ink);
  font-family: "Rajdhani", sans-serif;
  font-weight: 600;
  min-width: 0;
}

.field textarea {
  resize: vertical;
  min-height: 128px;
}

.field input:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.field.toggle {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.hint {
  color: var(--muted);
  margin: 4px 0 0;
}

.compact-actions {
  justify-content: flex-start;
  gap: 8px;
}

.online-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.profile-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 14px;
}

.profile-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(126, 178, 255, 0.09), transparent 44%),
    rgba(255, 255, 255, 0.035);
}

.profile-hero-card {
  grid-row: span 2;
}

.profile-card h3 {
  margin: 0;
  font-size: 1.34rem;
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-badge {
  padding: 6px 9px;
  border-radius: 999px;
  color: #d9f6ff;
  background: rgba(126, 178, 255, 0.13);
  border: 1px solid rgba(126, 178, 255, 0.18);
  font-weight: 900;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.profile-stat-grid div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid rgba(126, 178, 255, 0.12);
  border-radius: 14px;
  background: rgba(7, 11, 18, 0.5);
}

.profile-stat-grid span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.danger {
  border-color: rgba(255, 101, 64, 0.38);
  color: #ffd9cf;
  background: rgba(255, 101, 64, 0.12);
}

.online-panel,
.feedback-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
}

.advanced-online-settings {
  border-top: 1px solid rgba(126, 178, 255, 0.12);
  padding-top: 8px;
}

.advanced-online-settings summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.feedback-panel {
  max-width: min(92vw, 620px);
  text-align: left;
}

#feedback-modal {
  z-index: 22;
  background: rgba(4, 8, 14, 0.92);
}

#feedback-modal .feedback-panel {
  background:
    linear-gradient(180deg, rgba(9, 15, 24, 0.99), rgba(6, 10, 17, 0.97)),
    radial-gradient(circle at top, rgba(91, 156, 228, 0.12), transparent 54%);
  box-shadow: 0 30px 76px rgba(0, 0, 0, 0.82);
}

.online-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.online-status,
.feedback-status,
.online-room-card,
.online-list,
.chat-log {
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 14px;
  background: rgba(7, 11, 18, 0.58);
  color: var(--muted);
  line-height: 1.35;
}

.online-status,
.feedback-status,
.online-room-card {
  padding: 10px 12px;
}

.online-status[data-state="connected"],
.feedback-status[data-state="saved"] {
  border-color: rgba(74, 255, 166, 0.32);
  color: #d7ffe9;
}

.online-status[data-state="error"],
.feedback-status[data-state="error"] {
  border-color: rgba(255, 101, 64, 0.45);
  color: #ffd9cf;
}

.join-code-row,
.chat-compose,
.online-chat-header,
.chat-popout-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.join-code-row input,
.chat-compose input {
  flex: 1;
}

.online-chat-panel {
  grid-row: span 2;
}

.quick-chat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-chat-list button {
  padding: 7px 11px;
  font-size: 0.72rem;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 154px;
  max-height: 230px;
  overflow: auto;
  padding: 10px;
}

.chat-message {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.chat-sender,
.leaderboard-name,
.online-player-name {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

.chat-sender strong,
.leaderboard-name strong,
.online-player-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-message strong {
  color: var(--ink);
  font-size: 0.78rem;
}

.chat-message span {
  overflow-wrap: anywhere;
}

.online-list {
  display: grid;
  gap: 6px;
  min-height: 44px;
  padding: 10px;
}

.online-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.mini-action {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.player-badge {
  display: inline-grid;
  place-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(126, 178, 255, 0.28);
  color: #d9f6ff;
  background: rgba(126, 178, 255, 0.11);
  font-size: 0.62rem;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.badge-founder {
  border-color: rgba(255, 196, 87, 0.48);
  color: #ffe6a8;
  background: rgba(255, 196, 87, 0.15);
}

.badge-mod {
  border-color: rgba(255, 101, 64, 0.5);
  color: #ffd9cf;
  background: rgba(255, 101, 64, 0.14);
}

.badge-rizzler {
  border-color: rgba(255, 126, 228, 0.42);
  color: #ffe2fb;
  background: rgba(255, 126, 228, 0.12);
}

.badge-advanced-player {
  border-color: rgba(74, 255, 166, 0.36);
  color: #d7ffe9;
  background: rgba(74, 255, 166, 0.1);
}

.moderation-menu-btn {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.account-start-card {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(126, 178, 255, 0.2);
  border-radius: 16px;
  background: rgba(9, 16, 24, 0.52);
}

.account-start-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(86px, 0.5fr);
  gap: 10px;
}

#start-account-status[data-state="error"] {
  color: #ffb4a9;
}

.leaderboard-shell {
  display: grid;
  gap: 14px;
}

.leaderboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 196, 87, 0.24);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 196, 87, 0.14), transparent 48%),
    rgba(9, 16, 24, 0.44);
}

.leaderboard-hero h3 {
  margin: 0;
  font-size: 1.18rem;
}

.leaderboard-crown {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 1px solid rgba(255, 196, 87, 0.44);
  color: #ffe0a3;
  font-weight: 900;
  background: rgba(255, 196, 87, 0.12);
  box-shadow: inset 0 0 18px rgba(255, 196, 87, 0.14);
}

.leaderboard-list {
  gap: 8px;
  padding: 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  background: rgba(255, 255, 255, 0.045);
}

.rank-badge,
.tier-badge {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 900;
}

.rank-badge {
  color: #0a1018;
  background: #ffe0a3;
}

.leaderboard-racer {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.leaderboard-racer strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-racer span {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.leaderboard-score {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.tier-badge {
  min-height: 24px;
  color: #d9f6ff;
  background: rgba(126, 178, 255, 0.13);
  font-size: 0.68rem;
}

.tier-inferno {
  border-color: rgba(255, 122, 77, 0.44);
  box-shadow: inset 0 0 18px rgba(255, 122, 77, 0.1);
}

.tier-diamond {
  border-color: rgba(86, 233, 255, 0.34);
}

.tier-gold {
  border-color: rgba(255, 196, 87, 0.36);
}

.mode-help-card {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 13;
  width: min(430px, calc(100vw - 28px));
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(126, 178, 255, 0.28);
  border-radius: 16px;
  background: rgba(7, 11, 18, 0.94);
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(14px);
}

.mode-help-card[hidden] {
  display: none;
}

.mode-help-card h3 {
  margin: 0;
}

.mode-help-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-help-lines {
  display: grid;
  gap: 8px;
}

.mode-help-lines div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.mode-help-lines strong {
  color: #ffe0a3;
  font-size: 0.75rem;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .account-start-grid {
    grid-template-columns: 1fr;
  }

  .profile-shell {
    grid-template-columns: 1fr;
  }

  .profile-hero-card {
    grid-row: auto;
  }

  .leaderboard-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .leaderboard-score {
    grid-column: 1 / -1;
    grid-template-columns: auto auto;
    justify-content: end;
  }

  .mode-help-card {
    right: 14px;
    bottom: 14px;
    max-height: calc(100vh - 28px);
    overflow: auto;
  }
}

.chat-popout {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 12;
  width: min(360px, calc(100vw - 28px));
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(126, 178, 255, 0.26);
  border-radius: 16px;
  background: rgba(7, 11, 18, 0.92);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
}

.chat-popout[hidden] {
  display: none;
}

.chat-notice {
  position: fixed;
  right: clamp(14px, 2vw, 24px);
  bottom: clamp(18px, 3vh, 34px);
  z-index: 24;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  width: min(360px, calc(100vw - 28px));
  padding: 10px 10px 10px 12px;
  border: 1px solid rgba(122, 239, 255, 0.34);
  border-radius: 8px;
  background: rgba(7, 14, 22, 0.88);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  color: #f5fbff;
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

.chat-notice[hidden] {
  display: none;
}

.chat-notice strong,
.chat-notice span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-notice strong {
  color: #7aefff;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-notice span {
  margin-top: 2px;
  color: rgba(245, 251, 255, 0.88);
  font-size: 0.82rem;
}

.chat-popout-header {
  justify-content: space-between;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.dev-tools {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 184, 96, 0.24);
  border-radius: 18px;
  background: rgba(255, 184, 96, 0.08);
  display: grid;
  gap: 12px;
}

.dev-mode-panels {
  display: grid;
  gap: 12px;
}

.dev-mode-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(9, 16, 24, 0.32);
  border: 1px solid rgba(126, 178, 255, 0.14);
}

.dev-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.dev-tools .field {
  margin: 0;
}

.dev-tools input[type="range"] {
  width: 100%;
}

.dev-tools-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.dev-max-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dev-max-summary .match-stat {
  min-height: 62px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mode-board {
  display: grid;
  gap: 16px;
}

.mode-group {
  display: grid;
  gap: 10px;
}

.mode-group-title {
  color: var(--cool);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.game-card {
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(126, 178, 255, 0.2);
  background: linear-gradient(
    180deg,
    rgba(14, 20, 30, 0.95),
    rgba(8, 12, 18, 0.86)
  );
  display: grid;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.mode-card {
  grid-template-columns: 94px minmax(0, 1fr);
  align-items: stretch;
}

.mode-card-art {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(
      circle at 50% 25%,
      rgba(255, 209, 122, 0.55),
      transparent 22%
    ),
    linear-gradient(145deg, rgba(255, 77, 45, 0.52), rgba(86, 233, 255, 0.14)),
    rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.05);
}

.mode-card-art[data-scene="track"] {
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 14px,
      rgba(255, 255, 255, 0.18) 14px 16px
    ),
    linear-gradient(145deg, rgba(86, 233, 255, 0.28), rgba(255, 184, 96, 0.18));
}

.mode-card-art[data-scene="stunt"] {
  background:
    linear-gradient(
      135deg,
      transparent 38%,
      rgba(255, 209, 122, 0.72) 39% 48%,
      transparent 49%
    ),
    radial-gradient(
      circle at 72% 26%,
      rgba(86, 233, 255, 0.52),
      transparent 28%
    ),
    rgba(255, 118, 62, 0.2);
}

.mode-card-art[data-scene="chase"],
.mode-card-art[data-scene="boss"] {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 58, 94, 0.7), transparent 22%),
    conic-gradient(
      from 0deg,
      rgba(255, 77, 45, 0.62),
      rgba(86, 233, 255, 0.18),
      rgba(255, 77, 45, 0.62)
    );
}

.mode-card-art[data-scene="battle"],
.mode-card-art[data-scene="max"] {
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(255, 255, 255, 0.74),
      transparent 15%
    ),
    linear-gradient(90deg, rgba(86, 233, 255, 0.38), rgba(255, 77, 45, 0.42));
}

.mode-card-art[data-scene="lava"] {
  background:
    radial-gradient(
      circle at 45% 68%,
      rgba(255, 209, 122, 0.72),
      transparent 22%
    ),
    linear-gradient(145deg, rgba(255, 66, 38, 0.62), rgba(9, 12, 18, 0.8));
}

.mode-card-art[data-scene="zone"],
.mode-card-art[data-scene="drift"] {
  background:
    radial-gradient(
      circle at 50% 50%,
      transparent 29%,
      rgba(126, 255, 255, 0.58) 30% 34%,
      transparent 35%
    ),
    linear-gradient(145deg, rgba(86, 233, 255, 0.3), rgba(255, 77, 45, 0.22));
}

.mode-card-art[data-scene="bowling"] {
  background:
    linear-gradient(
      90deg,
      transparent 0 18%,
      rgba(255, 209, 122, 0.42) 19% 21%,
      transparent 22% 78%,
      rgba(255, 209, 122, 0.42) 79% 81%,
      transparent 82%
    ),
    radial-gradient(
      circle at 50% 24%,
      rgba(255, 255, 255, 0.76),
      transparent 16%
    ),
    linear-gradient(145deg, rgba(255, 184, 96, 0.36), rgba(86, 233, 255, 0.2));
}

.mode-card-art[data-thumb="generated"] {
  background-image:
    linear-gradient(180deg, rgba(3, 5, 8, 0.03), rgba(3, 5, 8, 0.35)),
    url("assets/mode-thumbnails-sprite.png");
  background-size:
    100% 100%,
    500% 300%;
  background-position: center, var(--thumb-position, 50% 50%);
  background-repeat: no-repeat;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(126, 178, 255, 0.44);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

.game-card.active {
  border-color: rgba(255, 184, 96, 0.58);
  box-shadow:
    0 0 0 1px rgba(255, 184, 96, 0.24),
    0 18px 40px rgba(255, 118, 62, 0.18);
}

.game-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.game-card-copy {
  display: grid;
  gap: 4px;
}

.game-card-copy strong {
  font-size: 1.06rem;
}

.game-card-copy span {
  color: var(--muted);
  line-height: 1.35;
}

.custom-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.garage-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(220px, 0.95fr);
  gap: 18px;
  align-items: stretch;
}

.garage-preview-card,
.garage-controls {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(15, 21, 30, 0.96),
    rgba(9, 13, 20, 0.84)
  );
}

.garage-preview {
  position: relative;
  min-height: clamp(220px, 34vh, 340px);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(126, 255, 255, 0.18);
  background:
    radial-gradient(
      circle at 50% 72%,
      rgba(255, 118, 62, 0.24),
      transparent 28%
    ),
    linear-gradient(180deg, rgba(10, 18, 30, 0.98), rgba(3, 7, 12, 0.92));
  touch-action: none;
}

.garage-preview canvas {
  width: 100%;
  height: 100%;
}

.garage-preview-actions,
.loadout-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.loadout-slot {
  flex: 1 1 120px;
  min-width: 0;
  justify-content: center;
}

.loadout-slot.active {
  border-color: rgba(255, 209, 122, 0.72);
  background: linear-gradient(
    120deg,
    rgba(255, 118, 62, 0.22),
    rgba(86, 233, 255, 0.16)
  );
}

.custom-column {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(15, 21, 30, 0.96),
    rgba(9, 13, 20, 0.84)
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.custom-section-title {
  margin-bottom: 12px;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.custom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}

.field {
  min-width: 0;
}

.field span {
  min-width: 0;
}

.field select {
  width: 100%;
  min-width: 0;
}

.field-full {
  grid-column: 1 / -1;
}

.custom-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
  margin-top: 8px;
  padding: 14px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 16px;
  background: linear-gradient(
    180deg,
    rgba(14, 20, 30, 0.94),
    rgba(9, 13, 20, 0.82)
  );
}

.progress-grid,
.control-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.progress-card,
.remap-row {
  padding: 12px 14px;
  border: 1px solid rgba(126, 178, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  display: grid;
  gap: 6px;
}

.progress-card-wide {
  grid-column: 1 / -1;
}

.progress-card strong,
.remap-row strong {
  color: var(--ink);
}

.progress-card span,
.remap-row span {
  color: var(--muted);
}

.remap-grid {
  display: grid;
  gap: 10px;
}

.remap-button {
  justify-self: start;
  min-width: 118px;
}

.remap-button.listening {
  border-color: rgba(255, 209, 122, 0.8);
  color: #111;
  background: linear-gradient(120deg, var(--heat), var(--cool));
}

.custom-stat {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.custom-stat .label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.custom-stat strong {
  font-size: 1.05rem;
  color: var(--ink);
}

.custom-stat span:last-child {
  color: var(--muted);
  line-height: 1.35;
}

.custom-group {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.custom-group-title {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field select option:disabled {
  color: rgba(182, 197, 213, 0.5);
}

.menu-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.menu-list strong {
  color: var(--ink);
}

h1,
h2 {
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
}

h1 {
  font-size: clamp(2.6rem, 5vw, 4.2rem);
}

h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
}

.subtitle {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 20px;
  max-width: 31rem;
  margin-left: auto;
  margin-right: auto;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

.result-stat {
  padding: 10px 12px;
  border: 1px solid rgba(126, 178, 255, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.result-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result-stat strong {
  color: var(--ink);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.primary {
  background: linear-gradient(120deg, var(--hot), var(--heat));
  color: #0d0f14;
  box-shadow: 0 16px 40px rgba(255, 77, 45, 0.45);
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
}

button:hover {
  transform: translateY(-2px);
}

.overlay-notes {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.overlay-notes span {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(126, 178, 255, 0.16);
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--muted);
  text-align: left;
  margin-top: 18px;
}

.controls span {
  color: var(--ink);
  font-weight: 600;
}

.touch-controls {
  position: absolute;
  inset: auto var(--touch-controls-right) var(--touch-controls-bottom)
    var(--touch-controls-left);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  transform: scale(var(--touch-scale));
  transform-origin: bottom center;
}

.touch-controls.enabled {
  opacity: 1;
}

.touch-buttons {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.touch-controls button {
  pointer-events: auto;
  padding: var(--touch-button-padding-y) var(--touch-button-padding-x);
  font-size: var(--touch-button-font-size);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  transform: scale(var(--touch-button-size));
  transform-origin: bottom right;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls .primary {
  background: linear-gradient(120deg, var(--cool), #5ee1ff);
  color: #091018;
  box-shadow: 0 10px 30px rgba(32, 212, 255, 0.4);
}

.touch-controls .ghost {
  background: rgba(255, 184, 96, 0.16);
  border-color: rgba(255, 184, 96, 0.34);
}

.touch-stick-wrap {
  pointer-events: auto;
  transform: translate(
    var(--touch-stick-offset-x),
    var(--touch-stick-offset-y)
  );
}

.touch-steer-pad {
  width: var(--touch-stick-size);
  height: var(--touch-stick-size);
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: radial-gradient(
    circle at 30% 30%,
    rgba(90, 155, 220, 0.28),
    rgba(10, 18, 30, 0.86)
  );
  position: relative;
  touch-action: none;
}

.touch-steer-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--touch-knob-size);
  height: var(--touch-knob-size);
  margin-left: calc(var(--touch-knob-size) * -0.5);
  margin-top: calc(var(--touch-knob-size) * -0.5);
  border-radius: 50%;
  background: linear-gradient(
    120deg,
    rgba(126, 233, 255, 0.92),
    rgba(255, 171, 92, 0.86)
  );
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  will-change: transform;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.touch-steer-pad.active .touch-steer-knob {
  opacity: 1;
}

.minimap-wrap {
  position: absolute;
  left: 24px;
  top: var(--minimap-top);
  z-index: 8;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(86, 233, 255, 0.14), transparent 52%),
    rgba(8, 14, 24, 0.86);
  backdrop-filter: blur(10px);
  padding: 9px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.24),
    var(--glow);
  display: grid;
  gap: 5px;
  transform: scale(var(--hud-scale));
  transform-origin: top left;
}

body.playing .minimap-wrap {
  background:
    radial-gradient(circle at top, rgba(86, 233, 255, 0.1), transparent 52%),
    rgba(8, 14, 24, 0.76);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.18),
    0 0 20px rgba(86, 233, 255, 0.12);
  padding: 7px;
  gap: 0;
}

.touch-controls,
.touch-controls * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body.dev-mode-enabled #menu-btn,
body.dev-mode-enabled #dev-mode-hint {
  box-shadow: 0 0 18px rgba(255, 184, 96, 0.22);
}

.minimap-title {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
}

body.playing .minimap-title {
  display: none;
}

#minimap {
  width: var(--minimap-size);
  height: var(--minimap-size);
  border-radius: 12px;
  border: 1px solid rgba(126, 255, 255, 0.16);
  background: rgba(10, 18, 30, 0.95);
}

body.device-tablet {
  --stack-gap: 22px;
  --minimap-top: calc(var(--hud-top) + 52px);
  --minimap-size: 148px;
  --touch-scale: 1.03;
  --touch-stick-size: 150px;
  --touch-knob-size: 62px;
  --touch-button-padding-y: 14px;
  --touch-button-padding-x: 20px;
  --touch-button-font-size: 0.96rem;
  --touch-controls-left: 34px;
  --touch-controls-right: 30px;
  --touch-controls-bottom: 30px;
  --touch-stick-offset-x: 18px;
  --touch-stick-offset-y: -4px;
  --hud-pill-padding-y: 6px;
  --hud-pill-padding-x: 9px;
  --hud-font-size: 0.87rem;
  --hud-label-size: 0.64rem;
  --overlay-panel-scale: 0.96;
}

body.device-tablet .touch-steer-pad {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

body.device-tablet .touch-controls button {
  min-width: 114px;
}

body.device-phone {
  --progress-top: 16px;
  --progress-height: 8px;
  --stack-gap: 18px;
  --minimap-top: calc(var(--hud-top) + 58px);
  --minimap-size: 96px;
  --touch-scale: 0.84;
  --touch-stick-size: 118px;
  --touch-knob-size: 50px;
  --touch-button-padding-y: 10px;
  --touch-button-padding-x: 14px;
  --touch-button-font-size: 0.82rem;
  --hud-scale: 0.84;
  --hud-pill-padding-y: 5px;
  --hud-pill-padding-x: 8px;
  --hud-font-size: 0.81rem;
  --hud-label-size: 0.58rem;
  --overlay-panel-scale: 0.9;
}

body.device-phone .hud {
  left: 10px;
  right: 10px;
  gap: 5px;
  flex-wrap: nowrap;
}

body.device-phone .hud-cluster {
  gap: 5px;
}

body.device-phone .hud-cluster-run {
  max-width: 57vw;
}

body.device-phone .hud-cluster-drive {
  max-width: 44vw;
}

body.device-phone .hud .status .pill {
  min-width: 78px;
  padding: 5px 7px;
}

body.device-phone .bar {
  width: 74px;
}

body.device-phone .effect-toast {
  top: calc(var(--hud-top) + 42px);
  max-width: 50vw;
  padding: 6px 10px;
  font-size: 0.72rem;
}

body.device-phone .daily-gift {
  right: 10px;
  top: calc(var(--hud-top) + 72px);
  min-width: 138px;
  max-width: 42vw;
  padding: 8px 10px;
  border-radius: 14px;
}

body.device-phone .daily-gift strong {
  font-size: 0.98rem;
}

body.device-phone .daily-gift span:last-child {
  font-size: 0.66rem;
}

body.device-phone .minimap-wrap {
  left: 10px;
  padding: 7px;
}

body.device-phone .menu-panel {
  max-width: min(94vw, 620px);
  padding: 16px 14px;
}

body.device-phone .debug-hud {
  left: 10px;
  bottom: 10px;
  max-width: min(64vw, 280px);
  padding: 8px 10px;
  font-size: 0.64rem;
}

body.device-phone .custom-layout,
body.device-phone .custom-grid,
body.device-phone .custom-stats,
body.device-phone .garage-shell,
body.device-phone .progress-grid,
body.device-phone .control-layout,
body.device-phone .result-grid,
body.device-phone .dev-tools-grid,
body.device-phone .games-grid,
body.device-phone .online-layout,
body.device-phone .online-grid {
  grid-template-columns: 1fr;
}

body.device-phone .garage-preview {
  min-height: 190px;
}

body.device-phone .mode-card {
  grid-template-columns: 78px minmax(0, 1fr);
}

body.device-phone .chat-popout {
  right: 14px;
  bottom: 14px;
}

body.device-phone .chat-notice {
  right: 10px;
  bottom: 10px;
  width: min(310px, calc(100vw - 20px));
}

body.device-tablet .menu-panel {
  max-width: min(92vw, 700px);
  padding: 22px 20px;
}

body.device-tablet .custom-stats,
body.device-tablet .garage-shell,
body.device-tablet .progress-grid,
body.device-tablet .control-layout,
body.device-tablet .online-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.touch-layout-compact .touch-buttons {
  gap: 8px;
}

body.touch-layout-compact .touch-controls button {
  min-width: 92px;
}

body.touch-layout-lefty {
  --touch-controls-left: 18px;
  --touch-controls-right: 18px;
}

body.touch-layout-lefty .touch-controls {
  flex-direction: row-reverse;
}

body.device-phone .overlay .panel .subtitle {
  margin-bottom: 14px;
  line-height: 1.45;
}

body.device-phone h1 {
  font-size: clamp(2rem, 8vw, 3rem);
}

body.device-phone h2 {
  font-size: clamp(1.5rem, 6vw, 2rem);
}

body.device-phone .cta-row {
  gap: 8px;
}

.bar {
  width: 78px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cool), var(--heat));
  box-shadow: 0 0 16px rgba(86, 233, 255, 0.35);
}

@media (max-width: 720px) {
  :root {
    --progress-top: 18px;
    --stack-gap: 20px;
    --minimap-top: calc(var(--hud-top) + 74px);
  }

  .hud {
    left: 12px;
    right: 12px;
    top: var(--hud-top);
    gap: 6px;
  }

  .match-panel {
    right: 12px;
    width: min(52vw, 320px);
  }

  .progress {
    left: 18px;
    right: 18px;
  }

  .touch-controls {
    inset: auto var(--touch-controls-right) var(--touch-controls-bottom)
      var(--touch-controls-left);
    justify-content: space-between;
  }

  .minimap-wrap {
    left: 14px;
    top: var(--minimap-top);
    padding: 8px;
  }

  #minimap {
    width: 140px;
    height: 140px;
  }

  .custom-layout,
  .custom-grid,
  .custom-stats {
    grid-template-columns: 1fr;
  }

  .match-panel-stats,
  .dev-max-summary,
  .dev-tools-grid,
  .games-grid {
    grid-template-columns: 1fr;
  }

  .mode-card {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}

body.replay-active::after {
  content: "Replay";
  position: fixed;
  inset: 16px;
  z-index: 38;
  pointer-events: none;
  border: 2px solid rgba(126, 255, 255, 0.5);
  border-radius: 26px;
  box-shadow:
    inset 0 0 42px rgba(86, 233, 255, 0.18),
    0 0 34px rgba(255, 118, 62, 0.16);
  color: rgba(232, 252, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 16px 18px;
}
