@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:wght@400;500;700&display=swap');

:root {
  --bg: #0c0c14;
  --bg2: #13131f;
  --bg3: #1a1a2a;
  --accent: #f0ff3d;
  --accent-dim: #c8d632;
  --energy: #ff4d6a;
  --energy-dim: #cc3d55;
  --cyan: #3df0ff;
  --text: #eaeaf0;
  --text-dim: #7a7a90;
  --text-muted: #44445a;
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius: 12px;
  --radius-sm: 6px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle gradient mesh background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(240,255,61,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 80%, rgba(255,77,106,0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== LANDING ===== */
.landing {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}

.landing h1 {
  font-family: var(--font-heading);
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 0.9;
  margin-bottom: 0.3rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--cyan) 50%, var(--energy) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing .tagline {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  font-weight: 400;
  color: var(--text-dim);
  margin-bottom: 2.5rem;
  letter-spacing: 0.02em;
}

.mode-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-btn {
  background: var(--bg2);
  border: 1.5px solid var(--bg3);
  color: var(--text-dim);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 100px;
}

.mode-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg3);
}

.mode-btn.active {
  border-color: var(--accent);
  color: var(--bg);
  background: var(--accent);
}

.start-btn {
  position: relative;
  background: var(--energy);
  color: #fff;
  border: none;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1.1rem 3.5rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.25s;
  text-transform: uppercase;
  border-radius: 100px;
  box-shadow: 0 0 30px rgba(255,77,106,0.3), 0 4px 15px rgba(255,77,106,0.2);
}

.start-btn:hover {
  background: var(--energy-dim);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 40px rgba(255,77,106,0.4), 0 8px 25px rgba(255,77,106,0.3);
}

.start-btn:active {
  transform: translateY(0) scale(0.98);
}

.privacy-note {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 340px;
  line-height: 1.5;
}

.privacy-note span { color: var(--cyan); font-weight: 500; }

/* ===== LOADING ===== */
.loading-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

.loading-bar-wrap {
  width: 240px;
  height: 4px;
  background: var(--bg3);
  border-radius: 100px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  transition: width 0.3s ease-out;
  border-radius: 100px;
}

.loading-text {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* ===== GAME ===== */
.game-screen {
  display: none;
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.game-screen video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.game-screen canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ===== SUMMARY ===== */
.summary-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2.5rem 1.5rem;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

.summary-screen h2 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--energy));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  width: 100%;
  max-width: 600px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  padding: 1.25rem 1rem;
  text-align: center;
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--text-muted); }

.stat-card .value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-card:nth-child(3) .value { color: var(--energy); }
.stat-card:nth-child(5) .value { color: var(--energy); }

.stat-card .label {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.charts-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 700px;
  flex-wrap: wrap;
  justify-content: center;
}

.chart-box {
  width: 320px;
  height: 280px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
}

.summary-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.summary-actions button {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.8rem 2rem;
  cursor: pointer;
  border-radius: 100px;
  border: 1.5px solid var(--bg3);
  background: var(--bg2);
  color: var(--text);
  transition: all 0.2s;
}

.summary-actions button:hover {
  border-color: var(--text-muted);
  background: var(--bg3);
}

.summary-actions button.primary {
  background: var(--energy);
  color: #fff;
  border-color: var(--energy);
  box-shadow: 0 0 20px rgba(255,77,106,0.2);
}

.summary-actions button.primary:hover {
  background: var(--energy-dim);
  box-shadow: 0 0 30px rgba(255,77,106,0.3);
}

/* ===== ERROR ===== */
.error-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12,12,20,0.97);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.error-overlay h3 {
  font-family: var(--font-heading);
  color: var(--energy);
  font-size: 1.3rem;
  font-weight: 600;
}

.error-overlay p {
  color: var(--text-dim);
  max-width: 400px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.error-overlay button {
  margin-top: 1rem;
  background: var(--energy);
  color: #fff;
  border: none;
  padding: 0.7rem 2rem;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  border-radius: 100px;
}

/* ===== FOOTER ===== */
footer {
  position: relative;
  z-index: 1;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--bg3);
}

footer a { color: var(--text-dim); margin: 0 0.5rem; }
footer a:hover { color: var(--accent); }

/* ===== STATIC PAGES ===== */
.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.page h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.page h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.page p, .page li {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-dim);
}

.page ul { padding-left: 1.25rem; }
.page li { margin-bottom: 0.5rem; }

.back-link {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.back-link:hover { color: var(--accent); }

/* ===== HISTORY PREVIEW (Landing) ===== */
.history-preview {
  margin-top: 2rem;
  width: 100%;
  max-width: 480px;
}

.hp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hp-item {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
  text-align: center;
}

.hp-val {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
}

.hp-label {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

.hp-best {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
}

.hp-best strong { color: var(--energy); }

/* ===== HISTORY SECTION (Summary) ===== */
.history-section {
  width: 100%;
  max-width: 700px;
  text-align: center;
}

.history-section h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.history-totals {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.ht-item {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.chart-box.wide {
  width: 100%;
  max-width: 700px;
  height: 220px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .mode-selector { flex-direction: column; align-items: center; }
  .mode-btn { width: 200px; text-align: center; }
  .chart-box { width: 100%; }
  .summary-stats { grid-template-columns: repeat(2, 1fr); }
}
