:root {
  --bg-deep: #070b16;
  --bg: #0b1022;
  --surface: rgba(18, 27, 51, 0.88);
  --surface-solid: #131d38;
  --surface-2: #1b284b;
  --surface-3: #243561;
  --text: #f8fafc;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-vivid: #6366f1;
  --violet: #a855f7;
  --accent: #fbbf24;
  --success: #10b981;
  --success-bright: #34d399;
  --danger: #fb7185;
  --border: rgba(148, 163, 184, 0.22);
  --border-strong: rgba(148, 163, 184, 0.34);
  --radius: 18px;
  --shadow: 0 10px 28px rgba(2, 6, 23, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  inset: 0;
  font-family: 'Rubik', 'Heebo', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 88% 8%, rgba(34, 211, 238, 0.18) 0%, transparent 42%),
    radial-gradient(circle at 12% 90%, rgba(139, 92, 246, 0.22) 0%, transparent 46%),
    radial-gradient(circle at 50% 45%, rgba(79, 70, 229, 0.10) 0%, transparent 60%),
    linear-gradient(165deg, #070b16 0%, #0d142b 52%, #161032 100%);
  color: var(--text);
  direction: rtl;
  user-select: none;
}

input, textarea, select {
  user-select: text;
}

/* Subtle cosmic grid overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 50% 40%, rgba(0, 0, 0, 0.75), transparent 88%);
  -webkit-mask-image: radial-gradient(circle at 50% 40%, rgba(0, 0, 0, 0.75), transparent 88%);
  z-index: 0;
}

/* Full-screen zero-scroll flex shell */
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 860px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.stage {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.stage-center {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.boot-loader-card {
  text-align: center;
  padding: 32px 20px;
}
.boot-emblem {
  font-size: 2.3rem;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.55));
}
.boot-title {
  font-weight: 800;
  font-size: 1.08rem;
  color: var(--text);
}

/* Compact single-row Top HUD */
.topbar {
  flex: 0 0 auto;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(15, 23, 44, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 0 10px;
  box-shadow: 0 4px 16px rgba(2, 6, 23, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: -0.2px;
  background: linear-gradient(135deg, #38bdf8 0%, #a78bfa 55%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.brand-icon {
  -webkit-text-fill-color: initial;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.5));
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(30, 41, 75, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text);
  white-space: nowrap;
}

.pill-level {
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(167, 139, 250, 0.48);
  color: #ede9fe;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.18);
}

.pill-xp {
  background: rgba(14, 165, 233, 0.18);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

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

.icon-btn {
  width: 33px;
  height: 33px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #1e2b4d 0%, #141d38 100%);
  color: var(--text);
  font-size: 0.96rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 0 #070b16;
  transition: transform 0.1s ease, border-color 0.14s ease, box-shadow 0.1s ease;
}
.icon-btn:hover {
  border-color: rgba(56, 189, 248, 0.55);
}
.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #070b16;
}

/* Tactile 3D Arcade Buttons */
.btn {
  border: none;
  border-radius: 13px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.14s ease, border-color 0.14s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 48%, #0ea5e9 100%);
  color: #ffffff;
  border: 1px solid rgba(165, 243, 252, 0.35);
  box-shadow:
    0 4px 0 #261b69,
    0 8px 20px rgba(79, 70, 229, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  text-shadow: 0 1px 2px rgba(9, 13, 26, 0.5);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 #261b69,
    0 3px 10px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: linear-gradient(180deg, #1f2d52 0%, #15203d 100%);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: 0 3px 0 #080d1b, inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.btn-secondary:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.5);
}
.btn-secondary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #080d1b;
}

.btn-danger-ghost {
  color: #fda4af !important;
  border-color: rgba(251, 113, 133, 0.4) !important;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: 10px;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.alert-error {
  background: rgba(136, 19, 55, 0.45);
  border: 1px solid rgba(251, 113, 133, 0.5);
  color: #ffe4e6;
  font-size: 0.85rem;
  text-align: center;
}

.err-msg {
  color: #fda4af;
  font-size: 0.84rem;
  font-weight: 600;
}

/* Login & Hero Welcome */
.hero-welcome {
  text-align: center;
}
.hero-welcome h1 {
  font-size: clamp(1.7rem, 4.2vh, 2.35rem);
  font-weight: 900;
  margin: 2px 0 4px;
  background: linear-gradient(135deg, #38bdf8 0%, #a855f7 52%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 16px rgba(56, 189, 248, 0.22));
}

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

.slot-card {
  background: linear-gradient(180deg, rgba(30, 43, 78, 0.92) 0%, rgba(19, 28, 54, 0.96) 100%);
  border: 1.5px solid var(--border-strong);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 0 #080c18;
  transition: border-color 0.14s ease, transform 0.1s ease, box-shadow 0.1s ease;
}
.slot-card:hover {
  border-color: rgba(56, 189, 248, 0.6);
}
.slot-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #080c18;
  border-color: var(--primary);
}

.slot-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.85rem;
  margin-bottom: 6px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 14px rgba(2, 6, 23, 0.5);
}

.pet-cheer-pill {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(139, 92, 246, 0.20));
  border: 1px solid rgba(251, 191, 36, 0.42);
  color: #fde68a;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

/* RPG Battle-Pass Player & Companion Banner */
.hub-pet-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(circle at 92% 18%, rgba(56, 189, 248, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 8% 85%, rgba(168, 85, 247, 0.16) 0%, transparent 50%),
    rgba(18, 27, 52, 0.92);
  border: 1px solid rgba(99, 102, 241, 0.38);
}

.hub-pet-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pet-stage-sm {
  width: clamp(76px, 12.2vh, 106px);
  height: clamp(76px, 12.2vh, 106px);
  flex-shrink: 0;
  position: relative;
}

.pet-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 14px rgba(2, 6, 23, 0.65));
}

@keyframes petFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-3px); }
}
@keyframes tailWag {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(9deg); }
}
.pet-bounce { animation: petFloat 2.8s ease-in-out infinite; }
.pet-tail { transform-origin: 140px 145px; animation: tailWag 0.9s ease-in-out infinite; }

.hub-stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
}

.progress-track {
  width: 100%;
  height: 9px;
  background: rgba(9, 13, 26, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

@keyframes xpLiquidShine {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1 0%, #22d3ee 50%, #a855f7 100%);
  background-size: 200% 100%;
  animation: xpLiquidShine 3.5s linear infinite;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.55);
  transition: width 0.35s ease;
}

.chest-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(9, 13, 26, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
}
.chest-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(51, 65, 85, 0.8);
  border: 1.5px solid rgba(100, 116, 139, 0.7);
  transition: transform 0.2s ease, background 0.2s ease;
}
.chest-dot.filled {
  background: #fbbf24;
  border-color: #fef08a;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.85);
}

.btn-mixed-quest {
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(135deg, #4f46e5 0%, #9333ea 50%, #06b6d4 100%);
  border: 1px solid rgba(165, 243, 252, 0.42);
}

/* Hub Realms Paged Deck (2x4 = 8 slots, fills remaining stage cleanly!) */
.realms-deck {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deck-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

.realms-page-grid {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

@media (min-width: 680px) {
  .realms-page-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

.realm-tile {
  --realm-color: #38bdf8;
  position: relative;
  background:
    radial-gradient(circle at 92% 20%, color-mix(in srgb, var(--realm-color) 18%, transparent) 0%, transparent 62%),
    linear-gradient(180deg, rgba(27, 39, 72, 0.92) 0%, rgba(17, 25, 48, 0.96) 100%);
  border: 1.5px solid color-mix(in srgb, var(--realm-color) 42%, rgba(148, 163, 184, 0.22));
  border-radius: 14px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 3px 0 #070b16, inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.1s ease, border-color 0.14s ease, box-shadow 0.1s ease;
}
.realm-tile:hover {
  border-color: var(--realm-color);
  box-shadow: 0 3px 0 #070b16, 0 0 14px color-mix(in srgb, var(--realm-color) 26%, transparent);
}
.realm-tile:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #070b16;
  border-color: var(--realm-color);
}

.realm-icon-sm {
  width: 35px;
  height: 35px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--realm-color) 22%, #0f172a);
  border: 1px solid color-mix(in srgb, var(--realm-color) 50%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.realm-tile.realm-surprise {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.36) 0%, rgba(236, 72, 153, 0.30) 52%, rgba(14, 165, 233, 0.30) 100%);
  border: 1.5px solid rgba(244, 114, 182, 0.6);
  box-shadow: 0 3px 0 #1e1038, 0 0 16px rgba(236, 72, 153, 0.18);
}
.realm-tile.realm-surprise .realm-icon-sm {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(251, 207, 232, 0.45);
}
.realm-surprise-sub {
  font-size: 0.73rem;
  color: #fbcfe8;
  font-weight: 600;
}

/* Quiz Arena — Zero-scroll adaptive flex layout */
.quiz-stage-card {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.quiz-header-row {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.quiz-cat-pill {
  --cat-color: #38bdf8;
  background: color-mix(in srgb, var(--cat-color) 24%, #131d38);
  border: 1px solid color-mix(in srgb, var(--cat-color) 58%, rgba(148, 163, 184, 0.3));
  color: #f8fafc;
  max-width: 56%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Combo / Streak Heat Pill */
@keyframes streakPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
  animation: streakPulse 1.6s ease-in-out infinite;
}
.streak-pill.tier-1 {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.28), rgba(245, 158, 11, 0.24));
  border: 1px solid rgba(251, 146, 60, 0.65);
  color: #fed7aa;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.32);
}
.streak-pill.tier-2 {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.30), rgba(139, 92, 246, 0.32));
  border: 1px solid rgba(34, 211, 238, 0.72);
  color: #cffafe;
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.42);
}
.streak-pill.tier-3 {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.36), rgba(168, 85, 247, 0.38), rgba(34, 211, 238, 0.34));
  border: 1px solid #fde047;
  color: #fef08a;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.48);
}

/* Non-blocking Floating Reward Burst */
@keyframes rewardFloatUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.86); }
  20% { opacity: 1; transform: translate(-50%, 0px) scale(1.04); }
  75% { opacity: 1; transform: translate(-50%, -18px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(0.96); }
}

.xp-float-burst {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  padding: 5px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(49, 46, 129, 0.94));
  border: 1.5px solid #fbbf24;
  color: #fef08a;
  font-size: 0.84rem;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.65), 0 0 16px rgba(251, 191, 36, 0.35);
  animation: rewardFloatUp 1.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.quiz-question-text {
  flex: 0 0 auto;
  font-size: clamp(1.02rem, 2.45vh, 1.34rem);
  line-height: 1.36;
  font-weight: 800;
  color: #f8fafc;
  margin: 2px 0;
  text-shadow: 0 1px 2px rgba(2, 6, 23, 0.5);
}

.quiz-options {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* Compact option rows once answered so Feedback + Next/Mana Button fit without scrolling! */
.quiz-options.answered {
  flex: 0 0 auto;
  grid-template-rows: repeat(4, auto);
  gap: 5px;
}

.option-btn {
  width: 100%;
  height: 100%;
  min-height: 0;
  text-align: right;
  background: linear-gradient(180deg, rgba(30, 42, 76, 0.94) 0%, rgba(19, 28, 54, 0.98) 100%);
  border: 1.5px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: clamp(0.92rem, 2.05vh, 1.06rem);
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.25;
  box-shadow: 0 4px 0 #070b16, inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.1s ease, border-color 0.14s ease, box-shadow 0.1s ease, background 0.14s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.65);
  background: linear-gradient(180deg, rgba(36, 51, 92, 0.96) 0%, rgba(23, 34, 64, 0.98) 100%);
}

.option-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #070b16;
}

.option-btn:disabled {
  cursor: default;
}

.quiz-options.answered .option-btn {
  padding: 5px 10px;
  font-size: clamp(0.79rem, 1.8vh, 0.88rem);
  line-height: 1.2;
  border-radius: 10px;
  box-shadow: 0 2px 0 #070b16;
}

.quiz-options.answered .option-btn:not(.correct):not(.selected-wrong) {
  opacity: 0.54;
}

.option-num {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #7dd3fc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.82rem;
  flex-shrink: 0;
  box-shadow: 0 2px 0 rgba(8, 145, 178, 0.3);
}

.quiz-options.answered .option-num {
  width: 22px;
  height: 22px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.option-btn.correct {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.92) 0%, rgba(16, 185, 129, 0.28) 100%);
  color: #ecfdf5;
  box-shadow: 0 2px 0 #064e3b, 0 0 16px rgba(16, 185, 129, 0.28);
  opacity: 1 !important;
}
.option-btn.correct .option-num {
  background: #10b981;
  border-color: #6ee7b7;
  color: #022c22;
}

.option-btn.selected-wrong {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.88) 0%, rgba(245, 158, 11, 0.24) 100%);
  color: #fef3c7;
  box-shadow: 0 2px 0 #451a03;
  opacity: 1 !important;
}
.option-btn.selected-wrong .option-num {
  background: #f59e0b;
  border-color: #fde68a;
  color: #451a03;
}

.feedback-dock {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 14px;
  gap: 6px;
  overflow: hidden;
}

.feedback-dock.is-correct {
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.68) 0%, rgba(15, 23, 44, 0.94) 100%);
  border: 1.5px solid rgba(52, 211, 153, 0.55);
  box-shadow: inset 0 0 18px rgba(16, 185, 129, 0.12);
}

.feedback-dock.is-learn {
  --mana-pct: 0;
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.86) 0%, rgba(15, 23, 44, 0.95) 55%, rgba(59, 7, 100, 0.78) 100%);
  border: 1.5px solid rgba(96, 165, 250, 0.45);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.feedback-dock.is-learn.is-charging {
  border-color: #a855f7;
  box-shadow:
    0 0 calc(10px + var(--mana-pct) * 22px) rgba(168, 85, 247, calc(0.24 + var(--mana-pct) * 0.38)),
    inset 0 0 calc(6px + var(--mana-pct) * 16px) rgba(34, 211, 238, calc(0.14 + var(--mana-pct) * 0.26));
}

.feedback-dock.is-learn.is-recharged {
  border-color: #22d3ee;
  background: linear-gradient(135deg, rgba(8, 51, 68, 0.90) 0%, rgba(49, 46, 129, 0.92) 100%);
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.52);
}

.feedback-explanation {
  font-size: clamp(0.81rem, 1.88vh, 0.89rem);
  line-height: 1.34;
  color: #e2e8f0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feedback-unlocks {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fde047;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Collection & Onboarding Paged Grids */
.paged-grid-6 {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 640px) {
  .paged-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

.choice-tile {
  background: linear-gradient(180deg, rgba(28, 40, 74, 0.90) 0%, rgba(17, 25, 48, 0.96) 100%);
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 3px 0 #070b16;
  transition: transform 0.1s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.choice-tile:hover:not(.locked) {
  border-color: rgba(56, 189, 248, 0.6);
}
.choice-tile:active:not(.locked) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #070b16;
}
.choice-tile.active {
  border-color: #38bdf8;
  background:
    radial-gradient(circle at 50% 25%, rgba(56, 189, 248, 0.22), transparent 70%),
    linear-gradient(180deg, rgba(30, 46, 88, 0.96) 0%, rgba(23, 33, 66, 0.98) 100%);
  box-shadow: 0 3px 0 #070b16, 0 0 16px rgba(56, 189, 248, 0.26);
}
.choice-tile.locked {
  opacity: 0.56;
  background: rgba(13, 19, 38, 0.78);
  border-style: dashed;
  cursor: default;
}

/* Bottom Navigation (in flex flow, never overlaps!) */
.bottom-nav {
  flex: 0 0 auto;
  height: 48px;
  background: rgba(15, 23, 44, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 15px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(2, 6, 23, 0.5);
}

.nav-tab {
  flex: 1;
  height: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 11px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: color 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}
.nav-tab:hover {
  color: var(--text-soft);
}
.nav-tab.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.36) 0%, rgba(14, 165, 233, 0.26) 100%);
  border-color: rgba(56, 189, 248, 0.45);
  color: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* Compact Parent Paged Views */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.kpi-mini {
  background: rgba(19, 28, 54, 0.88);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 6px;
  text-align: center;
}
.kpi-mini-val {
  font-size: 1.06rem;
  font-weight: 900;
  color: var(--primary);
}

.compact-list {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
}

.compact-row {
  flex: 1 1 0;
  min-height: 0;
  background: rgba(19, 28, 54, 0.86);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.83rem;
  color: var(--text);
}
.compact-row.clickable {
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.compact-row.clickable:hover {
  border-color: rgba(56, 189, 248, 0.48);
  background: rgba(27, 40, 75, 0.92);
}
.compact-row.clickable:active {
  background: rgba(36, 53, 97, 0.95);
}

.pager-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}

.input-field, select.input-field, textarea.input-field {
  width: 100%;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1.5px solid var(--border-strong);
  font-family: inherit;
  font-size: 0.92rem;
  background: rgba(9, 14, 28, 0.88);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-field::placeholder {
  color: #64748b;
}
.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}
select.input-field option {
  background: #0f172a;
  color: #f8fafc;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 100;
}
.modal-box {
  background: linear-gradient(180deg, #162140 0%, #0f172e 100%);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 20px;
  max-width: 520px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 18px;
  color: var(--text);
  box-shadow: 0 24px 52px rgba(2, 6, 23, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.snap-opt {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.86rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.snap-opt.is-correct {
  background: rgba(6, 78, 59, 0.65);
  border-color: #10b981;
  color: #ecfdf5;
}
.snap-opt.is-wrong {
  background: rgba(120, 53, 15, 0.65);
  border-color: #f59e0b;
  color: #fef3c7;
}

.code-info-box {
  background: rgba(7, 11, 22, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--text-soft);
}

.badge-rarity {
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.rarity-Common { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.35); }
.rarity-Uncommon { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.45); }
.rarity-Rare { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.48); }
.rarity-Legendary { background: rgba(251, 191, 36, 0.22); color: #fde047; border: 1px solid rgba(251, 191, 36, 0.55); }

/* Keep Google Sign-In button clean & compliant with official Google branding */
.google-signin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  background: #ffffff;
  color: #0f172a;
  border: 1.5px solid #e2e8f0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 4px 0 #cbd5e1, 0 8px 22px rgba(2, 6, 23, 0.45);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.google-signin-btn:hover {
  box-shadow: 0 4px 0 #cbd5e1, 0 10px 26px rgba(56, 189, 248, 0.25);
}
.google-signin-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #cbd5e1, 0 4px 12px rgba(2, 6, 23, 0.4);
}

/* --- 3-Second Mana / Aura Press-and-Hold Recharge Button --- */
@keyframes manaShimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes auraOrbPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.75)); }
  50% { transform: scale(1.16); filter: drop-shadow(0 0 11px rgba(34, 211, 238, 0.98)); }
}

@keyframes sparkFloat {
  0% { transform: translateY(4px) scale(0.7); opacity: 0; }
  45% { opacity: 0.95; }
  100% { transform: translateY(-14px) scale(1.15); opacity: 0; }
}

@keyframes manaBurstPop {
  0% { transform: scale(0.98); }
  55% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

.mana-hold-btn {
  --mana-pct: 0;
  position: relative;
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 13px;
  border: 2px solid #818cf8;
  background: linear-gradient(135deg, #17153b 0%, #2e1065 55%, #1e1b4b 100%);
  color: #f8fafc;
  font-family: inherit;
  font-size: clamp(0.86rem, 1.95vh, 0.96rem);
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  box-shadow: 0 3px 0 #090d1a, 0 6px 18px rgba(76, 29, 149, 0.45);
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mana-hold-btn.is-holding {
  transform: translateY(2px) scale(0.99);
  border-color: #22d3ee;
  box-shadow:
    0 1px 0 #090d1a,
    0 0 calc(12px + var(--mana-pct) * 24px) rgba(34, 211, 238, 0.72),
    0 0 calc(6px + var(--mana-pct) * 18px) rgba(168, 85, 247, 0.60);
}

.mana-hold-btn.is-complete {
  border-color: #67e8f9;
  background: linear-gradient(90deg, #0284c7, #6366f1, #a855f7);
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.85);
  animation: manaBurstPop 0.28s ease-out;
}

.mana-hold-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #06b6d4 0%, #6366f1 45%, #a855f7 80%, #06b6d4 100%);
  background-size: 200% 100%;
  animation: manaShimmer 2.2s linear infinite;
  /* RTL right-to-left fill */
  clip-path: inset(0 0 0 calc((1 - var(--mana-pct, 0)) * 100%));
  z-index: 1;
  pointer-events: none;
}

.mana-hold-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(2, 6, 23, 0.8);
}

.mana-orb-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mana-ring-svg {
  position: absolute;
  inset: 0;
  width: 28px;
  height: 28px;
  transform: rotate(-90deg);
}

.mana-orb-icon {
  font-size: 0.98rem;
  line-height: 1;
}

.mana-hold-btn.is-holding .mana-orb-icon {
  animation: auraOrbPulse 0.65s ease-in-out infinite;
}

.mana-sparks {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.mana-hold-btn.is-holding .mana-sparks {
  opacity: 1;
}

.mana-spark {
  position: absolute;
  bottom: 4px;
  font-size: 0.72rem;
  animation: sparkFloat 0.9s ease-out infinite;
}
.mana-spark.s1 { right: 14%; animation-delay: 0s; }
.mana-spark.s2 { right: 38%; animation-delay: 0.28s; }
.mana-spark.s3 { right: 64%; animation-delay: 0.52s; }
.mana-spark.s4 { right: 86%; animation-delay: 0.16s; }

/* Compact vertical screen safeguard (e.g. 360x640 / 375x667) — strict zero-scroll */
@media (max-height: 690px) {
  .app-shell {
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom));
  }
  .stage {
    gap: 6px;
  }
  .topbar {
    height: 42px;
  }
  .bottom-nav {
    height: 44px;
  }
  .card {
    padding: 9px 11px;
  }
  .pet-stage-sm {
    width: 68px;
    height: 68px;
  }
  .quiz-stage-card {
    gap: 6px;
  }
  .quiz-options.answered {
    gap: 4px;
  }
  .quiz-options.answered .option-btn {
    padding: 4px 8px;
    font-size: 0.78rem;
  }
  .feedback-dock {
    padding: 7px 10px;
    gap: 4px;
  }
  .feedback-explanation {
    -webkit-line-clamp: 3;
    font-size: 0.79rem;
  }
  .mana-hold-btn {
    min-height: 40px;
    padding: 6px 12px;
  }
}
