/* ── NEON RUSH — design tokens (pixel-art / arcade) ── */
:root {
  --bg:            #0F172A;
  --bg-deep:       #080d18;
  --bg-panel:      #141d33;
  --bg-card:       rgba(255,255,255,.05);
  --bg-hover:      rgba(255,255,255,.09);
  --border:        rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.18);
  --text:          #ffffff;
  --text-muted:    #8f9bb5;
  --primary:       #DC2626;
  --primary-dim:   #8f1a1a;
  --secondary:     #2563EB;
  --accent:        #22C55E;
  --gold:          #FBBF24;
  --danger:        #DC2626;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 4px 24px rgba(0,0,0,.45);
  --shadow-lg:     0 16px 56px rgba(0,0,0,.6);
  --red-glow:      0 0 24px rgba(220,38,38,.45);
  --blue-glow:     0 0 24px rgba(37,99,235,.4);
  --green-glow:    0 0 24px rgba(34,197,94,.4);
  --font-pixel:    'Press Start 2P', 'VT323', ui-monospace, 'Courier New', monospace;
  --font-mono:     'VT323', ui-monospace, 'Courier New', monospace;
  --font-ar:       'Noto Kufi Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ar);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, canvas, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── utilities ── */
.hidden { display: none !important; }

/* ── ambient layers ── */
.glow {
  position: fixed; inset: -30% -20% auto -20%; height: 70vh; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(220,38,38,.22), transparent 58%),
    radial-gradient(ellipse at 12% 20%, rgba(37,99,235,.2), transparent 55%);
}
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 60; opacity: .35; mix-blend-mode: overlay;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.05) 0 1px, transparent 1px 3px);
}
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: #26314d; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #35436a; }

/* ── navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 40; height: 62px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 clamp(1rem, 4vw, 2.25rem);
  background: rgba(15,23,42,.82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-mark {
  width: 16px; height: 16px; border-radius: 3px;
  background: linear-gradient(135deg, var(--primary), #7f1d1d);
  box-shadow: var(--red-glow);
}
.brand-text { font-family: var(--font-pixel); font-size: .72rem; letter-spacing: .06em; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-link { color: var(--text-muted); font-size: .88rem; font-weight: 600; transition: color .2s, transform .15s; }
.nav-link:hover { color: var(--text); transform: translateY(-1px); }
.nav-actions { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); transition: all .18s ease;
}
.icon-btn:hover { color: var(--text); background: var(--bg-hover); transform: translateY(-2px); border-color: var(--border-strong); }
.icon-btn .ic-off { display: none; }
.icon-btn[aria-pressed="false"] .ic-on { display: none; }
.icon-btn[aria-pressed="false"] .ic-off { display: block; color: var(--primary); }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.35rem; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-ar); font-size: .92rem; font-weight: 700;
  color: var(--text); background: var(--bg-card);
  transition: transform .15s ease, box-shadow .18s ease, background .18s ease, opacity .18s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm { padding: .48rem 1rem; font-size: .8rem; }
.btn-lg { padding: .85rem 2.1rem; font-size: 1rem; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #991b1b); box-shadow: 0 6px 26px rgba(220,38,38,.35); }
.btn-primary:hover { box-shadow: 0 12px 38px rgba(220,38,38,.5); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border-strong); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* ── hero ── */
.hero {
  position: relative; z-index: 1;
  max-width: 1240px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1rem, 3vw, 2rem);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 520px); gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}
.hero h1 { font-size: clamp(1.9rem, 4.4vw, 3.1rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-bottom: .9rem; }
.neon-red { color: var(--primary); text-shadow: 0 0 18px rgba(220,38,38,.7), 0 0 42px rgba(220,38,38,.35); font-family: var(--font-pixel); font-size: .78em; letter-spacing: 0; }
.hero-copy > p { color: var(--text-muted); font-size: 1.02rem; max-width: 54ch; }
.hero-badge {
  display: inline-flex; align-items: center; gap: .45rem; margin-bottom: 1rem;
  padding: .35rem .8rem; border-radius: 999px; border: 1px solid rgba(34,197,94,.35);
  background: rgba(34,197,94,.1); color: var(--accent);
  font-size: .74rem; font-weight: 700; letter-spacing: .04em;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: .7rem; margin: 1.6rem 0 1.4rem; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 1.6rem; }
.hero-stats .stat dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.hero-stats .stat dd { font-family: var(--font-pixel); font-size: .72rem; color: var(--accent); margin-top: .3rem; }

/* ── game stage ── */
.stage-wrap { position: relative; }
.stage {
  position: relative; padding: .75rem; border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(37,99,235,.12), rgba(220,38,38,.1)), var(--bg-deep);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255,255,255,.04);
}
.hud { display: flex; flex-direction: column; gap: .5rem; padding: .35rem .35rem .6rem; }
.hud-main { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; }
.hud-block { display: flex; flex-direction: column; gap: .2rem; }
.hud-label { font-size: .62rem; letter-spacing: .12em; color: var(--text-muted); text-transform: uppercase; }
.hud-value { font-family: var(--font-pixel); font-size: 1.1rem; color: var(--text); text-shadow: var(--red-glow); }
.hud-value.small { font-size: .78rem; color: var(--accent); text-shadow: var(--green-glow); }
.hud-sub { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .22rem .6rem; border-radius: 999px;
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  font-size: .74rem; font-weight: 700; color: var(--text-muted);
}
.chip b { font-family: var(--font-pixel); font-size: .68rem; color: var(--text); }
.chip-coin { color: var(--gold); border-color: rgba(251,191,36,.3); }
.chip-combo { color: var(--accent); border-color: rgba(34,197,94,.3); font-family: var(--font-pixel); font-size: .68rem; }
.chip-combo.hot { animation: pulse .4s ease infinite alternate; }
.lives { display: inline-flex; gap: .2rem; margin-inline-start: auto; }
.lives i { width: 12px; height: 12px; border-radius: 2px; background: var(--primary); box-shadow: var(--red-glow); }
.lives i.gone { background: #2b3350; box-shadow: none; }

.canvas-frame {
  position: relative; width: 100%; max-width: min(100%, calc(68vh * 2 / 3));
  margin-inline: auto; aspect-ratio: 2 / 3; overflow: hidden;
  border-radius: var(--radius); background: #05070d;
  border: 1px solid var(--border);
}
#game-canvas { width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.nitro-wrap { position: absolute; top: .6rem; inset-inline-end: .6rem; width: 96px; }
.nitro-label { font-family: var(--font-pixel); font-size: .48rem; color: var(--secondary); letter-spacing: .1em; }
.nitro-bar {
  margin-top: .3rem; height: 10px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.1); border: 1px solid var(--border-strong);
}
.nitro-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--secondary), #60a5fa);
  box-shadow: var(--blue-glow); transition: width .12s linear;
}
.nitro-bar i.full { background: linear-gradient(90deg, var(--accent), #86efac); box-shadow: var(--green-glow); }
.speedo {
  position: absolute; bottom: .6rem; inset-inline-start: .7rem;
  display: flex; align-items: baseline; gap: .3rem;
  font-family: var(--font-pixel); font-size: 1rem; color: var(--accent);
  text-shadow: var(--green-glow);
}
.speedo small { font-family: var(--font-ar); font-size: .6rem; color: var(--text-muted); }
.banner {
  position: absolute; top: 42%; inset-inline: 0; text-align: center;
  font-family: var(--font-pixel); font-size: 1.05rem; color: var(--gold);
  text-shadow: 0 0 20px rgba(251,191,36,.7); opacity: 0; pointer-events: none;
}
.banner.show { animation: bannerPop 1.6s ease forwards; }
@keyframes bannerPop {
  0% { opacity: 0; transform: scale(.7); }
  18% { opacity: 1; transform: scale(1.05); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1) translateY(-14px); }
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

/* ── overlay screens ── */
.screen {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem;
  padding: 1.4rem; text-align: center;
  background: linear-gradient(180deg, rgba(5,7,13,.9), rgba(5,7,13,.96));
  backdrop-filter: blur(3px);
  animation: fadeUp .28s ease;
}
.screen.hidden { display: none; }
.screen-title { font-family: var(--font-pixel); font-size: 1.05rem; letter-spacing: .04em; }
.screen-title.danger { color: var(--primary); text-shadow: var(--red-glow); }
.screen-sub { color: var(--text-muted); font-size: .86rem; }
.screen-note { color: var(--text-muted); font-size: .74rem; max-width: 34ch; }
.screen-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.pills { display: flex; gap: .3rem; padding: .25rem; border-radius: 999px; background: var(--bg-card); border: 1px solid var(--border); }
.pill {
  padding: .42rem 1.05rem; border: none; border-radius: 999px; background: transparent;
  color: var(--text-muted); font-weight: 700; font-size: .84rem; transition: all .2s ease;
}
.pill:hover { color: var(--text); }
.pill.active { background: linear-gradient(135deg, var(--primary), #991b1b); color: #fff; box-shadow: 0 4px 18px rgba(220,38,38,.4); }
.keys-hint { display: flex; flex-wrap: wrap; gap: .9rem; justify-content: center; list-style: none; margin-top: .3rem; }
.keys-hint li { display: flex; align-items: center; gap: .3rem; font-size: .74rem; color: var(--text-muted); }
kbd {
  font-family: var(--font-pixel); font-size: .58rem; padding: .3rem .42rem; border-radius: 4px;
  background: #1b2540; border: 1px solid var(--border-strong); border-bottom-width: 3px; color: var(--text);
}

/* ── result / record / boot ── */
.result-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; width: 100%; max-width: 300px;
}
.result-cell { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem .6rem; text-align: start; }
.result-cell span { display: block; font-size: .66rem; color: var(--text-muted); }
.result-cell b { font-family: var(--font-pixel); font-size: .78rem; color: var(--accent); }
.record-box { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: .35rem; }
.record-box.hidden { display: none; }
.record-box label { font-size: .72rem; font-weight: 700; color: var(--gold); }
input#player-name {
  width: 100%; padding: .6rem .8rem; text-align: center; font-family: var(--font-ar); font-weight: 700;
  color: var(--text); background: rgba(255,255,255,.07); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); outline: none; transition: border-color .2s, box-shadow .2s;
}
input#player-name:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
input#player-name.error { border-color: var(--primary); }
.field-error { font-size: .7rem; color: var(--primary); }
.field-error.hidden { display: none; }
.boot { width: 74%; display: flex; flex-direction: column; gap: .5rem; }
.skeleton {
  height: 12px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
.skeleton.bar.short { width: 55%; }
.boot-text { font-family: var(--font-pixel); font-size: .6rem; color: var(--text-muted); margin-top: .8rem; }
.dots { animation: blink 1s steps(2, start) infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.fade-up { animation: fadeUp .5s ease both; }
.delay-1 { animation-delay: .1s; }

/* ── touch controls + stage foot ── */
.touch-controls { display: none; gap: .5rem; padding: .6rem .35rem 0; }
.tbtn {
  flex: 1; height: 58px; display: flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text);
  background: var(--bg-card); font-family: var(--font-pixel); font-size: .6rem;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: background .12s ease, transform .1s ease;
}
.tbtn:active, .tbtn.press { background: rgba(220,38,38,.28); transform: scale(.97); }
.tbtn-boost { flex: 1.3; color: var(--accent); border-color: rgba(34,197,94,.4); }
.tbtn-boost:active, .tbtn-boost.press { background: rgba(34,197,94,.25); }
.stage-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem .35rem 0; }
.sound-row { display: flex; align-items: center; gap: .45rem; font-size: .74rem; color: var(--text-muted); }
.sound-row .sep { opacity: .4; }
.sound-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: var(--green-glow); }
.sound-row .dot.off { background: #2b3350; box-shadow: none; }
.mini-actions { display: flex; gap: .4rem; }

/* ── generic sections ── */
.section { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: clamp(2rem, 5vw, 3.5rem) clamp(1rem, 3vw, 2rem); }
.section-head { margin-bottom: 1.6rem; max-width: 62ch; }
.section-head h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: .4rem; }
.section-head p { color: var(--text-muted); font-size: .95rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(12px); padding: 1.25rem;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card.lift:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.card h3 { font-size: 1rem; margin-bottom: .45rem; }
.card p { color: var(--text-muted); font-size: .88rem; }
.card .muted { color: #6f7b95; font-size: .8rem; margin-top: .4rem; }
.card-icon {
  width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: .8rem;
  border-radius: var(--radius-sm); color: var(--primary);
  background: rgba(220,38,38,.12); border: 1px solid rgba(220,38,38,.28);
}

/* ── leaderboard ── */
.board { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; backdrop-filter: blur(12px); }
.tabs { display: flex; gap: .25rem; padding: .25rem; margin-bottom: 1rem; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--border); overflow-x: auto; }
.tab {
  flex: 1 0 auto; padding: .45rem 1rem; border: none; border-radius: 999px; background: transparent;
  color: var(--text-muted); font-size: .82rem; font-weight: 700; transition: all .2s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--secondary), #1d4ed8); color: #fff; box-shadow: 0 4px 18px rgba(37,99,235,.35); }
.board-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.board-table th {
  text-align: start; padding: .5rem .6rem; font-size: .68rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.board-table td { padding: .55rem .6rem; border-bottom: 1px solid rgba(255,255,255,.05); }
.board-table tbody tr { transition: background .18s ease; animation: fadeUp .3s ease both; }
.board-table tbody tr:hover { background: rgba(255,255,255,.045); }
.board-table td.rank { font-family: var(--font-pixel); font-size: .62rem; color: var(--text-muted); }
.board-table td.score { font-family: var(--font-pixel); font-size: .68rem; color: var(--accent); }
.board-table tr.top td.rank { color: var(--gold); }
.board-table tr.top { background: rgba(251,191,36,.05); }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.badge.easy { background: rgba(34,197,94,.14); color: var(--accent); }
.badge.normal { background: rgba(37,99,235,.16); color: #8fb4ff; }
.badge.hard { background: rgba(220,38,38,.16); color: #fca5a5; }
.board-foot { display: flex; justify-content: flex-end; margin-top: .9rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: .88rem; display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.empty.hidden { display: none; }

/* ── tips ── */
.tips { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tip {
  display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04); border: 1px solid var(--border); font-size: .88rem; color: var(--text-muted);
  transition: transform .18s ease, border-color .18s ease;
}
.tip:hover { transform: translateX(-3px); border-color: var(--border-strong); }
.tip b { color: var(--text); }
.tip-num { font-family: var(--font-pixel); font-size: .62rem; color: var(--primary); padding-top: .25rem; }

/* ── footer ── */
.footer { position: relative; z-index: 1; text-align: center; padding: 2.5rem 1.25rem 3.5rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .84rem; }
.footer-title { font-family: var(--font-pixel); font-size: .8rem; color: var(--primary); margin-bottom: .6rem; text-shadow: var(--red-glow); }
.footer p { max-width: 58ch; margin: 0 auto .5rem; }
.footer-meta { font-size: .78rem; opacity: .8; }

/* ── toasts ── */
.toast-wrap { position: fixed; bottom: 1.25rem; inset-inline-start: 1.25rem; z-index: 70; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  padding: .65rem 1.05rem; border-radius: var(--radius-sm); font-size: .84rem; font-weight: 600;
  background: var(--bg-panel); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease both; max-width: 78vw;
}
.toast.success { border-color: rgba(34,197,94,.45); color: var(--accent); }
.toast.error { border-color: rgba(220,38,38,.5); color: #fca5a5; }
.toast.info { border-color: rgba(37,99,235,.45); color: #8fb4ff; }
.toast.out { animation: fadeOut .3s ease forwards; }
@keyframes fadeOut { to { opacity: 0; transform: translateY(8px); } }

/* ── responsive ── */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .stage-wrap { max-width: 520px; margin-inline: auto; }
  .nav-links { display: none; }
}
@media (max-width: 640px) {
  .navbar { height: 56px; }
  .brand-text { font-size: .62rem; }
  #btn-play-top { display: none; }
  .hero { padding-top: 1.25rem; }
  .touch-controls { display: flex; }
  .hud-value { font-size: .95rem; }
  .nitro-wrap { width: 78px; }
  .result-grid { max-width: 260px; }
  .stage { padding: .5rem; }
  .board-table { font-size: .78rem; }
  .board-table th:nth-child(5), .board-table td:nth-child(5) { display: none; }
  .toast-wrap { inset-inline: 1rem; }
}
@media (hover: none) {
  .touch-controls { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fade-up, .screen, .board-table tbody tr, .toast, .banner.show { animation: none !important; }
  .card.lift:hover, .btn:hover, .tip:hover { transform: none; }
  .scanlines { display: none; }
}
body.reduce-motion .scanlines { display: none; }
body.reduce-motion .banner.show { animation: none; opacity: 1; }
