/* ─────────  NEON DRIFT · design tokens  ───────── */
:root {
  --bg: #070b14;
  --bg-2: #0F172A;
  --surface: rgba(255,255,255,.05);
  --surface-2: rgba(255,255,255,.09);
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.18);
  --text: #ffffff;
  --text-muted: #8b93a7;
  --primary: #DC2626;
  --primary-soft: rgba(220,38,38,.16);
  --secondary: #2563EB;
  --secondary-soft: rgba(37,99,235,.16);
  --accent: #22C55E;
  --accent-soft: rgba(34,197,94,.14);
  --warning: #fbbf24;
  --danger: #DC2626;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 4px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 60px rgba(0,0,0,.6);
  --font-display: 'Orbitron', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --font-ui: 'Segoe UI', 'Noto Sans Arabic', 'Tahoma', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(220,38,38,.20), transparent 62%),
    radial-gradient(ellipse 60% 45% at 12% 108%, rgba(37,99,235,.20), transparent 60%),
    radial-gradient(ellipse 55% 40% at 92% 96%, rgba(34,197,94,.12), transparent 60%);
}

.glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 50%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 20%, transparent 78%);
}

.stage {
  position: relative; z-index: 1;
  width: 100%; height: 100dvh;
  overflow: hidden;
}

#game {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none; cursor: crosshair;
}

/* ─────────  HUD  ───────── */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; padding: 1.1rem clamp(.9rem, 3vw, 2rem);
  pointer-events: none;
}
.hud-block { display: flex; flex-direction: column; gap: .1rem; }
.hud-center { align-items: center; }
.hud-end { align-items: flex-end; }
.hud-label {
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .16em;
  color: var(--text-muted); text-transform: uppercase;
}
.hud-value {
  font-family: var(--font-display); font-size: clamp(1.4rem, 4.4vw, 2.3rem);
  font-weight: 900; line-height: 1; letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255,255,255,.25);
}
#score { color: var(--accent); text-shadow: 0 0 22px rgba(34,197,94,.5); }
#wave  { color: var(--secondary); text-shadow: 0 0 22px rgba(37,99,235,.6); }
#best  { color: var(--warning); text-shadow: 0 0 22px rgba(251,191,36,.45); }

.meters {
  position: absolute; z-index: 5; top: clamp(4.4rem, 12vw, 5.6rem); left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0 clamp(.9rem, 3vw, 2rem); pointer-events: none;
}
.meter { display: flex; align-items: center; gap: .6rem; }
.meter-label {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .14em;
  color: var(--text-muted); text-transform: uppercase;
}
.bar {
  width: clamp(110px, 34vw, 260px); height: 10px; border-radius: 999px;
  background: rgba(255,255,255,.07); border: 1px solid var(--border);
  overflow: hidden; backdrop-filter: blur(8px);
}
.bar i {
  display: block; height: 100%; width: 100%; transform-origin: right center;
  background: linear-gradient(90deg, #DC2626, #22C55E 62%, #86efac);
  box-shadow: 0 0 16px rgba(34,197,94,.55);
  transition: width .18s ease-out, background .3s ease;
}
.combo {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(1rem, 3vw, 1.35rem);
  color: var(--warning); opacity: .35; transition: opacity .2s, transform .2s;
  text-shadow: 0 0 20px rgba(251,191,36,.4);
}
.combo em {
  font-family: var(--font-ui); font-style: normal; font-size: .7em;
  color: var(--text-muted); font-weight: 500;
}
.combo.hot { opacity: 1; transform: scale(1.12) translateY(-2px); }

/* ─────────  buffs · banner · toasts  ───────── */
.buff-row {
  position: absolute; z-index: 5; left: 0; right: 0;
  bottom: clamp(.8rem, 3vw, 1.6rem); display: flex; justify-content: center;
  gap: .5rem; flex-wrap: wrap; padding: 0 1rem; pointer-events: none;
}
.buff {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--font-mono); font-size: .7rem; font-weight: 500;
  padding: .35rem .7rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(10px); animation: pop .28s ease backwards;
}
.buff.shield { color: #7dd3fc; border-color: rgba(125,211,252,.35); }
.buff.rapid  { color: var(--warning); border-color: rgba(251,191,36,.35); }
.buff.triple { color: #f0abfc; border-color: rgba(240,171,252,.35); }

.banner {
  position: absolute; z-index: 6; top: 42%; left: 50%; transform: translate(-50%,-50%);
  font-family: var(--font-display); font-weight: 900; text-align: center;
  font-size: clamp(1.5rem, 6vw, 3rem); letter-spacing: .04em;
  color: #fff; opacity: 0; pointer-events: none; white-space: nowrap;
  text-shadow: 0 0 30px rgba(37,99,235,.75), 0 0 70px rgba(220,38,38,.45);
}
.banner small {
  display: block; font-family: var(--font-mono); font-size: .22em;
  letter-spacing: .3em; color: var(--text-muted); margin-top: .6rem;
}
.banner.show { animation: bannerIn 1.9s ease forwards; }
.banner.danger { color: #fecaca; text-shadow: 0 0 30px rgba(220,38,38,.9); }

.toast-wrap {
  position: absolute; z-index: 7; bottom: 1.4rem; right: clamp(.9rem, 3vw, 1.6rem);
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-end;
  pointer-events: none;
}
.toast {
  padding: .6rem 1rem; border-radius: var(--radius-sm); font-size: .85rem;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  backdrop-filter: blur(12px); box-shadow: var(--shadow);
  animation: fadeUp .3s ease;
}
.toast.good { color: #bbf7d0; border-color: rgba(34,197,94,.35); }
.toast.bad  { color: #fecaca; border-color: rgba(220,38,38,.4); }

/* ─────────  floating buttons  ───────── */
.controls-fab {
  position: absolute; z-index: 8; top: clamp(7.2rem, 19vw, 8.6rem); left: clamp(.9rem, 3vw, 2rem);
  display: flex; flex-direction: column; gap: .45rem;
}
.fab {
  width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer;
  color: var(--text-muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  backdrop-filter: blur(10px);
  transition: transform .15s ease, color .2s, border-color .2s, box-shadow .2s;
}
.fab svg { width: 18px; height: 18px; }
.fab:hover { color: var(--text); transform: translateY(-2px); border-color: var(--border-strong); box-shadow: 0 10px 26px rgba(0,0,0,.45); }
.fab:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.fab.off { color: #f87171; border-color: rgba(248,113,113,.4); }

/* ─────────  screenshot-style panels  ───────── */
.screen {
  position: absolute; inset: 0; z-index: 9;
  display: none; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: radial-gradient(ellipse at 50% 40%, rgba(7,11,20,.55), rgba(7,11,20,.92));
  backdrop-filter: blur(7px);
}
.screen.show { display: flex; animation: fadeUp .35s ease both; }

.panel {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: clamp(1.4rem, 4.5vw, 2.4rem); text-align: center;
  box-shadow: var(--shadow-lg); position: relative;
}
.panel::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(140deg, rgba(220,38,38,.5), transparent 40%, rgba(37,99,235,.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; padding: 1px;
}
.badge {
  display: inline-block; font-family: var(--font-mono); font-size: .64rem;
  letter-spacing: .22em; text-transform: uppercase; color: #fca5a5;
  background: var(--primary-soft); border: 1px solid rgba(220,38,38,.35);
  padding: .3rem .7rem; border-radius: 999px; margin-bottom: 1rem;
}
.badge-red { color: #fecaca; background: rgba(220,38,38,.22); }
.badge[hidden] { display: none; }
.title {
  font-size: clamp(2.1rem, 9vw, 3.4rem); line-height: 1.05; font-weight: 800;
  letter-spacing: -.01em; margin-bottom: .3rem;
  text-shadow: 0 0 26px rgba(220,38,38,.55), 0 0 60px rgba(37,99,235,.35);
}
.title::after {
  content: 'NEON DRIFT'; display: block; font-family: var(--font-display);
  font-weight: 700; font-size: .26em; letter-spacing: .42em;
  color: var(--text-muted); margin-top: .7rem;
}
.panel h2 { font-size: clamp(1.5rem, 6vw, 2.1rem); margin-bottom: .5rem; }
.tagline { color: var(--text-muted); font-size: .95rem; line-height: 1.8; margin-bottom: 1.4rem; }

/* ─────────  buttons · stats · lists  ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.5rem; border-radius: 999px; cursor: pointer;
  font-family: var(--font-ui); font-size: .95rem; font-weight: 700;
  border: 1px solid transparent; text-decoration: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s, color .2s;
}
.btn-primary {
  background: linear-gradient(135deg, #DC2626, #f97316 55%, #22C55E 130%);
  color: #fff; box-shadow: 0 8px 30px rgba(220,38,38,.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 42px rgba(220,38,38,.5); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); transform: translateY(-2px); }
.btn-lg { padding: .9rem 2.4rem; font-size: 1.05rem; width: 100%; max-width: 320px; }
.btn:focus-visible { outline: 2px solid var(--secondary); outline-offset: 3px; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }

.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: .6rem; margin: 1.2rem 0;
}
.stat {
  display: flex; flex-direction: column; gap: .3rem; padding: .7rem .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); backdrop-filter: blur(10px);
}
.stat span { font-size: .68rem; color: var(--text-muted); letter-spacing: .04em; }
.stat strong {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
  color: #fff; font-variant-numeric: tabular-nums;
}
.big-score {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(2.6rem, 13vw, 4.4rem);
  line-height: 1; color: var(--accent); margin: .6rem 0 0;
  text-shadow: 0 0 34px rgba(34,197,94,.5);
  font-variant-numeric: tabular-nums;
}
.controls-list {
  text-align: right; list-style: none; display: grid; gap: .5rem;
  margin: 0 0 1.4rem; font-size: .88rem; color: var(--text-muted);
  line-height: 1.7;
}
.controls-list li {
  padding: .55rem .8rem; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04); border-right: 2px solid var(--secondary);
}
.controls-list b { color: #fff; font-family: var(--font-mono); font-size: .85em; }
.hint {
  margin-top: 1.1rem; font-size: .78rem; color: var(--text-muted); line-height: 1.8;
}
.hint b { color: var(--warning); }

/* ─────────  animations  ───────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
@keyframes bannerIn {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(.8); }
  16%  { opacity: 1; transform: translate(-50%,-50%) scale(1.04); }
  26%  { transform: translate(-50%,-50%) scale(1); }
  76%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.06); }
}

/* ─────────  responsive  ───────── */
@media (max-width: 720px) {
  .hud { padding-top: .8rem; }
  .meters { flex-direction: column; align-items: flex-start; gap: .45rem; }
  .meter { width: 100%; }
  .bar { flex: 1; width: auto; }
  .controls-fab { flex-direction: row; top: auto; bottom: clamp(.8rem, 3vw, 1.4rem); left: 50%; transform: translateX(-50%); }
  .buff-row { bottom: 4.4rem; }
  .toast-wrap { bottom: 4.6rem; }
  .big-score { font-size: clamp(2.4rem, 16vw, 3.4rem); }
}
@media (max-width: 420px) {
  .hud-label { font-size: .55rem; letter-spacing: .1em; }
  .controls-list { font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
