/* Neon Overdrive - first-party game styles. */

:root {
  --bg: #0b1017;
  --panel: #151c27;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef3ff;
  --muted: #a3afc2;
  --accent: #ff8a1f;
  --accent-2: #ffd27a;
  --radius: 14px;
  --font: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-display: "Arial Black", "Avenir Next Condensed", Impact, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }

#app {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(255, 138, 31, 0.18), transparent 42%),
    radial-gradient(ellipse at 100% 110%, rgba(79, 141, 221, 0.22), transparent 40%),
    linear-gradient(180deg, #121a26 0%, var(--bg) 60%);
}
/* Faint perspective grid, like a lit car park floor. */
#app::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 46vh;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(255, 138, 31, 0.06), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 48px);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
}

h1, h2, h3, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }
.screen { min-height: 100%; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border: 0; border-radius: 999px;
  background: var(--accent); color: #04121a; font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255, 138, 31, 0.28); }
.button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.button--ghost { background: transparent; color: var(--text); border: 1px solid rgba(255, 255, 255, 0.22); }
.button--ghost:hover { box-shadow: none; background: rgba(255, 255, 255, 0.06); }
.button--small { min-height: 36px; padding: 6px 14px; font-size: 0.9rem; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--text); }

.screen--menu, .screen--lobby { display: grid; place-items: start center; padding: 24px 16px 48px; }
.menu-card {
  position: relative; width: min(760px, 100%); background: rgba(14, 19, 38, 0.86); border: 1px solid var(--line);
  border-radius: 22px; padding: 28px 24px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06); backdrop-filter: blur(12px);
}
.menu-card::before {
  content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent); opacity: 0.8;
}
.menu-head { text-align: center; margin-bottom: 20px; }
.brand { text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.72rem; color: var(--accent); font-weight: 700; }
.title {
  font-family: var(--font-display); font-size: clamp(2.3rem, 7vw, 3.9rem); line-height: 1; margin: 6px 0 10px; font-style: italic;
  letter-spacing: -0.01em; text-transform: uppercase;
  background: linear-gradient(100deg, #ffffff 15%, var(--accent-2) 55%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(255, 138, 31, 0.25));
}
.title--code { letter-spacing: 0.18em; font-style: normal; }
.tagline { color: var(--muted); max-width: 52ch; margin: 0 auto; }

.field { margin: 0 0 18px; }
.field label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.field input, .option-names input, #join-code, #lobby-link {
  width: 100%; min-height: 44px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.06); color: var(--text); outline: none;
}
.field input:focus, .option-names input:focus, #join-code:focus { border-color: var(--accent); }
.field--inline { display: flex; gap: 10px; }
.field--inline input { flex: 1; min-width: 0; font-size: 0.85rem; }
.invite { background: rgba(79, 140, 255, 0.15); border: 1px solid rgba(79, 140, 255, 0.4); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; }

.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.option { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.option--wide { grid-column: 1 / -1; }
.option h2 { font-size: 1.05rem; }
.option p { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }
.option-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.option-actions--online { align-items: center; }
.option-actions--online #join-code { flex: 1; min-width: 140px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }
.or { color: var(--muted); font-size: 0.85rem; }
.option-names { display: grid; gap: 8px; }
.option-names label { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.option-names input { min-height: 38px; }
.menu-foot { text-align: center; margin-top: 18px; }
.menu-note { margin-top: 12px; text-align: center; font-size: 0.82rem; }

/* The play stack: the main button first and biggest, create a room second. */
.play-stack { display: grid; gap: 10px; margin: 4px 0 18px; }
.button--hero, .button--second {
  width: 100%; justify-content: flex-start; text-align: left; border-radius: 16px; padding: 14px 18px; gap: 14px;
}
.button--hero { min-height: 76px; font-size: 1.1rem; box-shadow: 0 12px 34px rgba(255, 138, 31, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.button--hero:hover { box-shadow: 0 16px 40px rgba(255, 138, 31, 0.4); }
.button--second {
  min-height: 60px; background: rgba(255, 255, 255, 0.08); color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.22);
}
.button--second:hover { background: rgba(255, 255, 255, 0.13); box-shadow: none; }
.hero-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, 0.18); font-size: 1.2rem; flex: none; }
.hero-text { display: grid; gap: 2px; min-width: 0; }
.hero-text strong { font-size: 1.15em; line-height: 1.1; }
.hero-text small { font-weight: 600; font-size: 0.78rem; opacity: 0.82; line-height: 1.3; }
.button--second .hero-text small { color: var(--muted); }
.join-row { display: flex; gap: 10px; align-items: center; }
.join-row #join-code { flex: 1; min-width: 120px; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }
.muted { color: var(--muted); font-size: 0.9rem; }

.track-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.track-option {
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--text);
}
.track-option { transition: transform 120ms ease, border-color 120ms ease; }
.track-option:hover { transform: translateY(-1px); }
.track-option.is-selected { border-color: var(--accent); background: rgba(255, 138, 31, 0.1); box-shadow: 0 0 0 1px rgba(255, 138, 31, 0.35), 0 10px 30px rgba(255, 138, 31, 0.12); }

/* graphics quality */
.option--quality { gap: 12px; }
.quality-head { display: grid; gap: 4px; }
.quality-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quality-picker button {
  display: grid; gap: 2px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04); color: var(--text); text-align: left;
  transition: border-color 120ms ease, background 120ms ease;
}
.quality-picker button strong { font-size: 0.95rem; }
.quality-picker button small { color: var(--muted); font-size: 0.74rem; }
.quality-picker button.is-selected { border-color: var(--accent); background: rgba(255, 138, 31, 0.1); box-shadow: 0 0 0 1px rgba(255, 138, 31, 0.35); }
.track-swatch { grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }
.track-name { font-weight: 700; }
.track-blurb { color: var(--muted); font-size: 0.78rem; line-height: 1.35; }

.players { display: grid; gap: 6px; margin: 14px 0; }
.player { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.player--empty { opacity: 0.5; border: 1px dashed var(--line); }
.player-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); }
.player-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-meta { color: var(--muted); font-size: 0.8rem; }

/* race */
.screen--race { position: relative; height: 100%; overflow: hidden; background: #000; }
.race-canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.race-canvas--hud { pointer-events: none; z-index: 2; }
.race-menu { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 3; opacity: 0.8; }
.touch-controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px 14px; z-index: 3; pointer-events: none; }
.touch-group { display: flex; gap: 10px; pointer-events: auto; }
.touch-button {
  width: 68px; height: 68px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 14, 28, 0.55); color: #fff; font-weight: 900; font-size: 1.2rem; touch-action: none; user-select: none; -webkit-user-select: none;
}
.touch-button--brake { font-size: 0.72rem; }
.touch-button--nitro { font-size: 0.72rem; background: rgba(77, 242, 255, 0.28); border-color: rgba(77, 242, 255, 0.7); color: #dffbff; text-shadow: 0 0 8px rgba(77, 242, 255, 0.8); }
.touch-button--fire { font-size: 0.85rem; background: rgba(255, 93, 93, 0.5); border-color: rgba(255, 150, 150, 0.6); }
.touch-button.is-down { background: rgba(77, 242, 255, 0.75); color: #04121a; text-shadow: none; }

/* modals */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(5, 9, 18, 0.72); backdrop-filter: blur(4px); }
.modal-card { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 24px; text-align: center; display: grid; gap: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.modal-card--wide { width: min(620px, 100%); text-align: left; }
.modal-card h2 { font-size: 1.5rem; }
.modal-card h3 { font-size: 1rem; margin-top: 6px; }
.modal-card p { color: var(--muted); }
.modal-card .option-actions { justify-content: center; }
.rules { display: grid; gap: 8px; padding-left: 20px; list-style: disc; color: var(--text); line-height: 1.5; }
.rules strong { color: var(--accent); }
.results { display: grid; gap: 6px; text-align: left; }
.result { display: grid; grid-template-columns: 28px 12px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
.result.is-me { background: rgba(255, 138, 31, 0.12); border: 1px solid rgba(255, 138, 31, 0.5); }
.result-pos { font-family: var(--font-display); font-size: 1.1rem; }
.result-dot { width: 12px; height: 12px; border-radius: 50%; }
.result-name { font-weight: 700; }
.result-meta { color: var(--muted); font-size: 0.78rem; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px); z-index: 30; padding: 10px 16px; border-radius: 999px; background: #223457; color: #fff; font-size: 0.9rem; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; max-width: calc(100vw - 32px); text-align: center; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--good { background: #1f7a4d; }
.toast--warn { background: #8a3b2a; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 25; pointer-events: none; }

@media (max-width: 600px) {
  .menu-grid, .track-picker { grid-template-columns: 1fr; }
  .quality-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .menu-card { padding: 22px 16px 18px; }
  .touch-button { width: 60px; height: 60px; }
}
@media (prefers-reduced-motion: reduce) { .button, .toast { transition: none; } }
