:root {
  --bg-top: #090d1e;
  --bg-bottom: #131836;
  --surface: #171f3b;
  --surface-soft: #1e294d;
  --surface-elevated: #24305a;
  --primary: #818cf8;
  --primary-solid: #6366f1;
  --primary-dark: #a5b4fc;
  --primary-soft: rgba(99, 102, 241, 0.22);
  --accent: #fbbf24;
  --accent-dark: #f59e0b;
  --success: #4ade80;
  --success-soft: rgba(34, 197, 94, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(244, 63, 94, 0.16);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #2c3a67;
  --radius: 20px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.18), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(251, 191, 36, 0.1), transparent 35%),
    linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  min-height: 100vh;
  line-height: 1.5;
}

h1, h2, h3, .btn, .nav-tab, .answer-value, .quest-expression {
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif;
}

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

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* Header */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: #fff;
  font-size: 26px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.brand-title {
  font-size: 1.7rem;
  line-height: 1.1;
  color: #ffffff;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
}

.player-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-pill {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.account-pill {
  cursor: pointer;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.22));
  border-color: #6366f1;
  color: #e0e7ff;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.92rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.account-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.level-pill {
  padding: 6px 14px;
  min-width: 170px;
}

.level-info {
  flex: 1;
}

.level-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  line-height: 1.1;
  margin-bottom: 4px;
}

#hud-level {
  color: var(--primary-dark);
}

#hud-rank {
  color: var(--text-muted);
}

.xp-bar-track {
  height: 7px;
  background: #0f172a;
  border-radius: 999px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #818cf8, #fbbf24);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.star-pill {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(251, 191, 36, 0.45);
}

.streak-pill {
  color: #fdba74;
  background: rgba(249, 115, 22, 0.14);
  border-color: rgba(251, 146, 60, 0.45);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  transform: scale(1.06);
  border-color: var(--primary);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.nav-tab {
  flex: 1;
  min-width: 140px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-tab:hover {
  border-color: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

.nav-tab.active {
  background: linear-gradient(135deg, var(--primary-solid), #7c3aed);
  border-color: #818cf8;
  color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.count-pill {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.nav-tab:not(.active) .count-pill {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

/* Mascot Banner */
.mascot-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 2px solid #334175;
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.mascot-avatar {
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.mascot-avatar[data-mood="celebrate"] {
  animation: bounce 0.6s ease 2;
}

.mascot-avatar[data-mood="thinking"] {
  transform: rotate(-6deg);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.mascot-name {
  display: block;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  color: var(--primary-dark);
}

.mascot-bubble p {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
}

/* Panels & Cards */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.22s ease;
}

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

.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.5rem;
  color: #ffffff;
  margin-bottom: 4px;
}

.card-subtitle {
  color: var(--text-muted);
  margin-bottom: 18px;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-solid), #8b5cf6);
  color: #fff;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.38);
}

.btn-primary:hover {
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.52);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--primary-soft);
  color: #e0e7ff;
  border: 1px solid rgba(129, 140, 248, 0.35);
}

.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 2px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: #fff;
}

.btn-danger {
  background: var(--danger-soft);
  color: #fda4af;
  border: 2px solid rgba(251, 113, 133, 0.45);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.28);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 11px;
}

.btn-lg {
  width: 100%;
  padding: 15px 24px;
  font-size: 1.15rem;
}

/* Solver Input */
.section-label {
  display: block;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  margin-bottom: 10px;
  color: var(--primary-dark);
}

.solver-form {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.math-input {
  flex: 1;
  font-family: 'Nunito', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  padding: 14px 18px;
  border: 2px solid #38497d;
  border-radius: 16px;
  outline: none;
  color: #ffffff;
  background: #0f162e;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.math-input::placeholder {
  color: #64748b;
  font-weight: 600;
}

.math-input:focus {
  border-color: var(--primary);
  background: #131c38;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.symbol-pad, .examples-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.pad-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-right: 4px;
}

.sym-btn {
  min-width: 38px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #e0e7ff;
  cursor: pointer;
  transition: all 0.14s ease;
}

.sym-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: #fff;
}

.sym-clear {
  font-size: 0.85rem;
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.4);
}

.sym-clear:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.chip {
  border: 2px solid rgba(129, 140, 248, 0.3);
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.14s ease;
}

.chip:hover {
  background: var(--primary-solid);
  border-color: var(--primary);
  color: #fff;
}

/* Solver Result */
.result-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 2px dashed var(--border);
  margin-bottom: 18px;
}

.topic-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--primary-soft);
  color: #c7d2fe;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.result-expression {
  font-size: 1.7rem;
  color: #ffffff;
}

.answer-box {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(251, 191, 36, 0.16));
  border: 2px solid #f59e0b;
  border-radius: 16px;
  padding: 10px 22px;
  text-align: center;
  min-width: 120px;
}

.answer-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #fcd34d;
}

.answer-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: #fef3c7;
}

/* Visual Helper */
.visual-helper {
  background: #111830;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 18px;
}

.visual-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 0.95rem;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.dot-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.dot-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 10px;
  background: var(--surface);
  border: 2px solid #3b4b80;
  border-radius: 12px;
  max-width: 140px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #818cf8;
  box-shadow: 0 0 6px rgba(129, 140, 248, 0.5);
}

.dot.alt {
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.45);
}

.dot.crossed {
  background: #fb7185;
  opacity: 0.35;
  box-shadow: none;
}

.dot-op {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.3rem;
  color: var(--primary-dark);
}

.array-grid {
  display: inline-grid;
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 2px solid #3b4b80;
  border-radius: 12px;
}

.fraction-visuals {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.frac-bar-wrap {
  min-width: 140px;
}

.frac-bar-label {
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 5px;
  color: var(--text);
}

.frac-bar {
  display: flex;
  height: 28px;
  border: 2px solid #6366f1;
  border-radius: 8px;
  overflow: hidden;
  background: #0f162e;
}

.frac-seg {
  flex: 1;
  border-right: 1px solid #334175;
}

.frac-seg:last-child {
  border-right: none;
}

.frac-seg.filled {
  background: #818cf8;
}

.frac-seg.filled-alt {
  background: #fbbf24;
}

/* Steps List */
.steps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.steps-controls {
  display: flex;
  gap: 8px;
}

.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  animation: fadeIn 0.25s ease;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-solid);
  color: #fff;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.step-body strong {
  display: block;
  color: #c7d2fe;
  font-size: 0.98rem;
}

.step-body p {
  font-size: 0.94rem;
  color: var(--text);
}

.step-math {
  display: inline-block;
  margin-top: 6px;
  background: #0f162e;
  border: 1px solid #3b4b80;
  border-radius: 8px;
  padding: 3px 10px;
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  color: #fde68a;
}

/* Error Card */
.error-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--danger-soft);
  border-color: rgba(251, 113, 133, 0.5);
  color: #ffe4e6;
}

.error-icon {
  font-size: 2.2rem;
}

/* Quest Setup */
.setup-group {
  margin-bottom: 20px;
}

.setup-label {
  display: block;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text);
}

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

.choice-card {
  text-align: left;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s ease;
}

.choice-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.choice-card.selected {
  background: rgba(99, 102, 241, 0.24);
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.28);
}

.choice-emoji {
  font-size: 1.6rem;
}

.choice-card strong {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  color: #ffffff;
}

.choice-card span {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.choice-card small {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topic-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-pill {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
  transition: all 0.14s ease;
}

.topic-pill:hover {
  border-color: var(--primary);
}

.topic-pill.selected {
  background: var(--primary-solid);
  border-color: var(--primary);
  color: #fff;
}

/* Quest Play */
.quest-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.quest-counter {
  font-weight: 800;
  color: var(--text-muted);
}

.quest-dots {
  display: flex;
  gap: 8px;
}

.q-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2c3a67;
  transition: all 0.2s ease;
}

.q-dot.current {
  background: var(--primary);
  transform: scale(1.2);
}

.q-dot.correct {
  background: var(--success);
}

.q-dot.wrong {
  background: var(--danger);
}

.quest-question-box {
  text-align: center;
  background: linear-gradient(135deg, #1b254b, #141c3a);
  border: 2px solid #3c4d87;
  border-radius: 18px;
  padding: 24px 16px;
  margin-bottom: 18px;
}

.quest-prompt {
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.quest-expression {
  font-size: 2.3rem;
  color: #ffffff;
}

.quest-answer-form {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.quest-helpers {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.hint-box {
  background: rgba(245, 158, 11, 0.14);
  border: 2px solid rgba(251, 191, 36, 0.45);
  border-radius: 14px;
  padding: 12px 16px;
  color: #fde68a;
  font-weight: 700;
  margin-bottom: 12px;
}

.feedback-box {
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 800;
  margin-bottom: 14px;
}

.feedback-box.correct {
  background: var(--success-soft);
  border: 2px solid rgba(74, 222, 128, 0.5);
  color: #bbf7d0;
}

.feedback-box.wrong {
  background: var(--danger-soft);
  border: 2px solid rgba(251, 113, 133, 0.5);
  color: #fecdd3;
}

.quest-next-row {
  display: flex;
  justify-content: flex-end;
}

/* Quest Summary */
.quest-summary-card {
  text-align: center;
}

.summary-trophy {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.summary-stats, .stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.stat-tile {
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
}

.stat-num {
  display: block;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  color: #fde68a;
}

.stat-lbl {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-muted);
}

.summary-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Trophies */
.trophies-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.badge-card {
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface-soft);
  display: flex;
  gap: 12px;
  align-items: center;
  transition: transform 0.15s ease;
}

.badge-card.unlocked {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(251, 191, 36, 0.1));
  border-color: rgba(251, 191, 36, 0.6);
}

.badge-card.locked {
  opacity: 0.5;
  filter: grayscale(0.8);
}

.badge-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #0f162e;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.badge-info strong {
  display: block;
  font-family: 'Fredoka', sans-serif;
  color: #ffffff;
}

.badge-info small {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Modal (Login / Account) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 22, 0.78);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 2px solid #43538c;
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  animation: fadeIn 0.2s ease;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h2 {
  font-size: 1.4rem;
  color: #ffffff;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-tab {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-family: 'Fredoka', sans-serif;
  font-size: 0.98rem;
  cursor: pointer;
}

.modal-tab.active {
  background: var(--primary-solid);
  border-color: var(--primary);
  color: #fff;
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.form-field .math-input {
  width: 100%;
  font-size: 1rem;
  padding: 11px 14px;
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.avatar-opt {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  font-size: 1.4rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.avatar-opt:hover {
  transform: scale(1.08);
}

.avatar-opt.selected {
  border-color: var(--accent);
  background: rgba(251, 191, 36, 0.2);
}

.auth-error {
  background: var(--danger-soft);
  border: 1px solid rgba(251, 113, 133, 0.5);
  color: #fecdd3;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.saved-players {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px dashed var(--border);
}

.saved-players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.player-chip {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
}

.player-chip:hover {
  border-color: var(--primary);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
}

.profile-big-avatar {
  font-size: 2.5rem;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: #0f162e;
  display: grid;
  place-items: center;
}

.save-code-box {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 2px dashed var(--border);
}

.save-code-box small {
  display: block;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.save-code-row {
  display: flex;
  gap: 8px;
}

.modal-footer-note {
  margin-top: 14px;
  text-align: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #312e81;
  border: 2px solid #818cf8;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 1100;
  animation: fadeIn 0.2s ease;
}

.app-footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 20px;
}

@media (max-width: 600px) {
  .solver-form, .quest-answer-form, .save-code-row {
    flex-direction: column;
  }
  .quest-expression {
    font-size: 1.8rem;
  }
  .level-pill {
    min-width: 145px;
  }
}
