/* Racemax — style arcade */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sand: #f2c893;
  --sand-dark: #d9a86c;
  --rock: #8a5a3b;
  --ink: #2b1d12;
  --accent: #ff6b35;
  --accent2: #ffd60a;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #7ec8e3 0%, #ffd9a0 55%, var(--sand) 100%);
  color: var(--ink);
}

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

.hidden { display: none !important; }

/* ---------- Écrans ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(43, 29, 18, 0.25);
  backdrop-filter: blur(2px);
  z-index: 10;
  overflow-y: auto;
}

.panel {
  background: rgba(255, 248, 235, 0.97);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 12px 0 rgba(43, 29, 18, 0.35);
  padding: 28px 32px;
  width: 420px;
  max-width: 94vw;
  text-align: center;
}
.panel-wide { width: 620px; }

.logo {
  font-size: 56px;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--ink);
  transform: skew(-6deg);
}
.logo span { color: var(--ink); text-shadow: 3px 3px 0 var(--accent); }

.tagline { margin: 8px 0 20px; font-size: 14px; opacity: 0.8; }

h2 { margin-bottom: 14px; font-size: 26px; }
h3 { margin: 16px 0 8px; font-size: 18px; }

label {
  display: block;
  text-align: left;
  font-weight: 700;
  margin: 12px 0 4px;
  font-size: 14px;
}

input {
  width: 100%;
  padding: 12px 14px;
  font-size: 18px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
}
input:focus { outline: 3px solid var(--accent2); }

.code-input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 10px;
  font-weight: 900;
  font-size: 24px;
}

.btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 900;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: 3px solid var(--ink);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 7px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-big { font-size: 20px; }

.separator {
  margin: 14px 0 2px;
  font-weight: 700;
  opacity: 0.6;
}

.hint { margin-top: 14px; font-size: 13px; opacity: 0.75; }
.hint-inline { font-size: 12px; opacity: 0.65; font-weight: 400; }

.player-name { color: var(--accent); }

/* ---------- Lobby ---------- */
.code-display {
  margin: 6px 0 14px;
  font-size: 17px;
}
.code-display strong {
  font-size: 26px;
  letter-spacing: 6px;
  background: var(--ink);
  color: var(--accent2);
  padding: 4px 12px;
  border-radius: 10px;
}

.player-list { list-style: none; margin: 8px 0; text-align: left; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  margin-bottom: 6px;
  background: #fff;
  font-weight: 700;
}
.player-list .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex-shrink: 0;
}
.player-list .veh { margin-left: auto; font-size: 20px; }
.player-list .crown { color: #b8860b; }
.player-list .me-tag { font-size: 11px; opacity: 0.6; }

.vehicle-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.vehicle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.06s;
}
.vehicle-card:hover:not(:disabled) { transform: translateY(-3px); background: #fff7e0; }
.vehicle-card:disabled { opacity: 0.35; cursor: not-allowed; }
.vehicle-card.selected {
  background: var(--accent2);
  outline: 3px solid var(--accent);
}
.vehicle-emoji { font-size: 34px; }
.vehicle-name { font-weight: 900; font-size: 13px; }
.vehicle-desc { font-size: 11px; opacity: 0.7; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.hud-top {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 10px;
}
.hud-box {
  background: rgba(43, 29, 18, 0.8);
  color: #fff;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 22px;
  font-weight: 900;
  border: 2px solid rgba(255, 255, 255, 0.4);
}
.hud-box small { font-size: 13px; }
#hud-speed {
  position: absolute;
  bottom: 18px;
  right: 20px;
  font-size: 30px;
}
#hud-msg {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(43, 29, 18, 0.85);
  color: var(--accent2);
  font-size: 30px;
  font-weight: 900;
  padding: 12px 28px;
  border-radius: 16px;
  border: 3px solid var(--accent2);
  text-align: center;
  white-space: nowrap;
}
#hud-help {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  background: rgba(43, 29, 18, 0.55);
  color: #fff;
  padding: 5px 12px;
  border-radius: 8px;
}

/* ---------- Compte à rebours ---------- */
#countdown {
  position: fixed;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 130px;
  font-weight: 900;
  font-style: italic;
  color: var(--accent2);
  text-shadow: 6px 6px 0 var(--ink), 0 0 40px rgba(255, 214, 10, 0.6);
  z-index: 6;
  pointer-events: none;
  animation: pop 0.35s ease-out;
}
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---------- Résultats ---------- */
#results-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}
#results-table th, #results-table td {
  padding: 8px 10px;
  border-bottom: 2px solid rgba(43, 29, 18, 0.2);
  font-size: 16px;
  text-align: left;
}
#results-table th { font-size: 13px; text-transform: uppercase; opacity: 0.6; }
#results-table tr.me td { background: rgba(255, 214, 10, 0.35); font-weight: 900; }
#results-table .dot {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  margin-right: 7px;
  vertical-align: -1px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 22px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 30;
  border: 2px solid var(--accent2);
  max-width: 90vw;
  text-align: center;
}

@media (max-width: 560px) {
  .vehicle-picker { grid-template-columns: repeat(2, 1fr); }
  .logo { font-size: 42px; }
  #countdown { font-size: 80px; }
}
