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

:root {
  color-scheme: dark;
  --bg: #05020d;
  --bg-soft: #140a22;
  --bg-card: rgba(19, 10, 34, 0.72);
  --panel: rgba(255, 255, 255, 0.055);
  --panel-strong: rgba(255, 255, 255, 0.11);
  --border: rgba(210, 176, 255, 0.18);
  --text: #f8f4ff;
  --text-secondary: #c7b6e1;
  --text-muted: #9d8ab9;
  --accent: #b678ff;
  --accent-2: #5fd1ff;
  --accent-3: #ff79c6;
  --success: #7df4bc;
  --shadow: rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  color: var(--text);
  background:
          radial-gradient(circle at 20% 20%, rgba(182, 120, 255, 0.32), transparent 24%),
          radial-gradient(circle at 82% 16%, rgba(95, 209, 255, 0.24), transparent 22%),
          radial-gradient(circle at 50% 110%, rgba(255, 121, 198, 0.14), transparent 28%),
          linear-gradient(160deg, #1a0d2d 0%, #090410 52%, #030106 100%);
  overflow-x: hidden;
}

#particles-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 13rem;
  height: 13rem;
  top: 5rem;
  right: 12vw;
  background: radial-gradient(circle, rgba(182, 120, 255, 0.34), transparent 68%);
}

body::after {
  width: 15rem;
  height: 15rem;
  bottom: 4rem;
  left: -2rem;
  background: radial-gradient(circle, rgba(95, 209, 255, 0.24), transparent 72%);
}

a { color: inherit; }

/* ============================================
   SIDEBAR / MINI HUB
   ============================================ */

.hub-trigger {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: white;
  font-size: 1.5rem;
  font-family: 'Baloo 2', cursive;
  cursor: pointer;
  z-index: 1100;
  box-shadow: 0 10px 40px rgba(182, 120, 255, 0.45);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.hub-trigger:hover {
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 15px 50px rgba(182, 120, 255, 0.6);
}

.hub-trigger.active {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--accent);
  transform: scale(0.9) rotate(-15deg);
}

.sidebar {
  width: 18rem;
  background:
          linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03)),
          rgba(17, 8, 29, 0.88);
  border: 1px solid var(--border);
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  position: fixed;
  bottom: 6.5rem;
  left: 2rem;
  height: auto;
  max-height: calc(100vh - 10rem);
  overflow-y: auto;
  backdrop-filter: blur(22px);
  box-shadow: 0 25px 80px var(--shadow);
  z-index: 1050;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.4s, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

body.regular-sidebar .sidebar {
  position: sticky;
  top: 2rem;
  left: 0;
  bottom: auto;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  margin: 2rem 0 2rem 2rem;
  height: calc(100vh - 4rem);
  max-height: none;
}

body.regular-sidebar .hub-trigger { display: none; }

@media (max-width: 1024px) {
  .sidebar { width: calc(100vw - 4rem); }
}

.sidebar-header {
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 1.25rem;
  box-shadow: 0 10px 25px rgba(182, 120, 255, 0.35);
  flex-shrink: 0;
  font-family: 'Baloo 2', cursive;
}

.brand-text {
  font-weight: bold;
  font-size: 1.1rem;
  letter-spacing: -0.025em;
  color: white;
  font-family: 'Baloo 2', cursive;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-title {
  padding: 1.5rem 1rem 0.5rem;
  font-size: 0.625rem;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(182, 120, 255, 0.22), rgba(95, 209, 255, 0.12));
  border-color: rgba(182, 120, 255, 0.32);
  color: #f8f4ff;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 0 22px rgba(182, 120, 255, 0.16);
}

.nav-item .icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

.class-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-action    { background-color: #f97316; }
.dot-sports    { background-color: #22c55e; }
.dot-adventure { background-color: #a78bfa; }

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-signout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.2s, color 0.2s;
}

.btn-signout:hover {
  background-color: rgba(255, 255, 255, 0.09);
  color: var(--text);
}

/* ============================================
   LAYOUT
   ============================================ */

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

.main-column {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-shell {
  width: 100%;
  max-width: 1480px;
  padding: clamp(1rem, 3vw, 2rem);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ============================================
   GAME VIEWER
   ============================================ */

#gameView {
  display: none;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - 5rem);
  border-radius: 30px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(8, 4, 15, 0.96);
  box-shadow: 0 25px 80px var(--shadow);
}

.game-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 1rem;
  background: rgba(18, 10, 30, 0.94);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.game-view-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.game-view-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-game-control,
.btn-close-game {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, color 0.2s;
}

.btn-game-control:hover,
.btn-close-game:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.btn-game-control[hidden] { display: none; }

#gameFrame {
  width: 100%;
  flex-grow: 1;
  border: none;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideUpIn {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: slideUpIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

/* ============================================
   MOBILE NAV
   ============================================ */

.mobile-nav {
  display: none;
  background: rgba(13, 7, 22, 0.86);
  border: 1px solid var(--border);
  padding: 0.7rem;
  gap: 0.5rem;
  overflow-x: auto;
  position: sticky;
  top: 0.75rem;
  z-index: 100;
  margin: 0.75rem;
  border-radius: 999px;
  backdrop-filter: blur(16px);
}

@media (max-width: 1024px) {
  .mobile-nav { display: flex; }
}

.mobile-nav .nav-item {
  white-space: nowrap;
  padding: 0.5rem 0.875rem;
  font-size: 0.82rem;
}

/* ============================================
   HERO
   ============================================ */

.site-header {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.hero,
.toolbar,
.about {
  border: 1px solid var(--border);
  background:
          linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
          var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.9fr);
  gap: 1.25rem;
  align-items: stretch;
  padding: clamp(1.2rem, 2.8vw, 1.9rem);
  border-radius: 34px;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
          radial-gradient(circle at top right, rgba(182, 120, 255, 0.18), transparent 26%),
          linear-gradient(120deg, rgba(255, 255, 255, 0.03), transparent 55%);
  pointer-events: none;
}

.eyebrow,
.section-label,
.panel-label,
.math-tag {
  color: #d7b5ff;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.math-meta {
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.eyebrow,
.section-label {
  margin: 0 0 0.5rem;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0.85rem;
  font-size: clamp(2.1rem, 5.5vw, 4rem);
  line-height: 1.04;
  max-width: 11ch;
  text-shadow: 0 0 22px rgba(182, 120, 255, 0.18);
}

h2 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

h3 {
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}

.lead,
.toolbar-copy p,
.about p,
.about-list li,
.math-description,
.stat p,
.results-count,
.stack-list li {
  color: var(--text-muted);
  line-height: 1.65;
}

.hero-copy,
.hero-panel {
  position: relative;
  z-index: 1;
}

.hero-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-search {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  margin: 1.2rem 0 0;
  padding: 0.95rem 1.05rem;
  border-radius: 22px;
  border: 1px solid rgba(182, 120, 255, 0.24);
  background: linear-gradient(135deg, rgba(182, 120, 255, 0.12), rgba(95, 209, 255, 0.08));
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.hero-search-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 0.8rem;
  border-radius: 999px;
  background: rgba(8, 4, 15, 0.48);
  color: #f4eaff;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hero-search-text { color: var(--text-secondary); }

.hero-search-arrow {
  font-size: 1.4rem;
  line-height: 1;
  color: #f4eaff;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0 1.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.75rem 1.05rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.button:hover,
.card-button:hover,
.btn-game-control:hover,
.btn-close-game:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #150a1f;
  font-weight: 700;
  box-shadow: 0 15px 30px rgba(182, 120, 255, 0.24);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}

.stat,
.hero-panel,
.math-card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.045);
  border-radius: 22px;
}

.stat,
.hero-panel {
  padding: 1rem;
}

.hero-panel {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.stat span {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.panel-window {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 100%;
}

.panel-window-bar {
  display: flex;
  gap: 0.45rem;
}

.panel-window-bar span {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
}

.panel-window-bar span:first-child  { background: #ff6b9d; }
.panel-window-bar span:nth-child(2) { background: #ffbb66; }
.panel-window-bar span:nth-child(3) { background: #7df4bc; }

.panel-screen {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 0.9rem;
  flex: 1;
  min-height: 280px;
  padding: 0.95rem;
  border-radius: 24px;
  background:
          linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
          rgba(8, 4, 15, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 0.35rem 0;
}

.panel-rail-item {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.panel-rail-item.active {
  background: var(--accent);
  box-shadow: 0 0 16px rgba(182, 120, 255, 0.52);
}

.panel-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-display {
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
          radial-gradient(circle at top right, rgba(95, 209, 255, 0.18), transparent 30%),
          linear-gradient(135deg, rgba(182, 120, 255, 0.14), rgba(255, 255, 255, 0.03));
}

.panel-display strong {
  display: block;
  margin-bottom: 0.4rem;
}

.panel-display p {
  margin-bottom: 0;
  color: var(--text-secondary);
}

.stack-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* ============================================
   TOOLBAR & ABOUT
   ============================================ */

.toolbar,
.about {
  border-radius: 28px;
  padding: 1.25rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: end;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.control span {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.control input,
.control select {
  width: 100%;
  min-height: 46px;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(9, 5, 16, 0.78);
  color: var(--text);
  font: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

/* ============================================
   GAMES GRID
   ============================================ */

.math-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.math-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.math-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem;
  min-width: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s, border-color 0.3s;
}

.math-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--accent);
  box-shadow: 0 15px 40px var(--shadow), 0 0 20px rgba(182, 120, 255, 0.15);
}

.math-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.math-tag {
  display: inline-flex;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(182, 120, 255, 0.12);
}

.math-meta { color: var(--success); }

.math-actions {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.card-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.card-button.primary {
  background: linear-gradient(135deg, rgba(182, 120, 255, 0.92), rgba(95, 209, 255, 0.92));
  color: #150a1f;
  font-weight: 700;
  border-color: transparent;
}

/* ============================================
   ABOUT
   ============================================ */

.about {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr);
  gap: 1rem;
}

.about-list {
  margin: 0;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.empty-state {
  padding: 1.2rem;
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 860px) {
  .hero,
  .toolbar,
  .about {
    grid-template-columns: 1fr;
  }

  .sidebar { display: none; }

  h1 { max-width: unset; }
}

@media (max-width: 640px) {
  .hero,
  .toolbar,
  .about,
  .stat,
  .hero-panel,
  .math-card {
    border-radius: 20px;
  }

  .button,
  .card-button {
    width: 100%;
  }

  .hero-search { grid-template-columns: 1fr; }

  .panel-screen { grid-template-columns: 1fr; }

  .panel-rail {
    flex-direction: row;
    justify-content: flex-start;
  }
}