/* ==========================================================================
   MYSTERY BOX — LUXURY STEAMPUNK / VAULT STYLES
   ========================================================== */

:root {
  --bg-deep: #0d0f14;
  --bg-surface: #141824;
  --bg-card: #1b2030;
  --bg-card-border: #2a334c;
  
  --gold-100: #fef3c7;
  --gold-300: #fde047;
  --gold-400: #facc15;
  --gold-500: #eab308;
  --gold-600: #ca8a04;
  --gold-700: #a16207;
  --gold-glow: rgba(234, 179, 8, 0.45);
  
  --ruby-500: #ef4444;
  --ruby-glow: rgba(239, 68, 68, 0.45);
  --emerald-500: #10b981;
  --sapphire-500: #3b82f6;

  /* Biome Territory Color Palettes (High Contrast & Saturated) */
  --biome-0: #1e3a8a; /* Deep Lapis */
  --biome-1: #065f46; /* Emerald Forest */
  --biome-2: #831843; /* Ruby Rose */
  --biome-3: #581c87; /* Amethyst Hollow */
  --biome-4: #7c2d12; /* Amber Dune */
  --biome-5: #134e4a; /* Teal Lagoon */
  --biome-6: #713f12; /* Bronze Foundry */
  --biome-7: #1e293b; /* Obsidian Spire */
  --biome-8: #312e81; /* Indigo Abyss */
  --biome-9: #4c1d95; /* Mystic Orchid */

  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Cinzel", "Times New Roman", Georgia, serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: #f1f5f9;
  font-family: var(--font-main);
}

#game-app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  position: relative;
  background: radial-gradient(circle at 50% 30%, #1a2236 0%, #0d111b 70%, #06080d 100%);
  overflow: hidden;
}

/* Background Atmosphere Dust / Runes */
#game-app::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    radial-gradient(1px 1px at 20px 30px, rgba(234, 179, 8, 0.25), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 120px 180px, rgba(254, 243, 199, 0.3), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 320px 90px, rgba(234, 179, 8, 0.2), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 450px 300px, rgba(254, 243, 199, 0.15), rgba(0,0,0,0));
  background-repeat: repeat;
  background-size: 500px 500px;
  opacity: 0.7;
  pointer-events: none;
}

/* ==========================================================
   HEADER
   ========================================================== */

.game-header {
  width: 100%;
  max-width: 640px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 20;
}

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

.level-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.level-tag {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff7ed 0%, #facc15 50%, #ca8a04 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 12px rgba(234, 179, 8, 0.35);
}

.level-grid-size {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #94a3b8;
  text-transform: uppercase;
}

/* Gold Filigree Buttons */
.gold-btn {
  background: linear-gradient(180deg, #272f44 0%, #181e2e 100%);
  border: 1px solid #c89b3c;
  color: #fef08a;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-weight: 600;
}

.gold-btn:hover {
  background: linear-gradient(180deg, #323c57 0%, #1f273c 100%);
  border-color: #facc15;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.35);
  transform: translateY(-1px);
}

.gold-btn:active {
  transform: translateY(1px);
}

.icon-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
  gap: 5px;
}

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

/* ==========================================================
   STATUS BAR
   ========================================================== */

.status-bar {
  width: 100%;
  max-width: 580px;
  padding: 4px 16px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}

.status-pill {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(203, 161, 53, 0.25);
  border-radius: 20px;
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
}

.status-label {
  font-size: 0.68rem;
  letter-spacing: 1px;
  color: #94a3b8;
  font-weight: 600;
}

.status-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fef08a;
  font-variant-numeric: tabular-nums;
}

.diff-badge {
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 10px;
}

.badge-easy { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.badge-medium { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-hard { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-master { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); }

/* ==========================================================
   PUZZLE STAGE & GRID
   ========================================================== */

.puzzle-stage {
  flex: 1;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 16px;
  position: relative;
  z-index: 10;
}

.stage-frame {
  position: relative;
  padding: 10px;
  background: radial-gradient(circle at center, #182032 0%, #0e121d 100%);
  border: 2px solid #b88628;
  border-radius: 14px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.7),
    inset 0 0 20px rgba(0, 0, 0, 0.8),
    0 0 16px rgba(184, 134, 40, 0.2);
}

/* Corner Ornaments */
.corner-ornament {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #facc15;
  pointer-events: none;
}
.corner-ornament.top-left { top: -4px; left: -4px; border-right: none; border-bottom: none; border-radius: 4px 0 0 0; }
.corner-ornament.top-right { top: -4px; right: -4px; border-left: none; border-bottom: none; border-radius: 0 4px 0 0; }
.corner-ornament.bottom-left { bottom: -4px; left: -4px; border-right: none; border-top: none; border-radius: 0 0 0 4px; }
.corner-ornament.bottom-right { bottom: -4px; right: -4px; border-left: none; border-top: none; border-radius: 0 0 4px 0; }

.grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
}

.puzzle-grid {
  display: grid;
  gap: 3px;
  background-color: #080b11;
  padding: 3px;
  border-radius: 8px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.9);
}

/* ==========================================================
   MYSTERY BOX / GRID CELLS
   ========================================================== */

.cell {
  position: relative;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15), 0 2px 4px rgba(0,0,0,0.5);
}

/* Tactile 3D appearance */
.cell:hover {
  filter: brightness(1.15);
  transform: scale(0.97);
}

.cell:active {
  transform: scale(0.92);
}

/* Subtle Crate Plank Lines */
.cell::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.25) 100%);
  pointer-events: none;
}

/* Biome Regional Borders (Thick outer boundaries between different color groups) */
.cell.border-top { border-top: 2.5px solid #facc15; }
.cell.border-right { border-right: 2.5px solid #facc15; }
.cell.border-bottom { border-bottom: 2.5px solid #facc15; }
.cell.border-left { border-left: 2.5px solid #facc15; }

/* In-cell Keyhole / Rune (when cell is pristine / empty) */
.cell .keyhole {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
  pointer-events: none;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

/* State: Marked Empty 'X' */
.cell.marked-cross {
  background-color: rgba(15, 23, 42, 0.8) !important;
}

.cell.marked-cross .cross-mark {
  font-size: 1.1rem;
  color: #94a3b8;
  font-weight: 800;
  opacity: 0.7;
  transform: scale(0.9);
  animation: popIn 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* State: Opened Mystery Box with Hidden Animal! */
.cell.marked-animal {
  box-shadow: 
    0 0 16px var(--gold-glow),
    inset 0 0 10px rgba(254, 240, 138, 0.6) !important;
  transform: scale(0.97);
  animation: unlockBurst 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1.5px solid #fde047 !important;
}

.cell.marked-animal .animal-icon {
  font-size: 1.7rem;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
  animation: floatSmall 2.5s ease-in-out infinite;
  z-index: 5;
}

/* Glowing Halo behind Animal */
.cell.marked-animal::after {
  content: "";
  position: absolute;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.6) 0%, rgba(234, 179, 8, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseGlow 1.8s ease-in-out infinite;
}

/* State: Conflict / Rule Violation */
.cell.conflict {
  background-color: #7f1d1d !important;
  border: 2px solid #ef4444 !important;
  box-shadow: 0 0 16px var(--ruby-glow) !important;
  animation: shake 0.35s ease-in-out;
}

/* Row / Col Hover Highlighter */
.cell.hover-guide {
  filter: brightness(1.22);
}

/* Real-time Rule Alert */
.rule-alert {
  margin-top: 10px;
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
  animation: slideDown 0.25s ease-out;
  z-index: 20;
}

.rule-alert.hidden {
  display: none;
}

/* ==========================================================
   CONTROLS & ACTION BAR
   ========================================================== */

.game-controls {
  width: 100%;
  max-width: 580px;
  padding: 10px 16px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}

/* Tool Mode Switcher */
.tool-switch-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(15, 23, 42, 0.85);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(203, 161, 53, 0.3);
}

.tool-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.tool-btn .tool-icon {
  font-size: 1.15rem;
}

.tool-btn.active {
  background: linear-gradient(180deg, #3d4a6b 0%, #20273a 100%);
  color: #fef08a;
  border: 1px solid #eab308;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 12px rgba(234, 179, 8, 0.25);
}

/* Action Utility Bar (Undo, Redo, Hint, Reset) */
.action-bar {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.action-btn {
  flex: 1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.action-btn:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.85);
  border-color: #94a3b8;
  color: #f8fafc;
  transform: translateY(-1px);
}

.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.action-icon {
  font-size: 1rem;
}

.action-name {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================
   PARTICLE CANVAS
   ========================================================== */

#fx-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

/* ==========================================================
   MODALS
   ========================================================== */

.modal-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(6, 9, 15, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  transition: opacity 0.2s ease;
}

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

.modal-card, .win-card {
  background: radial-gradient(circle at center, #1e2638 0%, #111624 100%);
  border: 2px solid #ca8a04;
  border-radius: 16px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(202, 138, 4, 0.3);
  text-align: center;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(202, 138, 4, 0.4);
  color: #cbd5e1;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #334155;
  color: #fff;
  border-color: #facc15;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: #fef08a;
  letter-spacing: 1.5px;
}

.modal-ornament {
  color: #ca8a04;
  font-size: 0.9rem;
}

/* ==========================================================
   VICTORY CHEST & UNBOXING
   ========================================================== */

.win-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff 0%, #fde047 50%, #ca8a04 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-top: 14px;
}

.win-subtitle {
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-top: 4px;
  font-style: italic;
}

/* 3D Mystery Chest Box */
.chest-container {
  margin: 10px auto;
  width: 140px;
  height: 120px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chest-glow-halo {
  position: absolute;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(234, 179, 8, 0.4) 0%, rgba(234, 179, 8, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseGlow 2s ease-in-out infinite;
}

.revealed-creature {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: popFloat 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.creature-avatar {
  font-size: 3.5rem;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.7));
  animation: floatSmall 2.5s ease-in-out infinite;
}

.creature-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fef08a;
  letter-spacing: 1px;
  margin-top: 4px;
}

.creature-rarity {
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 10px;
  border-radius: 12px;
  margin-top: 2px;
}

.rarity-common { background: #334155; color: #94a3b8; }
.rarity-rare { background: rgba(59, 130, 246, 0.25); color: #60a5fa; border: 1px solid #3b82f6; }
.rarity-epic { background: rgba(168, 85, 247, 0.25); color: #c084fc; border: 1px solid #a855f7; }
.rarity-legendary { background: rgba(234, 179, 8, 0.25); color: #fde047; border: 1px solid #eab308; }
.rarity-mythic { background: rgba(236, 72, 153, 0.25); color: #f472b6; border: 1px solid #ec4899; }

.star-rating {
  font-size: 2rem;
  color: #475569;
  margin: 12px 0 8px 0;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.star.lit {
  color: #facc15;
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.6);
  animation: starPop 0.4s ease-out;
}

.win-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.win-stat-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(203, 161, 53, 0.3);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-caption {
  font-size: 0.65rem;
  color: #94a3b8;
  letter-spacing: 1px;
}

.stat-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fef08a;
  font-variant-numeric: tabular-nums;
}

.win-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.win-actions button {
  flex: 1;
  padding: 12px;
  font-size: 0.95rem;
}

.primary-btn {
  background: linear-gradient(180deg, #ca8a04 0%, #854d0e 100%) !important;
  color: #fff !important;
  border-color: #fde047 !important;
}

.secondary-btn {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%) !important;
  border-color: #64748b !important;
  color: #e2e8f0 !important;
}

/* ==========================================================
   HOW TO PLAY / RULES MODAL
   ========================================================== */

.rules-body {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.45;
}

.rules-intro {
  color: #94a3b8;
  margin-bottom: 4px;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.rule-badge {
  background: linear-gradient(180deg, #eab308 0%, #a16207 100%);
  color: #000;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.rule-content strong {
  display: block;
  color: #fef08a;
  margin-bottom: 2px;
  font-size: 0.9rem;
}

.tip-box {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.3);
}

.tip-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.modal-footer {
  margin-top: 18px;
}

.modal-footer button {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

/* ==========================================================
   LEVEL SELECTOR MODAL
   ========================================================== */

.tier-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 14px;
}

.tier-tab {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #94a3b8;
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tier-tab.active {
  background: #ca8a04;
  color: #000;
  font-weight: 700;
  border-color: #facc15;
}

.level-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 4px;
}

.level-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(203, 161, 53, 0.3);
  border-radius: 10px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.level-card:hover:not(.locked) {
  border-color: #facc15;
  background: rgba(30, 41, 59, 0.9);
  transform: translateY(-2px);
}

.level-card.current {
  border: 2px solid #facc15;
  background: rgba(234, 179, 8, 0.15);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.level-card-num {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fef08a;
}

.level-card-stars {
  font-size: 0.65rem;
  color: #facc15;
}

.level-card-grid {
  font-size: 0.6rem;
  color: #94a3b8;
}

/* ==========================================================
   CODEX MODAL
   ========================================================== */

.codex-sub {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-bottom: 14px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 4px;
}

.codex-card-item {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(203, 161, 53, 0.3);
  border-radius: 12px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.codex-card-item.locked {
  opacity: 0.4;
  filter: grayscale(0.9);
}

.codex-avatar {
  font-size: 2rem;
}

.codex-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fef08a;
  line-height: 1.15;
}

.codex-origin {
  font-size: 0.6rem;
  color: #94a3b8;
}

/* ==========================================================
   ANIMATIONS & KEYFRAMES
   ========================================================== */

@keyframes popIn {
  0% { transform: scale(0.4); opacity: 0; }
  80% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes unlockBurst {
  0% { transform: scale(0.7) rotate(-6deg); }
  60% { transform: scale(1.1) rotate(3deg); }
  100% { transform: scale(0.97) rotate(0deg); }
}

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

@keyframes pulseGlow {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 0.8; transform: scale(1.1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

@keyframes slideDown {
  0% { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes starPop {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.animate-pop {
  animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pulse-anim {
  animation: pulseButton 1.8s ease-in-out infinite;
}

@keyframes pulseButton {
  0%, 100% { box-shadow: 0 0 10px rgba(234, 179, 8, 0.4); }
  50% { box-shadow: 0 0 22px rgba(234, 179, 8, 0.8); }
}

/* ==========================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================== */

@media (max-width: 480px) {
  .game-header {
    padding: 6px 12px;
  }
  .gold-btn.icon-btn {
    padding: 5px 8px;
    font-size: 0.75rem;
  }
  .gold-btn.icon-btn .btn-label {
    display: none;
  }
  .puzzle-stage {
    padding: 4px 8px;
  }
  .stage-frame {
    padding: 6px;
  }
  .game-controls {
    padding: 6px 12px 10px 12px;
  }
  .tool-btn {
    padding: 8px;
    font-size: 0.82rem;
  }
}

