:root {
  color: #fff8ff;
  background: #08030f;
  color-scheme: dark;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --panel: rgba(17, 7, 40, 0.78);
  --panel-strong: rgba(28, 9, 70, 0.88);
  --line: rgba(255, 255, 255, 0.16);
  --muted: #d9cdfd;
  --hot: #ff39b7;
  --purple: #7444ff;
  --aqua: #71f8ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 57, 183, 0.38), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(113, 248, 255, 0.22), transparent 28%),
    linear-gradient(135deg, #27106f, #0b0318 52%, #05020b);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #fff8ff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    rgba(54, 23, 134, 0.92);
  cursor: pointer;
  font-weight: 900;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.66);
  box-shadow: 0 16px 34px rgba(5, 1, 18, 0.42);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: #fff;
  background: rgba(7, 2, 19, 0.72);
  padding: 0 12px;
  outline: none;
  font-weight: 900;
  text-transform: uppercase;
}

input:focus {
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(116, 68, 255, 0.34);
}

.arcade-shell {
  position: relative;
  min-height: 100vh;
  padding: 14px;
}

.arcade-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 84px);
  opacity: 0.62;
  transform: skew(-12deg);
}

.hud-panel {
  position: relative;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04)),
    var(--panel);
  box-shadow:
    0 22px 70px rgba(2, 0, 10, 0.46),
    inset 0 1px rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(18px);
}

.top-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 12px;
  padding: 12px;
  max-width: 1480px;
}

.brand-block,
.panel-head,
.mode-switch,
.room-row,
.button-grid {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  color: #26084f;
  background: linear-gradient(135deg, #fff, #f5d9ff 42%, #ff39b7);
  font-size: 1.72rem;
  font-weight: 1000;
  box-shadow: 0 0 36px rgba(255, 57, 183, 0.44);
}

.eyebrow,
.score-chip span,
.room-badge,
.status-line {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow,
h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 3.4vw, 3.1rem);
  line-height: 0.95;
  text-shadow:
    0 2px rgba(16, 4, 45, 0.9),
    0 0 26px rgba(255, 255, 255, 0.24);
}

h2 {
  margin-top: 2px;
  font-size: 1.05rem;
}

.mode-switch {
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.mode-switch button {
  min-width: 104px;
}

.mode-switch button.is-active,
.primary {
  color: #220749;
  background: linear-gradient(135deg, #ffffff, #eadcff 45%, #ffb5ec);
}

.race-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(230px, 310px) minmax(0, 1fr);
  gap: 12px;
  max-width: 1680px;
  margin: 0 auto;
  min-height: calc(100vh - 104px);
}

.garage-panel {
  align-self: stretch;
  padding: 12px;
  overflow: auto;
}

.panel-head {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.room-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  padding: 0 9px;
}

.character-grid {
  display: grid;
  gap: 8px;
}

.garage-box {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)),
    rgba(6, 2, 18, 0.22);
  padding: 10px;
}

.character-card {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 70px;
  padding: 8px;
  text-align: left;
}

.character-card.is-selected {
  border-color: rgba(255, 255, 255, 0.78);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.character-card.is-taken:not(.is-selected) {
  opacity: 0.52;
}

.avatar {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.character-name {
  display: block;
  color: #fff;
  font-size: 0.92rem;
}

.character-style {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.pick-state {
  color: var(--aqua);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.online-controls {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.room-row {
  gap: 8px;
}

.room-row button {
  min-width: 72px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 8px;
  margin-top: 0;
}

.status-line {
  min-height: 34px;
  margin: 0;
  border-left: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 9px 10px;
  overflow-wrap: anywhere;
}

.track-wrap {
  position: relative;
  min-height: 650px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(113, 248, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(25, 9, 70, 0.94), rgba(5, 2, 12, 0.98));
  box-shadow:
    0 24px 84px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 57, 183, 0.18);
  isolation: isolate;
}

.track-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 12%),
    radial-gradient(circle at 50% 92%, rgba(255, 57, 183, 0.2), transparent 28%);
}

#gameCanvas {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
  touch-action: none;
}

.race-overlay {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.score-chip {
  min-width: 112px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)),
    rgba(6, 2, 18, 0.76);
  padding: 9px 11px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.score-chip strong {
  display: block;
  margin-top: 2px;
  font-size: 1.16rem;
}

.countdown {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
  font-size: clamp(4rem, 18vw, 13rem);
  font-weight: 1000;
  text-shadow:
    0 6px rgba(18, 4, 50, 0.85),
    0 0 46px rgba(255, 57, 183, 0.7);
  animation: countdownPop 0.42s ease both;
}

@keyframes countdownPop {
  from {
    transform: scale(0.88);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.touch-controls {
  position: absolute;
  z-index: 4;
  right: 14px;
  bottom: 14px;
  left: 14px;
  display: none;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.touch-wheel,
.pedals button {
  pointer-events: auto;
  user-select: none;
}

.touch-wheel {
  width: 138px;
  height: 96px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(6, 2, 18, 0.48);
  backdrop-filter: blur(10px);
}

.touch-wheel span {
  width: 72px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff, #ffb9eb);
  box-shadow: 0 0 26px rgba(255, 57, 183, 0.48);
}

.pedals {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pedals button {
  width: 66px;
  height: 66px;
  min-height: 66px;
  border-radius: 999px;
  font-size: 1.65rem;
}

.pedals .weapon-button {
  width: 82px;
  border-radius: 8px;
  color: #220749;
  background: linear-gradient(135deg, #ffffff, #b7fbff 44%, #ffb5ec);
  font-size: 0.9rem;
  text-transform: uppercase;
}

.standings-list {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.standing-row {
  display: grid;
  grid-template-columns: 22px 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 5px 7px;
}

.standing-row.is-player {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.13);
}

.standing-place {
  color: var(--aqua);
  font-weight: 1000;
}

.standing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.standing-name {
  display: block;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 950;
}

.standing-meta {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.mini-map {
  min-width: 0;
  margin-top: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.06);
  aspect-ratio: 1.18;
  min-height: 160px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.34),
    0 0 42px rgba(255, 57, 183, 0.18),
    inset 0 1px rgba(255, 255, 255, 0.2);
}

#mapCanvas {
  width: 100%;
  height: 100%;
  min-width: 0;
  display: block;
}

.standings-panel {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  width: clamp(430px, 36vw, 560px);
  max-height: calc(100% - 28px);
  padding: 10px;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04)),
    rgba(11, 4, 29, 0.58);
  box-shadow:
    0 20px 58px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 57, 183, 0.12),
    inset 0 1px rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.standings-panel .panel-head {
  margin-bottom: 8px;
}

.standings-panel h2 {
  font-size: 0.98rem;
}

.standings-panel .room-badge {
  min-height: 25px;
  padding: 0 7px;
  font-size: 0.66rem;
}

.race-combo {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(168px, 0.92fr);
  align-items: stretch;
  gap: 8px;
}

.race-combo > * {
  min-width: 0;
}

@media (max-width: 1120px) {
  html,
  body {
    overflow: auto;
  }

  .race-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .track-wrap {
    order: -1;
  }

  .garage-panel {
    max-height: none;
    overflow: visible;
  }

  .character-grid {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .character-card {
    grid-template-columns: 48px 1fr;
  }

  .pick-state {
    grid-column: 1 / -1;
  }

  .standings-list {
    grid-template-columns: 1fr;
  }

  .mini-map {
    min-height: 180px;
  }

  .standings-panel {
    width: min(470px, calc(100% - 24px));
    max-height: calc(100% - 24px);
  }
}

@media (pointer: coarse), (max-width: 760px) {
  .arcade-shell {
    padding: 8px;
  }

  .top-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .mode-switch button {
    min-width: 0;
  }

  .track-wrap {
    min-height: min(76vh, 720px);
  }

  .race-overlay {
    flex-wrap: wrap;
  }

  .score-chip {
    min-width: calc(33.33% - 6px);
  }

  .mini-map {
    min-height: 128px;
  }

  .touch-controls {
    display: flex;
  }

  .standings-panel {
    right: 10px;
    bottom: 116px;
    width: min(310px, calc(100% - 20px));
    max-height: 38vh;
    padding: 8px;
  }

  .race-combo {
    grid-template-columns: minmax(132px, 0.9fr) minmax(132px, 1fr);
  }

  .mini-map {
    align-self: start;
    width: 100%;
    min-height: 0;
  }

  .standings-panel .panel-head,
  .standings-list {
    gap: 5px;
  }

  .standings-panel h2 {
    font-size: 0.86rem;
  }

  .standing-row {
    min-height: 34px;
    grid-template-columns: 18px 26px minmax(0, 1fr) auto;
    padding: 4px 6px;
  }

  .standing-avatar {
    width: 26px;
    height: 26px;
  }

  .standing-meta {
    display: none;
  }

  .touch-wheel {
    width: 112px;
    height: 82px;
  }

  .touch-wheel span {
    width: 56px;
    height: 36px;
  }

  .pedals {
    gap: 6px;
  }

  .pedals button {
    width: 56px;
    height: 56px;
    min-height: 56px;
  }

  .pedals .weapon-button {
    width: 68px;
    font-size: 0.78rem;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 1.72rem;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .character-grid {
    grid-template-columns: repeat(5, 138px);
  }

  .garage-panel {
    padding: 10px;
  }

  .button-grid,
  .room-row {
    grid-template-columns: 1fr;
  }

  .room-row {
    display: grid;
  }
}
