/* ==========================================================================
   Arrow Escape: Tap Away — Core Stylesheet
   Modern, Mobile-First, ASMR Dark Slate & Multi-Theme Aesthetic
   ========================================================================== */

:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #131722;
  --bg-card: #1c2230;
  --bg-elevated: #242c3d;
  
  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Directional Tile Accents (Vibrant & High Contrast) */
  --dir-up: #00e5ff;
  --dir-up-glow: rgba(0, 229, 255, 0.4);
  --dir-right: #10b981;
  --dir-right-glow: rgba(16, 185, 129, 0.4);
  --dir-down: #ff477e;
  --dir-down-glow: rgba(255, 71, 126, 0.4);
  --dir-left: #fbbf24;
  --dir-left-glow: rgba(251, 191, 36, 0.4);

  --accent-gold: #ffd166;
  --accent-purple: #8b5cf6;
  --accent-blue: #3b82f6;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.2);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==========================================================================
   THEME PALETTES & CUSTOM SKINS
   ========================================================================== */
[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0d;
  --bg-card: #121216;
  --bg-elevated: #1a1a22;
  --dir-up: #38bdf8;
  --dir-right: #34d399;
  --dir-down: #f43f5e;
  --dir-left: #fbbf24;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --border-active: rgba(255, 255, 255, 0.3);
}

[data-theme="synthwave"] {
  --bg-primary: #120426;
  --bg-secondary: #1a0836;
  --bg-card: #260d4e;
  --bg-elevated: #37146e;
  --dir-up: #00f0ff;
  --dir-right: #f72585;
  --dir-down: #ffb703;
  --dir-left: #7209b7;
  --accent-gold: #ffea00;
  --border-subtle: rgba(247, 37, 133, 0.2);
  --border-active: rgba(0, 240, 255, 0.4);
}

[data-theme="forest"] {
  --bg-primary: #07130d;
  --bg-secondary: #0c1e15;
  --bg-card: #132b1f;
  --bg-elevated: #1c3c2b;
  --dir-up: #5eead4;
  --dir-right: #4ade80;
  --dir-down: #f87171;
  --dir-left: #facc15;
  --border-subtle: rgba(74, 222, 128, 0.15);
  --border-active: rgba(94, 234, 212, 0.35);
}

[data-theme="candy"] {
  --bg-primary: #141026;
  --bg-secondary: #1d1838;
  --bg-card: #28214d;
  --bg-elevated: #382f6b;
  --dir-up: #a78bfa;
  --dir-right: #38bdf8;
  --dir-down: #f472b6;
  --dir-left: #fbbf24;
  --border-subtle: rgba(244, 114, 182, 0.2);
  --border-active: rgba(167, 139, 250, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html {
  width: 100%;
  min-height: 100%;
  scroll-behavior: smooth;
  background-color: var(--bg-primary);
}

body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(circle at 50% 15%, var(--bg-card) 0%, var(--bg-primary) 70%);
  transition: background 0.3s ease;
}

/* Background Canvas Overlays */
#trailCanvas, #confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}
#confettiCanvas {
  z-index: 200;
}

/* App Viewport Container */
.app-container {
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 12px) 16px;
  position: relative;
  z-index: 10;
}

/* Top App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 8px;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-info {
  display: flex;
  flex-direction: column;
}

.mode-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: var(--accent-gold);
  text-transform: uppercase;
}

.level-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.1;
  color: #fff;
}

/* Icon Buttons */
.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.icon-btn:active {
  transform: scale(0.92);
  background: var(--bg-elevated);
}

.icon-btn.muted {
  opacity: 0.5;
  color: var(--text-dim);
}

.svg-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Combo Pill (Animated ASMR Multiplier) */
.combo-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #ff477e, #ff8c00);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 16px rgba(255, 71, 126, 0.5);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.combo-pill.active {
  opacity: 1;
  transform: scale(1);
}

.combo-fire {
  font-size: 14px;
  animation: pulseFire 0.6s infinite alternate ease-in-out;
}

@keyframes pulseFire {
  0% { transform: scale(1); }
  100% { transform: scale(1.3); }
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-card:not(:last-child) {
  border-right: 1px solid var(--border-subtle);
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.stat-value {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

/* Main Game Board Viewport */
.board-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
  overflow: visible;
}

.board-wrapper {
  position: relative;
  width: min(86vw, 420px, 58vh);
  height: min(86vw, 420px, 58vh);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Grid Board */
.grid-board {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 8px;
  background: rgba(19, 23, 34, 0.7);
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 
    inset 0 2px 6px rgba(0, 0, 0, 0.6),
    0 16px 36px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  position: relative;
}

/* Arrow Tile (Card) */
.tile-cell {
  position: relative;
  width: 100%;
  height: 100%;
}

.arrow-tile {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.15s ease;
  will-change: transform, opacity;
  box-shadow: 
    0 4px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.35),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4);
}

.arrow-tile:active {
  transform: scale(0.92);
}

/* Direction-Specific Themes & Arrow Styling */
.arrow-tile[data-dir="UP"] {
  background: linear-gradient(145deg, var(--dir-up), #0482b4);
  color: #061e2b;
}

.arrow-tile[data-dir="RIGHT"] {
  background: linear-gradient(145deg, var(--dir-right), #066645);
  color: #042518;
}

.arrow-tile[data-dir="DOWN"] {
  background: linear-gradient(145deg, var(--dir-down), #b81442);
  color: #310310;
}

.arrow-tile[data-dir="LEFT"] {
  background: linear-gradient(145deg, var(--dir-left), #b47504);
  color: #2b1c03;
}

/* SVG Inside Tile */
.tile-arrow-svg {
  width: 62%;
  height: 62%;
  fill: currentColor;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.4));
  transition: transform 0.2s ease;
}

/* ==========================================================================
   SPECIAL OBSTACLE TILES (ICE, BOMB, LOCKED, KEY)
   ========================================================================== */

/* 1. FROZEN ICE TILE */
.arrow-tile.frozen {
  background: linear-gradient(135deg, rgba(186, 230, 253, 0.85) 0%, rgba(56, 189, 248, 0.6) 100%) !important;
  color: #0c4a6e !important;
  border: 2px solid #bae6fd;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.5), inset 0 0 10px rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
}

.arrow-tile.frozen::after {
  content: '❄️';
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 13px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.arrow-tile.shatter-ice {
  animation: shatterPulse 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes shatterPulse {
  0% { transform: scale(0.9); filter: brightness(1.8); }
  50% { transform: scale(1.12); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* 2. BOMB EXPLOSIVE TILE */
.arrow-tile.bomb {
  background: linear-gradient(135deg, #ef4444 0%, #7f1d1d 100%) !important;
  color: #fff !important;
  border: 2px solid #f87171;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  animation: bombPulse 1.4s infinite ease-in-out;
}

.arrow-tile.bomb::after {
  content: '💣';
  position: absolute;
  font-size: 24px;
}

.arrow-tile.bomb .tile-arrow-svg {
  display: none;
}

@keyframes bombPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(239, 68, 68, 0.6); }
  50% { transform: scale(1.06); box-shadow: 0 0 26px rgba(239, 68, 68, 0.95); }
}

/* 3. PADLOCK LOCKED TILE */
.arrow-tile.locked {
  background: linear-gradient(145deg, #334155 0%, #1e293b 100%) !important;
  color: #94a3b8 !important;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
  filter: saturate(0.4);
}

.arrow-tile.locked::after {
  content: '🔒';
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 13px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
}

.arrow-tile.locked-shake {
  animation: lockedRattle 0.35s ease-in-out both;
}

@keyframes lockedRattle {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-4px, 0) rotate(-4deg); }
  40% { transform: translate(4px, 0) rotate(4deg); }
  60% { transform: translate(-3px, 0) rotate(-2deg); }
  80% { transform: translate(3px, 0) rotate(2deg); }
}

/* 4. KEY ARROW TILE */
.arrow-tile.key-arrow {
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.7), inset 0 2px 3px rgba(255, 255, 255, 0.6);
  border: 2px solid #fef08a;
  animation: keyShine 1.8s infinite ease-in-out;
}

.arrow-tile.key-arrow::after {
  content: '🔑';
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 13px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

@keyframes keyShine {
  0%, 100% { box-shadow: 0 0 14px rgba(251, 191, 36, 0.6); }
  50% { box-shadow: 0 0 28px rgba(251, 191, 36, 0.95); }
}

/* BOARD RUMBLE SCREEN SHAKE (FOR BOMBS) */
.board-wrapper.shake {
  animation: boardRumble 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes boardRumble {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 6px); }
  30% { transform: translate(8px, -6px); }
  45% { transform: translate(-6px, -4px); }
  60% { transform: translate(6px, 4px); }
  75% { transform: translate(-3px, 2px); }
}

/* Tile Dynamic States */
.arrow-tile.hint-pulse {
  animation: hintGlow 1.2s infinite ease-in-out;
  z-index: 15;
}

@keyframes hintGlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 2px #fff, 0 0 20px rgba(255, 255, 255, 0.9);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 4px #ffd166, 0 0 32px rgba(255, 209, 102, 1);
  }
}

/* Blocked Bump & Wiggle Animation */
.arrow-tile.blocked-bump-UP {
  animation: bumpUp 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
.arrow-tile.blocked-bump-DOWN {
  animation: bumpDown 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
.arrow-tile.blocked-bump-LEFT {
  animation: bumpLeft 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
.arrow-tile.blocked-bump-RIGHT {
  animation: bumpRight 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes bumpUp {
  0% { transform: translateY(0); }
  25% { transform: translateY(-12px) rotate(-3deg); }
  50% { transform: translateY(4px) rotate(2deg); }
  75% { transform: translateY(-3px) rotate(-1deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

@keyframes bumpDown {
  0% { transform: translateY(0); }
  25% { transform: translateY(12px) rotate(3deg); }
  50% { transform: translateY(-4px) rotate(-2deg); }
  75% { transform: translateY(3px) rotate(1deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

@keyframes bumpLeft {
  0% { transform: translateX(0); }
  25% { transform: translateX(-12px) rotate(-3deg); }
  50% { transform: translateX(4px) rotate(2deg); }
  75% { transform: translateX(-3px) rotate(-1deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

@keyframes bumpRight {
  0% { transform: translateX(0); }
  25% { transform: translateX(12px) rotate(3deg); }
  50% { transform: translateX(-4px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(1deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* Flying Out Off Screen */
.arrow-tile.flying-UP {
  transform: translateY(-160vh) scale(0.9);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.4, 0, 1, 1), opacity 0.45s ease;
  pointer-events: none;
}
.arrow-tile.flying-DOWN {
  transform: translateY(160vh) scale(0.9);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.4, 0, 1, 1), opacity 0.45s ease;
  pointer-events: none;
}
.arrow-tile.flying-LEFT {
  transform: translateX(-160vw) scale(0.9);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.4, 0, 1, 1), opacity 0.45s ease;
  pointer-events: none;
}
.arrow-tile.flying-RIGHT {
  transform: translateX(160vw) scale(0.9);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.4, 0, 1, 1), opacity 0.45s ease;
  pointer-events: none;
}

/* Bottom Action Bar */
.app-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  position: relative;
  font-size: 12px;
  font-weight: 600;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.action-btn:active {
  transform: scale(0.94);
  background: var(--bg-elevated);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.action-btn .badge {
  position: absolute;
  top: 4px;
  right: 8px;
  background: var(--accent-purple);
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

/* Modals & Backdrops */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.open .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.close-btn:hover {
  color: #fff;
}

/* Mode Tabs */
.mode-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 18px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: #fff;
}

.tab-content {
  display: none;
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.tab-content.active {
  display: block;
}

/* Level Grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 4px;
}

.lvl-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.lvl-box:active:not(.locked) {
  transform: scale(0.93);
}

.lvl-box.current {
  border-color: var(--dir-up);
  box-shadow: 0 0 14px var(--dir-up-glow);
}

.lvl-box.locked {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(1);
}

.lvl-num {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.lvl-stars {
  font-size: 11px;
  color: var(--accent-gold);
  letter-spacing: 1px;
}

/* Endless Generator & Switch */
.endless-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
  text-align: center;
}

.special-toggle-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.special-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.special-toggle-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.special-toggle-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: .25s ease;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: .25s ease;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--dir-right);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.endless-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.endless-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.endless-btn:hover {
  border-color: var(--dir-up);
  background: var(--bg-elevated);
}

.endless-btn:active {
  transform: scale(0.96);
}

.endless-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.endless-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* THEME MODAL STYLING */
.theme-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.theme-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
}

.theme-choice-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-choice-card:hover {
  background: var(--bg-elevated);
}

.theme-choice-card.active {
  border-color: var(--dir-up);
  box-shadow: 0 0 14px var(--dir-up-glow);
}

.theme-swatch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  padding: 3px;
  background: #0a0d14;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.theme-swatch span {
  width: 100%;
  height: 100%;
  border-radius: 3px;
}

.theme-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex: 1;
}

.theme-tag {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}

/* Win Modal Specifics */
.win-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.win-sparkle {
  font-size: 40px;
  margin-bottom: 4px;
  animation: bounceSparkle 1.2s infinite ease-in-out;
}

@keyframes bounceSparkle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(15deg); }
}

.win-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffd166, #ff758c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.win-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.star-rating {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 38px;
  margin-bottom: 22px;
}

.star {
  color: #2a3144;
  transition: color 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star.earned {
  color: var(--accent-gold);
  transform: scale(1.15);
  text-shadow: 0 0 16px rgba(255, 209, 102, 0.8);
}

.win-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 22px;
}

.win-stat-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.win-stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.win-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.btn-primary:active, .btn-secondary:active {
  transform: scale(0.95);
}

/* Scrollbar Styling */
.tab-content::-webkit-scrollbar, .theme-options-grid::-webkit-scrollbar {
  width: 5px;
}
.tab-content::-webkit-scrollbar-track, .theme-options-grid::-webkit-scrollbar-track {
  background: transparent;
}
.tab-content::-webkit-scrollbar-thumb, .theme-options-grid::-webkit-scrollbar-thumb {
  background: var(--border-active);
  border-radius: 4px;
}

/* ==========================================================================
   ABOUT & HOW TO PLAY SEO GUIDE STYLING
   ========================================================================== */
.about-seo-content {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px;
}

.about-seo-content h3 {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.about-seo-content h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-top: 4px;
}

.about-seo-content ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.about-seo-content strong {
  color: #fff;
}

.about-specials-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.special-guide-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
}

.special-guide-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.about-features {
  background: var(--bg-secondary);
  border-left: 3px solid var(--dir-right);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-main);
}

/* ==========================================================================
   BELOW-THE-FOLD SEO CONTENT & FAQ STYLING (RANKING ACCELERATOR)
   ========================================================================== */
.seo-article-section {
  width: 100%;
  background: linear-gradient(180deg, transparent 0%, rgba(10, 13, 20, 0.95) 15%, var(--bg-primary) 100%);
  border-top: 1px solid var(--border-subtle);
  padding: 60px 20px 80px 20px;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.seo-container {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.68;
}

.seo-badge {
  align-self: flex-start;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid var(--dir-up);
  color: var(--dir-up);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.seo-main-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  letter-spacing: -0.5px;
}

.seo-sub-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-top: 24px;
}

.seo-lead {
  font-size: 16px;
  color: var(--text-main);
  line-height: 1.7;
}

.seo-lead strong, .seo-container strong {
  color: #fff;
}

/* Features Grid */
.seo-features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.seo-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.seo-card-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.seo-feature-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.seo-feature-card p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Steps list */
.seo-steps-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.seo-steps-list li strong {
  color: var(--dir-up);
}

/* Specials Explain Row */
.specials-explain-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}

.special-explain-pill {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px;
}

.special-explain-pill .icon {
  font-size: 24px;
  flex-shrink: 0;
}

/* FAQ Accordion (<details>) */
.faq-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.faq-accordion {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.faq-accordion[open] {
  border-color: var(--border-active);
  background: var(--bg-elevated);
}

.faq-question {
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '+';
  font-size: 22px;
  font-weight: 400;
  color: var(--dir-up);
  transition: transform 0.2s ease;
}

.faq-accordion[open] .faq-question::after {
  content: '−';
  transform: rotate(180deg);
}

.faq-answer {
  padding: 0 20px 18px 20px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  margin-top: 8px;
  padding-top: 12px;
}

/* Metadata Specs Table */
.seo-specs-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 10px;
}

.seo-specs-table th, .seo-specs-table td {
  padding: 12px 18px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.seo-specs-table th {
  width: 32%;
  color: var(--text-dim);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
}

.seo-specs-table td {
  color: var(--text-main);
  font-weight: 500;
}

.seo-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 24px;
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seo-footer-sub {
  font-size: 11px;
  opacity: 0.6;
}
