.game-shell {
  min-height: 100vh;
}

.race-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

/* ── Panels ── */
.lobby-panel,
.stage-panel {
  border: 1px solid rgba(184, 255, 92, 0.18);
  border-radius: 10px;
  background: rgba(14, 20, 30, 0.92);
  box-shadow: var(--shadow);
}

.lobby-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
}

/* ── Connection row ── */
.connection-row,
.room-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.connection-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 18px rgba(255, 200, 87, 0.55);
  transition: background 300ms, box-shadow 300ms;
}

.connection-dot.online {
  background: var(--lime);
  box-shadow: 0 0 18px rgba(184, 255, 92, 0.55);
}

.connection-dot.error {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(255, 102, 117, 0.55);
}

/* ── Form elements ── */
.field-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #070c14;
  color: var(--text);
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}

input:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 3px rgba(184, 255, 92, 0.12);
}

/* ── Buttons ── */
.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  min-height: 44px;
  border: 1px solid rgba(184, 255, 92, 0.22);
  border-radius: 8px;
  background: rgba(18, 32, 18, 0.9);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  transition: border-color 160ms, background 160ms;
}

button:hover:not(:disabled) {
  border-color: var(--lime);
  background: rgba(30, 52, 24, 0.9);
}

button:disabled {
  color: #687489;
  cursor: not-allowed;
  opacity: 0.6;
}

/* ── Room strip ── */
.room-strip {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d121b;
}

.room-strip strong {
  color: var(--lime);
  letter-spacing: 0.06em;
  font-family: "Courier New", monospace;
}

/* ── Race stats ── */
.race-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.race-stats div {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1018;
  text-align: center;
}

.race-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.race-stats strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: var(--lime);
}

/* ── Scoreboard ── */
.scoreboard {
  display: grid;
  gap: 6px;
  min-height: 80px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scoreboard li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  font-size: 0.84rem;
  transition: border-color 200ms;
}

/* Rank number (first span inside li) */
.scoreboard li > span:first-child {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.73rem;
  font-weight: 900;
  color: var(--muted);
}

/* Rank highlights — uses first span as rank indicator */
.scoreboard li:nth-child(1) {
  border-color: rgba(184, 255, 92, 0.45);
  background: rgba(184, 255, 92, 0.05);
}
.scoreboard li:nth-child(1) > span:first-child { color: var(--lime); }


.scoreboard li:nth-child(2) {
  border-color: rgba(255, 200, 87, 0.35);
  background: rgba(255, 200, 87, 0.04);
}
.scoreboard li:nth-child(2) > span:first-child { color: var(--amber); }

.scoreboard li:nth-child(3) {
  border-color: rgba(255, 102, 117, 0.3);
  background: rgba(255, 102, 117, 0.03);
}
.scoreboard li:nth-child(3) > span:first-child { color: var(--danger); }

.scoreboard b {
  color: var(--text);
  font-weight: 700;
}

/* Distance (last span inside li) */
.scoreboard li > span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

/* ── Status text ── */
.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
  min-height: 24px;
}

/* ── Stage panel / game canvas ── */
.stage-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  overflow: hidden;
}

#gameRoot {
  flex: 1;
}

#gameRoot canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Race overlay (countdown / result) ── */
.race-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(8, 10, 16, 0.72);
  backdrop-filter: blur(4px);
  border-radius: inherit;
  pointer-events: none;
  transition: opacity 300ms;
}

.race-overlay.hidden {
  opacity: 0;
}

.race-overlay strong {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1;
  color: var(--lime);
  text-shadow: 0 0 28px rgba(184, 255, 92, 0.5);
}

.race-overlay span {
  color: var(--muted);
  font-size: clamp(0.85rem, 2.5vw, 1.1rem);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .race-layout {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    min-height: 320px;
  }
}

@media (max-width: 600px) {
  .race-stats {
    grid-template-columns: repeat(3, 1fr);
  }

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