/* =========================================================
   MATHQUEST - 2ND GRADE MATH ADVENTURE
   Tablet-First Stylesheet: Mario-Style World Map & Leveling Achievements
   ========================================================= */

:root {
  --primary: #ec4899;
  --primary-hover: #db2777;
  --primary-shadow: #9d174d;
  
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-shadow: #b45309;

  --success: #10b981;
  --success-hover: #059669;
  --success-shadow: #047857;

  --bg-gradient: linear-gradient(135deg, #fdf2f8 0%, #fae8ff 40%, #fef3c7 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(255, 255, 255, 0.88);
  --text-main: #4a044e;
  --text-muted: #701a75;
  --card-shadow: 0 14px 36px -4px rgba(236, 72, 153, 0.18), 0 4px 14px rgba(0, 0, 0, 0.05);

  --font-display: 'Fredoka', cursive, -apple-system, sans-serif;
  --font-math: 'Nunito', -apple-system, sans-serif;
  
  --numpad-btn-bg: #ffffff;
  --numpad-btn-text: #4a044e;
  --numpad-btn-shadow: #fbcfe8;
}

/* =========================================================
   THEME VARIANTS
   ========================================================= */
body.theme-candyland {
  --primary: #ec4899;
  --primary-hover: #db2777;
  --primary-shadow: #9d174d;
  --accent: #f59e0b;
  --bg-gradient: linear-gradient(135deg, #fdf2f8 0%, #fae8ff 45%, #fef3c7 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --text-main: #4a044e;
  --text-muted: #86198f;
  --card-shadow: 0 14px 36px -4px rgba(236, 72, 153, 0.2);
  --numpad-btn-bg: #ffffff;
  --numpad-btn-text: #4a044e;
  --numpad-btn-shadow: #fbcfe8;
}

body.theme-cosmic {
  --primary: #a855f7;
  --primary-hover: #9333ea;
  --primary-shadow: #6b21a8;
  --accent: #22d3ee;
  --bg-gradient: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #0f172a 60%, #030712 100%);
  --card-bg: rgba(30, 27, 75, 0.92);
  --card-border: rgba(168, 85, 247, 0.35);
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --card-shadow: 0 16px 44px -4px rgba(168, 85, 247, 0.35);
  --numpad-btn-bg: #312e81;
  --numpad-btn-text: #f8fafc;
  --numpad-btn-shadow: #1e1b4b;
}

body.theme-jungle {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-shadow: #047857;
  --accent: #f59e0b;
  --bg-gradient: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 50%, #fef9c3 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(16, 185, 129, 0.25);
  --text-main: #064e3b;
  --text-muted: #047857;
  --card-shadow: 0 14px 36px -4px rgba(16, 185, 129, 0.2);
  --numpad-btn-bg: #ffffff;
  --numpad-btn-text: #064e3b;
  --numpad-btn-shadow: #a7f3d0;
}

body.theme-underwater {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-shadow: #075985;
  --accent: #14b8a6;
  --bg-gradient: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 50%, #ccfbf1 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(2, 132, 199, 0.25);
  --text-main: #082f49;
  --text-muted: #0369a1;
  --card-shadow: 0 14px 36px -4px rgba(2, 132, 199, 0.2);
  --numpad-btn-bg: #ffffff;
  --numpad-btn-text: #082f49;
  --numpad-btn-shadow: #bae6fd;
}

body.theme-castle {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-shadow: #3730a3;
  --accent: #eab308;
  --bg-gradient: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 50%, #fef3c7 100%);
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(99, 102, 241, 0.25);
  --text-main: #1e1b4b;
  --text-muted: #4338ca;
  --card-shadow: 0 14px 36px -4px rgba(99, 102, 241, 0.2);
  --numpad-btn-bg: #ffffff;
  --numpad-btn-text: #1e1b4b;
  --numpad-btn-shadow: #c7d2fe;
}

body.theme-cyberpunk {
  --primary: #d946ef;
  --primary-hover: #c026d3;
  --primary-shadow: #86198f;
  --accent: #22d3ee;
  --bg-gradient: linear-gradient(135deg, #09090b 0%, #18181b 50%, #2e1065 100%);
  --card-bg: rgba(24, 24, 27, 0.92);
  --card-border: rgba(217, 70, 239, 0.45);
  --text-main: #fafafa;
  --text-muted: #e4e4e7;
  --card-shadow: 0 16px 44px -4px rgba(217, 70, 239, 0.35);
  --numpad-btn-bg: #27272a;
  --numpad-btn-text: #22d3ee;
  --numpad-btn-shadow: #09090b;
}

/* =========================================================
   RESET & BASE
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  touch-action: manipulation;
}

body {
  font-family: var(--font-display);
  background: var(--bg-gradient);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  transition: background 0.5s ease;
  min-height: 100dvh;
}

#theme-ambient-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-particle {
  position: absolute;
  pointer-events: none;
  font-size: 1.4rem;
  opacity: 0.6;
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* =========================================================
   TOP NAVIGATION HUD
   ========================================================= */
.top-nav {
  height: 68px;
  min-height: 68px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.06), 0 3px 0 var(--primary-shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.nav-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 1px 0 var(--primary-shadow);
}

.icon-btn {
  min-width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
}

.btn-icon {
  font-size: 1.3rem;
}

/* Companion HUD */
.companion-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  padding: 4px 14px 4px 6px;
  border-radius: 999px;
  border: 2.5px solid var(--primary);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  cursor: pointer;
}

.hud-pet-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  position: relative;
}

.hud-pet-info {
  display: flex;
  flex-direction: column;
}

.hud-pet-name {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary);
}

.hud-badge-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Stat Pills */
.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.streak-pill {
  border-color: #f97316;
  color: #ea580c;
}

.multiplier-badge {
  background: #f97316;
  color: white;
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 900;
}

.coin-pill {
  border-color: #eab308;
  color: #ca8a04;
}

.coin-spin {
  display: inline-block;
  animation: coinBob 2s infinite ease-in-out;
}

/* =========================================================
   APP VIEWPORT & SCREEN MANAGEMENT
   ========================================================= */
#app-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: calc(100vh - 68px);
  z-index: 10;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 18px;
  display: none !important;
}

.screen.active {
  display: flex !important;
  flex-direction: column;
  opacity: 1;
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  width: 100%;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
  flex-shrink: 0;
}

.screen-header h2 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  text-align: center;
}

.back-btn {
  background: var(--card-bg);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--text-muted);
}
.back-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--text-muted);
}

.header-spacer {
  width: 80px;
}

/* =========================================================
   SCREEN 1: MAIN MENU
   ========================================================= */
#screen-menu {
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.hero-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  width: 100%;
  max-width: 920px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.world-location-tag {
  display: inline-block;
  background: var(--card-bg);
  border: 2px solid var(--primary);
  color: var(--primary);
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.game-title {
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 1px;
  color: var(--primary);
  text-shadow: 3px 3px 0px rgba(0,0,0,0.08);
}

.accent-text {
  color: var(--accent);
}

.subtitle {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

.hero-character-stage {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 30;
  flex-shrink: 0;
}

.giant-pet-display {
  width: 170px;
  height: 170px;
  min-width: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease;
  overflow: visible;
}

.giant-pet-display:hover {
  transform: scale(1.05);
}

.speech-bubble {
  position: relative;
  background: var(--card-bg);
  border: 2.5px solid var(--primary);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 20px;
  font-size: 0.98rem;
  font-weight: 700;
  max-width: 250px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.12);
  line-height: 1.35;
  z-index: 35;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 12px 8px 0;
  border-style: solid;
  border-color: transparent var(--primary) transparent transparent;
}

.menu-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 920px;
}

.action-card {
  position: relative;
  background: var(--card-bg);
  border: 3.5px solid var(--card-border);
  border-radius: 24px;
  padding: 20px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
  text-align: left;
}

.action-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(0,0,0,0.14);
}

.action-card:active {
  transform: translateY(2px);
}

.card-play {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border-color: #a5b4fc;
}
.card-play h3, .card-play p {
  color: white;
}

.card-levels {
  border-color: #38bdf8;
}

.card-playroom {
  border-color: #ec4899;
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.15) 0%, rgba(192, 132, 252, 0.15) 100%);
}

.card-shop {
  border-color: #f472b6;
}

.card-trophies {
  border-color: #fbbf24;
}

.card-icon {
  font-size: 2.6rem;
  flex-shrink: 0;
}

.card-details h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 3px;
}

.card-details p {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.card-arrow {
  margin-left: auto;
  font-size: 1.5rem;
  opacity: 0.8;
}

.badge-count {
  margin-left: auto;
  background: #f43f5e;
  color: white;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 800;
  animation: pulse 1.5s infinite;
}

/* =========================================================
   SCREEN 2: MARIO-STYLE OVERWORLD MAP
   ========================================================= */
.map-stars-counter {
  background: var(--card-bg);
  border: 2px solid #eab308;
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 1.1rem;
  color: #b45309;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
}

.mario-map-wrapper {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.mario-overworld-container {
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 1000 / 680;
  background: #38bdf8;
  border-radius: 28px;
  border: 4px solid #ffffff;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18), inset 0 0 40px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

.mario-map-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.mario-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mario-node-stone {
  position: absolute;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: #ffffff;
  border: 3.5px solid #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 900;
  color: #1e293b;
  box-shadow: 0 6px 12px rgba(0,0,0,0.25);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 10;
}

.mario-node-stone:hover {
  transform: scale(1.15);
  box-shadow: 0 8px 18px rgba(0,0,0,0.3);
}

.mario-node-stone.current {
  border-color: #f59e0b;
  background: #fef08a;
  animation: nodePulseGlow 1.8s infinite;
  z-index: 15;
}

.mario-node-stone.completed {
  border-color: #10b981;
  background: #dcfce7;
  color: #047857;
}

.mario-node-stone.locked {
  background: #94a3b8;
  border-color: #64748b;
  color: #e2e8f0;
  cursor: not-allowed;
  opacity: 0.75;
}

.mario-node-stone.boss-node {
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  font-size: 1.6rem;
  border-color: #eab308;
  background: #fef08a;
}

.mario-pet-sprite {
  position: absolute;
  width: 60px;
  height: 60px;
  margin-left: -30px;
  margin-top: -54px;
  pointer-events: none;
  z-index: 25;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pet-sprite-avatar {
  font-size: 2.8rem;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.pet-sprite-shadow {
  width: 32px;
  height: 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 50%;
  margin-top: -4px;
}

.mario-level-popover {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg);
  border: 3.5px solid var(--primary);
  border-radius: 22px;
  padding: 14px 22px;
  width: 92%;
  max-width: 560px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 30;
  animation: victoryCardPop 0.3s ease-out;
}

.popover-badge {
  position: absolute;
  top: -12px;
  left: 20px;
  background: var(--primary);
  color: white;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.popover-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.popover-icon {
  font-size: 2.4rem;
}

.popover-titles h3 {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-main);
}

.popover-titles p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.popover-stats-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.popover-stat-tag {
  font-size: 0.85rem;
  color: #b45309;
  font-weight: 800;
}

.popover-stars {
  font-size: 1.1rem;
  letter-spacing: 1px;
}

.popover-play-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--success-shadow);
  white-space: nowrap;
}
.popover-play-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--success-shadow);
}

/* =========================================================
   SCREEN 3: GAMEPLAY ARENA & SCENERY ARTWORK
   ========================================================= */
#screen-game {
  padding: 8px 16px;
}

.scenery-environment-banner {
  height: 110px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto 8px auto;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--card-shadow);
  border: 3px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.scenery-art-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.scenery-info-overlay {
  position: relative;
  z-index: 5;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: 14px;
  border: 2px solid var(--card-border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.scenery-zone-title {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--primary);
  text-transform: uppercase;
}

.scenery-level-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-main);
}

.level-progress-pill {
  position: relative;
  z-index: 5;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: 14px;
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  font-weight: 800;
  font-size: 0.88rem;
}

.progress-bar-track {
  width: 100px;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b 0%, #10b981 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.game-hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto 8px auto;
  flex-shrink: 0;
}

.game-streak-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  padding: 6px 16px;
  border-radius: 999px;
  border: 2.5px solid #f97316;
}

.meter-label {
  font-size: 0.85rem;
  font-weight: 900;
  color: #ea580c;
}

.streak-dots {
  display: flex;
  gap: 5px;
}

.streak-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: background 0.2s ease;
}

.streak-dots .dot.filled {
  background: #f97316;
  transform: scale(1.25);
}

.streak-fire-text {
  font-size: 1rem;
  font-weight: 900;
  color: #ea580c;
}

.scratch-btn {
  background: var(--card-bg);
  border: 2.5px solid #0284c7;
  color: #0284c7;
  border-radius: 999px;
  padding: 6px 16px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #0369a1;
}

/* 3-Column Arena Layout */
.gameplay-arena-grid {
  display: grid;
  grid-template-columns: 220px 1.25fr 1fr;
  gap: 16px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  align-items: stretch;
  flex: 1;
}

.companion-arena-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 24px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.companion-tag {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--primary);
  background: rgba(236, 72, 153, 0.12);
  padding: 2px 10px;
  border-radius: 999px;
}

.companion-pet-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-main);
}

.pet-character-arena-wrap {
  width: 95px;
  height: 95px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 4px 0;
}

.arena-pet-avatar {
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}

.pet-heart-effect {
  position: absolute;
  top: -10px;
  right: 10px;
  font-size: 1.8rem;
  opacity: 0;
  pointer-events: none;
}

.pet-heart-effect.show {
  animation: floatUpCoin 0.8s ease-out forwards;
}

.companion-speech-bubble {
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--primary);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.companion-speech-bubble::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 0 8px 9px 8px;
  border-style: solid;
  border-color: transparent transparent var(--primary) transparent;
}

.pill-pet-btn {
  background: rgba(236, 72, 153, 0.12);
  border: 2px solid var(--primary);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

/* Problem Board */
.problem-board {
  background: var(--card-bg);
  border: 3.5px solid var(--card-border);
  border-radius: 26px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  position: relative;
}

.problem-helper-hint {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.math-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.05);
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: 18px;
  padding: 14px 24px;
  width: 100%;
  max-width: 400px;
  min-height: 150px;
}

.math-expression-wrap {
  font-family: var(--font-math);
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.vertical-math {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-math);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  padding: 0 10px;
}

.vert-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.vert-op {
  font-size: 2.5rem;
  color: var(--primary);
}

.vert-line {
  width: 100%;
  height: 5px;
  background: var(--text-main);
  border-radius: 4px;
  margin: 5px 0;
}

.answer-display-box {
  margin-top: 10px;
  min-width: 140px;
  height: 62px;
  background: #ffffff;
  border: 3px solid var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-math);
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--primary);
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.08);
}

.answer-display-box .placeholder {
  color: #cbd5e1;
}

.blinking-cursor {
  font-weight: 300;
  color: var(--primary);
  animation: blink 1s step-end infinite;
  margin-left: 2px;
}

.visual-aid-bar {
  margin-top: 8px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pill-button-secondary {
  background: rgba(99, 102, 241, 0.1);
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 999px;
  padding: 5px 12px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

.visual-aid-container {
  margin-top: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  max-height: 110px;
  overflow-y: auto;
  width: 100%;
}

.visual-aid-container.hidden {
  display: none !important;
}

.ten-frame-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  border: 2px solid #64748b;
  border-radius: 6px;
  padding: 4px;
  background: white;
}

.ten-cell {
  width: 15px;
  height: 15px;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ten-cell.filled {
  background: #ec4899;
  border-style: solid;
  border-color: #db2777;
}

.ten-cell.filled-b {
  background: #3b82f6;
  border-style: solid;
  border-color: #2563eb;
}

.feedback-banner {
  position: absolute;
  bottom: -15px;
  background: #10b981;
  color: white;
  padding: 8px 22px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.35);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 15;
}

.feedback-banner.show {
  opacity: 1;
  transform: translateY(0);
}

.feedback-banner.incorrect {
  background: #f59e0b;
  box-shadow: 0 8px 16px rgba(245, 158, 11, 0.35);
}

/* Numpad */
.numpad-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.num-key {
  height: 66px;
  background: var(--numpad-btn-bg);
  color: var(--numpad-btn-text);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  font-family: var(--font-math);
  font-size: 2.1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--numpad-btn-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.num-key:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--numpad-btn-shadow);
}

.special-key {
  font-size: 1.7rem;
  color: #64748b;
  background: #f1f5f9;
}

.submit-btn {
  height: 64px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 18px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--success-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.submit-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--success-shadow);
}

/* =========================================================
   STAGE COMPLETE / LEVEL VICTORY MODAL
   ========================================================= */
.victory-modal-card {
  background: #ffffff;
  border: 4px solid #f59e0b;
  border-radius: 32px;
  padding: 30px 26px;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  animation: victoryCardPop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes victoryCardPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.victory-emoji {
  font-size: 3.2rem;
  display: inline-block;
  animation: petJump 1s infinite alternate;
}

.victory-header h2 {
  font-size: 2.1rem;
  font-weight: 900;
  color: #b45309;
  margin-top: 4px;
}

.victory-header p {
  font-size: 1rem;
  color: #64748b;
  font-weight: 700;
  margin-top: 4px;
}

.victory-stars-row {
  display: flex;
  gap: 12px;
  font-size: 2.8rem;
  margin: 16px 0;
}

.victory-star {
  display: inline-block;
  animation: starSpinIn 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes starSpinIn {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.victory-rewards-box {
  background: #fef3c7;
  border: 2px dashed #f59e0b;
  border-radius: 18px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  width: 100%;
  justify-content: center;
}

.reward-chest-icon {
  font-size: 2rem;
}

.reward-chest-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.reward-chest-text span {
  font-size: 0.8rem;
  font-weight: 700;
  color: #92400e;
}

.reward-chest-text strong {
  font-size: 1.1rem;
  font-weight: 900;
  color: #b45309;
}

.victory-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-primary-glow {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 0 #b45309;
}
.btn-primary-glow:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #b45309;
}

.btn-secondary-outline {
  background: transparent;
  border: 2px solid #cbd5e1;
  color: #64748b;
  padding: 10px 24px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

/* =========================================================
   PROGRESSIVE MULTI-TIER ACHIEVEMENTS (Trophy Room)
   ========================================================= */
.trophies-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.trophies-subtitle-tag {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 700;
}

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

.tiered-badge-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tiered-badge-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(0,0,0,0.1);
}

.tiered-badge-card.max-tier {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.9) 0%, rgba(255, 255, 255, 0.95) 100%);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4);
}

.badge-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge-icon-badge-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-main-icon {
  font-size: 2.4rem;
}

.badge-titles {
  display: flex;
  flex-direction: column;
}

.badge-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-main);
}

.badge-current-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tier-level-pill {
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.tier-level-pill.max {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.badge-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1.3;
}

/* Tier Progress Bar inside Achievement Card */
.tier-progress-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.tier-progress-track {
  width: 100%;
  height: 12px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.tier-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #ec4899 0%, #f59e0b 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.tier-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
}

.next-tier-reward-tag {
  font-size: 0.8rem;
  font-weight: 800;
  color: #b45309;
  background: #fef3c7;
  border-radius: 8px;
  padding: 4px 8px;
  text-align: center;
}

/* =========================================================
   FLOATING LEVEL-UP TOAST NOTIFICATION LAYER
   ========================================================= */
#achievement-toast-layer {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  width: 90%;
  max-width: 440px;
}

.achievement-toast {
  background: #ffffff;
  border: 3px solid #f59e0b;
  border-radius: 20px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 14px 36px rgba(245, 158, 11, 0.35);
  animation: toastSlideDown 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  pointer-events: auto;
}

@keyframes toastSlideDown {
  0% { transform: translateY(-30px) scale(0.85); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.toast-icon {
  font-size: 2.4rem;
  flex-shrink: 0;
  animation: petJump 0.8s infinite alternate;
}

.toast-body {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.toast-tag {
  font-size: 0.72rem;
  font-weight: 900;
  color: #b45309;
  letter-spacing: 0.5px;
}

.toast-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #1e293b;
}

.toast-sub {
  font-size: 0.82rem;
  font-weight: 700;
  color: #10b981;
}

/* =========================================================
   SHOP SHOWCASE & TABS
   ========================================================= */
.shop-coin-counter {
  background: var(--card-bg);
  border: 2px solid #eab308;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: 1.2rem;
  color: #b45309;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.shop-showcase-card {
  background: var(--card-bg);
  border: 3px solid var(--primary);
  border-radius: 24px;
  padding: 14px 20px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto 14px auto;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--card-shadow);
  flex-shrink: 0;
}

.showcase-pet-wrap {
  width: 76px;
  height: 76px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shop-showcase-avatar {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}

.showcase-details h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
}

.showcase-details p {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 600;
}

.shop-tabs {
  display: flex;
  gap: 12px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto 14px auto;
  border-bottom: 2px solid rgba(0,0,0,0.06);
  padding-bottom: 8px;
  flex-shrink: 0;
}

.shop-tab {
  background: transparent;
  border: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.shop-tab.active {
  background: var(--primary);
  color: white;
}

.shop-tab-content {
  display: none !important;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.shop-tab-content.active {
  display: block !important;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  padding-bottom: 30px;
}

.shop-item-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 20px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--card-shadow);
  position: relative;
  transition: transform 0.15s ease;
}

.shop-item-card.equipped {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.shop-item-preview {
  width: 78px;
  height: 78px;
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin-bottom: 10px;
  position: relative;
}

.shop-item-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 3px;
}

.shop-item-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
  min-height: 32px;
}

.shop-item-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.shop-item-btn.buy-btn {
  background: #f59e0b;
  color: white;
  box-shadow: 0 3px 0 #b45309;
}
.shop-item-btn.buy-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b45309;
}

.shop-item-btn.equip-btn {
  background: var(--primary);
  color: white;
  box-shadow: 0 3px 0 var(--primary-shadow);
}
.shop-item-btn.equip-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--primary-shadow);
}

.shop-item-btn.equipped-btn {
  background: #10b981;
  color: white;
  cursor: default;
}

.shop-item-btn.locked-btn {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}

/* =========================================================
   TROPHIES & STATS OVERVIEW
   ========================================================= */
.trophy-content-wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 40px;
}

.stats-overview-card {
  background: var(--card-bg);
  border: 3px solid var(--card-border);
  border-radius: 24px;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  box-shadow: var(--card-shadow);
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-num {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--primary);
}

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

.section-subtitle {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
}

.reset-area {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.btn-danger-outline {
  background: transparent;
  border: 2px dashed #f43f5e;
  color: #f43f5e;
  padding: 8px 22px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
}

/* =========================================================
   SCRATCHPAD MODAL
   ========================================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none !important;
}

.scratchpad-container {
  background: #ffffff;
  border-radius: 24px;
  width: 100%;
  max-width: 900px;
  height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 4px solid var(--primary);
}

.scratchpad-header {
  background: #f8fafc;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #e2e8f0;
}

.scratch-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e293b;
}

.scratchpad-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid white;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.color-btn.active {
  outline: 3px solid var(--primary);
}

.tool-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.close-tool-btn {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.scratchpad-body {
  flex: 1;
  position: relative;
  touch-action: none;
  background: #ffffff;
}

#scratch-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* =========================================================
   FLOATING COINS ANIMATION LAYER
   ========================================================= */
#floating-coins-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2000;
}

.floating-coin-item {
  position: absolute;
  font-size: 1.7rem;
  font-weight: 900;
  color: #eab308;
  text-shadow: 0 2px 6px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 4px;
  animation: floatUpCoin 1.2s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

/* =========================================================
   SCREEN 6: PET PLAYROOM & SANCTUARY
   ========================================================= */
#screen-pet-playroom {
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

.pet-bond-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 2.5px solid #ec4899;
  padding: 4px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.15);
}

.bond-icon {
  font-size: 1.3rem;
  animation: petHeartPop 2s ease-in-out infinite;
}

.bond-level {
  font-weight: 800;
  font-size: 0.95rem;
  color: #ec4899;
}

.bond-meter-mini {
  width: 55px;
  height: 10px;
  background: #fdf2f8;
  border: 1.5px solid #fbcfe8;
  border-radius: 999px;
  overflow: hidden;
}

.bond-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #ec4899, #f43f5e);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Playroom Stage Wrapper */
.playroom-stage-wrapper {
  position: relative;
  width: 100%;
  height: 420px;
  min-height: 400px;
  border-radius: 28px;
  border: 4px solid var(--card-border);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e1b4b;
}

.playroom-scene-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.playroom-props-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.playroom-character-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  margin-top: 10px;
}

.playroom-pet-speech {
  background: var(--card-bg);
  border: 3px solid var(--primary);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  margin-bottom: 8px;
  max-width: 380px;
  text-align: center;
  position: relative;
  animation: speechBubbleBob 3s ease-in-out infinite alternate;
}

.playroom-pet-speech::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: var(--primary) transparent transparent;
}

.playroom-pet-stage {
  cursor: pointer;
  transform-origin: bottom center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 280px;
  height: 280px;
  min-width: 280px;
  min-height: 280px;
}

.playroom-pet-stage:hover {
  transform: scale(1.04);
}

.playroom-pet-stage:active {
  transform: scale(0.96);
}

.playroom-pet-nameplate {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 4px 16px;
  border-radius: 999px;
  margin-top: -10px;
  color: white;
}

.nameplate-name {
  font-weight: 900;
  font-size: 1.05rem;
  color: #fde047;
}

.nameplate-species {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 600;
}

/* Playroom Interactive Deck */
.playroom-deck {
  width: 100%;
  background: var(--card-bg);
  border: 3.5px solid var(--card-border);
  border-radius: 24px;
  padding: 14px 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.playroom-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--card-border);
  padding-bottom: 8px;
  overflow-x: auto;
}

.playroom-tab {
  background: transparent;
  border: 2px solid transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.playroom-tab:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.playroom-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.playroom-panel {
  display: none;
  animation: fadeInPanel 0.25s ease-out;
}

.playroom-panel.active {
  display: block;
}

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

/* Action Rows & Large Interactive Buttons */
.cuddle-actions-row, .snack-cards-row, .toy-cards-row, .trick-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.playroom-action-btn, .snack-btn, .toy-btn, .trick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--card-bg);
  border: 2.5px solid var(--card-border);
  border-radius: 18px;
  padding: 12px 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--card-border);
  transition: all 0.15s ease;
  font-family: var(--font-display);
}

.playroom-action-btn:hover, .snack-btn:hover, .toy-btn:hover, .trick-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 7px 0 var(--card-border);
  border-color: var(--primary);
}

.playroom-action-btn:active, .snack-btn:active, .toy-btn:active, .trick-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--card-border);
}

.pbtn-icon, .snack-icon, .toy-icon, .trick-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.pbtn-label, .snack-name, .toy-name, .trick-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text-main);
}

.pbtn-hint {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ec4899;
}

/* Wardrobe Quick Tray */
.wardrobe-quick-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wardrobe-group-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: block;
}

.wardrobe-item-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.wardrobe-item-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: 6px 10px;
  min-width: 78px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wardrobe-item-pill:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.wardrobe-item-pill.active {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 2px var(--primary);
}

.wardrobe-item-pill.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.wardrobe-avatar-wrap {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wardrobe-name {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

.wardrobe-lock {
  font-size: 0.8rem;
}

/* Shop Hat Preview Wrapper */
.shop-hat-preview-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   RESPONSIVE OPTIMIZATIONS (TABLET / PHONE)
   ========================================================= */
@media (max-width: 900px) {
  .gameplay-arena-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .companion-arena-card {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-around;
    padding: 12px 18px;
  }
  .companion-speech-bubble {
    max-width: 300px;
  }
  .companion-speech-bubble::before {
    top: 50%;
    left: -9px;
    transform: translateY(-50%);
    border-width: 8px 9px 8px 0;
    border-color: transparent var(--primary) transparent transparent;
  }
  .mario-level-popover {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
  }
  .popover-stats-row {
    align-items: center;
  }
  .tiered-badges-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .top-nav {
    height: 60px;
    min-height: 60px;
    padding: 6px 10px;
    gap: 6px;
  }
  .nav-left, .nav-right {
    gap: 6px;
  }
  #btn-home .btn-text {
    display: none;
  }
  .icon-btn {
    min-width: 38px;
    height: 38px;
  }
  .btn-icon {
    font-size: 1.15rem;
  }
  .companion-hud {
    padding: 3px 8px 3px 4px;
    gap: 6px;
  }
  .hud-pet-avatar {
    width: 34px;
    height: 34px;
    font-size: 1.4rem;
  }
  .hud-badge-title {
    display: none;
  }
  .stat-pill {
    padding: 4px 8px;
    font-size: 0.9rem;
    gap: 4px;
  }
  .gameplay-arena-grid {
    grid-template-columns: 1fr;
  }
  .companion-arena-card {
    flex-direction: column;
  }
  .hero-character-stage {
    flex-direction: row;
    justify-content: center;
    gap: 12px;
  }
  .speech-bubble {
    font-size: 0.88rem;
    max-width: 220px;
    padding: 8px 12px;
  }
  .menu-actions-grid {
    grid-template-columns: 1fr;
  }
  .stats-overview-card {
    grid-template-columns: repeat(2, 1fr);
  }
  .num-key {
    height: 58px;
    font-size: 2rem;
  }
  .submit-btn {
    height: 58px;
    font-size: 1.3rem;
  }
}

/* Phones and tablets: stack the title above the pet and its speech bubble, so the menu fits
   the screen with no sideways scrolling. */
@media (max-width: 900px) {
  .hero-banner { flex-direction: column; gap: 8px; }
  .hero-character-stage { flex-shrink: 1; max-width: 100%; min-width: 0; }
  .giant-pet-display { width: 120px; height: 120px; min-width: 120px; }
  .speech-bubble { max-width: none; min-width: 0; flex: 1 1 auto; }
  .game-title { font-size: 2.6rem; }
}

/* Narrow phones: the top bar keeps every button and both counters on screen. The pet's name
   tucks away (its picture stays and still opens the shop), and so does the streak multiplier. */
@media (max-width: 440px) {
  .top-nav { gap: 4px; padding: 6px 8px; }
  .nav-left, .nav-right { gap: 4px; }
  .icon-btn { min-width: 34px; height: 34px; }
  .hud-pet-info { display: none; }
  .companion-hud { padding: 3px; }
  .multiplier-badge { display: none; }
  .stat-pill { padding: 4px 6px; }
}

/* Phones: the level goal pill, the Pet Playroom header and its tabs fit the screen. The tabs
   wrap onto a second line instead of scrolling sideways. */
@media (max-width: 640px) {
  .scenery-environment-banner { padding-left: 10px; padding-right: 10px; gap: 8px; }
  .scenery-info-overlay { min-width: 0; }
  .level-progress-pill { padding: 5px 8px; gap: 6px; flex-shrink: 1; min-width: 0; }
  .progress-bar-track { width: 56px; }
  .screen-header { flex-wrap: wrap; gap: 8px; }
  .screen-header h2 { font-size: 1.3rem; flex: 1 1 100%; order: 3; }
  .playroom-tabs { flex-wrap: wrap; overflow-x: visible; }
  .playroom-tab { padding: 6px 12px; }
}
