:root {
  --bg: #080912;
  --bg-card: rgba(17, 21, 38, 0.78);
  --bg-card-solid: #111526;
  --border: rgba(124, 148, 255, 0.18);
  --border-bright: rgba(56, 232, 255, 0.45);
  --text: #eef2ff;
  --muted: #94a3c8;
  --cyan: #38e8ff;
  --pink: #ff3e9d;
  --purple: #9d5cff;
  --lime: #43ff9c;
  --amber: #ffbe3b;
  --danger: #ff4f6d;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 232, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 232, 255, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 { top: -160px; left: -120px; background: var(--purple); }
.bg-glow-2 { bottom: -180px; right: -120px; background: var(--cyan); }

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  background: rgba(8, 9, 18, 0.78);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
}

.brand-icon { color: var(--cyan); font-size: 1.25rem; text-shadow: 0 0 12px var(--cyan); }
.brand-text .accent { color: var(--pink); }
.brand-badge {
  font-size: 0.62rem;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(56, 232, 255, 0.12);
  border: 1px solid rgba(56, 232, 255, 0.35);
  color: var(--cyan);
  letter-spacing: 0.14em;
}

.nav-links {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 9px;
  transition: 0.2s ease;
}

.nav-link:hover { color: var(--text); }
.nav-link.active {
  color: #061018;
  background: linear-gradient(135deg, var(--cyan), #72f5ff);
  box-shadow: 0 0 18px rgba(56, 232, 255, 0.35);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.chip-btn, .icon-btn, .btn {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  transition: 0.18s ease;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.chip-btn:hover, .icon-btn:hover { border-color: var(--border-bright); background: rgba(56, 232, 255, 0.1); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px var(--lime); }

.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; font-size: 1rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-color: transparent;
  color: #060914;
  box-shadow: 0 8px 24px rgba(56, 232, 255, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-ghost:hover { border-color: var(--border-bright); background: rgba(255, 255, 255, 0.08); }

/* Main view */
.main-view {
  flex: 1;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.view-enter { animation: viewFade 0.24s ease-out; }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hero */
.hero {
  position: relative;
  padding: 32px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(157, 92, 255, 0.18), rgba(56, 232, 255, 0.08) 55%, rgba(255, 62, 157, 0.12));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.hero-kicker {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  color: var(--cyan);
  margin-bottom: 10px;
}

.hero h1 {
  margin: 0 0 10px;
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(1.6rem, 3.2vw, 2.5rem);
  line-height: 1.15;
}

.hero p { margin: 0; color: var(--muted); max-width: 560px; line-height: 1.6; }

.hero-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-pill {
  background: rgba(8, 9, 18, 0.65);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 112px;
}
.stat-val { font-family: 'Orbitron', sans-serif; font-size: 1.35rem; color: var(--cyan); }
.stat-lbl { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

/* Filter & Section Header */
.section-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-title {
  margin: 0;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.pill.active, .pill:hover { color: var(--text); border-color: var(--cyan); background: rgba(56, 232, 255, 0.12); }

/* Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 18px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-color, var(--cyan));
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.card-banner {
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: radial-gradient(circle at 80% 20%, var(--accent-color, var(--cyan)) 0%, transparent 65%),
              linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(8, 9, 18, 0.85));
  border-bottom: 1px solid var(--border);
}

.card-icon { font-size: 2.6rem; filter: drop-shadow(0 0 14px var(--accent-color, var(--cyan))); }
.card-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(8, 9, 18, 0.7);
  border: 1px solid var(--border);
  color: var(--text);
}

.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.card-title { margin: 0 0 6px; font-family: 'Orbitron', sans-serif; font-size: 1.05rem; }
.card-desc { margin: 0 0 16px; font-size: 0.88rem; color: var(--muted); line-height: 1.5; flex: 1; }
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.card-best strong { color: var(--amber); font-family: 'Orbitron', sans-serif; }
.card-play { color: var(--cyan); font-weight: 700; }

/* Game Stage */
.stage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
  align-items: start;
}

.cabinet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.cabinet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.hud-row { display: flex; gap: 10px; flex-wrap: wrap; }
.hud-box {
  background: rgba(8, 9, 18, 0.8);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 84px;
}
.hud-lbl { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.hud-val { font-family: 'Orbitron', sans-serif; font-size: 1.05rem; color: var(--cyan); }

.stage-wrap {
  position: relative;
  background: #05070e;
  border: 1px solid rgba(56, 232, 255, 0.25);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 440px;
}

.stage-wrap canvas {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  aspect-ratio: 4 / 3;
  touch-action: none;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 14, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 12px;
  z-index: 5;
}
.stage-overlay.hidden { display: none; }
.stage-overlay h2 { margin: 0; font-family: 'Orbitron', sans-serif; font-size: 1.5rem; }
.stage-overlay p { margin: 0; color: var(--muted); max-width: 360px; font-size: 0.92rem; }
.overlay-score { font-family: 'Orbitron', sans-serif; font-size: 2rem; color: var(--amber); }

.touch-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.touch-btn {
  min-width: 56px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.touch-btn:active { background: rgba(56, 232, 255, 0.25); border-color: var(--cyan); }

/* Sidebar panel */
.side-panel { display: flex; flex-direction: column; gap: 16px; }
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.panel-card h3 {
  margin: 0 0 12px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  color: var(--cyan);
}
.panel-card p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }

/* Score list */
.score-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.85rem;
}
.score-rank { font-family: 'Orbitron', sans-serif; width: 26px; color: var(--muted); font-size: 0.78rem; }
.score-row:nth-child(1) .score-rank { color: var(--amber); }
.score-row:nth-child(2) .score-rank { color: #d8e2ff; }
.score-row:nth-child(3) .score-rank { color: #ff9d6e; }
.score-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-pts { font-family: 'Orbitron', sans-serif; color: var(--cyan); }

/* DOM Game Grids (Memory & Whack) */
.dom-board {
  width: 100%;
  max-width: 480px;
  padding: 20px;
  display: grid;
  gap: 10px;
}
.memory-grid { grid-template-columns: repeat(4, 1fr); }
.mem-card {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #161c36, #0d1124);
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  color: transparent;
  user-select: none;
}
.mem-card::after { content: '◈'; color: rgba(56, 232, 255, 0.35); font-size: 1.2rem; }
.mem-card.flipped, .mem-card.matched {
  color: var(--text);
  background: rgba(56, 232, 255, 0.14);
  border-color: var(--cyan);
  transform: scale(1.03);
}
.mem-card.flipped::after, .mem-card.matched::after { content: none; }
.mem-card.matched { border-color: var(--lime); background: rgba(67, 255, 156, 0.16); }

.whack-grid { grid-template-columns: repeat(3, 1fr); max-width: 420px; }
.whack-hole {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 50% 60%, #171e3a, #090c18);
  display: grid;
  place-items: center;
  font-size: 2.3rem;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.12s, box-shadow 0.12s;
  user-select: none;
}
.whack-hole.active-bug { border-color: var(--cyan); box-shadow: inset 0 0 24px rgba(56, 232, 255, 0.35); }
.whack-hole.active-gold { border-color: var(--amber); box-shadow: inset 0 0 26px rgba(255, 190, 59, 0.45); }
.whack-hole.active-bomb { border-color: var(--danger); box-shadow: inset 0 0 26px rgba(255, 79, 109, 0.45); }
.whack-hole:active { transform: scale(0.95); }

/* Leaderboard & About */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
}
.modal-backdrop.hidden { display: none; }
.modal-card {
  width: 100%;
  max-width: 390px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-family: 'Orbitron', sans-serif; font-size: 1rem; }
.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #080a14;
  color: var(--text);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}
.input:focus { outline: none; border-color: var(--cyan); }

.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}
.toast {
  background: #121830;
  border: 1px solid var(--cyan);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: viewFade 0.2s ease;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px;
  color: var(--muted);
  font-size: 0.8rem;
}
.footer-inner {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 880px) {
  .stage-layout { grid-template-columns: 1fr; }
  .brand-badge { display: none; }
}
@media (max-width: 600px) {
  .topbar-inner { flex-wrap: wrap; }
  .nav-links { order: 3; width: 100%; justify-content: center; }
  .hero { padding: 22px; }
}
