/* === MineLearn - Vibrant Minecraft Kids UI === */
/* Design: Playful maximalist MC aesthetic with depth, glow, and bold color */

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

:root {
  /* Deep night-sky palette with MC accent colors */
  --bg-deep: #1a1a2e;
  --bg-mid: #16213e;
  --bg-surface: #0f3460;
  --bg-card: #1a1a3e;

  /* MC accent colors — vivid & saturated */
  --mc-green: #4ade80;
  --mc-green-glow: rgba(74, 222, 128, 0.4);
  --mc-green-dark: #166534;
  --mc-emerald: #34d399;
  --mc-gold: #fbbf24;
  --mc-gold-glow: rgba(251, 191, 36, 0.4);
  --mc-red: #f87171;
  --mc-red-glow: rgba(248, 113, 113, 0.3);
  --mc-blue: #60a5fa;
  --mc-purple: #a78bfa;
  --mc-purple-glow: rgba(167, 139, 250, 0.3);
  --mc-cyan: #22d3ee;
  --mc-xp-green: #80FF20;

  /* Text */
  --text-white: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Surfaces */
  --panel-bg: rgba(15, 23, 42, 0.85);
  --panel-border: rgba(148, 163, 184, 0.15);
  --slot-bg: rgba(30, 41, 59, 0.8);
  --slot-border: rgba(100, 116, 139, 0.3);
  --slot-highlight: rgba(255, 255, 255, 0.05);

  /* Buttons */
  --btn-bg: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  --btn-hover: linear-gradient(180deg, #475569 0%, #334155 100%);
  --btn-border: rgba(148, 163, 184, 0.2);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 20px;
}

/* === Background: deep gradient with subtle grid === */
body {
  font-family: Arial, Helvetica, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  image-rendering: pixelated;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(74, 222, 128, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(167, 139, 250, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-deep) 0%, #0f172a 100%);
  background-attachment: fixed;
}

/* Pixel grid overlay for MC feel */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 8px 8px;
  z-index: 0;
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
}

.app-hidden {
  display: none !important;
}

/* =============================================
   LOADING SCREEN
   ============================================= */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 50% 50%, rgba(74, 222, 128, 0.1) 0%, transparent 70%);
}

.loading-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 8px 8px;
  pointer-events: none;
}

.loading-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
}

.loading-bar-container {
  width: 300px;
  max-width: 80vw;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid var(--slot-border);
  border-radius: var(--r-sm);
  margin: 24px auto 12px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mc-green-dark), var(--mc-green));
  box-shadow: 0 0 12px var(--mc-green-glow);
  border-radius: var(--r-sm);
  transition: width 0.3s ease;
}

.loading-text {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
}

.loading-tip {
  text-align: center;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 16px 0 0;
}

.loading-tip-icon {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
  transition: opacity 0.4s ease;
}

.loading-tip-caption {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 6px;
  opacity: 0.6;
  transition: opacity 0.4s ease;
  max-width: 250px;
}

.loading-tip-icon.tip-fade,
.loading-tip-caption.tip-fade {
  opacity: 0;
}

.loading-screen.done {
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

/* === Screens === */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* =============================================
   TITLE
   ============================================= */
.mc-title-block {
  text-align: center;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.mc-title {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 6px;
  text-shadow:
    0 0 20px var(--mc-green-glow),
    0 4px 0 rgba(0, 0, 0, 0.4);
  line-height: 1.3;
}

.mc-title-green {
  color: var(--mc-green);
  text-shadow:
    0 0 30px var(--mc-green-glow),
    0 0 60px rgba(74, 222, 128, 0.2),
    0 4px 0 var(--mc-green-dark);
}

.mc-logo-icon {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
  margin-bottom: 4px;
}

/* =============================================
   HOME SCREEN
   ============================================= */
#home-screen {
  justify-content: center;
  gap: 16px;
  padding: 24px 16px 40px;
}

/* =============================================
   DIFFICULTY TOGGLE
   ============================================= */
/* Settings row: difficulty + max number */
.settings-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.maxnum-toggle {
  display: flex;
  gap: 4px;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  padding: 4px;
  backdrop-filter: blur(8px);
}

.maxnum-btn {
  min-width: 44px;
  min-height: 44px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
}

.maxnum-btn:active {
  background: rgba(255,255,255,0.1);
}

.maxnum-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 6px;
  white-space: nowrap;
}

/* Parent game description — small, subtle */
.game-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 600px;
  width: 100%;
  padding: 4px 12px;
  min-height: 1em;
}

/* Game ended state — all controls disabled, visual overlay */
.game-ended .game-area,
.game-ended .mgmt-area {
  pointer-events: none;
  opacity: 0.4;
  filter: grayscale(0.5);
}

.game-ended .game-area::after,
.game-ended .mgmt-area::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
}

.difficulty-toggle {
  display: flex;
  gap: 4px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  padding: 4px;
  backdrop-filter: blur(8px);
}

.difficulty-btn {
  min-width: 80px;
  min-height: 44px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
}

.difficulty-btn.active {
  background: linear-gradient(180deg, var(--mc-green-dark) 0%, #14532d 100%);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--mc-gold);
  box-shadow: 0 0 16px var(--mc-green-glow), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* =============================================
   GAME BUTTONS
   ============================================= */

/* Home sections — visual grouping */
.home-section {
  width: 100%;
  max-width: 400px;
}

/* Mini-games 2×2 grid */
.game-buttons {
  display: grid;
  gap: 10px;
  width: 100%;
}

.game-buttons-mini {
  grid-template-columns: 1fr 1fr;
}

/* Think: 3-column grid */
.game-buttons-think {
  grid-template-columns: 1fr 1fr 1fr;
  max-width: 420px;
  margin: 0 auto;
}

/* Adventure: 3 columns */
.game-buttons-adventure {
  grid-template-columns: 1fr 1fr 1fr;
}

.mc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 12px;
  min-height: 80px;
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-white);
  position: relative;
  background: var(--btn-bg);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  flex-direction: column;
  overflow: hidden;
}

.mc-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 50%);
  pointer-events: none;
}

.mc-btn::after {
  content: none;
}

.mc-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 20px var(--mc-green-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
}

.mc-btn:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.mc-btn .btn-img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* Stars on home buttons */
.btn-stars {
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--mc-gold);
  min-height: 1em;
}

/* Section divider — sword icon between sections */
.section-divider {
  text-align: center;
  color: var(--mc-gold);
  font-size: 1.2rem;
  font-weight: 700;
  text-shadow: 0 0 12px var(--mc-gold-glow);
  padding: 2px 0;
  letter-spacing: 4px;
  opacity: 0.7;
}

/* Adventure button variant — green tint */
.mc-btn-adventure {
  background: linear-gradient(180deg, #166534 0%, #14532d 100%);
  border-color: rgba(74, 222, 128, 0.15);
}

.mc-btn-adventure:hover {
  background: linear-gradient(180deg, #15803d 0%, #166534 100%);
  border-color: rgba(74, 222, 128, 0.4);
}

/* Daily challenge — full width, horizontal layout, purple */
.home-section-daily {
  display: flex;
  justify-content: center;
}

.mc-btn-daily {
  width: 100%;
  background: linear-gradient(180deg, #5b21b6 0%, #4c1d95 100%);
  border-color: rgba(167, 139, 250, 0.2);
  flex-direction: row;
  min-height: 64px;
  padding: 10px 20px;
}

.mc-btn-daily .btn-img {
  width: 40px;
  height: 40px;
}

.mc-btn-daily:hover {
  background: linear-gradient(180deg, #6d28d9 0%, #5b21b6 100%);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 20px var(--mc-purple-glow);
  border-color: rgba(167, 139, 250, 0.4);
}

.mc-btn-daily.completed {
  background: linear-gradient(180deg, #166534 0%, #14532d 100%);
  border-color: rgba(74, 222, 128, 0.3);
}

.btn-daily-status {
  font-size: 1.1rem;
  min-width: 40px;
  text-align: right;
}

/* =============================================
   GAME SCREEN
   ============================================= */
#game-screen {
  padding-top: 10px;
}

/* === Game Header V2 === */
.game-header-v2 {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin-bottom: 8px;
  gap: 8px;
  padding: 6px;
}

.gh-back {
  font-size: 1.4rem;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.15s ease;
}

.gh-back:active {
  transform: scale(0.9);
}

/* Progress dots — each round is a dot */
.gh-progress {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.gh-progress-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.pdot {
  font-size: 0.75rem;
  line-height: 1;
  transition: all 0.2s ease;
}

.pdot-done {
  color: var(--mc-green);
  text-shadow: 0 0 6px var(--mc-green-glow);
}

.pdot-active {
  color: var(--mc-gold);
  font-size: 0.9rem;
  text-shadow: 0 0 8px var(--mc-gold-glow);
  animation: pdot-pulse 1s ease infinite;
}

.pdot-todo {
  color: rgba(255, 255, 255, 0.2);
}

@keyframes pdot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Score display */
.gh-score {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--r-md);
  padding: 6px 12px;
  min-width: 60px;
  justify-content: center;
}

.gh-score-num {
  color: var(--mc-xp-green);
  font-size: 1.3rem;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(128, 255, 32, 0.6);
}

.gh-score-icon {
  font-size: 1rem;
}

.gh-score.combo-active {
  box-shadow: 0 0 16px var(--mc-gold-glow), inset 0 0 12px rgba(255, 170, 0, 0.1);
}

.combo-display {
  color: var(--mc-gold);
  font-size: 1rem;
  font-weight: 900;
  margin-left: 4px;
  text-shadow: 0 0 8px var(--mc-gold-glow);
  animation: combo-pulse 0.5s ease;
}

.combo-display.hidden {
  display: none;
}

@keyframes combo-pulse {
  0% { transform: scale(1.6); }
  100% { transform: scale(1); }
}

/* =============================================
   TIMER BAR
   ============================================= */
.timer-bar-container {
  width: 100%;
  max-width: 600px;
  height: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  overflow: hidden;
}

.timer-bar-container.hidden {
  display: none;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--mc-green-dark), var(--mc-green));
  box-shadow: 0 0 8px var(--mc-green-glow);
  border-radius: var(--r-sm);
  transition: width 0.1s linear;
}

.timer-bar-fill.timer-warning {
  background: linear-gradient(90deg, #b45309, var(--mc-gold));
  box-shadow: 0 0 8px var(--mc-gold-glow);
}

.timer-bar-fill.timer-danger {
  background: linear-gradient(90deg, #991b1b, var(--mc-red));
  box-shadow: 0 0 8px var(--mc-red-glow);
}

/* =============================================
   GAME PROMPT
   ============================================= */
.mc-prompt {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-white);
  text-align: center;
  margin: 8px 0;
  padding: 16px 24px;
  max-width: 600px;
  width: 100%;
  line-height: 1.8;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
}

/* =============================================
   GAME AREA
   ============================================= */
.game-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 600px;
  width: 100%;
  margin-top: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  padding: 16px;
  backdrop-filter: blur(8px);
  transition: opacity 0.2s ease;
}

.game-area.fade-out {
  opacity: 0;
}

.game-area.fade-in {
  opacity: 1;
}

/* =============================================
   ANSWER CARDS
   ============================================= */
.answer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
  padding: 14px;
  cursor: pointer;
  min-width: 110px;
  min-height: 110px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  image-rendering: pixelated;
  /* Staggered entrance */
  opacity: 0;
  transform: scale(0.8) translateY(10px);
  animation: card-entrance 0.35s ease forwards;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

/* Subtle inner shine */
.answer-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 40%);
  pointer-events: none;
}

.answer-card:nth-child(1) { animation-delay: 0s; }
.answer-card:nth-child(2) { animation-delay: 0.06s; }
.answer-card:nth-child(3) { animation-delay: 0.12s; }
.answer-card:nth-child(4) { animation-delay: 0.18s; }
.answer-card:nth-child(5) { animation-delay: 0.24s; }
.answer-card:nth-child(6) { animation-delay: 0.30s; }

@keyframes card-entrance {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.answer-card:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px rgba(255, 255, 255, 0.05);
  border-color: rgba(148, 163, 184, 0.3);
}

.answer-card:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Inline prompt image */
.prompt-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
  vertical-align: middle;
  margin: 0 4px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.prompt-icon-large {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
  display: block;
  margin: 0 auto 6px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.prompt-question {
  font-size: 2.5em;
}

.craft-arrow {
  font-size: 1.5em;
  color: var(--text-dim);
}

.food-drain-indicator {
  text-align: center;
  padding: 4px 0;
}

.mc-icon {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.mc-icon-small {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
  margin: 4px;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.card-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-white);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* Card labels — hidden (icons should be self-explanatory) */
.answer-card .card-label {
  display: none;
}

/* Correct answer */
.answer-card.correct {
  background: linear-gradient(180deg, #166534 0%, #14532d 100%);
  border-color: var(--mc-green);
  box-shadow: 0 0 24px var(--mc-green-glow), inset 0 0 12px rgba(74, 222, 128, 0.1);
  animation: mc-pop 0.3s ease;
}

/* Wrong answer */
.answer-card.wrong {
  background: linear-gradient(180deg, #991b1b 0%, #7f1d1d 100%);
  border-color: var(--mc-red);
  box-shadow: 0 0 24px var(--mc-red-glow), inset 0 0 12px rgba(248, 113, 113, 0.1);
  animation: mc-shake 0.3s ease;
}

/* Costly choice in management games — orange shake.
   Distinct from quiz .wrong (red) — this means "valid but costly", not "incorrect". */
.answer-card.choice-costly {
  background: linear-gradient(180deg, #92400e 0%, #78350f 100%);
  border-color: #f59e0b;
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.5), inset 0 0 12px rgba(245, 158, 11, 0.15);
  animation: mc-shake 0.45s ease;
}

/* Good management-game choice — stronger pop + green sparkle burst */
.answer-card.card-choice-good {
  animation: mc-choice-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
  box-shadow: 0 0 32px var(--mc-green-glow), 0 0 64px rgba(74, 222, 128, 0.2), inset 0 0 16px rgba(74, 222, 128, 0.15);
}

@keyframes mc-choice-pop {
  0% { transform: scale(1); filter: brightness(1); }
  15% { transform: scale(1.18); filter: brightness(1.4); }
  30% { transform: scale(0.95); filter: brightness(1.15); }
  50% { transform: scale(1.08); filter: brightness(1.2); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Math cards */
.answer-card.math-card {
  min-width: 90px;
  min-height: 90px;
}

.answer-card.math-card .card-emoji {
  font-size: 1.5rem;
  color: var(--text-white);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.answer-card.math-card:hover .card-emoji,
.answer-card.math-card.correct .card-emoji,
.answer-card.math-card.wrong .card-emoji {
  color: #FFFFFF;
}

/* =============================================
   COUNTING DISPLAY
   ============================================= */
.counting-objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 16px;
  max-width: 600px;
  width: 100%;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
}

.counting-equals {
  font-size: 2rem;
  font-weight: 700;
  color: var(--mc-gold);
  text-shadow: 0 0 12px var(--mc-gold-glow);
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
}

.counting-options-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

/* =============================================
   PATTERN BUILDER
   ============================================= */
.pattern-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
}

.pattern-item {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.pattern-gap {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--mc-gold);
  text-shadow: 0 0 12px var(--mc-gold-glow);
  border: 3px dashed var(--mc-gold);
  border-radius: var(--r-sm);
  background: rgba(255,170,0,0.1);
}

/* =============================================
   MEMORY CARDS
   ============================================= */
.memory-grid {
  display: grid !important;
  gap: 8px;
  padding: 8px;
  justify-content: center;
}

.memory-grid-4 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 340px;
  margin: 0 auto;
}

.memory-grid-6 {
  grid-template-columns: repeat(4, 1fr);
  max-width: 340px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  min-width: 60px;
  min-height: 60px;
  border: 3px solid var(--slot-border);
  border-radius: var(--r-md);
  background: var(--slot-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.3s, border-color 0.3s;
  padding: 4px;
}

.memory-card:active {
  transform: scale(0.95);
}

.memory-card-back {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--mc-gold);
  text-shadow: 0 0 8px var(--mc-gold-glow);
  user-select: none;
}

.memory-card-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.memory-face-up {
  border-color: var(--mc-blue);
  background: rgba(85, 170, 255, 0.15);
}

.memory-matched {
  border-color: var(--mc-green) !important;
  background: rgba(128, 255, 32, 0.15) !important;
  animation: mc-pop 0.3s ease-out;
  cursor: default;
}

.memory-wrong {
  border-color: var(--mc-red) !important;
  background: rgba(255, 85, 85, 0.15) !important;
  animation: mc-shake 0.3s ease-out;
}

.memory-moves {
  font-size: 1rem;
  font-weight: 700;
  color: var(--mc-gold);
}

/* =============================================
   NUMBER COMPARISON
   ============================================= */
.compare-arrow {
  display: inline-block;
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  margin-right: 8px;
  vertical-align: middle;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.compare-arrow-up {
  color: var(--mc-green);
  text-shadow: 0 0 12px var(--mc-green);
}

.compare-arrow-down {
  color: var(--mc-red);
  text-shadow: 0 0 12px var(--mc-red);
}

.compare-card {
  min-height: 80px;
  padding: 8px;
}

.compare-item-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  align-items: center;
}

.compare-item-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
  object-fit: contain;
}

/* =============================================
   FEEDBACK
   ============================================= */
.feedback {
  font-size: 2.5rem;
  font-weight: 700;
  margin-top: 12px;
  min-height: 48px;
  text-align: center;
  color: var(--text-white);
}

.feedback.correct-feedback {
  color: var(--mc-green);
  text-shadow: 0 0 20px var(--mc-green-glow);
  animation: feedback-pop 0.4s ease;
}

.feedback.wrong-feedback {
  color: var(--mc-red);
  text-shadow: 0 0 20px var(--mc-red-glow);
}

@keyframes feedback-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

.combo-text {
  display: block;
  color: var(--mc-gold);
  font-size: 0.85rem;
  text-shadow: 0 0 8px var(--mc-gold-glow);
  animation: combo-pulse 0.4s ease;
}

/* =============================================
   CELEBRATION
   ============================================= */
.celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
}

.celebration.hidden {
  display: none;
}

.mc-celebration-box {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-xl);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(74, 222, 128, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  padding: 28px 32px;
  text-align: center;
  animation: mc-pop 0.35s ease;
  max-width: 400px;
  width: 90%;
  position: relative;
  cursor: default;
}

.mc-celebration-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-white);
  margin: 0;
}

.mc-stars-display {
  font-size: 3rem;
  margin: 16px 0;
  letter-spacing: 8px;
}

.star-earned {
  color: var(--mc-gold);
  text-shadow: 0 0 16px var(--mc-gold-glow);
  display: inline-block;
  animation: star-pop 0.4s ease forwards;
  opacity: 0;
}

.star-earned:nth-child(1) { animation-delay: 0.2s; }
.star-earned:nth-child(2) { animation-delay: 0.5s; }
.star-earned:nth-child(3) { animation-delay: 0.8s; }

.star-empty {
  color: var(--text-dim);
  text-shadow: none;
}

@keyframes star-pop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.5) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.mc-xp-display {
  margin: 12px 0;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}

.cel-score-num {
  font-size: 3rem;
  font-weight: 700;
  color: var(--mc-xp-green);
  text-shadow: 0 0 20px rgba(128, 255, 32, 0.5);
}

.cel-score-sep {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dim);
  margin: 0 2px;
}

.cel-score-den {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-dim);
}

.mc-cel-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.mc-cel-btn {
  font-size: 1.8rem;
  width: 68px;
  height: 68px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-lg);
}

/* =============================================
   ACHIEVEMENT TOAST
   ============================================= */
.achievement-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px var(--mc-gold-glow);
  padding: 14px 22px;
  animation: toast-slide-in 0.5s ease forwards;
}

.achievement-toast.hidden {
  display: none;
}

.achievement-toast.toast-exit {
  animation: toast-slide-out 0.5s ease forwards;
}

@keyframes toast-slide-in {
  to { transform: translateX(-50%) translateY(0); }
}

@keyframes toast-slide-out {
  to { transform: translateX(-50%) translateY(-100px); }
}

.achievement-icon {
  font-size: 2rem;
  color: var(--mc-gold);
  text-shadow: 0 0 12px var(--mc-gold-glow);
}

.achievement-desc {
  color: var(--text-white);
  font-size: 1.2rem;
  font-weight: 700;
}

/* =============================================
   MANAGEMENT GAMES
   ============================================= */

/* MC panel (generic) */
.mc-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
}

.mc-panel-dark {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-md);
}

.mc-btn-small {
  /* used by difficulty toggle */
}

/* Status bar */
.mgmt-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 600px;
  width: 100%;
  margin-bottom: 4px;
}

#mgmt-scoreboard {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.res-counter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--r-sm);
  border: 1px solid var(--slot-border);
}

.res-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-white);
  min-width: 14px;
  text-align: right;
}

/* =============================================
   BIG RESOURCE BAR
   ============================================= */
/* Inventory label for chest sections */
.big-res-bar::before {
  content: '📦';
  position: absolute;
  top: -12px;
  left: 12px;
  font-size: 1rem;
  background: rgba(60, 40, 20, 0.9);
  padding: 0 6px;
  border-radius: var(--r-sm);
}

/* Inventory chest style — player's resources */
.big-res-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: stretch;
  max-width: 600px;
  width: 100%;
  padding: 10px 8px;
  background: linear-gradient(180deg, rgba(101, 67, 33, 0.6) 0%, rgba(60, 40, 20, 0.7) 100%);
  border: 2px solid rgba(139, 90, 43, 0.5);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 200, 100, 0.1), 0 4px 16px rgba(0, 0, 0, 0.3);
  position: relative;
}

.big-res {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  padding: 8px 4px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
}

.big-res-icon {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.big-res-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-white);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* =============================================
   BIG GOALS
   ============================================= */
/* Goals label */
.big-goals::before {
  content: '🎯';
  position: absolute;
  top: -12px;
  left: 12px;
  font-size: 1rem;
  background: rgba(20, 40, 20, 0.9);
  padding: 0 6px;
  border-radius: var(--r-sm);
}

/* Goals — target/mission slots */
.big-goals {
  position: relative;
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  max-width: 600px;
  width: 100%;
  padding: 8px;
  background: linear-gradient(180deg, rgba(40, 60, 40, 0.7) 0%, rgba(20, 40, 20, 0.8) 100%);
  border: 2px solid rgba(74, 222, 128, 0.15);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.big-goal {
  width: 68px;
  height: 68px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  opacity: 0.35;
  transition: opacity 0.3s, box-shadow 0.3s, border-color 0.3s;
}

.big-goal-done {
  opacity: 1;
  background: linear-gradient(180deg, #166534 0%, #14532d 100%);
  border-color: rgba(74, 222, 128, 0.4);
  box-shadow: 0 0 16px var(--mc-green-glow);
  animation: mc-pop 0.4s ease;
}

.big-goal-icon {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.big-goal-label {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-white);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.big-goal-check {
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 1.1rem;
  color: var(--mc-green);
  text-shadow: 0 0 8px var(--mc-green-glow);
}

/* =============================================
   BIG FOOD DRAIN
   ============================================= */
.big-drain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  max-width: 600px;
  width: 100%;
  background: linear-gradient(180deg, rgba(153, 27, 27, 0.5) 0%, rgba(127, 29, 29, 0.4) 100%);
  border: 2px solid rgba(248, 113, 113, 0.3);
  border-radius: var(--r-md);
  animation: drainBreathe 2s ease-in-out infinite;
}

@keyframes drainBreathe {
  0%, 100% { border-color: rgba(248, 113, 113, 0.3); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
  50% { border-color: rgba(248, 113, 113, 0.6); box-shadow: 0 0 12px 2px rgba(248, 113, 113, 0.2); }
}

.big-drain-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--mc-red);
  text-shadow: 0 0 10px var(--mc-red-glow);
}

.big-drain-icon {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  object-fit: contain;
  animation: drainIconWobble 2s ease-in-out infinite;
}

@keyframes drainIconWobble {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(0.9) rotate(-5deg); }
  75% { transform: scale(0.9) rotate(5deg); }
}

/* =============================================
   RESOURCE CHANGE ANIMATIONS
   ============================================= */

/* Big full-screen overlay showing resource changes */
.res-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.res-overlay-gain { background: rgba(34, 120, 50, 0.35); }
.res-overlay-spend { background: rgba(140, 30, 30, 0.35); }
.res-overlay-show { opacity: 1; }

.res-overlay-item {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: overlayPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.res-overlay-num {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
}
.res-overlay-gain .res-overlay-num {
  color: #4ade80;
  text-shadow: 0 0 20px rgba(74, 222, 128, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
}
.res-overlay-spend .res-overlay-num {
  color: #f87171;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
}
.res-overlay-icon {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

@keyframes overlayPop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Resource box animations — big and obvious */
.big-res { position: relative; }

/* Gain: green glow + bounce up */
.res-gain {
  animation: resGain 1s ease-out !important;
}
@keyframes resGain {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); transform: scale(1); }
  20% { box-shadow: 0 0 24px 8px rgba(74, 222, 128, 0.6); transform: scale(1.2); }
  50% { transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); transform: scale(1); }
}

/* Spend: shrink + dim */
.res-spend {
  animation: resSpend 1s ease-out !important;
}
@keyframes resSpend {
  0% { transform: scale(1); opacity: 1; }
  20% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* Drain: red pulse for food consumption */
.res-drain {
  animation: resDrain 1s ease-out !important;
}
@keyframes resDrain {
  0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); transform: scale(1); }
  20% { box-shadow: 0 0 20px 6px rgba(248, 113, 113, 0.5); transform: scale(0.85); }
  50% { transform: scale(0.95); }
  100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); transform: scale(1); }
}

/* Resource zero warning: shake + red flash (one-shot) */
@keyframes resLowWarning {
  0%, 100% { transform: translateX(0);   background: var(--slot-bg); }
  12%, 62% { transform: translateX(-4px); background: rgba(239, 68, 68, 0.4); }
  37%, 87% { transform: translateX( 4px); background: rgba(239, 68, 68, 0.4); }
}
.res-low {
  animation: resLowWarning 0.8s ease-in-out !important;
}

/* Sustained critical state: continuous red glow */
@keyframes resDangerPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50%       { box-shadow: 0 0 18px 5px rgba(239, 68, 68, 0.55); }
}
.res-danger {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.55) !important;
  animation: resDangerPulse 1.4s ease-in-out infinite !important;
}

/* Villager distress — sprite droops + desaturates when happiness is critical (≤ 1) */
@keyframes villagerDroop {
  0%, 100% { transform: scale(1) rotate(0deg); }
  30%       { transform: scale(0.92) rotate(-5deg); }
  70%       { transform: scale(0.92) rotate(5deg); }
}
.villagers-sad .big-res-icon {
  filter: grayscale(0.75) brightness(0.75);
  animation: villagerDroop 2.5s ease-in-out infinite;
}

/* Villager caution — subtle yellow tint when happiness = 3 ("getting tired") */
.villagers-caution .big-res-icon {
  filter: sepia(0.25) brightness(0.95);
  transition: filter 0.5s ease;
}

/* Villager warning — orange-amber tint when happiness = 2 ("struggling") */
@keyframes villagerWobble {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%       { transform: scale(0.96) rotate(-3deg); }
}
.villagers-warning .big-res-icon {
  filter: sepia(0.6) hue-rotate(-15deg) brightness(0.85);
  animation: villagerWobble 3s ease-in-out infinite;
}

/* Full-screen dramatic fail animation for management game loss */
@keyframes mgmtFailSequence {
  0%        { background: transparent; transform: translateX(0); }
  10%       { background: rgba(239, 68, 68, 0.45); transform: translateX(-6px); }
  25%       { background: rgba(239, 68, 68, 0.60); transform: translateX( 6px); }
  40%       { background: rgba(239, 68, 68, 0.45); transform: translateX(-4px); }
  55%       { background: rgba(239, 68, 68, 0.30); transform: translateX( 3px); }
  70%       { background: rgba(239, 68, 68, 0.20); transform: translateX(-2px); }
  100%      { background: transparent; transform: translateX(0); }
}
.mgmt-fail {
  animation: mgmtFailSequence 0.9s ease-in-out !important;
}

/* Drain bar active pulse — overrides the breathing animation */
.drain-pulse {
  animation: drainPulse 1.2s ease-out !important;
}
@keyframes drainPulse {
  0% { transform: scale(1); background: linear-gradient(180deg, rgba(153, 27, 27, 0.5) 0%, rgba(127, 29, 29, 0.4) 100%); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
  15% { transform: scale(1.08); background: linear-gradient(180deg, rgba(240, 50, 50, 0.8) 0%, rgba(200, 30, 30, 0.7) 100%); box-shadow: 0 0 30px 8px rgba(248, 113, 113, 0.5); border-color: rgba(248, 113, 113, 0.8); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}
.drain-pulse .big-drain-icon {
  animation: drainChomp 0.3s ease-in-out 3 !important;
}
@keyframes drainChomp {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.3) rotate(-10deg); }
}

/* =============================================
   BIG HEARTS
   ============================================= */
.big-hearts {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 8px;
  max-width: 600px;
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
}

.big-heart {
  font-size: 2.6rem;
  line-height: 1;
}

.big-heart-full {
  color: #ef4444;
  text-shadow: 0 0 12px var(--mc-red-glow);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.big-heart-empty {
  color: var(--text-dim);
  text-shadow: none;
}

/* =============================================
   BIG BACKPACK
   ============================================= */
/* Backpack — player's collected items */
.big-backpack {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 10px 8px;
  max-width: 600px;
  width: 100%;
  background: linear-gradient(180deg, rgba(101, 67, 33, 0.6) 0%, rgba(60, 40, 20, 0.7) 100%);
  border: 2px solid rgba(139, 90, 43, 0.5);
  border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 200, 100, 0.1), 0 4px 16px rgba(0, 0, 0, 0.3);
  position: relative;
}

.big-backpack::before {
  content: '🎒';
  position: absolute;
  top: -12px;
  left: 12px;
  font-size: 1rem;
  background: rgba(60, 40, 20, 0.9);
  padding: 0 6px;
  border-radius: var(--r-sm);
}

.big-bp-slot {
  width: 56px;
  height: 56px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.big-bp-slot.empty {
  opacity: 0.3;
}

.big-bp-icon {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
}

/* Footer goals (village) */
.footer-goals {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.footer-goals .big-res {
  min-width: auto;
  padding: 4px 8px;
}

.footer-goals .big-res-icon {
  width: 28px;
  height: 28px;
}

.footer-goals .big-res-num {
  font-size: 1rem;
}

/* Management game area */
.mgmt-area {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* Disabled card — not enough resources.
   Must be VERY obvious for a 4-year-old: strong greyscale, low opacity,
   big lock icon, diagonal stripes, and red-tinted border. */
.answer-card.card-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  filter: grayscale(0.9) brightness(0.5);
  border-color: rgba(248, 113, 113, 0.5);
  border-width: 3px;
  border-style: dashed;
  position: relative;
  background:
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 6px,
      rgba(0, 0, 0, 0.15) 6px,
      rgba(0, 0, 0, 0.15) 10px
    ),
    var(--slot-bg);
}

.answer-card.card-disabled::after {
  content: '🔒';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  filter: none;
  opacity: 0.85;
  pointer-events: none;
  z-index: 2;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Shake-deny animation when child taps a disabled card */
.answer-card.card-disabled.card-denied {
  animation: mc-shake-deny 0.4s ease;
  border-color: rgba(248, 113, 113, 0.8);
}

.answer-card.card-disabled:hover {
  transform: none;
  box-shadow: none;
  background:
    repeating-linear-gradient(
      135deg,
      transparent,
      transparent 6px,
      rgba(0, 0, 0, 0.15) 6px,
      rgba(0, 0, 0, 0.15) 10px
    ),
    var(--slot-bg);
  border-color: rgba(248, 113, 113, 0.5);
}

/* Built card — already crafted successfully */
.answer-card.card-built {
  filter: opacity(0.7);        /* animation-immune, won't be overridden by forwards fill */
  border-color: var(--mc-green);
  box-shadow: 0 0 8px var(--mc-green-glow);
  pointer-events: none;
  cursor: default;
}

.answer-card.card-built:hover {
  transform: none;
  box-shadow: 0 0 8px var(--mc-green-glow);
}

/* Built checkmark — replaces inline style */
.card-built-check {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 1.3em;
  color: #4caf50;
  pointer-events: none;
  line-height: 1;
}

/* Required item card — star badge + gold accent border */
.answer-card.card-required {
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
}

.answer-card.card-required:hover {
  border-color: #fbbf24;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.5);
}

.card-req-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 1.1em;
  color: #fbbf24;
  pointer-events: none;
  line-height: 1;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.7);
}

/* Bonus craft card — optional, earns extra star */
.answer-card.card-bonus {
  border-color: #22d3ee;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.35);
}

.answer-card.card-bonus:hover {
  border-color: #22d3ee;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.5);
}

.card-bonus-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 1.1em;
  pointer-events: none;
  line-height: 1;
  text-shadow: 0 0 6px rgba(34, 211, 238, 0.8);  /* cyan glow matching card-bonus border */
}

/* Card badges */
.card-badges {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.card-trade {
  display: flex;
  gap: 3px;
}

.card-res-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  line-height: 1;
  border: 1px solid;
}

/* Unified neutral badge style — no red/green bias */
.trade-badge {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Tiny icons in badges */
.mc-icon-tiny {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  vertical-align: middle;
}

.badge-heart {
  color: #ef4444;
  font-size: 1.1rem;
  vertical-align: middle;
}

/* Tutorial hint — first-play pulse on the recommended card */
.card-hint-pulse {
  outline: 3px solid #fbbf24 !important;
  outline-offset: 2px;
  animation: hint-pulse 0.85s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { filter: drop-shadow(0 0 0px rgba(251, 191, 36, 0.6)); }
  50%       { filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.8)); }
}

/* Math level-up flash — brief gold sparkle when difficulty tier increases */
@keyframes mathLevelUp {
  0%   { background: transparent; transform: scale(1); }
  25%  { background: rgba(255, 215, 0, 0.35); transform: scale(1.04);
         box-shadow: 0 0 24px 6px rgba(255, 215, 0, 0.5); }
  70%  { background: rgba(255, 215, 0, 0.12); transform: scale(1.01); }
  100% { background: transparent; transform: scale(1); box-shadow: none; }
}
.math-levelup {
  animation: mathLevelUp 0.7s ease-out;
  border-radius: 8px;
}

/* Goal slots for survival */
.mgmt-goals {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.goal-slot {
  width: 56px;
  height: 56px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  opacity: 0.3;
  transition: all 0.3s ease;
}

.goal-slot.goal-done {
  opacity: 1;
  border-color: rgba(74, 222, 128, 0.4);
  box-shadow: 0 0 12px var(--mc-green-glow);
}

.goal-count {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-white);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Quest hearts */
.quest-heart {
  font-size: 1.6rem;
  margin: 0 2px;
}

.quest-heart.heart-full {
  color: #ef4444;
  text-shadow: 0 0 8px var(--mc-red-glow);
}

.quest-heart.heart-empty {
  color: var(--text-dim);
  text-shadow: none;
}

/* Game log */
.mgmt-log {
  max-width: 600px;
  width: 100%;
  margin-top: 6px;
  max-height: 60px;
  overflow-y: auto;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-md);
  font-size: 0.55rem;
  color: var(--text-dim);
}

.mgmt-log-entry {
  padding: 1px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  animation: card-entrance 0.3s ease forwards;
}

.mgmt-log-entry.good {
  color: var(--mc-green);
}

.mgmt-log-entry.bad {
  color: var(--mc-red);
}

/* Game footer */
.mgmt-footer {
  max-width: 600px;
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-md);
  font-size: 0.6rem;
  color: var(--text-dim);
  line-height: 1.4;
  text-align: center;
}

/* Backpack display */
.backpack-display {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.backpack-slot {
  width: 40px;
  height: 40px;
  background: var(--slot-bg);
  border: 1px solid var(--slot-border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.backpack-slot.empty {
  opacity: 0.4;
}

/* =============================================
   FLOATING RESULT BUTTON
   ============================================= */
.show-result-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 101;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 50%;
  background: linear-gradient(180deg, #b45309 0%, #92400e 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 20px var(--mc-gold-glow);
  color: var(--mc-gold);
  font-size: 1.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: result-btn-pulse 2s ease-in-out infinite;
}

.show-result-btn.hidden {
  display: none;
}

@keyframes result-btn-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 20px var(--mc-gold-glow); }
  50% { transform: scale(1.1); box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 32px var(--mc-gold-glow); }
}

/* =============================================
   PARTICLES
   ============================================= */
.mc-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99;
}

.mc-particle {
  position: absolute;
  top: -10px;
  animation: particle-fall linear forwards;
  image-rendering: pixelated;
}

@keyframes particle-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* =============================================
   ANIMATIONS
   ============================================= */
@keyframes mc-pop {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes mc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Denied shake — quicker, smaller, with red flash for disabled card tap */
@keyframes mc-shake-deny {
  0%, 100% { transform: translateX(0); box-shadow: none; }
  10%, 50%, 90% { transform: translateX(-4px); box-shadow: 0 0 12px rgba(248, 113, 113, 0.6); }
  30%, 70% { transform: translateX(4px); box-shadow: 0 0 12px rgba(248, 113, 113, 0.6); }
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 520px) {
  .mc-title {
    font-size: 1.5rem;
    letter-spacing: 3px;
  }

  .mc-logo-icon {
    width: 56px;
    height: 56px;
  }

  .loading-tip-icon {
    width: 64px;
    height: 64px;
  }

  .loading-tip {
    min-height: 100px;
  }

  .game-buttons {
    gap: 8px;
  }

  .mc-btn {
    min-height: 64px;
    padding: 10px 8px;
  }

  .mc-btn .btn-img {
    width: 40px;
    height: 40px;
  }

  .game-header-v2 {
    padding: 4px;
    gap: 4px;
  }

  .gh-back {
    min-width: 44px;
    min-height: 44px;
    font-size: 1.2rem;
  }

  .gh-score-num {
    font-size: 1.1rem;
  }

  .pdot {
    font-size: 0.6rem;
  }
  .pdot-active {
    font-size: 0.75rem;
  }

  .mc-prompt {
    font-size: 0.9rem;
    padding: 12px 16px;
  }

  .game-area {
    padding: 10px;
    gap: 6px;
    /* 2x2 grid on mobile */
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .answer-card {
    min-width: unset;
    min-height: 80px;
    padding: 10px;
    width: 100%;
  }

  .mc-icon {
    width: 48px;
    height: 48px;
  }

  .mc-icon-small {
    width: 36px;
    height: 36px;
    margin: 2px;
  }

  .card-number {
    font-size: 1.3rem;
  }

  .answer-card.math-card {
    min-width: unset;
    min-height: 70px;
  }

  .answer-card.math-card .card-emoji {
    font-size: 1.2rem;
  }

  .counting-objects {
    padding: 10px;
  }

  .counting-objects,
  .counting-options-row {
    display: flex;
  }

  .pattern-item {
    width: 36px;
    height: 36px;
  }

  .pattern-gap {
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
  }

  .pattern-sequence {
    gap: 4px;
    padding: 8px;
  }

  .memory-card {
    min-width: 48px;
    min-height: 48px;
  }

  .memory-card-back {
    font-size: 1.4rem;
  }

  .memory-grid {
    gap: 6px;
    padding: 6px;
  }

  .compare-arrow {
    font-size: 2.2rem;
  }

  .compare-item-icon {
    width: 22px;
    height: 22px;
  }

  .compare-card {
    min-height: 64px;
    padding: 6px;
  }

  .mgmt-area {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }

  .big-res-icon {
    width: 36px;
    height: 36px;
  }

  .big-res-num {
    font-size: 1.2rem;
  }

  .big-goal {
    width: 56px;
    height: 56px;
  }

  .big-goal-icon {
    width: 36px;
    height: 36px;
  }

  .big-heart {
    font-size: 2.2rem;
  }

  .big-bp-slot {
    width: 48px;
    height: 48px;
  }

  .big-bp-icon {
    width: 34px;
    height: 34px;
  }

  .card-res-badge {
    font-size: 0.8rem;
  }

  .mc-celebration-box {
    padding: 20px;
    width: 94%;
  }

  .mc-stars-display {
    font-size: 2.5rem;
  }

  .cel-score-num {
    font-size: 2.5rem;
  }

  .mc-cel-btn {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  .feedback {
    font-size: 2rem;
  }

  .fish-album-badge img {
    width: 14px;
    height: 14px;
  }

  .fish-album-badge {
    height: 16px;
  }

  .brewing-stand-backdrop {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 360px) {
  .mc-title {
    font-size: 1.2rem;
  }

  .answer-card {
    min-height: 70px;
    padding: 6px;
  }

  .mc-icon {
    width: 40px;
    height: 40px;
  }

  .mc-icon-small {
    width: 32px;
    height: 32px;
  }

  .answer-card.math-card {
    min-height: 60px;
  }

  .loading-tip-icon {
    width: 56px;
    height: 56px;
  }

  .loading-tip {
    min-height: 90px;
  }

  .fish-album-badge img {
    width: 12px;
    height: 12px;
  }

  .fish-album-badge {
    height: 14px;
    gap: 2px;
  }

  .brewing-stand-backdrop {
    width: 90px;
    height: 90px;
  }
}

/* Touch-friendly active states */
@media (hover: none) {
  .answer-card:hover {
    transform: none;
    box-shadow: none;
    background: var(--slot-bg);
    border-color: var(--slot-border);
  }

  .answer-card:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.05);
  }

  .mc-btn:hover {
    transform: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    border-color: var(--panel-border);
  }

  .mc-btn:active {
    transform: scale(0.96);
    box-shadow: 0 0 20px var(--mc-green-glow);
    border-color: rgba(74, 222, 128, 0.3);
  }

  .mc-btn-daily:hover {
    background: linear-gradient(180deg, #5b21b6 0%, #4c1d95 100%);
    border-color: rgba(167, 139, 250, 0.2);
  }

  .mc-btn-daily:active {
    background: linear-gradient(180deg, #6d28d9 0%, #5b21b6 100%);
    box-shadow: 0 0 20px var(--mc-purple-glow);
  }

  .mc-btn-daily.completed:hover {
    background: linear-gradient(180deg, #166534 0%, #14532d 100%);
    border-color: rgba(74, 222, 128, 0.3);
  }
}

/* ============================================
   DAILY STREAK TRACKER
   ============================================ */
.day-streak-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 6px 0 4px;
  min-height: 36px;
}

.streak-star {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: inline-block;
}

.streak-filled {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.7);
  transform: scale(1.05);
}

.streak-empty {
  color: #374151;
  opacity: 0.35;
}

/* 7-day complete streak: rainbow shimmer on the bar */
.day-streak-bar.streak-complete {
  animation: streakRainbow 2.5s linear infinite;
}

@keyframes streakRainbow {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

/* ============================================
   SURVIVAL ENVIRONMENT THEMES
   Applied as env-{forest|cave|nether|ocean} on #mgmt-screen
   ============================================ */

/* Forest — deep green glow, default Overworld feel */
#mgmt-screen.env-forest {
  background: linear-gradient(180deg, #0a1a0e 0%, #0d1f10 100%);
  border-top: 3px solid #166534;
  box-shadow: inset 0 0 60px rgba(22, 101, 52, 0.15);
}
#mgmt-screen.env-forest .game-header-v2 {
  border-bottom-color: rgba(22, 101, 52, 0.4);
}

/* Cave — dark stone with faint blue torch-glow */
#mgmt-screen.env-cave {
  background: linear-gradient(180deg, #0a0a12 0%, #10101a 100%);
  border-top: 3px solid #1e3a5f;
  box-shadow: inset 0 0 60px rgba(30, 58, 95, 0.2);
}
#mgmt-screen.env-cave .game-header-v2 {
  border-bottom-color: rgba(30, 58, 95, 0.5);
}

/* Nether — deep red/lava tint */
#mgmt-screen.env-nether {
  background: linear-gradient(180deg, #1a0a08 0%, #200d08 100%);
  border-top: 3px solid #7f1d1d;
  box-shadow: inset 0 0 60px rgba(127, 29, 29, 0.25);
}
#mgmt-screen.env-nether .game-header-v2 {
  border-bottom-color: rgba(127, 29, 29, 0.5);
}

/* Ocean — cool blue-green depth */
#mgmt-screen.env-ocean {
  background: linear-gradient(180deg, #08121a 0%, #0a1820 100%);
  border-top: 3px solid #164e63;
  box-shadow: inset 0 0 60px rgba(22, 78, 99, 0.25);
}
#mgmt-screen.env-ocean .game-header-v2 {
  border-bottom-color: rgba(22, 78, 99, 0.5);
}

/* ============================================
   ENCHANTING TABLE GAME STYLES
   ============================================ */

.enchant-card.correct {
  background: linear-gradient(180deg, #4c1d95 0%, #2e1065 100%);
  border-color: #a78bfa;
  box-shadow: 0 0 24px rgba(167, 139, 250, 0.6), 0 0 48px rgba(167, 139, 250, 0.3), inset 0 0 12px rgba(167, 139, 250, 0.15);
  animation: enchant-glow 0.5s ease;
}

@keyframes enchant-glow {
  0%   { transform: scale(0.95); box-shadow: 0 0 8px rgba(167, 139, 250, 0.3); }
  50%  { transform: scale(1.05); box-shadow: 0 0 32px rgba(167, 139, 250, 0.8), 0 0 64px rgba(167, 139, 250, 0.4); }
  100% { transform: scale(1); }
}

.enchant-card.wrong {
  background: linear-gradient(180deg, #991b1b 0%, #450a0a 100%);
  border-color: var(--mc-red);
  box-shadow: 0 0 24px var(--mc-red-glow);
  animation: enchant-drain 0.4s ease;
}

@keyframes enchant-drain {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(0.92) translateY(4px); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   POTION BREWING GAME STYLES
   ============================================ */

/* Colored potion target in prompt */
.potion-target {
  display: inline-block;
  position: relative;
  padding: 12px;
  border-radius: var(--r-lg);
  background: radial-gradient(circle, var(--potion-color) 0%, transparent 70%);
  margin-bottom: 8px;
}

.potion-bottle {
  position: relative;
  z-index: 1;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 8px var(--potion-color));
}

.brewing-stand-backdrop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  opacity: 0.3;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 0 12px var(--potion-color));
}

/* Shown ingredients row (pre-filled slots for medium/hard) */
.potion-ingredients-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.potion-shown-ingredient {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  opacity: 0.85;
  border: 2px solid var(--mc-green);
  border-radius: var(--r-md);
  padding: 4px;
  background: rgba(74, 222, 128, 0.15);
}

.potion-slot-empty {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--mc-gold);
  border-radius: var(--r-md);
  color: var(--mc-gold);
  font-size: 1.5rem;
  font-weight: 700;
}

/* Brewing animation on correct answer */
.potion-target.brewing {
  animation: potion-brew 0.8s ease-in-out;
}

@keyframes potion-brew {
  0%   { filter: brightness(1); transform: scale(1); }
  30%  { filter: brightness(1.5); transform: scale(1.1); }
  60%  { filter: brightness(1.2); transform: scale(1.05); }
  100% { filter: brightness(1); transform: scale(1); }
}

@keyframes brewing-stand-glow {
  0%   { opacity: 0.3; }
  50%  { opacity: 0.6; }
  100% { opacity: 0.3; }
}

.potion-target.brewing .brewing-stand-backdrop {
  animation: brewing-stand-glow 0.8s ease-in-out;
}

/* ============================================
   REDSTONE CIRCUIT GAME STYLES
   ============================================ */

/* Grid layout */
.redstone-grid {
  display: grid !important;
  gap: 4px;
  justify-content: center;
  padding: 8px;
  max-width: 400px;
  margin: 0 auto;
}
.redstone-grid-4 { grid-template-columns: repeat(4, 1fr); }
.redstone-grid-5 { grid-template-columns: repeat(5, 1fr); }

/* Base cell */
.redstone-cell {
  aspect-ratio: 1;
  min-width: 56px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--slot-bg);
  border: 2px solid transparent;
  position: relative;
  box-sizing: border-box;
}

/* Empty cell */
.redstone-cell-empty {
  opacity: 0.25;
}

/* Switch (lever) */
.redstone-switch {
  cursor: pointer;
  border-color: rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
  min-width: 60px;
  min-height: 60px;
}
.redstone-switch:active {
  transform: scale(0.92);
}
.redstone-switch-on {
  border-color: var(--mc-red);
  background: rgba(248, 113, 113, 0.2);
  box-shadow: 0 0 12px var(--mc-red-glow);
}
.redstone-switch-on img {
  filter: brightness(1.4) drop-shadow(0 0 6px var(--mc-red));
  transform: scaleY(-1);
}

/* Lever toggle snap animation */
@keyframes lever-snap-on {
  0%   { transform: scaleY(1); }
  60%  { transform: scaleY(-1.15); }
  100% { transform: scaleY(-1); }
}
@keyframes lever-snap-off {
  0%   { transform: scaleY(-1); }
  60%  { transform: scaleY(1.15); }
  100% { transform: scaleY(1); }
}
.lever-anim-on img {
  animation: lever-snap-on 0.2s ease-out forwards;
}
.lever-anim-off img {
  animation: lever-snap-off 0.2s ease-out forwards;
}

/* Wire (redstone dust) */
.redstone-wire {
  opacity: 0.35;
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.redstone-wire-powered {
  opacity: 1;
  border-color: var(--mc-red);
  background: rgba(248, 113, 113, 0.15);
}
.redstone-wire-powered img {
  filter: brightness(1.6) drop-shadow(0 0 4px red);
}

/* Signal propagation animation */
.redstone-wire-animating {
  animation: redstone-signal 0.3s ease-out forwards;
}
@keyframes redstone-signal {
  0%   { opacity: 0.35; }
  100% { opacity: 1; }
}

/* Lamp */
.redstone-lamp {
  border-color: rgba(255, 255, 255, 0.15);
  transition: all 0.4s ease;
}
.redstone-lamp-lit {
  border-color: var(--mc-gold);
  background: rgba(251, 191, 36, 0.3);
  box-shadow: 0 0 20px var(--mc-gold-glow), 0 0 40px rgba(251, 191, 36, 0.2);
  animation: lamp-glow 0.5s ease-out;
}
.redstone-lamp-lit img {
  filter: brightness(1.5) drop-shadow(0 0 10px var(--mc-gold));
}

@keyframes lamp-glow {
  0%   { transform: scale(1); box-shadow: 0 0 0 transparent; }
  50%  { transform: scale(1.1); box-shadow: 0 0 30px var(--mc-gold-glow); }
  100% { transform: scale(1); box-shadow: 0 0 20px var(--mc-gold-glow), 0 0 40px rgba(251, 191, 36, 0.2); }
}

/* Goal indicator in prompt */
.redstone-goal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.redstone-goal-arrow {
  font-size: 1.5rem;
  color: var(--mc-gold);
}
.redstone-goal-lamp-off {
  opacity: 0.35;
  filter: grayscale(0.8);
}
.redstone-goal-lamp-on {
  filter: brightness(1.4) drop-shadow(0 0 8px var(--mc-gold));
}

/* Level badge */
.redstone-level-badge {
  font-size: 0.9rem;
  color: var(--mc-red);
  font-weight: 700;
}

/* Responsive: smaller screens */
@media (max-width: 380px) {
  .redstone-grid { gap: 3px; padding: 4px; }
  .redstone-cell { min-width: 48px; min-height: 48px; }
  .redstone-switch { min-width: 48px; min-height: 48px; }
}

/* --- Fishing Game --- */
.fishing-pond {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 280px;
  margin: 0 auto;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, #1a3a5c 0%, #0d2137 40%, #0a1a2e 100%);
  overflow: hidden;
  border: 3px solid #1e4d7a;
  cursor: pointer;
  user-select: none;
}

.fishing-sky {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(180deg, #0a1a2e 0%, #1a3a5c 100%);
}

.fishing-water {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72%;
  background: linear-gradient(180deg, rgba(30, 90, 160, 0.7) 0%, rgba(10, 50, 100, 0.9) 100%);
  overflow: hidden;
}

.fishing-water-surface {
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 18px;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 40px,
    rgba(100, 180, 255, 0.35) 40px,
    rgba(100, 180, 255, 0.35) 80px
  );
  animation: fishing-wave 3s linear infinite;
}

@keyframes fishing-wave {
  0%   { transform: translateX(0); }
  100% { transform: translateX(80px); }
}

.fishing-bobber {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  z-index: 2;
  animation: fishing-float 2s ease-in-out infinite;
}

.fishing-bobber-img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

@keyframes fishing-float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(-6px); }
}

.fishing-bobber-dip {
  animation: fishing-dip 0.3s ease-out forwards !important;
}

@keyframes fishing-dip {
  0%   { transform: translateX(-50%) translateY(0); }
  60%  { transform: translateX(-50%) translateY(22px) scale(0.9); }
  100% { transform: translateX(-50%) translateY(14px) scale(0.95); }
}

.fishing-splash {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.8rem;
  z-index: 3;
  animation: fishing-splash-up 0.55s ease-out forwards;
  pointer-events: none;
}

@keyframes fishing-splash-up {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(0.5); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-32px) scale(1.5); }
}

.fishing-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fishing-feedback-symbol {
  font-size: 3rem;
  animation: mc-pop 0.35s ease-out;
}

.fishing-catch { color: var(--mc-green); }
.fishing-miss  { color: var(--mc-red); }

.fishing-caught-fish {
  animation: fishing-catch-fly 0.7s ease-out forwards;
}

.fishing-caught-fish img {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
}

@keyframes fishing-catch-fly {
  0%   { transform: scale(0.4) translateY(20px); opacity: 0; }
  50%  { transform: scale(1.2) translateY(-10px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Collection grid in footer */
.fishing-collection {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 4px;
}

.fishing-slot {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 2px solid var(--slot-border);
  background: var(--slot-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.fishing-slot img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.fishing-slot-caught {
  border-color: var(--mc-green);
  background: rgba(128, 255, 32, 0.15);
  animation: mc-pop 0.3s ease-out;
}

.fishing-slot-miss {
  border-color: var(--mc-red);
  background: rgba(255, 85, 85, 0.1);
  opacity: 0.5;
}

.fishing-slot-empty {
  opacity: 0.3;
}

@media (max-width: 380px) {
  .fishing-pond  { height: 220px; max-width: 300px; }
  .fishing-slot  { width: 32px; height: 32px; }
  .fishing-slot img { width: 22px; height: 22px; }
}

/* ===== FISHING ALBUM (celebration overlay) ===== */

.fishing-album {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 10px 0 4px;
}

.fishing-album-slot {
  width: 52px;
  height: 52px;
  border-radius: var(--r-sm);
  border: 2px solid var(--slot-border);
  background: var(--slot-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fishing-album-slot img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
}

.fishing-album-caught {
  border-color: var(--mc-green);
  background: rgba(128, 255, 32, 0.15);
}

.fishing-album-uncaught {
  opacity: 0.3;
  filter: grayscale(1) brightness(0.5);
}

.fishing-album-new {
  animation: mc-pop 0.4s ease-out both;
}

/* ===== FISH ALBUM BADGE (home tile) ===== */

.fish-album-badge {
  display: flex;
  gap: 3px;
  justify-content: center;
  align-items: center;
  height: 18px;
}

.fish-album-badge img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.fish-badge-uncaught {
  opacity: 0.25;
  filter: grayscale(1);
}

.fish-album-badge.fish-badge-complete {
  filter: drop-shadow(0 0 3px var(--mc-green));
}

/* ===== SHEEP COLOR SORT ===== */

.sheep-field {
  position: relative;
  width: 100%;
  max-width: 360px;
  height: 320px;
  margin: 0 auto;
  background: linear-gradient(180deg, #87CEEB 0%, #87CEEB 30%, #4ade80 30%, #4ade80 100%);
  border-radius: 12px;
  overflow: hidden;
}

.sheep-track {
  position: relative;
  width: 100%;
  height: 55%;
  overflow: hidden;
}

.sheep-walking {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  animation: sheep-walk var(--sheep-walk-duration, 5000ms) linear forwards;
  z-index: 2;
}

.sheep-walking img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

@keyframes sheep-walk {
  from { left: -60px; }
  to   { left: calc(100% + 60px); }
}

.sheep-sorted {
  animation: sheep-drop 0.4s ease-in forwards !important;
}

@keyframes sheep-drop {
  0%   { transform: translateY(-50%) scale(1); opacity: 1; }
  100% { transform: translateY(120px) scale(0.7); opacity: 0.5; }
}

.sheep-pens {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  flex-wrap: wrap;
}

.sheep-pen {
  width: 52px;
  height: 52px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  border: 3px solid rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
}

.sheep-pen:active {
  transform: scale(0.92);
}

.sheep-pen-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  filter: brightness(1.1);
}

.sheep-pen-new {
  animation: mc-pop 0.3s ease-out backwards;
}

.sheep-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  z-index: 10;
  pointer-events: none;
}

.sheep-feedback-symbol {
  animation: feedback-pop 0.5s ease-out;
}

.sheep-catch { color: var(--mc-green); }
.sheep-miss  { color: var(--mc-red); }

.sheep-collection {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 4px;
}

.sheep-slot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
}

.sheep-slot-sorted {
  border-color: rgba(255,255,255,0.6);
  box-shadow: 0 0 4px rgba(255,255,255,0.3);
}

.sheep-slot-miss {
  background: rgba(255,255,255,0.1);
  border-style: dashed;
}

.sheep-slot-empty {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.15);
}

@media (max-width: 520px) {
  .sheep-field { height: 280px; max-width: 300px; }
  .sheep-pen   { width: 44px; height: 44px; }
  .sheep-pen-icon { width: 28px; height: 28px; }
}

@media (max-width: 360px) {
  .sheep-field { height: 240px; max-width: 280px; }
  .sheep-pen   { width: 44px; height: 44px; }
  .sheep-walking { width: 40px; height: 40px; }
  .sheep-walking img { width: 40px; height: 40px; }
}

/* ============================================
   TNT NUMBER BLAST
   ============================================ */

.tnt-game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.tnt-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}

.tnt-cell {
  width: 100%;
  aspect-ratio: 1;
  min-width: 44px;
  min-height: 44px;
  background: var(--slot-bg);
  border: 2px solid var(--slot-border);
  border-radius: var(--r-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  padding: 0;
}

.tnt-cell:hover {
  transform: scale(1.05);
  border-color: var(--mc-gold);
}

.tnt-cell-placed {
  border-color: #FF4400;
  background: rgba(255, 68, 0, 0.15);
  animation: mc-pop 0.2s ease-out;
}

.tnt-cell img {
  width: 70%;
  height: 70%;
  image-rendering: pixelated;
  object-fit: contain;
  pointer-events: none;
}

.tnt-cell-explode {
  animation: tnt-explode 0.6s ease-out forwards;
}

@keyframes tnt-explode {
  0%   { transform: scale(1);   opacity: 1;   background: rgba(255, 68, 0, 0.3); }
  30%  { transform: scale(1.3); background: rgba(255, 170, 0, 0.8); }
  60%  { transform: scale(1.1); opacity: 0.6; }
  100% { transform: scale(0);   opacity: 0; }
}

@keyframes tnt-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.tnt-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.tnt-detonator {
  --charge: 0;
  width: 72px;
  height: 72px;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, #8B0000 0%, #5C0000 100%);
  border: 3px solid #FF2200;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 12px rgba(255, 34, 0, 0.4),
    0 0 calc(var(--charge) * 24px) calc(var(--charge) * 8px) rgba(255, 100, 0, calc(var(--charge) * 0.7));
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  padding: 0;
}

.tnt-detonator:hover {
  transform: scale(1.08);
  box-shadow:
    0 6px 20px rgba(255, 34, 0, 0.6),
    0 0 calc(var(--charge) * 28px) calc(var(--charge) * 10px) rgba(255, 100, 0, calc(var(--charge) * 0.8));
}

.tnt-detonator:active {
  transform: scale(0.95);
}

.tnt-detonator img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  pointer-events: none;
}

.tnt-detonator-charged {
  border-color: #FF6600;
  animation: tnt-pulse 0.8s ease-in-out infinite;
}
.tnt-detonator-charged.tnt-shake {
  animation: mc-shake 0.3s ease;
}

.tnt-placed-badge {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--mc-gold);
  text-shadow: 0 0 8px rgba(255, 170, 0, 0.5);
  min-width: 40px;
  text-align: center;
}

.tnt-prompt-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--mc-gold);
  text-shadow: 0 0 16px rgba(255, 170, 0, 0.4);
}

.tnt-shake {
  animation: mc-shake 0.3s ease;
}

.tnt-collection {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.tnt-slot {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 2px solid var(--slot-border);
  background: var(--slot-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.tnt-slot-success {
  border-color: var(--mc-green);
  background: rgba(128, 255, 32, 0.15);
  color: var(--mc-green);
}

.tnt-slot-empty {
  opacity: 0.3;
}

/* ============================================
   Redstone Level Select Grid
   ============================================ */
.redstone-level-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 12px;
  max-width: 360px;
  margin: 0 auto;
}

.redstone-level-tile {
  aspect-ratio: 1;
  min-width: 80px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--r-md);
  background: var(--slot-bg);
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.redstone-level-tile:active {
  transform: scale(0.93);
}

.redstone-logic-single { border-color: #FF4444; --logic-color: #FF4444; }
.redstone-logic-distractor { border-color: #FF8800; --logic-color: #FF8800; }
.redstone-logic-and { border-color: #AA44FF; --logic-color: #AA44FF; }
.redstone-logic-or { border-color: #4488FF; --logic-color: #4488FF; }

/* Subtle border-glow pulse for unplayed tiles (0 stars) */
@keyframes redstone-border-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: 0 0 10px 3px var(--logic-color, rgba(255, 255, 255, 0.3));
  }
}

.redstone-tile-unplayed {
  animation: redstone-border-pulse 2.5s ease-in-out infinite;
}

.redstone-level-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--mc-red);
  line-height: 1;
}

.redstone-level-stars {
  font-size: 0.9rem;
  letter-spacing: 2px;
}

.redstone-level-stars .star-earned {
  color: #FFAA00;
}

.redstone-level-stars .star-empty {
  color: #555;
}

.redstone-level-logic {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  opacity: 0.6;
  image-rendering: pixelated;
}

.redstone-play-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--slot-bg);
  border: 2px solid var(--mc-red);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--mc-red);
  min-height: 48px;
  margin: 8px auto;
  transition: all 0.2s ease;
}

.redstone-play-all:active {
  transform: scale(0.95);
}

/* Gold particle burst on star upgrade */
@keyframes gold-burst {
  0% {
    opacity: 1;
    box-shadow:
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00,
      0 0 0 0 #FFAA00;
  }
  50% {
    opacity: 1;
    box-shadow:
      -12px -16px 0 0 #FFAA00,
      12px -14px 0 0 #FFAA00,
      16px -4px 0 0 #FFAA00,
      14px 12px 0 0 #FFAA00,
      4px 18px 0 0 #FFAA00,
      -8px 16px 0 0 #FFAA00,
      -18px 6px 0 0 #FFAA00,
      -16px -8px 0 0 #FFAA00;
  }
  100% {
    opacity: 0;
    box-shadow:
      -18px -24px 0 -1px #FFAA00,
      18px -22px 0 -1px #FFAA00,
      24px -6px 0 -1px #FFAA00,
      20px 18px 0 -1px #FFAA00,
      6px 26px 0 -1px #FFAA00,
      -12px 24px 0 -1px #FFAA00,
      -26px 10px 0 -1px #FFAA00,
      -24px -12px 0 -1px #FFAA00;
  }
}

@keyframes gold-glow {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 170, 0, 0), 0 0 0 0 rgba(255, 170, 0, 0); }
  30% { box-shadow: inset 0 0 12px rgba(255, 170, 0, 0.4), 0 0 16px 4px rgba(255, 170, 0, 0.3); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 170, 0, 0), 0 0 0 0 rgba(255, 170, 0, 0); }
}

.redstone-tile-upgraded {
  animation: gold-glow 0.6s ease-out forwards;
}

.redstone-tile-upgraded::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin: -2px 0 0 -2px;
  pointer-events: none;
  z-index: 1;
  animation: gold-burst 0.5s ease-out 0.05s forwards;
  opacity: 0;
}

@media (max-width: 380px) {
  .redstone-level-grid { gap: 8px; padding: 8px; }
  .redstone-level-tile { min-width: 64px; min-height: 64px; }
}
