/* CSS Variables */
:root {
  --primary: #f48c25;
  --accent: #ff4d00;
  --background-dark: #0a0a0c;
  --surface-dark: #16161a;
}

/* Material Symbols Default */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-size: 24px;
  font-variation-settings: 'FILL' 0, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

.fill-icon {
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 24;
}

/* Safe Area Insets for Mobile */
:root {
  --nav-bar-offset: 0px; /* Set dynamically by JS for Android nav bar */
  --banner-height: 0px;  /* Set dynamically by JS when AdMob banner is visible */
  
  /* 
     Composite bottom offset. 
     On iOS, the banner usually overlaps the safe area at the bottom.
     We use the maximum of the safe-area and any system-detected offset (Android),
     then add the banner height on top.
  */
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-system-offset: max(var(--safe-area-bottom), var(--nav-bar-offset));
  
  --bottom-ui-offset: calc(var(--banner-height) + var(--bottom-system-offset));
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overflow: hidden;
  touch-action: none;
}

/* Bottom Navigation: sits above the banner + safe area + Android nav bar */
#bottom-nav {
  bottom: var(--bottom-ui-offset);
  padding-bottom: 0.75rem;
}

/* Game action buttons: leave enough room so the last button clears the nav */
#gameActions {
  /* Reserve space for the bottom-nav height (~56px) + banner + safe area */
  padding-bottom: calc(4.5rem + var(--bottom-ui-offset));
}

/* Custom Template Utilities */
.tab-active {
  background: linear-gradient(135deg, #f48c25 0%, #ff4d00 100%);
  color: white !important;
  box-shadow: 0 4px 15px rgba(244, 140, 37, 0.3);
}

.glass-panel {
  background: rgba(22, 22, 26, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.hero-gradient {
  background: radial-gradient(circle at center, rgba(244, 140, 37, 0.15) 0%, transparent 70%);
}

.glow-orange {
  box-shadow: 0 0 15px rgba(244, 140, 37, 0.4);
}

.glow-white {
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.ai-card-glow {
  box-shadow: 0 0 20px rgba(198, 106, 78, 0.2);
}

.active-tab-glow {
  box-shadow: 0 -4px 10px rgba(198, 106, 78, 0.4);
}

/* Board specific */
#board {
  user-select: none;
  position: relative;
}

.tile {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
}

.board-cell-light {
  background: rgba(255, 255, 255, 0.14);
  /* Brighter for more contrast */
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.board-cell-dark {
  background: rgba(0, 0, 0, 0.25);
  /* Darker for more contrast */
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.tile.highlight {
  background: rgba(244, 140, 37, 0.3) !important;
  box-shadow: inset 0 0 10px rgba(244, 140, 37, 0.5);
}

.tile.selected {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: rgba(244, 140, 37, 0.1) !important;
}

.tile.inactive {
  opacity: 0.1;
  cursor: default;
}

/* Simplified Last Move Highlights */
.tile.last-move-source {
  border: 1px dashed rgba(244, 140, 37, 0.3) !important;
}

.tile.last-move-target {
  border: 2px solid rgba(244, 140, 37, 0.4) !important;
  box-shadow: inset 0 0 10px rgba(244, 140, 37, 0.1);
}

.moving-piece {
  position: absolute !important;
  z-index: 100;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Piece Styles */
.piece {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  will-change: transform;
  position: relative;
}

.piece span {
  display: block;
  /* Icon slightly lifted with solid drop shadow */
  transform: translateY(-2px);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.15),
    0 2px 2px rgba(0, 0, 0, 0.2);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.piece-light {
  background: #f8fafc;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  /* Thin cylinder solid layers */
  box-shadow:
    0 1px 0 #94a3b8,
    0 2px 0 #64748b,
    0 3px 0 #475569,
    0 4px 6px rgba(0, 0, 0, 0.35);
}

.piece-dark {
  background: #f48c25;
  color: #ffffff;
  border: 1px solid #c86910;
  /* Thin cylinder solid layers */
  box-shadow:
    0 1px 0 #c86910,
    0 2px 0 #9e5008,
    0 3px 0 #7a3c04,
    0 4px 6px rgba(0, 0, 0, 0.35);
}

.piece:not(.shattering-piece):not(.shatter-sink):hover,
.tile.selected .piece:not(.shattering-piece):not(.shatter-sink) {
  transform: translateY(-2px);
}

.piece:hover span,
.tile.selected .piece span {
  /* Icon pops up more */
  transform: translateY(-4px) scale(1.1);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.15),
    0 4px 0 rgba(0, 0, 0, 0.1),
    0 6px 6px rgba(0, 0, 0, 0.3);
}

.piece-light:not(.shattering-piece):not(.shatter-sink):hover,
.tile.selected .piece-light:not(.shattering-piece):not(.shatter-sink) {
  border: 1px solid #e2e8f0;
  box-shadow:
    0 1px 0 #94a3b8,
    0 2px 0 #64748b,
    0 3px 0 #475569,
    0 4px 0 #334155,
    0 5px 0 #1e293b,
    0 7px 10px rgba(0, 0, 0, 0.4);
}

.piece-dark:not(.shattering-piece):not(.shatter-sink):hover,
.tile.selected .piece-dark:not(.shattering-piece):not(.shatter-sink) {
  border: 1px solid #e26910;
  box-shadow:
    0 1px 0 #c86910,
    0 2px 0 #9e5008,
    0 3px 0 #7a3c04,
    0 4px 0 #5c2d03,
    0 5px 0 #422002,
    0 7px 10px rgba(0, 0, 0, 0.4);
}

/* Active state (on click) */
.piece:not(.shattering-piece):not(.shatter-sink):active {
  transform: translateY(2px);
}

.piece:active span {
  transform: translateY(0) scale(0.95);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.piece-light:not(.shattering-piece):not(.shatter-sink):active {
  box-shadow:
    0 1px 0 #64748b,
    0 1px 3px rgba(0, 0, 0, 0.3);
}

.piece-dark:not(.shattering-piece):not(.shatter-sink):active {
  box-shadow:
    0 1px 0 #9e5008,
    0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Modern Custom Toggle Switch Styles */
.toggle-container {
  display: inline-block;
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-container input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.05);
  /* surface-dark opacity */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: #94a3b8;
  /* slate-400 */
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.toggle-slider {
  background-color: rgba(244, 140, 37, 0.2);
  /* primary light */
  border-color: rgba(244, 140, 37, 0.5);
}

input:checked+.toggle-slider:before {
  transform: translateX(20px);
  background-color: #f48c25;
  /* primary */
  box-shadow: 0 0 10px rgba(244, 140, 37, 0.5);
}

/* Utilities */
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Active Area Boundaries (Shrink effect) */
.tile.active-border-top {
  border-top: 2px solid #f48c25 !important;
}

.tile.active-border-bottom {
  border-bottom: 2px solid #f48c25 !important;
}

.tile.active-border-left {
  border-left: 2px solid #f48c25 !important;
}

.tile.active-border-right {
  border-right: 2px solid #f48c25 !important;
}

/* Apply glow to the whole active area if shrunk */
.tile:not(.inactive).active-border-top,
.tile:not(.inactive).active-border-bottom,
.tile:not(.inactive).active-border-left,
.tile:not(.inactive).active-border-right {
  box-shadow: inset 0 0 10px rgba(244, 140, 37, 0.1);
}

.shake-rumble {
  animation: shakerumble 1.0s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shakerumble {

  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translate3d(-1px, 0, 0);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translate3d(1px, 0, 0);
  }
}

.shatter-sink {
  animation: shattersink 1s forwards cubic-bezier(0.5, 0, 0.5, 1);
  pointer-events: none;
  z-index: 0;
}

@keyframes shattersink {
  0% {
    transform: translateZ(0);
    opacity: 1;
  }

  30% {
    transform: translateY(10px) rotateX(20deg);
    opacity: 0.8;
  }

  100% {
    transform: translateY(150px) rotateX(100deg);
    opacity: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Earthquake Shake Animation - More Dramatic */
@keyframes shake-intense {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  10% {
    transform: translate(-5px, -5px) rotate(-1deg);
  }

  20% {
    transform: translate(5px, 5px) rotate(1deg);
  }

  30% {
    transform: translate(-5px, 5px) rotate(-1deg);
  }

  40% {
    transform: translate(5px, -5px) rotate(1deg);
  }

  50% {
    transform: translate(-2px, -2px) rotate(0deg);
  }

  60% {
    transform: translate(2px, 2px) rotate(0deg);
  }

  70% {
    transform: translate(-2px, 2px) rotate(-0.5deg);
  }

  80% {
    transform: translate(2px, -2px) rotate(0.5deg);
  }

  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

.shake-earthquake {
  animation: shake-intense 1s cubic-bezier(.36, .07, .19, .97) both;
}

.hidden {
  display: none !important;
}

/* Firework Effect */
.firework-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 50;
  animation: explode 5s cubic-bezier(0.1, 0.7, 0.1, 1.0) forwards;
}

@keyframes explode {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

.glow-orange-particle {
  background-color: #f48c25;
  box-shadow: 0 0 10px #f48c25, 0 0 20px #f48c25;
}

.glow-white-particle {
  background-color: #ffffff;
  box-shadow: 0 0 10px #ffffff, 0 0 20px #ffffff;
}

/* Piece Capture Animations */
@keyframes piece-shake {

  0%,
  100% {
    transform: scale(1) translate(0, 0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: scale(1.1) translate(-2px, -2px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: scale(1.1) translate(2px, 2px);
  }
}

@keyframes shatter {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(0) rotate(360deg);
    opacity: 0;
  }
}

.shattering-piece {
  position: absolute;
  pointer-events: none;
  z-index: 100;
  animation: piece-shake 0.4s ease-in-out;
  will-change: transform;
}

.shatter-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 101;
  animation: shatter 0.8s cubic-bezier(0.1, 0.7, 0.1, 1.0) forwards;
  will-change: transform;
}

/* Push Impact Animations */
@keyframes board-bump {
  0% {
    transform: translateX(0) translateY(0);
  }

  30% {
    transform: translateX(calc(var(--bdx) * 10px)) translateY(calc(var(--bdy) * 10px));
  }

  100% {
    transform: translateX(0) translateY(0);
  }
}

.bump-board {
  animation: board-bump 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#turnStatusContainer {
  height: auto;
  min-height: 52px;
  overflow: hidden;
  transition: all 0.3s ease;
}

#turnTimerBar.warning {
  background: #ef4444 !important;
  /* Red */
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  animation: timer-pulse 1s ease-in-out infinite;
}

@keyframes timer-pulse {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
    filter: brightness(1.2);
  }
}

/* Emote Overlay */
#emoteTrayOverlay {
  transition: all 0.3s ease;
}

#emoteTrayOverlay:not(.hidden) {
  opacity: 1;
}

#emoteTrayOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#emoteTrayContent {
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#emoteTrayOverlay.hidden #emoteTrayContent {
  transform: scale(0.85) translateY(20px);
}

.emote-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.emote-btn:hover {
  background: rgba(244, 140, 37, 0.15);
  border-color: rgba(244, 140, 37, 0.3);
  transform: translateY(-2px);
}

.emote-btn:active {
  transform: scale(0.95);
}

/* Matchmaking Pref Tabs */
.match-pref-tab {
  cursor: pointer;
}

.match-pref-tab:not(.bg-primary):hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Fix emote popup contrast */
[id^="emotePopup"] {
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

[id^="emoteText"] {
  color: #ffffff !important;
  font-weight: 800;
}

@keyframes impact-flash {
  0% {
    transform: scale(0.5);
    opacity: 1;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.impact-ring {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 4px solid var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 90;
  animation: impact-flash 0.4s ease-out forwards;
}

/* Winner Text Animation */
@keyframes color-shift {

  0%,
  100% {
    color: white;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 255, 255, 0.4);
  }

  50% {
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary), 0 0 30px var(--primary);
  }
}

.winner-text {
  animation: color-shift 0.4s linear infinite;
  font-size: 1.25rem;
  font-weight: 900 !important;
  letter-spacing: 0.05em;
  filter: brightness(1.5);
  display: inline-block;
  max-width: 240px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  vertical-align: middle;
}

/* Start Game Effect */
@keyframes start-pop {
  0% {
    transform: scale(0.1) rotate(-45deg);
    opacity: 0;
  }

  50% {
    transform: scale(1.5) rotate(15deg);
    opacity: 1;
  }

  70% {
    transform: scale(1.2) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: scale(0) rotate(45deg);
    opacity: 0;
  }
}

.start-effect-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 200;
}

.start-effect-overlay span {
  animation: start-pop 1s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
  color: var(--primary);
  text-shadow: 0 0 40px var(--primary);
}

/* Premium Toast Styling */
.toast-premium {
  background: rgba(15, 15, 20, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(244, 140, 37, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(244, 140, 37, 0.1);
  border-left: 4px solid var(--primary);
  animation: toast-in 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
}

@keyframes toast-in {
  0% {
    transform: translateY(-100%) scale(0.9);
    opacity: 0;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes toast-out {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translateX(100%) scale(0.9);
    opacity: 0;
  }
}

.toast-exit {
  animation: toast-out 0.5s ease-in forwards;
}

.toast-glow-icon {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px rgba(244, 140, 37, 0.6));
}

/* Radar & Matchmaking Effects */
@keyframes spin-slow {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.animate-radar-spin {
  animation: spin-slow 3s linear infinite;
}

@keyframes radar-pulse {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }

  50% {
    transform: scale(1.1);
    opacity: 0.1;
  }

  100% {
    transform: scale(1);
    opacity: 0.3;
  }
}

.radar-circle {
  animation: radar-pulse 2s ease-in-out infinite;
}

/* Glass panel depth */
.glass-panel-deep {
  background: rgba(15, 15, 18, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Streak & Achievement Styles */
.animate-pulse-slow {
  animation: pulse-slow 3s ease-in-out infinite;
}

@keyframes pulse-slow {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.drop-shadow-glow {
  filter: drop-shadow(0 0 8px rgba(244, 140, 37, 0.6));
}

.streak-badge-pulse {
  animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.piece-icon-opt {
  cursor: pointer;
  border-width: 2px;
}

.piece-icon-opt:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.piece-icon-opt.active {
  background: rgba(244, 140, 37, 0.2);
  border-color: rgba(244, 140, 37, 0.4);
  opacity: 1 !important;
}

.piece-icon-opt.active span {
  color: white !important;
}

#streakBadge:not(.hidden) {
  display: flex !important;
  animation: badge-pulse 2s infinite;
}

/* Page transitions */
.page-view {
  animation: fadeIn 0.4s ease-out forwards;
}

/* Leaderboard Specific Fixes */
#page-leaderboard header {
  position: sticky;
  top: 0;
  background: var(--background-dark);
  z-index: 10;
  padding-bottom: 1rem;
}

/* Modifiers Visuals */
#shieldValue, #bonusValue {
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}


/* Shatter & Sink Animation for Shrinking */
@keyframes shatterSink {
  0% {
    transform: translateY(0) scale(1) rotate(0);
    opacity: 1;
    filter: brightness(1);
  }

  25% {
    transform: translateY(2px) scale(0.98) rotate(1deg);
    filter: brightness(1.2);
  }

  100% {
    transform: translateY(100px) scale(0.5) rotate(15deg);
    opacity: 0;
    filter: contrast(0.5) brightness(0.5);
  }
}

.shatter-sink {
  animation: shatterSink 0.8s cubic-bezier(0.5, 0, 0.7, 0.4) forwards;
  pointer-events: none;
}

/* Animation utilities for JIT-like behavior if Tailwind is missing them */
.animate-ping-slow {
  animation: ping 3s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {

  75%,
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.rounded-3x-large {
  border-radius: 2.5rem;
}

/* ══════════════════════════════════════════════
   GUIDE & WELCOME SCREEN STYLES
   ══════════════════════════════════════════════ */

/* Overlay Base */
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 12, 0.98);
  backdrop-filter: blur(20px);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  transform: scale(1.02);
  overflow-y: auto;
  padding: 1rem;
}

.guide-overlay-visible {
  opacity: 1;
  transform: scale(1);
}

/* ─── Welcome Card ─── */
.guide-welcome-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: guideCardIn 0.8s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
}

@keyframes guideCardIn {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.guide-welcome-logo {
  margin-bottom: 1.5rem;
}

.guide-logo-ring {
  display: inline-flex;
  width: 80px;
  height: 80px;
  border-radius: 1.25rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  padding: 3px;
  box-shadow: 0 8px 32px rgba(244, 140, 37, 0.3);
  animation: guideLogoPulse 3s ease-in-out infinite;
}

@keyframes guideLogoPulse {

  0%,
  100% {
    box-shadow: 0 8px 32px rgba(244, 140, 37, 0.3);
  }

  50% {
    box-shadow: 0 8px 48px rgba(244, 140, 37, 0.5);
  }
}

.guide-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(1.25rem - 3px);
  background: var(--background-dark);
}

.guide-welcome-title {
  font-size: 2.5rem;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: -0.05em;
  color: white;
  margin-bottom: 0.25rem;
}

.guide-welcome-title span {
  color: var(--primary);
}

.guide-welcome-sub {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 2rem;
}

.guide-welcome-rules-img {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.guide-welcome-rules-img img {
  width: 100%;
  display: block;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.guide-welcome-rules-img:hover img {
  opacity: 1;
}

.guide-rules-overlay-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  transition: background 0.3s;
  cursor: pointer;
}

.guide-rules-overlay-btn:hover {
  background: rgba(0, 0, 0, 0.3);
}

.guide-rules-overlay-btn .material-symbols-outlined {
  color: var(--primary);
}

/* ─── Buttons ─── */
.guide-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 900;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(244, 140, 37, 0.3);
  transition: all 0.3s;
  margin-bottom: 0.75rem;
}

.guide-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(244, 140, 37, 0.4);
}

.guide-btn-primary:active {
  transform: scale(0.97);
}

.guide-btn-skip {
  background: none;
  border: none;
  color: #475569;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  cursor: pointer;
  padding: 0.75rem;
  transition: color 0.3s;
}

.guide-btn-skip:hover {
  color: #94a3b8;
}

.guide-btn-skip-small {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #64748b;
  font-weight: 800;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  transition: all 0.3s;
}

.guide-btn-skip-small:hover {
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
}

/* ─── Guide Container ─── */
.guide-container {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 1rem;
}

.guide-step-counter {
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--primary);
  background: rgba(244, 140, 37, 0.1);
  border: 1px solid rgba(244, 140, 37, 0.2);
  padding: 0.3rem 0.75rem;
  border-radius: 0.5rem;
}

.guide-sim-title {
  font-size: 1.25rem;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: white;
  margin-bottom: 0.25rem;
  text-align: center;
}

.guide-sim-desc {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 1rem;
  text-align: center;
  line-height: 1.5;
}

/* ─── Hint Bar ─── */
.guide-hint-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: rgba(244, 140, 37, 0.08);
  border: 1px solid rgba(244, 140, 37, 0.15);
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  animation: guideHintPulse 2s ease-in-out infinite;
}

@keyframes guideHintPulse {

  0%,
  100% {
    border-color: rgba(244, 140, 37, 0.15);
  }

  50% {
    border-color: rgba(244, 140, 37, 0.35);
  }
}

.guide-hint-icon {
  color: var(--primary);
  font-size: 20px;
  animation: guideHandTap 1.5s ease-in-out infinite;
}

@keyframes guideHandTap {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

#guideHintText {
  font-size: 0.75rem;
  font-weight: 700;
  color: #cbd5e1;
}

/* ─── Guide Board ─── */
.guide-board-wrapper {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1;
  margin-bottom: 1.25rem;
}

.guide-board {
  display: grid;
  gap: 3px;
  width: 100%;
  height: 100%;
  background: rgba(22, 22, 26, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  padding: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  transition: opacity 0.3s, transform 0.3s;
  user-select: none;
}

.guide-tile {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 4px;
  position: relative;
  z-index: 10;
}

.guide-piece {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
}

/* Piece appearance tokens */
.guide-piece-light {
  background: #f8fafc;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.guide-piece-dark {
  background: #f48c25;
  color: #ffffff;
  border: 1px solid #c86910;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.guide-pulse-target {
  position: relative;
}

.guide-pulse-target::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(244, 140, 37, 0.5);
  animation: guidePulse 1.5s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes guidePulse {
  0% { transform: scale(0.7); opacity: 0; }
  50% { opacity: 0.7; }
  100% { transform: scale(1.6); opacity: 0; }
}



.guide-piece span {
  font-size: 28px;
}



/* ─── Move Indicators ─── */
.guide-tile-valid {
  background: rgba(244, 140, 37, 0.2) !important;
  box-shadow: inset 0 0 10px rgba(244, 140, 37, 0.3) !important;
  border: 1px solid rgba(244, 140, 37, 0.4) !important;
}

.guide-path-highlight {
  position: relative;
}

.guide-path-highlight::before {
  content: "";
  position: absolute;
  inset: 5px;
  background: linear-gradient(to bottom, rgba(244, 140, 37, 0.6), rgba(244, 140, 37, 0.25));
  border-radius: 6px;
  z-index: 5;
  pointer-events: none;
  animation: guidePathPulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(244, 140, 37, 0.4);
}


@keyframes guidePathPulse {

  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.95);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ─── Hand Pointer ─── */

.guide-hand-pointer {
  position: absolute;
  z-index: 300;
  pointer-events: none;
  transition: left 0.5s cubic-bezier(0.4, 0, 0.2, 1), top 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  transform: translate(-50%, -50%);
}

.guide-hand-pointer .material-symbols-outlined {
  color: white;
  font-size: 32px;
  animation: guideHandBounce 1s ease-in-out infinite;
}

@keyframes guideHandBounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

/* ─── Restricted Cell (Red X) ─── */
.guide-tile.guide-restricted {
  background: rgba(239, 68, 68, 0.15) !important;
}

.guide-x-marker {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: guideXBlink 0.6s ease-in-out infinite;
}

.guide-x-marker .material-symbols-outlined {
  color: #ef4444;
  font-size: 28px;
  font-weight: 900;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

@keyframes guideXBlink {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.85);
  }
}

/* ─── Guide Arrow Highlights ─── */
[class*="guide-arrow-"] {
  position: relative;
}

[class*="guide-arrow-"]::after {
  content: "arrow_forward";
  font-family: 'Material Symbols Outlined';
  position: absolute;
  font-size: 32px;
  color: var(--primary);
  z-index: 100;
  animation: guideArrowPulse 1s ease-in-out infinite;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(244, 140, 37, 0.8);
}

.guide-arrow-right::after {
  right: -25px;
  top: 50%;
  transform: translateY(-50%);
}

.guide-arrow-left::after {
  left: -25px;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
}

.guide-arrow-up::after {
  top: -25px;
  left: 50%;
  transform: translateX(-50%) rotate(-90deg);
}

.guide-arrow-down::after {
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
}

@keyframes guideArrowPulse {

  0%,
  100% {
    opacity: 0.5;
    margin-right: 0;
    margin-left: 0;
    margin-top: 0;
    margin-bottom: 0;
  }

  50% {
    opacity: 1;
  }
}

.guide-arrow-right {
  animation: guideArrowRightFloat 1s ease-in-out infinite;
}

@keyframes guideArrowRightFloat {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(5px);
  }
}

/* ─── Tile Sink (Shrink) ─── */
.guide-tile-sink {
  animation: guideTileSink 0.8s cubic-bezier(0.5, 0, 0.7, 0.4) forwards;
  pointer-events: none;
}

@keyframes guideTileSink {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  30% {
    transform: translateY(4px) scale(0.97);
    opacity: 0.8;
  }

  100% {
    transform: translateY(60px) scale(0.5) rotateX(25deg);
    opacity: 0;
  }
}

/* ─── Collision Effects ─── */
.guide-impact-ring {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 200;
  animation: guideImpactFlash 0.5s ease-out forwards;
}

@keyframes guideImpactFlash {
  0% {
    transform: scale(0.3);
    opacity: 1;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.guide-collision-particle {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  pointer-events: none;
  z-index: 201;
  animation: guideParticleExplode 0.6s cubic-bezier(0.1, 0.7, 0.1, 1) forwards;
}

@keyframes guideParticleExplode {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

/* ─── Progress Dots ─── */
.guide-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 1.25rem;
}

.guide-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.4s;
}

.guide-dot-active {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(244, 140, 37, 0.5);
  transform: scale(1.3);
}

.guide-dot-done {
  background: rgba(244, 140, 37, 0.3);
  border-color: rgba(244, 140, 37, 0.4);
}

/* ─── Next Button ─── */
.guide-btn-next {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 900;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(244, 140, 37, 0.3);
  transition: all 0.3s;
  animation: guideNextPop 0.4s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
}

@keyframes guideNextPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.guide-btn-next:hover {
  transform: translateY(-2px);
}

.guide-btn-next:active {
  transform: scale(0.95);
}

/* ─── Final Board Message ─── */
.guide-final-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 1.5rem;
  font-weight: 950;
  text-transform: uppercase;
  z-index: 100;
  border-radius: 1rem;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  font-style: italic;
  text-shadow: 0 0 20px rgba(244, 140, 37, 0.5);
  text-align: center;
  padding: 20px;
}

.guide-final-message-visible {
  opacity: 1;
  transform: scale(1);
}

/* ─── Final actions below board ─── */
.guide-final-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.guide-btn-outline {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
  cursor: pointer;
  text-decoration: none;
}

.guide-btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
}