/* 65536 - The Reverse 2048 Stylesheet */
:root {
  --bg-main: #090d16;
  --bg-card: rgba(22, 29, 49, 0.75);
  --border-card: rgba(99, 102, 241, 0.25);
  --board-bg: #0f172a;
  --cell-bg: rgba(30, 41, 59, 0.6);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-purple: #8b5cf6;
  --accent-cyan: #00f0ff;
  --accent-gold: #ffd600;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --grid-size: 8;
}

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

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.18) 0%, transparent 60%),
    radial-gradient(circle at 10% 90%, rgba(217, 70, 239, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.12) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 auto;
}

/* Header Section */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.title-area h1 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #a855f7 0%, #6366f1 50%, #00f0ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.subtitle {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 3px;
  display: flex;
  align-items: center;
}

.version-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  color: #00f0ff;
  background: rgba(0, 240, 255, 0.12);
  border: 1px solid rgba(0, 240, 255, 0.35);
  padding: 1px 7px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  margin-left: 8px;
  text-transform: none;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.icon-btn:hover {
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.6);
  transform: translateY(-2px);
}

.icon-btn:active {
  transform: translateY(0);
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
  position: relative;
  backdrop-filter: blur(8px);
}

.stat-card.score {
  border-color: rgba(255, 214, 0, 0.4);
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 900;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card.score .stat-value {
  color: #ffd600;
}

/* Breaker Legend & Big Bang Status Banner */
.breaker-banner {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  gap: 8px;
}

.breaker-legend-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breaker-banner-title {
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.breaker-pills {
  display: flex;
  gap: 8px;
}

.breaker-pill {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.pill-2 {
  background: #ff1744;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 23, 68, 0.5);
}

.pill-4 {
  background: #ffea00;
  color: #000000;
  box-shadow: 0 0 10px rgba(255, 234, 0, 0.5);
}

.pill-8 {
  background: #00f0ff;
  color: #000000;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.pill-16 {
  background: #00ff66;
  color: #000000;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
}

/* Supernova Big Bang Finishing Status Box */
.big-bang-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
  transition: all 0.25s ease;
  font-size: 0.75rem;
  font-weight: 600;
}

.big-bang-box:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.big-bang-box:active {
  transform: translateY(0);
}

.big-bang-icon {
  font-size: 0.85rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(255, 100, 0, 0.6));
}

.big-bang-label {
  color: var(--text-secondary, #94a3b8);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.big-bang-val {
  color: #ff9e00;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
}

/* When Big Bang is READY */
.big-bang-box.ready {
  background: rgba(0, 240, 255, 0.15);
  border-color: rgba(0, 240, 255, 0.6);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
  animation: bigBangReadyPulse 1.6s ease-in-out infinite alternate;
}

.big-bang-box.ready .big-bang-val {
  color: #00f0ff;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.8);
}

.big-bang-box.ready .big-bang-icon {
  animation: bigBangIconBounce 0.8s ease-in-out infinite alternate;
}

@keyframes bigBangReadyPulse {
  0% {
    box-shadow: 0 0 6px rgba(0, 240, 255, 0.3);
    border-color: rgba(0, 240, 255, 0.5);
  }
  100% {
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.7), 0 0 24px rgba(255, 0, 212, 0.3);
    border-color: rgba(0, 240, 255, 0.9);
  }
}

@keyframes bigBangIconBounce {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.25) rotate(10deg);
  }
}

/* Critical Mass / Spontaneous Fission Status Box */
.fission-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
  transition: all 0.25s ease;
  font-size: 0.75rem;
  font-weight: 600;
}

.fission-box:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.fission-box:active {
  transform: translateY(0);
}

.fission-icon {
  font-size: 0.85rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(236, 72, 153, 0.6));
}

.fission-label {
  color: var(--text-secondary, #94a3b8);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fission-val {
  color: #ec4899;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
  transition: color 0.3s ease;
}

/* Warning phase (moves 20 to 23) */
.fission-box.warning {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.65);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
  animation: fissionWarningPulse 1.1s ease-in-out infinite alternate;
}

.fission-box.warning .fission-val {
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.6);
}

.fission-box.warning .fission-icon {
  animation: fissionIconPulse 0.9s ease-in-out infinite alternate;
}

/* Imminent phase (move 24 / 1 move left) */
.fission-box.imminent {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.7);
  animation: fissionImminentPulse 0.45s ease-in-out infinite alternate;
}

.fission-box.imminent .fission-val {
  color: #ff3366;
  text-shadow: 0 0 8px rgba(255, 51, 102, 0.9);
}

.fission-box.imminent .fission-icon {
  animation: fissionIconTremble 0.15s ease-in-out infinite alternate;
}

@keyframes fissionWarningPulse {
  0% {
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
    border-color: rgba(245, 158, 11, 0.5);
  }
  100% {
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.65), 0 0 20px rgba(236, 72, 153, 0.3);
    border-color: rgba(245, 158, 11, 0.9);
  }
}

@keyframes fissionImminentPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    border-color: rgba(239, 68, 68, 0.7);
  }
  100% {
    transform: scale(1.05);
    box-shadow: 0 0 18px rgba(255, 0, 85, 0.9), 0 0 26px rgba(255, 215, 0, 0.5);
    border-color: #ff0055;
  }
}

@keyframes fissionIconPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.2) rotate(15deg); }
}

@keyframes fissionIconTremble {
  0% { transform: translate(-1px, 1px) rotate(-8deg); }
  100% { transform: translate(1px, -1px) rotate(8deg); }
}

@media (max-width: 420px) {
  .breaker-banner {
    padding: 6px 10px;
    gap: 6px;
  }
  .breaker-banner-title {
    display: none;
  }
  .big-bang-box {
    padding: 2px 8px;
    font-size: 0.7rem;
    gap: 4px;
  }
  .big-bang-label {
    display: none;
  }
}

/* Game Board Container */
.board-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--board-bg);
  border-radius: 18px;
  border: 2px solid rgba(99, 102, 241, 0.35);
  padding: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.2);
  touch-action: none;
}

#particleCanvas,
#replayParticleCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  border-radius: 18px;
}

.board-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.grid-background {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  grid-template-rows: repeat(var(--grid-size), 1fr);
  gap: 8px;
  width: 100%;
  height: 100%;
}

.grid-cell-bg {
  background: var(--cell-bg);
  border-radius: 12px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.4);
}

/* Tiles Container & Tiles */
.tile-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tile {
  position: absolute;
  top: 0;
  left: 0;
  padding: 4px;
  transition: transform 0.12s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

.tile-inner {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* BREAKER TILES: HIGH CONTRAST (2, 4, 8, 16) */
.tile-breaker .tile-inner {
  border: 2px solid #ffffff;
}

.tile-breaker .breaker-label {
  font-size: 0.55rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
  opacity: 0.9;
}

.tile-breaker .tile-number {
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
}

/* Breaker 2: Vivid Crimson / Hot Coral */
.tile-breaker.val-2 .tile-inner {
  background: linear-gradient(135deg, #ff1744 0%, #ff5252 100%);
  color: #ffffff;
  border-color: #ffebee;
  box-shadow: 0 0 16px rgba(255, 23, 68, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Breaker 4: Laser Gold / Intense Yellow */
.tile-breaker.val-4 .tile-inner {
  background: linear-gradient(135deg, #ffea00 0%, #ffd600 100%);
  color: #000000;
  border-color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 234, 0, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.6);
}

/* Breaker 8: Electric Neon Cyan */
.tile-breaker.val-8 .tile-inner {
  background: linear-gradient(135deg, #00f0ff 0%, #00b0ff 100%);
  color: #000000;
  border-color: #ffffff;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.6);
}

/* Breaker 16: Radiant Neon Lime */
.tile-breaker.val-16 .tile-inner {
  background: linear-gradient(135deg, #00ff66 0%, #00e676 100%);
  color: #000000;
  border-color: #ffffff;
  box-shadow: 0 0 18px rgba(0, 255, 102, 0.8), inset 0 0 10px rgba(255, 255, 255, 0.6);
}

/* TARGET TILES: Rich Cosmic Gradients */
.tile-target .tile-inner {
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tile-target .target-badge {
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.tile-target .tile-number {
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.5px;
}

/* 65536 Target (The Master Tile) */
.tile-target.val-65536 .tile-inner {
  background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 50%, #2563eb 100%);
  border: 2px solid #c084fc;
  color: #ffffff;
  animation: targetPulse 2.5s infinite ease-in-out;
}
.tile-target.val-65536 .tile-number {
  font-size: 1.3rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 12px rgba(192, 132, 252, 0.8);
}

.tile-target.val-32768 .tile-inner {
  background: linear-gradient(135deg, #9333ea 0%, #c026d3 100%);
  color: #ffffff;
  border: 2px solid #e879f9;
  box-shadow: 0 0 14px rgba(192, 38, 211, 0.5);
}
.tile-target.val-32768 .tile-number { font-size: 1.3rem; }

.tile-target.val-16384 .tile-inner {
  background: linear-gradient(135deg, #c026d3 0%, #e11d48 100%);
  color: #ffffff;
  border: 2px solid #f43f5e;
  box-shadow: 0 0 14px rgba(225, 29, 72, 0.5);
}
.tile-target.val-16384 .tile-number { font-size: 1.3rem; }

.tile-target.val-8192 .tile-inner {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #ffffff;
  border: 1px solid #60a5fa;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.5);
}
.tile-target.val-8192 .tile-number { font-size: 1.45rem; }

.tile-target.val-4096 .tile-inner {
  background: linear-gradient(135deg, #1d4ed8 0%, #0284c7 100%);
  color: #ffffff;
  border: 1px solid #38bdf8;
}
.tile-target.val-4096 .tile-number { font-size: 1.45rem; }

.tile-target.val-2048 .tile-inner {
  background: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
  color: #ffffff;
  border: 1px solid #2dd4bf;
}
.tile-target.val-2048 .tile-number { font-size: 1.45rem; }

.tile-target.val-1024 .tile-inner {
  background: linear-gradient(135deg, #0d9488 0%, #059669 100%);
  color: #ffffff;
}
.tile-target.val-1024 .tile-number { font-size: 1.45rem; }

.tile-target.val-512 .tile-inner {
  background: linear-gradient(135deg, #059669 0%, #16a34a 100%);
  color: #ffffff;
}
.tile-target.val-512 .tile-number { font-size: 1.6rem; }

.tile-target.val-256 .tile-inner {
  background: linear-gradient(135deg, #ca8a04 0%, #d97706 100%);
  color: #ffffff;
}
.tile-target.val-256 .tile-number { font-size: 1.6rem; }

.tile-target.val-128 .tile-inner {
  background: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
  color: #ffffff;
}
.tile-target.val-128 .tile-number { font-size: 1.6rem; }

.tile-target.val-64 .tile-inner {
  background: linear-gradient(135deg, #ea580c 0%, #dc2626 100%);
  color: #ffffff;
}
.tile-target.val-64 .tile-number { font-size: 1.7rem; }

.tile-target.val-32 .tile-inner {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: #ffffff;
}
.tile-target.val-32 .tile-number { font-size: 1.7rem; }

/* Responsive font scaling for various board grid sizes */
[style*="--grid-size: 5"] .tile-target .tile-number { font-size: 1.12rem; }
[style*="--grid-size: 5"] .tile-breaker .tile-number { font-size: 1.45rem; }

[style*="--grid-size: 6"] .tile-target .tile-number { font-size: 0.88rem; }
[style*="--grid-size: 6"] .tile-breaker .tile-number { font-size: 1.25rem; }
[style*="--grid-size: 6"] .tile-target .target-badge { font-size: 0.42rem; }
[style*="--grid-size: 6"] .tile-breaker .breaker-label { font-size: 0.44rem; }
[style*="--grid-size: 6"] .grid-background { gap: 6px; }
[style*="--grid-size: 6"] .tile { padding: 3px; }

[style*="--grid-size: 7"] .tile-target .tile-number { font-size: 0.72rem; }
[style*="--grid-size: 7"] .tile-breaker .tile-number { font-size: 1.05rem; }
[style*="--grid-size: 7"] .tile-target .target-badge,
[style*="--grid-size: 7"] .tile-breaker .breaker-label { display: none; }
[style*="--grid-size: 7"] .grid-background { gap: 4px; }
[style*="--grid-size: 7"] .tile { padding: 2px; }

[style*="--grid-size: 8"] .tile-target .tile-number { font-size: 0.64rem; font-weight: 800; letter-spacing: -0.3px; }
[style*="--grid-size: 8"] .tile-breaker .tile-number { font-size: 0.95rem; font-weight: 900; }
[style*="--grid-size: 8"] .tile-target .target-badge,
[style*="--grid-size: 8"] .tile-breaker .breaker-label { display: none; }
[style*="--grid-size: 8"] .grid-background { gap: 4px; }
[style*="--grid-size: 8"] .tile { padding: 2px; }
[style*="--grid-size: 8"] .tile-inner { border-radius: 8px; }
[style*="--grid-size: 8"] .grid-cell-bg { border-radius: 8px; }

/* Controls Bar */
.controls-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  padding: 10px 6px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: rgba(99, 102, 241, 0.3);
  border-color: rgba(99, 102, 241, 0.6);
  transform: translateY(-2px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-color: #818cf8;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: #fbbf24;
  color: #000000;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.btn-warning:hover:not(:disabled) {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.btn-warning.hammer-active {
  animation: targetPulse 1s infinite alternate;
  border-color: #ffffff;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.9);
}

/* Warp Breaker Button */
.btn-warp {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  border-color: #22d3ee;
  color: #000000;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.btn-warp:hover:not(:disabled) {
  background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%);
}

.btn-warp.warp-active {
  animation: targetPulse 1s infinite alternate;
  border-color: #ffffff;
  box-shadow: 0 0 18px rgba(6, 182, 212, 0.9);
}

/* Targeting Banners */
.hammer-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  background: #f59e0b;
  color: #000000;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
  z-index: 200;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.warp-banner {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  background: #06b6d4;
  color: #000000;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
  z-index: 200;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* Hammer Smash & Immune Indicators */
.hammer-smash-indicator,
.hammer-immune-indicator {
  display: none;
}

/* Hammer Targeting Active States */
body.hammer-targeting .tile {
  pointer-events: auto !important;
}

/* Eligible smashable tiles: vivid golden glow, border, and badge */
body.hammer-targeting .tile-smashable .tile-inner {
  border: 3px solid #ffd600 !important;
  box-shadow: 0 0 22px rgba(255, 214, 0, 0.95), inset 0 0 12px rgba(255, 214, 0, 0.5) !important;
  animation: smashGlowPulse 1.1s infinite alternate ease-in-out !important;
  cursor: crosshair;
}

body.hammer-targeting .tile-smashable .hammer-smash-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 3px;
  right: 3px;
  background: #ffd600;
  color: #000000;
  font-size: 0.58rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.5px;
  animation: smashBadgeBounce 0.8s infinite alternate ease-in-out;
  z-index: 20;
  pointer-events: none;
}

body.hammer-targeting .tile-smashable:hover .tile-inner {
  filter: brightness(1.4);
  border-color: #ffffff !important;
  box-shadow: 0 0 30px rgba(255, 214, 0, 1), inset 0 0 16px rgba(255, 214, 0, 0.8) !important;
}

/* Ineligible / Immune tiles (> 256): dimmed and shielded */
body.hammer-targeting .tile-immune .tile-inner {
  opacity: 0.25 !important;
  filter: grayscale(0.9) brightness(0.5) !important;
  border: 1px dashed rgba(255, 255, 255, 0.2) !important;
  box-shadow: none !important;
  cursor: not-allowed;
}

body.hammer-targeting .tile-immune .hammer-immune-indicator {
  display: block;
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 0.7rem;
  opacity: 0.8;
  pointer-events: none;
}

body.hammer-targeting .tile-breaker .tile-inner {
  opacity: 0.25 !important;
  filter: grayscale(0.8) brightness(0.6) !important;
  cursor: not-allowed;
}

.hammer-banner-warning {
  background: #dc2626 !important;
  color: #ffffff !important;
}

/* Mobile Toast Notification */
.game-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.6);
  color: #f8fafc;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.8), 0 0 18px rgba(99, 102, 241, 0.4);
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(12px);
  white-space: nowrap;
}

.game-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Warp Targeting States */
body.warp-targeting .grid-cell-bg {
  cursor: pointer;
  border: 1.5px dashed rgba(6, 182, 212, 0.7);
  background: rgba(6, 182, 212, 0.1);
  transition: all 0.15s ease;
  z-index: 10;
}

body.warp-targeting .grid-cell-bg:hover {
  background: rgba(6, 182, 212, 0.4);
  border-color: #22d3ee;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.8);
  transform: scale(1.05);
}

body.warp-targeting .tile {
  cursor: not-allowed;
  opacity: 0.55;
  pointer-events: none;
}

.stat-card.level {
  border-color: rgba(16, 185, 129, 0.5);
}

.stat-card.level .stat-value {
  color: #34d399;
}

/* Virtual D-Pad (Optional for touch/accessibility) */
.dpad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.dpad-middle {
  display: flex;
  gap: 36px;
}

.dpad-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-primary);
  width: 48px;
  height: 44px;
  border-radius: 10px;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: rgba(99, 102, 241, 0.4);
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal.active {
  display: flex;
  animation: modalBackdropFade 0.25s ease-out forwards;
}

.modal-content {
  background: #1e293b;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.8), 0 0 24px rgba(99, 102, 241, 0.3);
  animation: modalContentZoom 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  max-height: 88vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
}

.modal-body {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rule-highlight {
  background: rgba(15, 23, 42, 0.6);
  border-left: 4px solid var(--accent-gold);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  color: #f1f5f9;
}

.breaker-legend-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.form-select {
  background: #0f172a;
  border: 1px solid var(--border-card);
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

/* Win / Loss Specific Modal Themes */
.modal-win .modal-content {
  border-color: #ffd600;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 35px rgba(255, 214, 0, 0.4);
  text-align: center;
}

.modal-win .modal-title {
  color: #ffd600;
  font-size: 1.8rem;
}

.modal-gameover .modal-content {
  border-color: #ef4444;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 35px rgba(239, 68, 68, 0.4);
  text-align: center;
}

.modal-gameover .modal-title {
  color: #ef4444;
  font-size: 1.8rem;
}

/* PWA Install Banner */
.install-banner {
  display: none;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.9) 0%, rgba(139, 92, 246, 0.9) 100%);
  border-radius: 12px;
  padding: 10px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.install-banner.show {
  display: flex;
}

.install-banner-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffffff;
}

.install-banner-btn {
  background: #ffffff;
  color: #4f46e5;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.install-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1.2rem;
  cursor: pointer;
}

/* Update Available variant */
.install-banner.update-available {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95) 0%, rgba(6, 182, 212, 0.95) 100%);
  border: 1px solid rgba(52, 211, 153, 0.6);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.45);
  animation: pulseUpdateGlow 2s infinite alternate ease-in-out;
}

.install-banner.update-available .install-banner-btn {
  background: #ffffff;
  color: #047857;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes pulseUpdateGlow {
  0% { box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35); }
  100% { box-shadow: 0 8px 26px rgba(6, 182, 212, 0.7); }
}

/* First-Time Onboarding Tutorial Card */
.tutorial-banner {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96) 0%, rgba(24, 24, 60, 0.98) 100%);
  border: 1.5px solid rgba(139, 92, 246, 0.6);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(139, 92, 246, 0.25);
  animation: slideDownTutorial 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f8fafc;
  margin-bottom: 2px;
}

@keyframes slideDownTutorial {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tutorial-step {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.tutorial-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(139, 92, 246, 0.3);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.4);
  padding: 2px 8px;
  border-radius: 9999px;
}

.tutorial-badge-success {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
}

.tutorial-skip-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
}

.tutorial-skip-btn:hover {
  color: #ffffff;
}

.tutorial-heading {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
}

.tutorial-text {
  font-size: 0.84rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.tutorial-text strong {
  color: #38bdf8;
}

.tutorial-swipe-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #a5b4fc;
  font-weight: 600;
  margin-top: 2px;
}

.swipe-hand-icon {
  font-size: 1.1rem;
  animation: swipeMotion 1.4s infinite ease-in-out;
  display: inline-block;
}

@keyframes swipeMotion {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-4px, -4px); }
}

.tutorial-done-btn {
  margin-top: 6px;
  align-self: flex-start;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transition: transform 0.15s ease;
}

.tutorial-done-btn:active {
  transform: scale(0.97);
}

/* Spotlight pulse on active breaker during tutorial */
.tutorial-active .tile-breaker {
  animation: breakerSpotlightPulse 1.2s infinite alternate ease-in-out !important;
  z-index: 10;
}

@keyframes breakerSpotlightPulse {
  0% {
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.7), inset 0 0 8px rgba(255, 255, 255, 0.5);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.95), 0 0 35px rgba(255, 214, 0, 0.6), inset 0 0 14px rgba(255, 255, 255, 0.8);
    transform: scale(1.08);
  }
}

/* Responsive tuning */
@media (max-width: 400px) {
  .title-area h1 { font-size: 1.65rem; }
  .stat-value { font-size: 0.95rem; }
  .board-wrapper { padding: 8px; }
  .btn { padding: 8px 12px; font-size: 0.82rem; }
}

/* ==========================================================
   TRAJECTORY & COLLISION PREVIEW STYLES
   ========================================================== */

.trajectory-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
  overflow: visible;
}

.trajectory-laser-glow {
  stroke-linecap: round;
  filter: drop-shadow(0 0 1.5px currentColor);
}

.trajectory-laser-core {
  stroke-linecap: round;
  filter: drop-shadow(0 0 1.2px rgba(255, 255, 255, 0.9));
  animation: laserCoreFlow 0.8s linear infinite;
}

.trajectory-emitter-pulse {
  animation: emitterPulse 1s infinite alternate ease-in-out;
  filter: drop-shadow(0 0 2px #ffffff);
}

.trajectory-target-ring {
  animation: targetRingPulse 0.9s infinite alternate ease-in-out;
  filter: drop-shadow(0 0 2.5px currentColor);
}

.tile-target-locked {
  z-index: 30 !important;
}

.tile-target-locked .tile-inner {
  outline: 2px solid var(--target-lock-color, #00f0ff) !important;
  outline-offset: 1px !important;
  animation: targetLockedPulse 0.9s infinite alternate ease-in-out !important;
}

.tile-target-secondary {
  z-index: 28 !important;
}

.tile-target-secondary .tile-inner {
  outline: 1.5px dashed var(--secondary-target-color, #00f0ff) !important;
  outline-offset: 1px !important;
  opacity: 0.92;
}

.collision-preview-badge {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid var(--target-lock-color, #00ff66);
  border-radius: 8px;
  padding: 2.5px 8px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.85), 0 0 10px var(--target-lock-color, rgba(0, 255, 102, 0.45));
  pointer-events: none;
  z-index: 40;
  animation: badgePopIn 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  text-align: center;
}

.collision-preview-badge.badge-tier-green {
  border-color: #00ff66;
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.96), rgba(15, 23, 42, 0.96));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8), 0 0 12px rgba(0, 255, 102, 0.6);
}

.collision-preview-badge.badge-tier-green .badge-equation {
  color: #00ff66;
}

.collision-preview-badge.badge-tier-amber {
  border-color: #ffb300;
  background: linear-gradient(135deg, rgba(69, 39, 4, 0.96), rgba(15, 23, 42, 0.96));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8), 0 0 12px rgba(255, 179, 0, 0.55);
}

.collision-preview-badge.badge-tier-amber .badge-equation {
  color: #ffd600;
}

.collision-preview-badge.badge-tier-red {
  border-color: #ff1744;
  background: linear-gradient(135deg, rgba(88, 10, 25, 0.96), rgba(15, 23, 42, 0.96));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.8), 0 0 14px rgba(255, 23, 68, 0.65);
}

.collision-preview-badge.badge-tier-red .badge-equation {
  color: #ff5252;
}

.badge-equation {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.25px;
}

/* 50% Transparent Ghost Preview Outcome Tiles */
.ghost-preview-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 35;
}

.ghost-preview-tile {
  position: absolute;
  top: 0;
  left: 0;
  padding: 4px;
  box-sizing: border-box;
  pointer-events: none;
  opacity: 0.28;
  animation: ghostFadeIn 0.15s ease-out forwards;
}

[style*="--grid-size: 6"] .ghost-preview-tile { padding: 3px; }
[style*="--grid-size: 7"] .ghost-preview-tile { padding: 2px; }
[style*="--grid-size: 8"] .ghost-preview-tile { padding: 2px; }

.ghost-preview-tile .ghost-inner {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  box-sizing: border-box;
  position: relative;
  background: rgba(30, 41, 59, 0.5);
  border: 1.5px dashed rgba(255, 255, 255, 0.45);
}

[style*="--grid-size: 7"] .ghost-preview-tile .ghost-inner { border-radius: 8px; }
[style*="--grid-size: 8"] .ghost-preview-tile .ghost-inner { border-radius: 6px; }

.ghost-preview-tile.ghost-new-piece .ghost-inner {
  border: 2px dashed #00ff66;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.4), inset 0 0 6px rgba(0, 255, 102, 0.15);
  background: rgba(6, 78, 59, 0.5);
  animation: ghostPulse 1s infinite alternate ease-in-out;
}

.ghost-preview-tile.ghost-new-piece[style*="--preview-tier: amber"] .ghost-inner {
  border-color: #ffd600;
  box-shadow: 0 0 10px rgba(255, 214, 0, 0.4), inset 0 0 6px rgba(255, 214, 0, 0.15);
  background: rgba(69, 39, 4, 0.5);
}

.ghost-preview-tile.ghost-new-piece[style*="--preview-tier: red"] .ghost-inner {
  border-color: #ff1744;
  box-shadow: 0 0 10px rgba(255, 23, 68, 0.5), inset 0 0 6px rgba(255, 23, 68, 0.2);
  background: rgba(88, 10, 25, 0.55);
}

.ghost-preview-tile .ghost-tag {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.4px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  padding: 0 4px;
  border-radius: 3px;
}

.ghost-preview-tile .ghost-dir-badge {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.65rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.ghost-preview-tile .tile-number {
  font-size: 1.05rem;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  line-height: 1;
}

[style*="--grid-size: 7"] .ghost-preview-tile .tile-number { font-size: 0.82rem; }
[style*="--grid-size: 8"] .ghost-preview-tile .tile-number { font-size: 0.76rem; }

.ghost-preview-tile[class*="val-1024"] .tile-number,
.ghost-preview-tile[class*="val-2048"] .tile-number,
.ghost-preview-tile[class*="val-4096"] .tile-number,
.ghost-preview-tile[class*="val-8192"] .tile-number {
  font-size: 0.72rem;
}
.ghost-preview-tile[class*="val-16384"] .tile-number,
.ghost-preview-tile[class*="val-32768"] .tile-number {
  font-size: 0.62rem;
}

.ghost-preview-tile.ghost-displaced-piece .ghost-inner {
  border: 2px dashed #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.4), inset 0 0 6px rgba(0, 229, 255, 0.15);
  background: rgba(8, 47, 73, 0.5);
  animation: ghostPulse 1s infinite alternate ease-in-out;
}

/* Dim original position of displaced tiles during move preview */
.tile.tile-displaced-origin .tile-inner {
  opacity: 0.22 !important;
  filter: grayscale(0.6) !important;
}

/* Tile marked for guaranteed elimination blinks */
.tile.tile-elimination-blink .tile-inner {
  animation: eliminationTileBlink 0.8s infinite ease-in-out !important;
  border: 3px solid #00ff66 !important;
  box-shadow: 0 0 22px rgba(0, 255, 102, 0.95), inset 0 0 12px rgba(0, 255, 102, 0.5) !important;
}

/* Alternating before/after flip for dividing target tile and breaker tile when pieces land on them */
.tile.tile-target-dividing .tile-inner,
.tile.tile-breaker-dividing .tile-inner {
  animation: fissionBeforeFlip 1.6s infinite ease-in-out !important;
  outline: none !important;
}

.tile.tile-target-dividing .tile-inner {
  border: 3px solid var(--target-lock-color, #ffd600) !important;
}

.tile.tile-breaker-dividing .tile-inner {
  border: 2.5px solid var(--target-lock-color, #ffd600) !important;
  box-shadow: 0 0 20px var(--target-lock-color, #ffd600), inset 0 0 10px rgba(255, 255, 255, 0.6) !important;
}

.tile.tile-target-dividing .tile-fission-preview,
.tile.tile-breaker-dividing .tile-fission-preview {
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.96);
  border: 2.5px dashed var(--target-lock-color, #ffd600);
  box-shadow: 0 0 16px var(--target-lock-color, #ffd600), inset 0 0 8px var(--target-lock-color, #ffd600);
  animation: fissionAfterFlip 1.6s infinite ease-in-out;
}

[style*="--grid-size: 6"] .tile.tile-target-dividing .tile-fission-preview,
[style*="--grid-size: 6"] .tile.tile-breaker-dividing .tile-fission-preview {
  top: 3px; left: 3px; right: 3px; bottom: 3px;
  border-radius: 10px;
}
[style*="--grid-size: 7"] .tile.tile-target-dividing .tile-fission-preview,
[style*="--grid-size: 7"] .tile.tile-breaker-dividing .tile-fission-preview {
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  border-radius: 8px;
}
[style*="--grid-size: 8"] .tile.tile-target-dividing .tile-fission-preview,
[style*="--grid-size: 8"] .tile.tile-breaker-dividing .tile-fission-preview {
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  border-radius: 6px;
}

.tile-fission-preview .ghost-dir-badge {
  font-size: 0.78rem;
  line-height: 1;
  color: var(--target-lock-color, #ffd600);
  margin-bottom: 2px;
  font-weight: 800;
}

.tile-fission-preview .tile-number {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: #ffffff;
}

[style*="--grid-size: 5"] .tile-fission-preview .tile-number { font-size: 1.12rem; }
[style*="--grid-size: 6"] .tile-fission-preview .tile-number { font-size: 0.88rem; }
[style*="--grid-size: 7"] .tile-fission-preview .tile-number { font-size: 0.72rem; }
[style*="--grid-size: 8"] .tile-fission-preview .tile-number { font-size: 0.64rem; }

/* Directional Trajectory Compass HUD */
.trajectory-compass {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 12px;
  padding: 6px 10px;
  backdrop-filter: blur(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.compass-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.compass-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.compass-hint {
  font-size: 0.64rem;
  color: #64748b;
  font-weight: 500;
}

.compass-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.compass-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 3px 5px;
  cursor: pointer;
  color: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
  transition: all 0.15s ease;
  min-height: 32px;
  user-select: none;
}

.compass-chip:hover,
.compass-chip.chip-active {
  background: rgba(99, 102, 241, 0.35);
  border-color: #818cf8;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.45);
}

.compass-chip .chip-dir {
  font-size: 0.72rem;
  opacity: 0.85;
}

.compass-chip .chip-outcome {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.compass-chip .chip-action {
  white-space: nowrap;
}

.compass-chip .chip-occ {
  font-size: 0.58rem;
  opacity: 0.8;
  font-weight: 600;
}

.compass-chip.chip-tier-green {
  border-color: rgba(0, 255, 102, 0.7);
  background: rgba(6, 78, 59, 0.45);
  color: #00ff66;
}

.compass-chip.chip-tier-amber {
  border-color: rgba(255, 179, 0, 0.7);
  background: rgba(69, 39, 4, 0.45);
  color: #ffd600;
}

.compass-chip.chip-tier-red {
  border-color: rgba(255, 23, 68, 0.75);
  background: rgba(88, 10, 25, 0.5);
  color: #ff5252;
}

.compass-chip.chip-wall {
  opacity: 0.6;
  color: #94a3b8;
}

.compass-chip.chip-disabled {
  opacity: 0.35;
  cursor: default;
}

/* User Settings Toggles */
.hide-trajectory-preview .trajectory-overlay,
.hide-trajectory-preview .tile-target-locked,
.hide-trajectory-preview .tile-target-secondary,
.hide-trajectory-preview .collision-preview-badge,
.hide-trajectory-preview .ghost-preview-container {
  display: none !important;
}

.hide-trajectory-compass {
  display: none !important;
}

/* Replay Modal Styling */
.modal-replay .replay-modal-content {
  max-width: 480px;
  width: 96vw;
  padding: 18px 16px;
  background: #0f172a;
  border: 1px solid rgba(0, 240, 255, 0.4);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.9), 0 0 28px rgba(0, 240, 255, 0.25);
  display: flex;
  flex-direction: column;
  max-height: 94vh;
  overflow-y: auto;
}

.replay-header {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.replay-title-area {
  display: flex;
  flex-direction: column;
}

.replay-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 2px;
}

.replay-board-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 380px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  background: var(--bg-board, #0a0f1d);
}

.replay-action-banner {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  padding: 6px 12px;
  margin: 10px 0 6px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: #f8fafc;
  font-weight: 700;
  min-height: 32px;
}

.replay-score-delta {
  color: #ffd600;
  font-weight: 800;
  font-size: 0.85rem;
}

.replay-scrubber-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px 0;
}

.replay-time, .replay-step {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 700;
  min-width: 42px;
}

.replay-step {
  text-align: right;
  min-width: 48px;
}

.replay-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.replay-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00f0ff;
  box-shadow: 0 0 10px #00f0ff;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.replay-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.replay-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00f0ff;
  box-shadow: 0 0 10px #00f0ff;
  border: none;
  cursor: pointer;
}

.replay-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.replay-transport-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.replay-ctrl-btn {
  padding: 6px 10px;
  font-size: 0.95rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.replay-play-btn {
  min-width: 84px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 0.9rem;
  border-radius: 8px;
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  border-color: #22d3ee;
  color: #000;
}

.replay-speed-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.speed-label {
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 700;
  margin-right: 2px;
}

.speed-chip {
  padding: 3px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.12s ease;
}

.speed-chip:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.speed-chip.speed-active {
  background: rgba(0, 240, 255, 0.2);
  border-color: #00f0ff;
  color: #00f0ff;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

.replay-file-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.replay-file-actions .btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.replay-file-actions .btn:hover {
  background: rgba(99, 102, 241, 0.3);
  border-color: #818cf8;
}


