:root {
  color-scheme: dark;
  --bg: #050711;
  --panel: rgba(6, 10, 22, 0.84);
  --line: rgba(88, 232, 255, 0.3);
  --cyan: #35eaff;
  --coral: #ff6256;
  --gold: #ffd85a;
  --text: #f6f9ff;
  --muted: #a9b9d4;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(53, 234, 255, 0.2), transparent 28rem),
    radial-gradient(circle at 80% 10%, rgba(255, 98, 86, 0.18), transparent 26rem),
    linear-gradient(180deg, #08101f, #050711 62%, #02040a);
}

button, input { font: inherit; }

.shell {
  width: min(1280px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 26px;
}

.topbar, .fight-call, .race-hud, footer {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  filter: drop-shadow(0 0 14px rgba(53, 234, 255, 0.5));
}

.brand span { display: grid; line-height: 1; }
.brand small, .eyebrow {
  color: #62fff1;
  font-size: 0.72rem;
  font-weight: 1000;
  letter-spacing: 0.12em;
}
.brand strong { font-size: 1.34rem; }

.top-actions, .fight-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.mode, .secondary-button, .primary-button, .icon-button {
  border: 1px solid rgba(96, 236, 255, 0.34);
  border-radius: 999px;
  color: var(--text);
  background: rgba(12, 18, 34, 0.9);
  text-decoration: none;
  font-weight: 1000;
}

.mode {
  padding: 9px 12px;
  color: #72fff3;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

.secondary-button, .primary-button, .icon-button {
  cursor: pointer;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-button {
  padding: 10px 13px;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
}

.primary-button {
  padding: 13px 18px;
  background: linear-gradient(135deg, rgba(53, 234, 255, 0.28), rgba(255, 98, 86, 0.22));
}

.icon-button { width: 42px; height: 42px; }

.fight-call {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin: 14px 0;
  padding: 14px;
  border-radius: 18px;
}

.fight-call span {
  display: block;
  color: #62fff1;
  font-size: 0.74rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#roomLink {
  grid-column: 1 / -1;
  width: 100%;
  display: none;
  padding: 11px 14px;
  border: 1px solid rgba(96, 236, 255, 0.3);
  border-radius: 12px;
  color: #dce8ff;
  background: rgba(0, 0, 0, 0.28);
}

#roomLink.visible { display: block; }

.race-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 18px 18px 0 0;
}

.driver, .race-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.driver span, .driver strong, .driver i, .race-status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.driver strong {
  font-size: clamp(1rem, 3vw, 1.48rem);
}

.driver i {
  padding: 6px 9px;
  border-radius: 999px;
  color: #08101f;
  background: #dce8ff;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 1000;
}

.driver.cyan strong { color: var(--cyan); }
.driver.coral { justify-content: flex-end; }
.driver.coral strong { color: var(--coral); }

.race-status {
  display: grid;
  justify-items: center;
  min-width: 170px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
}

.race-status span {
  color: #62fff1;
  font-size: 0.68rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.track-stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 300px;
  border: 1px solid rgba(96, 236, 255, 0.26);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  background: #060914;
  isolation: isolate;
}

.track-art {
  position: absolute;
  inset: 0;
  background: url("./source-gameplay-v1.png") center / cover no-repeat;
  filter: saturate(1.06) contrast(1.02);
  z-index: 0;
}

.track-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 36% 80%, rgba(53, 234, 255, 0.24), transparent 16%),
    radial-gradient(circle at 62% 72%, rgba(255, 98, 86, 0.2), transparent 14%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.18));
  pointer-events: none;
}

.race-effects {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.kart {
  position: absolute;
  width: 5.8%;
  aspect-ratio: 1.45 / 1;
  left: 0;
  top: 0;
  z-index: 4;
  transform-origin: center;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-radius: 24% 30% 26% 26%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: clamp(0.9rem, 2vw, 1.6rem);
  font-weight: 1000;
  box-shadow: 0 14px 22px rgba(0, 0, 0, 0.42), 0 0 22px var(--glow);
}

.kart::before, .kart::after {
  content: "";
  position: absolute;
  left: 17%;
  right: 17%;
  height: 16%;
  border-radius: 999px;
  background: #06070b;
}
.kart::before { top: -9%; }
.kart::after { bottom: -9%; }
.kart b {
  position: relative;
  z-index: 1;
  transform: skew(-8deg);
}

.cyan-kart {
  --glow: rgba(53, 234, 255, 0.9);
  background: linear-gradient(135deg, #10d8ff, #00627a 65%, #04111f);
}

.coral-kart {
  --glow: rgba(255, 98, 86, 0.9);
  background: linear-gradient(135deg, #ff7062, #912c36 65%, #13050a);
}

.kart.boosting::after {
  box-shadow: -26px 0 24px var(--glow), -44px 0 34px var(--glow);
}

.pickup {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  z-index: 3;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cube {
  width: 4.2%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  color: #fff;
  font-weight: 1000;
  box-shadow: 0 0 24px var(--cube);
  background: color-mix(in srgb, var(--cube), transparent 34%);
}
.cube.blue { --cube: #35eaff; }
.cube.red { --cube: #ff6256; }

.banana {
  width: 4.5%;
  aspect-ratio: 1.4 / 1;
  border-bottom: 12px solid #ffe554;
  border-radius: 0 0 999px 999px;
  transform: translate(-50%, -50%) rotate(-12deg);
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
}

.oil {
  width: 7.5%;
  aspect-ratio: 1.6 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, rgba(255, 255, 255, 0.2), transparent 20%), #07090e;
  box-shadow: inset 0 0 18px rgba(53, 234, 255, 0.22), 0 8px 18px rgba(0, 0, 0, 0.48);
}

.rocket {
  position: absolute;
  width: 3.6%;
  aspect-ratio: 2.2 / 1;
  z-index: 5;
  border-radius: 999px 60% 60% 999px;
  background: linear-gradient(90deg, #fff, #ff3d33 48%, #761721);
  box-shadow: 0 0 20px rgba(255, 98, 86, 0.78);
}

.event-banner {
  position: absolute;
  left: 50%;
  top: 16%;
  z-index: 6;
  transform: translate(-50%, -8px);
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.64);
  opacity: 0;
  pointer-events: none;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 160ms ease, transform 160ms ease;
}

.event-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  left: 22px;
  bottom: 22px;
  z-index: 7;
  max-width: 570px;
  padding: 22px;
  border: 1px solid rgba(96, 236, 255, 0.38);
  border-radius: 18px;
  background: rgba(4, 8, 18, 0.84);
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
}

.overlay.hidden { display: none; }

.overlay h1 {
  margin: 6px 0 8px;
  font-size: clamp(2rem, 7vw, 4.2rem);
  line-height: 0.92;
}

.overlay p {
  margin: 0 0 16px;
  color: #d2def2;
}

.control-guide {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.control-guide div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.control-guide strong {
  color: #62fff1;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.touch-controls button {
  min-height: 50px;
  border: 1px solid rgba(96, 236, 255, 0.26);
  border-radius: 14px;
  color: #eaf4ff;
  background: rgba(10, 18, 34, 0.9);
  font-weight: 1000;
  letter-spacing: 0.06em;
  touch-action: manipulation;
}

.touch-controls button.is-down {
  border-color: rgba(53, 234, 255, 0.9);
  background: rgba(53, 234, 255, 0.2);
}

.touch-controls .boost, .touch-controls .item {
  border-color: rgba(255, 98, 86, 0.46);
  background: rgba(255, 98, 86, 0.17);
}

footer {
  margin-top: 16px;
  padding: 12px;
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
}

@media (max-width: 760px) {
  .shell { width: min(100% - 18px, 1280px); padding-top: 10px; }
  .topbar, .fight-call { align-items: stretch; }
  .topbar { flex-direction: column; }
  .fight-call, .race-hud { grid-template-columns: 1fr; }
  .top-actions, .fight-actions { justify-content: stretch; }
  .fight-actions > * { flex: 1 1 auto; text-align: center; }
  .driver, .driver.coral { justify-content: space-between; }
  .race-status { order: -1; }
  .overlay {
    position: relative;
    left: auto;
    bottom: auto;
    max-width: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .track-stage { min-height: 260px; }
  .touch-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
