/* Eko Rush – game UI */
/* This file styles game.html: HUD, top bar, menus, overlays, PvP lobby and in-game effects. */
/* Variables shared by both themes. --grad is the red gradient used on buttons and badges. */
:root { --primary: #ff385c; --primary-dark: #e31c5f; --grad: linear-gradient(135deg, #ff385c, #e31c5f 60%, #d70466); --font: "Plus Jakarta Sans", "Segoe UI", system-ui, Arial, sans-serif; --ease: cubic-bezier(0.2, 0.8, 0.2, 1); }
/* LIGHT THEME colours (used when <html data-theme="light">). --panel and --chip are semi-transparent so the game shows through. */
:root[data-theme="light"] { --panel: rgba(255, 255, 255, 0.9); --text: #222; --muted: #6a6a6a; --border: rgba(0, 0, 0, 0.08); --chip: rgba(255, 255, 255, 0.85); --soft: #f4f4f4; }
/* DARK THEME colours: same names, darker values. */
:root[data-theme="dark"] { --panel: rgba(22, 22, 28, 0.88); --text: #f5f5f7; --muted: #a1a1aa; --border: rgba(255, 255, 255, 0.1); --chip: rgba(22, 22, 28, 0.78); --soft: #26262e; }

/* border-box makes sizes include padding and borders. */
* { box-sizing: border-box; }
/* Full-screen page with no scrolling. user-select: none stops text getting highlighted while swiping; tap-highlight removes the grey flash on mobile taps. */
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; font-family: var(--font); color: var(--text); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
/* Reset default button and link styles. */
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
/* Red outline for keyboard users. */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
/* Game canvas fills the screen. touch-action: none stops the browser scrolling or zooming so swipes go to the game. */
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Top bar: fixed across the top. env(safe-area-inset-top) is the space taken by a phone notch; max() picks whichever is bigger. pointer-events: none lets taps pass through to the game... */
.topbar { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; z-index: 10; }
/* ...except on the bar's direct children (the buttons and score). */
.topbar > * { pointer-events: auto; }
/* Row of items with small gaps. */
.cluster { display: flex; gap: 8px; align-items: center; }
/* Round frosted button used in the top bar. */
.chip-btn { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); border: 1px solid var(--border); transition: transform 0.2s; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }
/* Grow slightly on hover; icon size. */
.chip-btn:hover { transform: scale(1.07); }
.chip-btn svg { width: 20px; height: 20px; }
/* Icon swapping: hide the moon and muted icon by default; show the right ones for dark mode and when sound is muted. */
.theme-toggle .moon, .sound .off { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
.sound.muted .on { display: none; }
.sound.muted .off { display: block; }

/* Score area: stacked and aligned to the right. */
.hud-score { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
/* Big white score with a shadow so it is readable over the game. tabular-nums makes every digit the same width so the number does not jiggle. */
.score { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45); font-variant-numeric: tabular-nums; }
/* Small rounded info pill (multiplier, coins, opponent). */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); font-weight: 800; font-variant-numeric: tabular-nums; }
/* Gold coin icon made with a radial gradient and an inner ring (inset box-shadow). */
.coin-ic { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe57a, #e0a400); display: grid; place-items: center; color: #8a5a00; font-size: 0.75rem; font-weight: 900; box-shadow: inset 0 0 0 2px #c48f00; }
/* Multiplier pill uses the red gradient. */
.mult { background: var(--grad); color: #fff; border: 0; padding: 7px 14px; }
/* HUD items only show while JS has the .playing class on the body. */
body:not(.playing) .hud { display: none; }

/* Power-up list under the top bar on the left; calc() adds 60px below the safe top edge. */
.powers { position: fixed; left: 14px; top: calc(max(14px, env(safe-area-inset-top)) + 60px); display: flex; flex-direction: column; gap: 8px; z-index: 10; pointer-events: none; }
/* Single power-up row: name plus a progress bar. */
.power { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: var(--chip); border: 1px solid var(--border); font-weight: 700; font-size: 0.85rem; min-width: 150px; }
/* Progress bar track and its red fill (JS sets the fill width). */
.power .bar { flex: 1; height: 6px; border-radius: 6px; background: var(--soft); overflow: hidden; }
.power .bar i { display: block; height: 100%; background: var(--grad); border-radius: 6px; }

/* Toast message: centred near the top, hidden (transparent, slightly raised) until .show is added. */
.toast { position: fixed; top: 18%; left: 50%; transform: translate(-50%, -16px); z-index: 12; padding: 12px 20px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-weight: 800; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); display: flex; gap: 10px; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.45s var(--ease); white-space: nowrap; max-width: calc(100% - 24px); }
/* Visible state: fades in and slides down into place. */
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* Small grey text and the red pin icon inside the toast. */
.toast small { color: var(--muted); font-weight: 600; }
.toast .pin { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; flex: none; }
.toast .pin svg { width: 14px; height: 14px; }

/* Overlay layer covering the screen; by default the panel sits bottom-left. clamp() gives fluid padding between 16px and 48px. */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: flex-start; padding: clamp(16px, 4vw, 48px); pointer-events: none; }
/* Make sure hidden overlays are really hidden (display: flex above would otherwise override hidden). */
.overlay[hidden] { display: none; }
/* Centred overlays (pause, game over) dim and blur the game behind them and block clicks to it. */
.overlay.center { align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); pointer-events: auto; }
/* Panel card: frosted glass (backdrop-filter blur) with a rise-in animation. */
.panel { pointer-events: auto; width: min(440px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 28px; padding: 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); animation: rise 0.5s var(--ease); }
/* rise animation: fades in while moving up 24px. */
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
/* Brand line at the top of the menu: small red uppercase text with the pin logo. */
.brand { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 800; font-size: 0.9rem; letter-spacing: 0.12em; text-transform: uppercase; }
.brand svg { width: 26px; height: 26px; }
/* Panel headings and paragraph spacing. */
.panel h1 { margin: 8px 0 6px; font-size: clamp(2rem, 6vw, 2.6rem); line-height: 1; letter-spacing: -0.04em; }
.panel h2 { margin: 4px 0 6px; font-size: 1.8rem; letter-spacing: -0.03em; line-height: 1.1; }
.panel p { margin: 0 0 18px; color: var(--muted); }
/* Small uppercase label (e.g. "Choose your runner"). */
.label { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 6px 0 10px; }
/* Runner picker: grid of 3 equal columns. */
.runners { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
/* Runner button: outlined card; the selected one (.active) gets a red border and tint. */
.runner-btn { padding: 12px 8px; border-radius: 16px; border: 2px solid var(--border); background: transparent; text-align: center; transition: border-color 0.2s, background 0.2s, transform 0.2s; }
.runner-btn:hover { transform: translateY(-2px); }
.runner-btn.active { border-color: var(--primary); background: rgba(255, 56, 92, 0.1); }
/* Colour swatch circle, runner name and area. */
.runner-btn .sw { width: 34px; height: 34px; border-radius: 50%; margin: 0 auto 6px; }
.runner-btn strong { display: block; font-size: 0.95rem; }
.runner-btn small { color: var(--muted); font-size: 0.72rem; }
/* Runner tagline; min-height reserves space so the layout does not jump when text changes. */
.tagline { font-size: 0.9rem; min-height: 2.6em; }
/* Base pill button for the game UI. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 15px 24px; border-radius: 999px; font-weight: 800; font-size: 1.02rem; transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.btn svg { width: 18px; height: 18px; }
/* Primary full-width red gradient button. */
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 28px rgba(255, 56, 92, 0.4); width: 100%; }
.btn-primary:hover { transform: translateY(-2px); }
/* Outlined secondary button. */
.btn-ghost { border: 1.5px solid var(--border); background: transparent; }
/* Row of buttons that share the width equally (flex: 1). */
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row .btn { flex: 1; padding: 13px 16px; font-size: 0.95rem; }
/* Best score and total naira line. */
.meta { display: flex; justify-content: space-between; margin-top: 16px; color: var(--muted); font-size: 0.85rem; gap: 10px; flex-wrap: wrap; }
.meta b { color: var(--text); }
/* Game-over stats: 3 equal boxes in a grid. */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stats div { padding: 14px 10px; border-radius: 16px; background: var(--soft); text-align: center; }
.stats strong { display: block; font-size: 1.4rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
/* "New high score!" badge. */
.newbest { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--grad); color: #fff; font-weight: 800; font-size: 0.8rem; margin-bottom: 6px; }
/* Keyboard hint line with small key graphics. */
.keys-hint { font-size: 0.8rem; color: var(--muted); margin-top: 14px; text-align: center; }
.keys-hint kbd { display: inline-block; padding: 2px 7px; border-radius: 6px; background: var(--soft); border: 1px solid var(--border); font-family: var(--font); font-weight: 800; font-size: 0.75rem; }

/* Loading screen covering everything (z-index 30); .done fades it out and lets clicks through. */
.loading { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: #0f0f12; color: #fff; font-weight: 800; transition: opacity 0.5s; }
.loading.done { opacity: 0; pointer-events: none; }
/* Spinner: a circle whose top border is red, rotated forever by the sp animation. */
.loading .spin { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--primary); animation: sp 0.8s linear infinite; margin: 0 auto 14px; }
/* sp animation: one full turn. */
@keyframes sp { to { transform: rotate(360deg); } }

/* Hit flash: red glow at the screen edges. .on shows it instantly (transition: none), removing .on fades it out. */
.flash { position: fixed; inset: 0; z-index: 9; pointer-events: none; background: radial-gradient(circle, transparent 40%, rgba(255, 56, 92, 0.55)); opacity: 0; transition: opacity 0.4s; }
.flash.on { opacity: 1; transition: none; }

/* modes + pvp */
/* Mode tabs: two equal columns in a rounded track; the active tab turns red. */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 999px; background: var(--soft); margin: 12px 0 14px; }
.tab { padding: 10px 12px; border-radius: 999px; font-weight: 800; font-size: 0.9rem; color: var(--muted); transition: background 0.2s, color 0.2s; }
.tab.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(255, 56, 92, 0.35); }
/* Smaller paragraph text. */
.small { font-size: 0.9rem; }
/* "or" divider: the ::before and ::after pseudo-elements draw lines on each side of the text. */
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.8rem; font-weight: 700; margin: 14px 0 10px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
/* Join-code and invite-link rows: input plus button side by side. */
.join-row, .link-row { display: flex; gap: 8px; }
/* Inputs: rounded, uppercase, widely spaced letters for codes. min-width: 0 lets the input shrink in flexbox. */
.join-row input, .link-row input { flex: 1; min-width: 0; padding: 13px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--soft); color: var(--text); font: inherit; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; outline: none; }
/* The link input uses normal text (links are case-sensitive). */
.link-row input { letter-spacing: 0; text-transform: none; font-weight: 600; font-size: 0.85rem; }
/* Red border when an input is focused. */
.join-row input:focus, .link-row input:focus { border-color: var(--primary); }
/* Smaller buttons in these rows. */
.join-row .btn, .link-row .btn { padding: 12px 18px; font-size: 0.92rem; }
/* Match code display: label on the left, big red code on the right. */
.code-box { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-radius: 18px; background: var(--soft); margin-bottom: 10px; }
.code-box span { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.code-box strong { font-size: 1.7rem; letter-spacing: 0.22em; color: var(--primary); font-variant-numeric: tabular-nums; }
/* Status line with spinner. */
.status { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; font-weight: 700; color: var(--text); font-size: 0.92rem; }
/* Small spinner reusing the sp rotation animation. */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--border); border-top-color: var(--primary); animation: sp 0.8s linear infinite; flex: none; }
/* Full-width secondary buttons (Cancel, Leave, Share). */
.btn.wide { width: 100%; margin-top: 4px; padding: 12px; font-size: 0.92rem; }
.share-btn { width: 100%; margin-top: 8px; padding: 11px; font-size: 0.9rem; }
/* VS block: 3-column grid (you, "VS", friend); auto makes the middle column only as wide as its text. */
.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 16px; border-radius: 18px; background: var(--soft); margin-bottom: 14px; text-align: center; }
.versus b { display: block; font-size: 1.15rem; }
.versus small { color: var(--muted); font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.versus > span { font-weight: 900; color: var(--primary); font-size: 1.2rem; }
/* Red error text and small grey note in the PvP panel. */
.pvp-error { color: #e53935; font-weight: 700; font-size: 0.88rem; margin: 10px 0 0; }
.pvp-note { font-size: 0.78rem; color: var(--muted); margin: 12px 0 0; }
/* Opponent pill in the HUD: teal dot normally, red when the friend is ahead, grey when they are out. */
.opp { font-size: 0.85rem; padding: 7px 14px; }
.opp-dot { width: 10px; height: 10px; border-radius: 50%; background: #00a699; box-shadow: 0 0 0 3px rgba(0, 166, 153, 0.25); }
.opp.ahead .opp-dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(255, 56, 92, 0.25); }
.opp.out .opp-dot { background: #888; box-shadow: none; }
/* Race results: two equal boxes; the winner (.win) gets a red border and tint. */
.race-result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.rr { padding: 16px 10px; border-radius: 18px; background: var(--soft); border: 2px solid transparent; display: flex; flex-direction: column; gap: 2px; }
.rr.win { border-color: var(--primary); background: rgba(255, 56, 92, 0.1); }
/* Text inside each result box. */
.rr small { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.08em; }
.rr b { font-size: 1rem; }
.rr strong { font-size: 1.6rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rr span { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
/* In PvP mode (body.pvp), hide solo-only controls such as the pause button. !important beats other display rules. */
body.pvp .solo-only { display: none !important; }

/* Big 3-2-1 countdown in the middle of the screen; clamp() scales it with screen width. */
.countdown { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; pointer-events: none; font-size: clamp(5rem, 22vw, 12rem); font-weight: 900; color: #fff; text-shadow: 0 8px 40px rgba(255, 56, 92, 0.7), 0 2px 0 rgba(0, 0, 0, 0.25); letter-spacing: -0.04em; }
/* JS adds .pop for each number, playing the cd animation: zooms in, holds, then shrinks and fades. */
/* "forwards" keeps the faded-out final frame, so the text doesn't reappear when the animation ends. */
.countdown.pop { animation: cd 0.9s var(--ease) forwards; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(0.8); opacity: 0; } }
/* Floating pop-up text (centred via translateX(-50%)), invisible until .show plays the pop animation. */
.popup { position: fixed; left: 50%; top: 38%; z-index: 12; transform: translateX(-50%); pointer-events: none; font-weight: 900; font-size: clamp(1.2rem, 3.4vw, 1.8rem); color: #fff; text-shadow: 0 3px 16px rgba(0, 0, 0, 0.45); opacity: 0; white-space: nowrap; }
.popup.show { animation: pop 1s var(--ease); }
/* pop animation: grows in, bounces slightly, then floats up and fades out. */
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 20px) scale(0.7); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px) scale(1); } }
/* Speed vignette: darkens the screen edges; JS raises its opacity at high speed. */
.speed-vignette { position: fixed; inset: 0; pointer-events: none; z-index: 8; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.35) 100%); transition: opacity 0.3s; }

/* Media query for phones (720px wide or less). */
@media (max-width: 720px) {
  /* Panel sits at the bottom centre; padding respects the home-indicator area via env(safe-area-inset-bottom). */
  .overlay { align-items: flex-end; justify-content: center; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  /* Smaller panel and heading; hide the tagline to save space. */
  .panel { padding: 22px; border-radius: 24px; }
  .panel h1 { font-size: 2rem; }
  .tagline { display: none; }
  /* Move power-ups to the bottom-left so they do not cover the score. */
  .powers { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); }
  .power { min-width: 130px; }
  /* Hide keyboard hints on touch devices. */
  .keys-hint { display: none; }
}
/* Media query for phones held sideways (short and in landscape orientation). */
@media (max-height: 560px) and (orientation: landscape) {
  /* Panel moves to the left and can scroll if it is taller than the screen; paragraphs are hidden to save space. */
  .overlay { justify-content: flex-start; align-items: center; }
  .panel { padding: 18px; max-height: calc(100vh - 24px); overflow: auto; }
  .panel p, .tagline { display: none; }
}
/* Global rule: anything with the hidden attribute is never shown, even if other rules set display. */

.pill[hidden], [hidden] { display: none !important; }
