/* ==========================================================================
   Block Blast: Master Aesthetic Soft & Eye-Catching Edition
   High-Contrast Grid Legibility, Tactile 3D Bevels, Harmonious Pastel-Gem Colors
   Pure CSS3, Zero External Assets, Instant Loading (<50ms)
   ========================================================================== */

:root, [data-theme="royal"] {
  /* --- Iconic Royal Arcade Blue Theme (High-Contrast, Crisp & Vibrant) --- */
  --bg-tabletop: radial-gradient(circle at 50% 18%, #283a75 0%, #1b2854 58%, #111936 100%);
  --bg-secondary: #1b2854;

  /* Board Outer Frame (Deep Indigo & Crisp Sky Rim) */
  --board-frame: linear-gradient(145deg, #24356b 0%, #17234a 60%, #101835 100%);
  --board-frame-border: #435fa8;
  --board-frame-glow: rgba(56, 189, 248, 0.22);
  --board-inner-bg: #0e1630;

  /* High-Contrast Recessed Sockets (Clearly Visible 8x8 Grid) */
  --socket-bg: linear-gradient(145deg, #1b2852 0%, #152042 100%);
  --socket-border: rgba(148, 184, 255, 0.16);
  --socket-shadow: inset 1.5px 1.5px 3px rgba(0, 0, 0, 0.65), inset -1px -1px 2px rgba(255, 255, 255, 0.06);

  --text-main: #f8fafc;
  --text-muted: #93b4ef;
  --accent-gold: #facc15;
  --accent-amber: #f59e0b;

  /* --- Glossy 3D Arcade Block Palette --- */
  --block-1-bg: linear-gradient(135deg, #fde047 0%, #eab308 48%, #ca8a04 100%);
  --block-1-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.14) 0px, rgba(255,255,255,0.14) 2px, transparent 2px, transparent 8px);

  --block-2-bg: linear-gradient(135deg, #fb7185 0%, #f43f5e 48%, #e11d48 100%);
  --block-2-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.14) 0px, rgba(255,255,255,0.14) 2px, transparent 2px, transparent 8px);

  --block-3-bg: linear-gradient(135deg, #4ade80 0%, #22c55e 50%, #15803d 100%);
  --block-3-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.14) 0px, rgba(255,255,255,0.14) 2px, transparent 2px, transparent 8px);

  --block-4-bg: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 48%, #0369a1 100%);
  --block-4-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.14) 0px, rgba(255,255,255,0.14) 2px, transparent 2px, transparent 8px);

  --block-5-bg: linear-gradient(135deg, #c084fc 0%, #a855f7 48%, #7e22ce 100%);
  --block-5-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.14) 0px, rgba(255,255,255,0.14) 2px, transparent 2px, transparent 8px);

  --block-6-bg: linear-gradient(135deg, #fb923c 0%, #f97316 50%, #c2410c 100%);
  --block-6-grain: repeating-linear-gradient(90deg, rgba(255,255,255,0.14) 0px, rgba(255,255,255,0.14) 2px, transparent 2px, transparent 8px);

  --wood-bevel:
    inset 2px 2px 2px rgba(255, 255, 255, 0.68),
    inset 3px 3px 6px rgba(255, 255, 255, 0.22),
    inset -2.5px -2.5px 3px rgba(0, 0, 0, 0.38),
    0 3px 6px rgba(0, 0, 0, 0.35);

  --dock-tray: linear-gradient(180deg, #1b2956 0%, #131d3f 100%);
  --dock-tray-border: #3b5598;
  --dock-slot-bg: rgba(10, 16, 38, 0.45);

  --card-wood: linear-gradient(145deg, #213266 0%, #152147 100%);
  --card-border: #3d589e;
}

[data-theme="wood"] {
  --bg-tabletop: radial-gradient(circle at 50% 18%, #4a3020 0%, #2c1b11 60%, #1b1009 100%);
  --bg-secondary: #332014;
  --board-frame: linear-gradient(145deg, #694229 0%, #472b19 60%, #2f1b0f 100%);
  --board-frame-border: #966341;
  --board-frame-glow: rgba(245, 158, 11, 0.25);
  --board-inner-bg: #24140b;
  --socket-bg: linear-gradient(145deg, #3b2416 0%, #2d1a0f 100%);
  --socket-border: rgba(255, 224, 178, 0.14);
  --text-main: #fffbeb;
  --text-muted: #e6c5a3;
  --dock-tray: linear-gradient(180deg, #422919 0%, #2d1b10 100%);
  --dock-tray-border: #784d30;
  --dock-slot-bg: rgba(18, 10, 5, 0.4);
  --card-wood: linear-gradient(145deg, #4c2f1d 0%, #331e12 100%);
  --card-border: #7c5032;
}

/* --- Theme 2: Calming Nordic Slate & Pastel --- */
[data-theme="cyber"], [data-theme="nordic"] {
  --bg-tabletop: radial-gradient(circle at 50% 18%, #1f2736 0%, #131924 60%, #0a0d14 100%);
  --bg-secondary: #161d2b;
  --board-frame: linear-gradient(145deg, #28354c 0%, #182130 100%);
  --board-frame-border: #3b4e6d;
  --board-frame-glow: rgba(56, 189, 248, 0.2);
  --board-inner-bg: #0d121c;

  --socket-bg: linear-gradient(145deg, #182232 0%, #121926 100%);
  --socket-border: rgba(255, 255, 255, 0.08);
  --socket-shadow: inset 1.5px 1.5px 3px rgba(0, 0, 0, 0.7), inset -1px -1px 2px rgba(255, 255, 255, 0.06);

  --text-main: #f0fdf4;
  --text-muted: #94a3b8;
  --accent-gold: #38bdf8;
  --accent-amber: #0284c7;

  --block-1-bg: linear-gradient(135deg, #67e8f9 0%, #06b6d4 50%, #0891b2 100%);
  --block-2-bg: linear-gradient(135deg, #fda4af 0%, #f43f5e 50%, #e11d48 100%);
  --block-3-bg: linear-gradient(135deg, #86efac 0%, #22c55e 50%, #15803d 100%);
  --block-4-bg: linear-gradient(135deg, #fde047 0%, #eab308 50%, #ca8a04 100%);
  --block-5-bg: linear-gradient(135deg, #d8b4fe 0%, #a855f7 50%, #7e22ce 100%);
  --block-6-bg: linear-gradient(135deg, #fed7aa 0%, #fb923c 50%, #ea580c 100%);

  --dock-tray: linear-gradient(180deg, #182232 0%, #101622 100%);
  --dock-tray-border: #2a3a54;
  --dock-slot-bg: rgba(0, 0, 0, 0.3);
  --card-wood: linear-gradient(145deg, #1c2738 0%, #111824 100%);
  --card-border: #2e405c;
}

/* --- Theme 3: Cozy Midnight OLED --- */
[data-theme="amoled"], [data-theme="midnight"] {
  --bg-tabletop: radial-gradient(circle at 50% 18%, #17171c 0%, #0d0d10 60%, #050507 100%);
  --bg-secondary: #121216;
  --board-frame: linear-gradient(145deg, #24242e 0%, #14141a 100%);
  --board-frame-border: #383848;
  --board-frame-glow: rgba(192, 132, 252, 0.2);
  --board-inner-bg: #08080a;

  --socket-bg: linear-gradient(145deg, #16161c 0%, #0e0e13 100%);
  --socket-border: rgba(255, 255, 255, 0.09);
  --socket-shadow: inset 1.5px 1.5px 3px rgba(0, 0, 0, 0.8), inset -1px -1px 2px rgba(255, 255, 255, 0.05);

  --text-main: #ffffff;
  --text-muted: #a1a1aa;
  --accent-gold: #fbbf24;
  --accent-amber: #f59e0b;

  --block-1-bg: linear-gradient(135deg, #fde047 0%, #facc15 50%, #eab308 100%);
  --block-2-bg: linear-gradient(135deg, #fb7185 0%, #f43f5e 50%, #e11d48 100%);
  --block-3-bg: linear-gradient(135deg, #4ade80 0%, #22c55e 50%, #16a34a 100%);
  --block-4-bg: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #0284c7 100%);
  --block-5-bg: linear-gradient(135deg, #c084fc 0%, #a855f7 50%, #9333ea 100%);
  --block-6-bg: linear-gradient(135deg, #fb923c 0%, #f97316 50%, #ea580c 100%);

  --dock-tray: #101014;
  --dock-tray-border: #262632;
  --dock-slot-bg: rgba(0, 0, 0, 0.4);
  --card-wood: #15151b;
  --card-border: #282834;
}

/* ==========================================================================
   Base Reset & Layout
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html {
  font-size: 16px;
  background-color: #0f0a0d;
  background-image: var(--bg-tabletop);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100%;
  background-image: var(--bg-tabletop);
  background-attachment: fixed;
  overflow-x: hidden;
  touch-action: pan-y;
  line-height: 1.5;
}

/* Canvas Overlays */
#blastCanvas, #confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* ==========================================================================
   First-Screen App Container (100vh Responsive)
   ========================================================================== */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px 14px;
  position: relative;
  box-sizing: border-box;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  gap: 10px;
  padding-bottom: 4px;
}

.header-left {
  display: flex;
  flex-direction: column;
}

.game-logo {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #fffbeb 0%, #fde68a 35%, #fbbf24 70%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.7));
}

.logo-sub {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Combo Streak Pill */
.combo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #b45309 0%, #ea580c 100%);
  border: 1.5px solid #fbbf24;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.5);
  font-size: 0.82rem;
  font-weight: 900;
  color: #fffbeb;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: scale(0.85);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.combo-pill.active {
  opacity: 1;
  transform: scale(1);
  animation: pulseCombo 0.75s infinite alternate ease-in-out;
}

@keyframes pulseCombo {
  0% { transform: scale(1); box-shadow: 0 0 12px rgba(245, 158, 11, 0.4); }
  100% { transform: scale(1.08); box-shadow: 0 0 24px rgba(245, 158, 11, 0.85); }
}

.combo-fire {
  font-size: 1.1rem;
}

/* Header Buttons */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--card-wood);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.93);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.svg-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ==========================================================================
   Score Bar
   ========================================================================== */
.score-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 6px 0 10px;
}

.score-card {
  background: var(--card-wood);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.18),
    inset 0 -2px 4px rgba(0, 0, 0, 0.5);
  position: relative;
}

.score-card::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 11px;
  border: 1px dashed rgba(245, 158, 11, 0.15);
  pointer-events: none;
}

.score-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.crown-icon {
  font-size: 0.85rem;
}

.score-value {
  font-size: 1.65rem;
  font-weight: 900;
  color: #fffbeb;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85), 0 0 12px rgba(245, 158, 11, 0.35);
  transition: transform 0.15s ease;
}

.score-value.bump {
  animation: bumpNumber 0.25s ease-out;
}

@keyframes bumpNumber {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); color: #fbbf24; text-shadow: 0 0 16px #f59e0b; }
  100% { transform: scale(1); }
}

/* ==========================================================================
   Master 8x8 Wooden Tray & High-Contrast Sockets
   ========================================================================== */
.board-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 0;
}

.grid-wrapper {
  background: var(--board-frame);
  border: 4px solid var(--board-frame-border);
  outline: 1.5px solid rgba(0, 0, 0, 0.75);
  border-radius: 20px;
  padding: 8px;
  box-shadow:
    0 20px 42px rgba(0, 0, 0, 0.75),
    0 8px 16px rgba(0, 0, 0, 0.5),
    0 0 20px var(--board-frame-glow),
    inset 0 3px 6px rgba(0, 0, 0, 0.8),
    inset 0 -1.5px 2px rgba(255, 230, 200, 0.2);
  position: relative;
  touch-action: none;
  transition: transform 0.12s ease;
}

/* Screen shake on combos */
.grid-wrapper.shake-sm {
  animation: boardShakeSm 0.22s ease;
}

.grid-wrapper.shake-lg {
  animation: boardShakeLg 0.35s ease;
}

@keyframes boardShakeSm {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 3px); }
  75% { transform: translate(2px, -2px); }
}

@keyframes boardShakeLg {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-4px, 4px) rotate(-0.5deg); }
  40% { transform: translate(4px, -3px) rotate(0.5deg); }
  60% { transform: translate(-3px, 2px); }
  80% { transform: translate(2px, -1px); }
}

.grid-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  width: min(88vw, 390px, 46vh);
  height: min(86vw, 400px, 48vh);
  aspect-ratio: 1 / 1;
  background: var(--board-inner-bg);
  padding: 5px;
  border-radius: 14px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.95);
}

/* High-Contrast Carved Sockets (Clear, visible 8x8 grid) */
.grid-cell {
  background: var(--socket-bg);
  border-radius: 6px;
  position: relative;
  box-shadow: var(--socket-shadow);
  border: 1px solid var(--socket-border);
  transition: transform 0.1s ease, background 0.12s ease;
  overflow: hidden;
}

/* Subtle router groove inside empty socket */
.grid-cell::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

/* Filled Tactile Block with 3D Chamfer & Eye-Catching Pop */
.grid-cell.filled {
  border: none;
  box-shadow: var(--wood-bevel);
  position: relative;
  overflow: visible;
  animation: woodBlockPopIn 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes woodBlockPopIn {
  0% { transform: scale(0.7); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* Realistic Satin Wood Sheen Overlay */
.grid-cell.filled::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 40%, rgba(0,0,0,0.18) 100%);
  pointer-events: none;
}

/* Block Colors (Eye-Catching Aesthetic Gem & Timber) */
.block-color-1 {
  background: var(--block-1-grain), var(--block-1-bg);
}
.block-color-2 {
  background: var(--block-2-grain), var(--block-2-bg);
}
.block-color-3 {
  background: var(--block-3-grain), var(--block-3-bg);
}
.block-color-4 {
  background: var(--block-4-grain), var(--block-4-bg);
}
.block-color-5 {
  background: var(--block-5-grain), var(--block-5-bg);
}
.block-color-6 {
  background: var(--block-6-grain), var(--block-6-bg);
}

/* Ghost Preview State */
.grid-cell.ghost-valid {
  background: rgba(245, 158, 11, 0.45) !important;
  border: 1.5px solid #fbbf24 !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.7), inset 0 0 8px rgba(255, 255, 255, 0.4) !important;
  transform: scale(0.96);
  z-index: 5;
}

.grid-cell.ghost-invalid {
  background: rgba(239, 68, 68, 0.38) !important;
}

/* Line Clear Exploding Animation */
.grid-cell.clearing {
  animation: woodBlastOut 0.28s ease-in forwards;
  z-index: 10;
}

@keyframes woodBlastOut {
  0% {
    transform: scale(1);
    filter: brightness(1.8);
  }
  40% {
    transform: scale(1.18);
    filter: brightness(2.8);
  }
  100% {
    transform: scale(0.1);
    opacity: 0;
  }
}

/* ==========================================================================
   Dock: Presentation Tray & Chunky Tactile Pieces
   ========================================================================== */
.dock-container {
  background: var(--dock-tray);
  border: 2px solid var(--dock-tray-border);
  border-radius: 20px;
  padding: 8px 8px;
  margin-top: 8px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.65),
    inset 0 3px 6px rgba(0, 0, 0, 0.7),
    inset 0 -1px 2px rgba(255, 235, 210, 0.12);
}

.dock-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  min-height: 98px;
}

.dock-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 98px;
  background: var(--dock-slot-bg);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  position: relative;
  touch-action: none;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* Dock Shape Pieces */
.dock-shape {
  display: grid;
  gap: 3px;
  cursor: grab;
  touch-action: none;
  transition: transform 0.12s ease;
  position: relative;
}

.dock-shape:hover {
  transform: scale(1.08);
}

.dock-shape:active {
  cursor: grabbing;
}

.dock-shape.disabled {
  opacity: 0.28;
  filter: grayscale(0.85);
  cursor: not-allowed;
}

.shape-cell {
  /* Dynamic size assigned by game.js */
  width: 22px;
  height: 22px;
  border-radius: 5px;
  box-shadow: var(--wood-bevel);
  pointer-events: none;
  position: relative;
}

.shape-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 55%);
  pointer-events: none;
}

.shape-cell.empty {
  visibility: hidden;
  box-shadow: none !important;
}

.shape-cell.empty::after {
  display: none;
}

/* Active Dragging Shape (High Elevation 3D Drop Shadow) */
.dragging-shape {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  display: grid;
  filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.8)) drop-shadow(0 6px 12px rgba(0, 0, 0, 0.55));
  opacity: 0.98;
  transform: translate(-50%, -50%) scale(1.06);
  transition: none !important;
}

.dragging-shape .shape-cell {
  border-radius: 6px;
}

/* Floating Score Popups */
.floating-scores-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

.floating-score {
  position: absolute;
  font-size: 1.65rem;
  font-weight: 900;
  color: #fffbeb;
  text-shadow:
    0 2px 6px rgba(0, 0, 0, 0.9),
    0 0 18px rgba(245, 158, 11, 0.85);
  pointer-events: none;
  animation: floatUp 0.85s ease-out forwards;
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translateY(-16px) scale(1.22);
  }
  80% {
    opacity: 1;
    transform: translateY(-42px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-64px) scale(0.85);
  }
}

/* ==========================================================================
   Modals (Themes & Game Over)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 8, 10, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--card-wood);
  border: 2px solid var(--board-frame-border);
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.8),
    inset 0 1px 3px rgba(255, 255, 255, 0.2);
  transform: scale(0.9);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.modal-backdrop.show .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: left;
}

.theme-options-grid {
  display: grid;
  gap: 10px;
}

.theme-choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.theme-choice-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent-gold);
}

.theme-choice-card.active {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.16);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.3);
}

.theme-swatch {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 3px;
  padding: 4px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-swatch span {
  border-radius: 3px;
  box-shadow: inset 0.5px 0.5px 1px rgba(255, 255, 255, 0.4);
}

.theme-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  flex: 1;
}

.theme-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Game Over Card */
.game-over-icon {
  font-size: 3.2rem;
  margin-bottom: 4px;
  animation: shakeGameOver 0.6s ease;
}

@keyframes shakeGameOver {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg) scale(1.1); }
  75% { transform: rotate(10deg) scale(1.1); }
}

.game-over-title {
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ef4444;
  margin-bottom: 4px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.game-over-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.game-over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.game-over-stat-box {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.game-over-stat-val {
  font-size: 1.45rem;
  font-weight: 900;
  color: #fffbeb;
}

.new-record-badge {
  display: none;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 6px 14px;
  border-radius: 9999px;
  margin: 0 auto 16px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
  animation: bounceBadge 0.6s ease infinite alternate;
}

.new-record-badge.show {
  display: inline-block;
}

@keyframes bounceBadge {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 50%, #b45309 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: scale(0.97);
}

/* ==========================================================================
   Below-the-Fold Crawlable SEO & FAQ Article
   ========================================================================== */
.seo-article-section {
  background: #140d12;
  border-top: 2px solid var(--board-frame-border);
  padding: 48px 16px 64px;
}

.seo-container {
  max-width: 680px;
  margin: 0 auto;
}

.seo-badge {
  display: inline-block;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 5px 12px;
  border-radius: 9999px;
  margin-bottom: 12px;
}

.seo-main-title {
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 14px;
}

.seo-lead {
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 24px;
}

.seo-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.seo-feature-card {
  background: #1e151b;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.seo-card-icon {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 6px;
}

.seo-feature-card h3 {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.seo-feature-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.seo-sub-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
}

.seo-steps-list {
  padding-left: 20px;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.seo-steps-list strong {
  color: var(--text-main);
}

/* FAQ Accordions */
.faq-container {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.faq-accordion {
  background: #1e151b;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.faq-accordion[open] {
  border-color: var(--accent-gold);
}

.faq-question {
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-gold);
  transition: transform 0.2s ease;
}

.faq-accordion[open] .faq-question::after {
  transform: rotate(45deg);
}

.faq-answer {
  padding: 0 16px 14px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Metadata Specs Table */
.seo-specs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: #1e151b;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.seo-specs-table th, .seo-specs-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.seo-specs-table th {
  color: var(--text-muted);
  font-weight: 700;
  width: 35%;
}

.seo-specs-table td {
  color: var(--text-main);
  font-weight: 700;
}

.seo-footer {
  margin-top: 36px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Booster Power-Up Bar */
.booster-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin: 2px 0;
}

.booster-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--card-wood);
  border: 1.5px solid var(--card-border);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.booster-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent-gold);
}

.booster-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.booster-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.booster-icon {
  font-size: 1rem;
  line-height: 1;
}

.booster-badge {
  background: rgba(250, 204, 21, 0.2);
  color: var(--accent-gold);
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 900;
}

.grid-cell.hint-cell {
  outline: 2.5px dashed #facc15 !important;
  outline-offset: -2px;
  background: rgba(250, 204, 21, 0.28) !important;
  animation: hintPulseCell 0.9s infinite alternate ease-in-out;
}

@keyframes hintPulseCell {
  0% { transform: scale(0.95); box-shadow: 0 0 4px rgba(250, 204, 21, 0.4); }
  100% { transform: scale(1.02); box-shadow: 0 0 14px rgba(250, 204, 21, 0.9); }
}
