@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/rubik-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/rubik-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../assets/fonts/rubik-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../assets/fonts/rubik-900.woff2') format('woff2');
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #0a0620;
  --panel: #150e33;
  --panel-border: rgba(140,120,255,0.28);
  --accent: #2fe4ff;
  --accent2: #ff6bd8;
  --text: #f3f0ff;
  --text-dim: #a79fd6;
  color-scheme: dark;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

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

.top-controls {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 70;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(20,14,50,0.7);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(0.92); }

#hud {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 10px;
  z-index: 50;
}
.hud-row { display: flex; gap: 10px; }
.hud-row.small { justify-content: center; margin: 10px 0; }
.hud-stat {
  background: rgba(20,14,50,0.7);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 64px;
  text-align: center;
  backdrop-filter: blur(6px);
}
.hud-label { display: block; font-size: 10px; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 600; }
.hud-value { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-value.pulse { animation: pulse 0.5s ease infinite; color: #ff6b6b; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.near-miss {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  background: linear-gradient(135deg, #ff6bd8, #b46bff);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  box-shadow: 0 0 24px rgba(255,107,216,0.6);
  animation: floatIn 0.3s ease;
}
@keyframes floatIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(60,30,120,0.55), rgba(4,2,14,0.92));
  backdrop-filter: blur(4px);
  padding: 16px;
  overflow-y: auto;
}

.menu-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-height: 92vh;
  overflow-y: auto;
}

.logo { line-height: 1; margin-bottom: 4px; }
.logo-word {
  display: block;
  font-weight: 900;
  font-size: 34px;
  letter-spacing: 0.03em;
}
.logo-color { color: var(--accent); text-shadow: 0 0 18px rgba(47,228,255,0.55); }
.logo-collapse { color: var(--accent2); text-shadow: 0 0 18px rgba(255,107,216,0.55); }
.tagline { color: var(--text-dim); margin: 4px 0 18px; font-size: 13px; }

.mode-tabs, .lb-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.mode-tab, .lb-tab {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
}
.mode-tab.active, .lb-tab.active {
  background: linear-gradient(135deg, rgba(47,228,255,0.25), rgba(180,107,255,0.25));
  color: var(--text);
  border-color: var(--accent);
}
.mode-desc { color: var(--text-dim); font-size: 12px; min-height: 32px; margin: 4px 0 16px; }

.btn-primary {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #0a0620;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47,228,255,0.35);
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  width: 100%;
  padding: 11px;
  margin-top: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:active { transform: scale(0.97); }

.menu-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.menu-stats strong { color: var(--text); font-size: 16px; }
.streak-badge {
  background: rgba(255,176,32,0.15);
  border: 1px solid rgba(255,176,32,0.4);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.nickname-badge {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nickname-badge:active { transform: scale(0.95); }

.menu-links { margin-top: 12px; }

.ad-slot { min-height: 50px; margin-top: 16px; opacity: 0.5; }

h2 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }

.howto-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0;
}
.howto-swatch.r { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg,#ff7a9c,#ff3b6b); box-shadow: 0 0 12px rgba(255,59,107,0.6); }
.howto-arrow { font-size: 12px; color: var(--text-dim); }
.howto-boom { font-size: 22px; }
.howto-list { text-align: left; font-size: 13px; line-height: 1.6; color: var(--text-dim); padding-left: 18px; margin: 0 0 18px; }
.howto-list strong { color: var(--text); }

.skins-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.skin-item {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 6px;
  cursor: pointer;
  background: rgba(255,255,255,0.03);
  position: relative;
}
.skin-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,228,255,0.3); }
.skin-item.locked { opacity: 0.55; cursor: not-allowed; }
.skin-swatch-row { display: flex; justify-content: center; gap: 2px; margin-bottom: 6px; }
.skin-dot { width: 9px; height: 9px; border-radius: 50%; }
.skin-name { font-size: 11px; font-weight: 700; }
.skin-lock { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.lb-list { max-height: 300px; overflow-y: auto; margin: 10px 0; text-align: left; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 13px; }
.lb-rank { width: 26px; font-weight: 800; color: var(--text-dim); }
.lb-rank.top1 { color: #ffd166; }
.lb-rank.top2 { color: #c9d6ff; }
.lb-rank.top3 { color: #ffb37a; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-loading, .lb-empty { color: var(--text-dim); text-align: center; padding: 20px 0; font-size: 13px; }

.nickname-input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 15px;
  text-align: center;
  margin: 10px 0 6px;
}
.nickname-hint { font-size: 11px; color: var(--text-dim); margin: 0 0 14px; }
.nickname-error { font-size: 12px; font-weight: 700; color: #ff6b8a; margin: -8px 0 14px; }

.final-score {
  font-size: 46px;
  font-weight: 900;
  margin: 10px 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.new-best-tag {
  display: inline-block;
  background: rgba(255,209,102,0.15);
  border: 1px solid rgba(255,209,102,0.5);
  color: #ffd166;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 10px;
}
.go-actions { display: flex; gap: 8px; margin-top: 10px; }
.go-actions .btn-primary, .go-actions .btn-secondary { margin-top: 0; }

.achievement-toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(20,14,50,0.92);
  border: 1px solid rgba(255,209,102,0.5);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toastIn 0.35s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.ach-icon { font-size: 22px; }
.ach-title { font-size: 10px; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; }
.ach-name { font-size: 14px; font-weight: 800; color: #ffd166; }

.seo-content {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 400px) {
  .logo-word { font-size: 28px; }
  .final-score { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .streak-badge, .near-miss, .achievement-toast { animation: none; }
}
