/* Epic Racing — page layout, loading and error screens. */

:root {
  --ink: #0A0F1C;
  --ink-2: #111a2e;
  --ink-3: #1a2540;
  --line: rgba(255, 255, 255, .12);
  --text: #F3F5FA;
  --muted: #9AA6C2;
  --accent: #FFD21F;
  --accent-ink: #1C1600;
  --red: #FF3B3B;
  --green: #35D07F;
  --purple: #B26BFF;
  --blue: #3D8BFF;
  --display: "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.4 var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

/* The game fills the window below the Pixelrain bar. */
#app {
  position: fixed;
  top: var(--pixelrain-bar, 0px);
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
  background: var(--ink);
  contain: strict;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

#hud, #touch, #ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

button { font: inherit; color: inherit; }

/* ── Loading ── */
#loading {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 600px at 50% 120%, rgba(255, 210, 31, .12), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 22px),
    var(--ink);
  transition: opacity .6s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.loading-inner { width: min(420px, 86vw); text-align: center; }
.loading-logo { color: var(--accent); margin-bottom: 10px; }
.loading-title {
  margin: 0;
  font: italic 800 clamp(40px, 9vw, 64px)/0.95 var(--display);
  letter-spacing: -.01em;
  text-transform: uppercase;
}
.loading-title span { color: var(--accent); }
.loading-sub {
  margin: 8px 0 26px;
  font: 600 13px/1 var(--body);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--muted);
}
.loading-track {
  height: 6px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, .1);
}
#loading-bar {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--accent) 0 14px, #fff 14px 28px);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform .25s ease;
}
#loading-text { margin: 12px 0 0; color: var(--muted); font-size: 13px; min-height: 1.4em; }

/* ── Fatal ── */
#fatal {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 18, .92);
}
#fatal[hidden] { display: none; }
.fatal-inner { width: min(440px, 88vw); text-align: center; }
.fatal-inner h2 {
  margin: 0 0 10px;
  font: italic 800 34px/1 var(--display);
  text-transform: uppercase;
  color: var(--red);
}
.fatal-inner p { color: var(--muted); margin: 0 0 22px; }
.fatal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.fatal-actions button {
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
}
.fatal-actions button.ghost { background: rgba(255, 255, 255, .1); color: var(--text); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; }

/* Flash of colour when the screen fades between scenes. */
#fade {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}
#fade.on { opacity: 1; }
