:root {
  --bg-1: #e8fff3;
  --bg-2: #d4ffe8;
  --bg-3: #8df3b9;
  --bg-4: #38d98d;
  --bg-5: #18a86a;
  --text: #17352a;
  --muted: #4f7063;
  --white: rgba(255,255,255,0.82);
  --border: rgba(255,255,255,0.56);
  --shadow: 0 18px 55px rgba(17, 78, 51, 0.18);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --emerald: #10b981;
  --purple: #8b5cf6;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255,255,255,0.94), rgba(232,255,243,0.95), rgba(163,245,200,0.92), rgba(74,222,128,0.88), rgba(16,185,129,0.92));
  min-height: 100vh;
  position: relative;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(14px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.orb-1 {
  width: 280px;
  height: 280px;
  top: 30px;
  left: -70px;
  background: rgba(52, 211, 153, 0.45);
}

.orb-2 {
  width: 230px;
  height: 230px;
  top: 230px;
  right: -50px;
  background: rgba(167, 139, 250, 0.32);
}

.orb-3 {
  width: 200px;
  height: 200px;
  bottom: 60px;
  left: 8%;
  background: rgba(59, 130, 246, 0.24);
}

.orb-4 {
  width: 240px;
  height: 240px;
  bottom: -30px;
  right: 12%;
  background: rgba(251, 191, 36, 0.26);
}

.glass {
  background: var(--white);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  z-index: 1;
  max-width: 1380px;
  margin: 22px auto 0;
  border-radius: var(--radius-xl);
  padding: 28px 28px;
  display: flex;
  gap: 22px;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 900;
  font-size: 12px;
  color: #0f8f59;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.3rem);
  line-height: 1.04;
}

.subtitle,
.panel-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-badge {
  display: grid;
  gap: 10px;
  min-width: 220px;
  padding: 18px 18px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(16,185,129,0.95), rgba(34,197,94,0.88), rgba(96,165,250,0.82));
  color: #fff;
  font-weight: 900;
}

.layout {
  position: relative;
  z-index: 1;
  max-width: 1380px;
  margin: 20px auto 36px;
  padding: 0 4px;
  display: grid;
  gap: 22px;
  grid-template-columns: 340px minmax(0, 1fr);
}

.sidebar,
.games-panel,
.play-panel {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.sidebar {
  height: fit-content;
}

.sidebar section + section {
  margin-top: 22px;
}

.section-head,
.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.section-head h2,
.panel-title-row h2 {
  margin: 0;
  font-size: 1.35rem;
}

.small-tag,
.status-pill,
.catalogue-note,
.score-badge,
.small-pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  background: rgba(240,253,244,0.95);
  color: #0b7a4a;
}

.catalogue-note {
  background: rgba(219, 234, 254, 0.95);
  color: #1d4ed8;
}

.profile-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.profile-form label {
  font-size: 13px;
  font-weight: 900;
}

.profile-form input,
.profile-form select {
  width: 100%;
  border: 1px solid rgba(16,185,129,0.22);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.96);
  color: var(--text);
  outline: none;
}

.profile-form input:focus,
.profile-form select:focus {
  border-color: rgba(16,185,129,0.8);
}

.form-message {
  min-height: 18px;
  margin: 10px 2px 0;
  font-size: 13px;
  color: var(--muted);
}

.form-message.success {
  color: #047857;
  font-weight: 700;
}

.form-message.error {
  color: #b91c1c;
  font-weight: 700;
}

.profile-card {
  margin-top: 14px;
  border-radius: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.7);
}

.profile-card.empty {
  color: var(--muted);
}

.player-name {
  font-size: 1.24rem;
  font-weight: 900;
  margin-bottom: 12px;
}

.profile-meta {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-pill {
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(220,252,231,0.96), rgba(236,253,245,0.98));
  font-size: 12px;
  color: #215c46;
  line-height: 1.4;
}

.meta-pill strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  color: var(--text);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.theme-btn {
  border: 0;
  border-radius: 20px;
  padding: 12px 10px;
  text-align: left;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  display: flex;
  gap: 10px;
  align-items: center;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.theme-btn:hover,
.game-card:hover,
.level-chip:hover {
  transform: translateY(-2px);
}

.theme-btn.active {
  background: linear-gradient(135deg, rgba(16,185,129,0.16), rgba(59,130,246,0.08));
  box-shadow: 0 10px 22px rgba(16,185,129,0.18);
  outline: 2px solid rgba(16,185,129,0.3);
}

.theme-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(236,253,245,0.98);
  font-size: 1.4rem;
}

.theme-title {
  font-size: 13px;
  font-weight: 900;
}

.theme-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.progress-head {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.progress-bar-wrap {
  margin-top: 10px;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.86);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 2.5%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(16,185,129,1), rgba(34,197,94,0.96), rgba(59,130,246,0.85));
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.level-chip {
  border-radius: 14px;
  padding: 10px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  background: rgba(255,255,255,0.9);
  transition: transform .16s ease;
}

.level-chip.done {
  background: rgba(16,185,129,0.18);
  color: #047857;
}

.level-chip.current {
  background: linear-gradient(135deg, rgba(16,185,129,0.94), rgba(59,130,246,0.84));
  color: #fff;
}

.level-chip.locked {
  background: rgba(203,213,225,0.46);
  color: #64748b;
}

.leaderboard {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.leader-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,0.92);
  border-radius: 20px;
  padding: 12px;
}

.rank-badge {
  min-width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(253,230,138,0.98), rgba(251,191,36,0.95));
  color: #7c2d12;
  font-weight: 900;
}

.leader-name {
  font-weight: 900;
}

.leader-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.content {
  display: grid;
  gap: 22px;
}

.games-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.game-card {
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 28px;
  padding: 18px;
  background: rgba(255,255,255,0.92);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  box-shadow: 0 10px 24px rgba(17,78,51,0.08);
  display: grid;
  gap: 12px;
}

.game-card.active {
  border-color: rgba(16,185,129,0.5);
  box-shadow: 0 14px 26px rgba(16,185,129,0.15);
  background: linear-gradient(135deg, rgba(236,253,245,0.96), rgba(255,255,255,0.96));
}

.game-top-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
}

.game-icon {
  width: 64px;
  height: 64px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: linear-gradient(135deg, rgba(16,185,129,0.16), rgba(59,130,246,0.1));
}

.game-category {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #0f8f59;
}

.game-card h3 {
  margin: 0;
  font-size: 1.12rem;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.game-tag {
  border-radius: 999px;
  background: rgba(240,253,244,0.95);
  color: #0b7a4a;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 900;
}

.btn {
  border: 0;
  border-radius: 18px;
  padding: 12px 16px;
  font-weight: 900;
  transition: transform .15s ease, filter .15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn.primary {
  background: linear-gradient(135deg, rgba(16,185,129,1), rgba(59,130,246,0.9));
  color: white;
}

.btn.secondary {
  background: rgba(15,23,42,0.92);
  color: white;
}

.btn.ghost {
  background: rgba(255,255,255,0.96);
  color: var(--text);
}

.btn.amber {
  background: linear-gradient(135deg, rgba(245,158,11,0.98), rgba(239,68,68,0.86));
  color: white;
}

.play-area {
  margin-top: 18px;
}

.play-area.intro-state {
  min-height: 280px;
  display: grid;
  place-items: center;
}

.intro-box {
  max-width: 440px;
  text-align: center;
  border-radius: 30px;
  background: rgba(255,255,255,0.94);
  padding: 28px;
}

.intro-box h3 {
  margin: 8px 0;
}

.intro-box p {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
}

.mascot {
  font-size: 3rem;
}

.top-right-stack {
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-game {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 0;
  font-size: 30px;
  line-height: 1;
  background: linear-gradient(135deg, rgba(239,68,68,0.96), rgba(244,114,182,0.86));
  color: white;
  font-weight: 900;
  box-shadow: 0 10px 18px rgba(239,68,68,0.22);
}

.game-shell {
  display: grid;
  gap: 16px;
}

.game-shell.special-theme {
  --local-accent: rgba(16,185,129,0.18);
}

.game-topbar {
  background: rgba(255,255,255,0.96);
  border-radius: 28px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.topbar-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.message-box,
.card-panel,
.choice-card,
.quiz-card,
.metric-panel,
.toto-panel,
.toto-round,
.toto-cards-preview,
.slot-row,
.game-panel-box {
  background: rgba(255,255,255,0.94);
  border-radius: 24px;
  padding: 16px;
  box-shadow: 0 10px 22px rgba(17,78,51,0.08);
}

.game-panel-box {
  display: grid;
  gap: 14px;
}

.choice-grid,
.option-grid,
.pattern-options,
.theme-choice-grid,
.toto-choice-grid,
.toto-cards-grid,
.theme-symbol-grid,
.memory-grid,
.flash-grid,
.word-grid,
.quick-answers,
.position-options {
  display: grid;
  gap: 12px;
}

.memory-grid {
  justify-content: start;
}

.memory-card {
  width: 74px;
  height: 74px;
  border-radius: 20px;
  border: 0;
  font-size: 1.9rem;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 10px 18px rgba(17,78,51,0.08);
}

.memory-card.hidden-face {
  background: linear-gradient(135deg, rgba(16,185,129,0.94), rgba(96,165,250,0.9));
  color: transparent;
}

.memory-card.matched {
  background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(251,191,36,0.24));
}

.battle-board {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.team-column {
  background: rgba(255,255,255,0.94);
  border-radius: 24px;
  padding: 16px;
}

.team-column h3 {
  margin: 0 0 10px;
}

.card-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mini-card,
.path-node,
.theme-symbol-btn,
.color-card,
.quiz-option,
.order-card,
.pattern-card,
.flash-cell,
.position-option,
.toto-card,
.toto-slot {
  border: 0;
  border-radius: 18px;
  background: rgba(255,255,255,0.98);
  box-shadow: 0 8px 16px rgba(17,78,51,0.08);
}

.mini-card {
  width: 58px;
  height: 78px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.2rem;
}

.card-back {
  background: linear-gradient(135deg, rgba(59,130,246,0.92), rgba(16,185,129,0.92));
  color: #fff;
}

.choice-grid,
.option-grid,
.quick-answers,
.position-options {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.choice-card,
.quiz-option,
.position-option {
  border: 0;
  text-align: left;
  font-weight: 900;
  color: var(--text);
}

.quiz-option,
.position-option {
  padding: 14px 16px;
}

.uno-grid,
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 12px;
}

.uno-card,
.color-card {
  min-height: 96px;
  border: 0;
  border-radius: 24px;
  color: white;
  font-weight: 900;
  font-size: 1.6rem;
}

.uno-red,
.color-red { background: linear-gradient(135deg, #fb7185, #ef4444); }
.uno-blue,
.color-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.uno-green,
.color-green { background: linear-gradient(135deg, #34d399, #10b981); }
.uno-yellow,
.color-yellow { background: linear-gradient(135deg, #facc15, #f59e0b); }
.uno-purple,
.color-purple { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }

.selected-good {
  outline: 4px solid rgba(16,185,129,0.95);
}

.selected-bad {
  outline: 4px solid rgba(239,68,68,0.95);
}

.path-grid,
.flash-grid {
  display: grid;
  gap: 10px;
}

.path-grid {
  grid-template-columns: repeat(5, minmax(0, 70px));
  justify-content: start;
}

.path-node,
.flash-cell {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.path-node.disabled {
  opacity: 0.75;
}

.path-node.active-show,
.flash-cell.show {
  background: linear-gradient(135deg, rgba(16,185,129,0.95), rgba(59,130,246,0.88));
  color: white;
}

.path-node.user-good,
.flash-cell.user-good {
  background: rgba(16,185,129,0.18);
  color: #047857;
}

.path-node.user-wrong,
.flash-cell.user-wrong {
  background: rgba(239,68,68,0.18);
  color: #b91c1c;
}

.theme-symbol-grid {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.theme-symbol-btn {
  min-height: 86px;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
}

.word-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.word-card {
  border-radius: 20px;
  padding: 16px;
  background: rgba(255,255,255,0.96);
  font-weight: 900;
  text-align: center;
}

.pattern-sequence,
.order-sequence,
.position-sequence {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pattern-chip,
.order-card,
.position-chip {
  min-width: 70px;
  min-height: 70px;
  padding: 14px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  font-weight: 900;
}

.order-card.done {
  background: rgba(16,185,129,0.16);
  color: #047857;
}

.metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.metric-panel {
  min-width: 120px;
  font-weight: 900;
}

.metric-panel span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.flash-grid.big {
  grid-template-columns: repeat(5, minmax(0, 70px));
}

.flash-grid.medium {
  grid-template-columns: repeat(4, minmax(0, 70px));
}

.flash-grid.small {
  grid-template-columns: repeat(3, minmax(0, 70px));
}

.intruder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
}

.intruder-card {
  min-height: 100px;
  border: 0;
  border-radius: 24px;
  background: rgba(255,255,255,0.96);
  font-size: 2rem;
  font-weight: 900;
}

.intruder-card.reveal-good {
  outline: 4px solid rgba(16,185,129,0.95);
}

.intruder-card.reveal-bad {
  outline: 4px solid rgba(239,68,68,0.9);
}

.toto-layout {
  display: grid;
  gap: 18px;
}

.toto-choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.toto-choice-btn {
  border: 0;
  border-radius: 26px;
  padding: 18px;
  text-align: left;
  background: rgba(255,255,255,0.96);
}

.toto-cards-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.toto-card {
  padding: 16px;
  min-height: 154px;
  text-align: left;
}

.toto-card .big-icon {
  font-size: 2rem;
}

.toto-card.selected {
  outline: 3px solid rgba(16,185,129,0.42);
  background: linear-gradient(135deg, rgba(236,253,245,0.98), rgba(255,255,255,0.98));
}

.toto-slot-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.toto-slot {
  min-height: 88px;
  padding: 12px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}

.toto-slot.filled {
  color: var(--text);
  background: rgba(16,185,129,0.1);
}

.toto-round {
  display: grid;
  gap: 14px;
}

.toto-battle-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toto-versus-card {
  border-radius: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.98);
}

.toto-history {
  display: grid;
  gap: 10px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: rgba(255,255,255,0.96);
  border-radius: 20px;
  padding: 12px 14px;
}

.theme-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: rgba(236,253,245,0.96);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  color: #047857;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(15,23,42,0.92);
  color: white;
  box-shadow: 0 18px 26px rgba(15,23,42,0.28);
  font-weight: 900;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .games-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .games-grid,
  .battle-board,
  .toto-battle-grid {
    grid-template-columns: 1fr;
  }

  .theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toto-slot-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hero,
  .sidebar,
  .games-panel,
  .play-panel {
    padding: 18px;
  }

  .games-grid,
  .theme-grid,
  .profile-meta,
  .choice-grid,
  .option-grid,
  .quick-answers,
  .position-options {
    grid-template-columns: 1fr;
  }

  .path-grid {
    grid-template-columns: repeat(5, minmax(0, 56px));
  }

  .path-node,
  .flash-cell,
  .pattern-chip,
  .order-card,
  .position-chip {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
  }

  .memory-card {
    width: 64px;
    height: 64px;
  }

  .top-right-stack,
  .game-topbar,
  .section-head,
  .panel-title-row {
    flex-direction: column;
    align-items: stretch;
  }
}


.helper-text {
  margin: -2px 2px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.button-row {
  display: grid;
  gap: 10px;
}

.subsection-box {
  margin-top: 16px;
  border-radius: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.7);
}

.section-head.compact h3 {
  margin: 0;
  font-size: 1rem;
}

.compact-form {
  margin-top: 12px;
}

.migration-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(239, 246, 255, 0.95);
  color: #1e3a8a;
  font-size: 12px;
  line-height: 1.5;
}

.migration-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(255,255,255,0.82);
  padding: 2px 6px;
  border-radius: 8px;
}

.btn.ghost {
  background: rgba(255,255,255,0.94);
  color: var(--text);
  border: 1px solid rgba(16,185,129,0.22);
}
