/* Dash Through — Game CMB. Neon cyber reflex theme. */
:root {
  --bg: #05060f;
  --bg-2: #0b0e24;
  --panel: rgba(11, 13, 34, 0.9);
  --panel-line: rgba(120, 140, 255, 0.22);
  --text: #eef0ff;
  --muted: #9aa3d6;
  --cyan: #35f2ff;
  --pink: #ff3fa4;
  --violet: #8a5cff;
  --purple: #b26bff;
  --gold: #ffd23b;
  --orange: #ff7a3b;
  --lime: #9dff3a;
  --header-h: 52px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

/* The one rule that keeps every hidden overlay/button really hidden. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #17123d 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
}
a { color: var(--cyan); }
kbd {
  font: 700 0.78em/1 var(--font);
  padding: 0.2em 0.45em;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.07);
}
.skip-link { position: absolute; left: -999px; top: 0; }
.skip-link:focus { left: 8px; top: 8px; z-index: 50; background: #000; padding: 6px 10px; }

/* ---------- Site header ---------- */
.site-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 max(16px, var(--safe-left)) 0 max(16px, var(--safe-left));
  max-width: 1100px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: 0.04em; white-space: nowrap; }
.brand-mark { color: var(--pink); text-shadow: 0 0 10px var(--pink); }
.site-nav { display: flex; gap: 16px; font-size: 0.9rem; white-space: nowrap; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--text); }

/* ---------- Ads (empty until AdSense fills them) ---------- */
.ad-slot { max-width: 1100px; margin: 0 auto; text-align: center; }
.ad-slot:empty { display: none; }
.ad-bottom { margin-top: 24px; }

/* ---------- Stage ---------- */
.game-wrap { max-width: 1100px; margin: 0 auto; padding: 0 0 8px; }
.stage {
  position: relative;
  width: 100%;
  height: min(calc(100vh - var(--header-h) - 8px), 860px);
  height: min(calc(100svh - var(--header-h) - 8px), 860px);
  min-height: 480px;
  overflow: hidden;
  background: #040512;
  border-radius: 18px;
  border: 1px solid var(--panel-line);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 30px 80px rgba(20, 10, 60, 0.55), inset 0 0 60px rgba(60, 40, 160, 0.15);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.stage:fullscreen { border-radius: 0; height: 100%; max-height: none; border: 0; }
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
  cursor: pointer;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 3;
  text-shadow: 0 0 12px rgba(53, 242, 255, 0.55);
}
.hud-label { display: block; font: 700 0.68rem/1 var(--font); letter-spacing: 0.24em; color: var(--muted); }
.hud-value { display: block; font: 800 2rem/1.05 var(--font-display); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.hud-combo { display: flex; align-items: baseline; gap: 8px; opacity: 0; transition: opacity 0.2s; }
.hud-combo.is-on { opacity: 1; }
.combo-mult { font: 900 1.25rem/1 var(--font-display); color: var(--gold); text-shadow: 0 0 14px rgba(255, 210, 59, 0.8); }
.combo-count { font: 700 0.72rem/1 var(--font); letter-spacing: 0.18em; color: #ffe9a3; }
.hud-combo.bump .combo-mult { animation: bump 0.25s ease-out; }
@keyframes bump { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }

.icon-row {
  position: absolute;
  top: calc(10px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  display: flex;
  gap: 8px;
  z-index: 6;
}
.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 12, 30, 0.55);
  backdrop-filter: blur(6px);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.icon-btn:hover { border-color: rgba(53, 242, 255, 0.6); }
.icon-btn:focus-visible, .btn:focus-visible, .tab:focus-visible, .close-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.icon-btn .off { display: none; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.icon-btn[aria-pressed="false"] .on { display: none; }
.icon-btn[aria-pressed="false"] .off { display: inline; }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(60px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(5, 6, 20, 0.45), rgba(3, 4, 14, 0.82));
}
.overlay-menu { background: linear-gradient(180deg, rgba(4, 5, 16, 0.25), rgba(4, 5, 16, 0.72)); }
.overlay-ready { background: transparent; pointer-events: none; flex-direction: column; gap: 10px; }
.overlay-loading { flex-direction: column; background: var(--bg); }
.overlay-modal { z-index: 8; background: rgba(3, 4, 14, 0.8); }
.loading-text { color: var(--muted); letter-spacing: 0.3em; font-size: 0.8rem; }

.card, .menu-card {
  width: min(420px, 100%);
  margin: auto;
  text-align: center;
}
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 20px;
  padding: 22px 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.card h2 { margin: 0 0 12px; font: 900 1.35rem/1.1 var(--font-display); letter-spacing: 0.14em; }

.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.88; font-family: var(--font-display); font-weight: 900; font-style: italic; letter-spacing: 0.02em; }
.logo span { display: block; font-size: clamp(3rem, 12vw, 4.6rem); }
.logo span:first-child {
  background: linear-gradient(90deg, #7ff8ff, var(--cyan) 40%, #8a5cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(53, 242, 255, 0.55));
}
.logo span:last-child {
  background: linear-gradient(90deg, var(--pink), #ff8ad0 60%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 63, 164, 0.55));
  transform: translateX(0.35em);
}
.logo-sm span { font-size: 2.6rem; }
.tagline { margin: 14px 0 22px; font-weight: 800; letter-spacing: 0.42em; font-size: 0.8rem; color: #cfd5ff; }
.hint { margin: 14px 0 4px; color: var(--muted); font-size: 0.85rem; }
.best-line { margin: 6px 0 18px; letter-spacing: 0.2em; font-size: 0.8rem; color: var(--muted); }
.best-line strong { color: var(--gold); font-size: 1.05rem; letter-spacing: 0.04em; margin-left: 6px; }
.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.btn {
  font: 800 0.95rem/1 var(--font);
  letter-spacing: 0.08em;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  padding: 12px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: rgba(53, 242, 255, 0.6); }
.btn:active { transform: scale(0.97); }
.btn svg { width: 1.2em; height: 1.2em; fill: currentColor; }
.btn-play {
  width: 100%;
  max-width: 300px;
  font-size: 1.3rem;
  padding: 16px 20px;
  color: #041017;
  border: 0;
  background: linear-gradient(90deg, #35f2ff, #7c8bff 55%, #ff3fa4);
  box-shadow: 0 0 28px rgba(53, 242, 255, 0.45), 0 0 50px rgba(255, 63, 164, 0.25);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 40px rgba(53, 242, 255, 0.7), 0 0 70px rgba(255, 63, 164, 0.4); } }
.btn-ghost { background: rgba(255, 255, 255, 0.05); font-weight: 700; letter-spacing: 0.03em; }
.btn-small { min-height: 44px; padding: 10px 14px; background: var(--cyan); color: #041017; border: 0; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; color: var(--cyan); text-decoration: underline; cursor: pointer; font: inherit; }
.close-btn {
  position: absolute; top: 8px; right: 10px;
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); font-size: 1.8rem; line-height: 1; cursor: pointer;
}
.close-btn:hover { color: var(--text); }
.card-pause .btn { width: 100%; max-width: none; margin-top: 10px; }
.badge { font-size: 0.62rem; padding: 3px 6px; border-radius: 6px; background: var(--pink); color: #fff; letter-spacing: 0.08em; }
.trail-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px currentColor; display: inline-block; }

/* Ready */
.ready-text { font: 900 italic clamp(2.6rem, 10vw, 4rem)/1 var(--font-display); letter-spacing: 0.08em; color: #fff; text-shadow: 0 0 24px var(--cyan), 0 0 50px var(--violet); animation: readyIn 0.4s ease-out; }
.ready-text.go { color: var(--gold); text-shadow: 0 0 24px var(--gold), 0 0 60px var(--pink); }
.ready-hint { color: #cfd5ff; font-weight: 700; letter-spacing: 0.08em; font-size: 0.85rem; text-align: center; padding: 0 20px; text-shadow: 0 2px 8px #000; }
@keyframes readyIn { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Game over */
.over-title { color: var(--pink); text-shadow: 0 0 18px rgba(255, 63, 164, 0.7); }
.over-score { font: 900 clamp(2.8rem, 12vw, 3.8rem)/1 var(--font-display); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; text-shadow: 0 0 20px rgba(53, 242, 255, 0.6); }
.over-badge { display: inline-block; margin-top: 8px; padding: 5px 12px; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--orange)); color: #1a0d00; font-weight: 900; letter-spacing: 0.14em; font-size: 0.8rem; animation: bump 0.5s ease-out; }
.over-best { margin: 8px 0 12px; color: var(--muted); letter-spacing: 0.2em; font-size: 0.78rem; }
.over-best strong { color: var(--gold); letter-spacing: 0.03em; font-size: 1rem; margin-left: 6px; }
.over-stats { list-style: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 0 0 12px; padding: 10px 4px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.over-stats li { display: flex; flex-direction: column; gap: 2px; font-weight: 800; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.over-stats small { font-weight: 600; font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.over-rank { min-height: 1.3em; margin: 0 0 8px; font-weight: 700; color: var(--cyan); }
.over-rank.warn { color: var(--gold); }
.over-unlock { min-height: 1.2em; margin: 6px 0 12px; font-size: 0.82rem; color: var(--muted); }
.over-unlock b { color: var(--text); }
.over-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.over-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.card-over.locked .over-actions { pointer-events: none; }

.nick-form { margin: 4px 0 6px; text-align: left; }
.nick-form label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; text-align: center; }
.nick-row { display: flex; gap: 8px; }
.nick-row input {
  flex: 1; min-width: 0; min-height: 44px;
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.35); color: var(--text);
  padding: 0 12px; font: 700 1rem var(--font);
}
.nick-row input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.nick-msg { min-height: 1.1em; margin: 6px 0 0; font-size: 0.8rem; color: var(--pink); text-align: center; }
.nick-msg.ok { color: var(--lime); }
.nick-saved { margin: 2px 0 4px; font-size: 0.85rem; color: var(--muted); }

/* Leaderboard */
.card-board { max-height: 100%; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.tab { flex: 1; min-height: 38px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.14); background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.is-active { background: rgba(53, 242, 255, 0.14); color: var(--text); border-color: rgba(53, 242, 255, 0.5); }
.board-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: min(50vh, 420px); text-align: left; }
.board-list li { display: grid; grid-template-columns: 38px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.board-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.035); }
.board-list li.me { background: rgba(53, 242, 255, 0.16); outline: 1px solid rgba(53, 242, 255, 0.5); }
.board-list .rk { font-weight: 900; color: var(--muted); }
.board-list li:nth-child(1) .rk { color: var(--gold); }
.board-list li:nth-child(2) .rk { color: #d9e2ff; }
.board-list li:nth-child(3) .rk { color: #ff9f6b; }
.board-list .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .sc { font-weight: 900; color: var(--cyan); }
.board-status { min-height: 1.2em; margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; }

/* Help */
.help-list { text-align: left; padding-left: 1.1em; margin: 0 0 16px; display: grid; gap: 8px; font-size: 0.92rem; }
.h-cyan { color: var(--cyan); } .h-pink { color: var(--pink); } .h-violet { color: var(--purple); }
.h-orange { color: var(--orange); } .h-purple { color: #c58bff; } .h-gold { color: var(--gold); }

/* Trails */
.muted { color: var(--muted); font-size: 0.85rem; margin: -4px 0 12px; }
.trail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.trail-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04); color: var(--text); cursor: pointer; font: 700 0.78rem/1.2 var(--font);
  min-height: 108px;
}
.trail-card .sw { width: 34px; height: 34px; border-radius: 50%; }
.trail-card small { font-weight: 600; color: var(--muted); font-size: 0.66rem; }
.trail-card.is-locked { cursor: default; opacity: 0.55; }
.trail-card.is-locked .sw { filter: grayscale(1) brightness(0.6); }
.trail-card.is-selected { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(53, 242, 255, 0.3); }

/* Toast / notice */
.toast {
  position: absolute; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 9; padding: 10px 16px; border-radius: 12px; background: rgba(12, 14, 36, 0.95);
  border: 1px solid rgba(255, 210, 59, 0.6); color: var(--text); font-weight: 700; font-size: 0.88rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); max-width: calc(100% - 32px); text-align: center;
}
.notice { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 9; padding: 8px 12px; border-radius: 10px; background: rgba(255, 63, 164, 0.18); border: 1px solid var(--pink); font-size: 0.8rem; text-align: center; }

/* ---------- SEO article ---------- */
.seo { max-width: 820px; margin: 28px auto 0; padding: 0 16px; color: #d6dbff; }
.seo h1 { font: 900 clamp(1.5rem, 4vw, 2.1rem)/1.2 var(--font-display); color: var(--text); margin: 0 0 12px; }
.seo h2 { font: 800 1.3rem/1.3 var(--font-display); color: var(--text); margin: 30px 0 10px; }
.seo .lead { font-size: 1.05rem; }
.seo li { margin-bottom: 6px; }
.grid-list { columns: 2 280px; column-gap: 28px; }
.faq details { border: 1px solid var(--panel-line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; background: rgba(255, 255, 255, 0.02); }
.faq summary { cursor: pointer; font-weight: 700; color: var(--text); }
.faq p { margin: 8px 0 2px; }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; padding: 0; list-style: none; }
.related li { padding: 10px 12px; border: 1px solid var(--panel-line); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.site-footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 30px 16px calc(30px + var(--safe-bottom)); }
.noscript { text-align: center; padding: 20px; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  :root { --header-h: 46px; }
  .site-header { padding: 0 12px; }
  .site-nav a[href="#how-to-play"] { display: none; }
  .game-wrap { padding: 0; }
  .stage { border-radius: 0; border-left: 0; border-right: 0; min-height: 440px; }
  .hud-value { font-size: 1.6rem; }
  .icon-btn { width: 40px; height: 40px; }
  .over-stats { grid-template-columns: repeat(3, 1fr); row-gap: 8px; }
  .card { padding: 18px 14px 16px; }
  .menu-actions .btn { flex: 1 1 40%; padding: 10px 8px; font-size: 0.85rem; }
}
@media (max-height: 620px) {
  .tagline { margin: 8px 0 12px; }
  .overlay { padding-top: calc(54px + var(--safe-top)); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-play { animation: none; }
  .ready-text { animation: none; }
}
