/* === RESET & BASE STYLES === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === CHECKPOINT ITEM STYLES (NEW) === */
.checkpoint-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--transition);
  margin: 0 8px;
}

.checkpoint-item .checkpoint-label {
  width: 42px;
  height: 42px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary);
  box-shadow: var(--shadow-md);
  margin-bottom: 0.5rem;
  border: 3px solid var(--primary);
  transition: all 0.3s ease;
}

.checkpoint-item.mark .checkpoint-label {
  background: var(--success);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(56, 176, 0, 0.5);
}

.checkpoint-item.active .checkpoint-label {
  transform: scale(1.2);
  box-shadow: 0 0 15px rgba(106, 17, 203, 0.6);
  border-color: var(--accent);
}

/* === MUSIC TOGGLE BUTTON === */
.music-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 18px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.music-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.music-btn:active {
  transform: scale(0.95);
}

.music-btn.off {
  opacity: 0.6;
  filter: grayscale(100%);
  text-decoration: line-through;
}

/* === START OVERLAY POPUP === */
#start-overlay .popup-content {
  text-align: center;
  animation: popup-fade-in 0.6s ease forwards;
}

#start-overlay h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(255,183,3,0.6);
}

#start-overlay p {
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
  color: var(--light);
  opacity: 0.9;
}

#start-overlay .primary-btn {
  font-size: 1.2rem;
  padding: 0.9rem 2rem;
  border-radius: 30px;
}

/* === ANIMATION FOR START POPUP === */
@keyframes popup-fade-in {
  0% { opacity: 0; transform: translateY(30px) scale(0.9); }
  50% { opacity: 0.7; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

:root {
  /* Colors */
  --primary: #6a11cb;
  --primary-light: #8e2de2;
  --secondary: #2575fc;
  --accent: #ffb703;
  --success: #38b000;
  --danger: #e63946;
  --warning: #ff9500;
  --dark: #222;
  --light: #f8f9fa;
  --background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  --card-bg: rgba(255, 255, 255, 0.1);
  
  /* Shadows & Effects */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.2);
  --glow: 0 0 10px rgba(106, 17, 203, 0.5);
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Game specific */
  --cell-size-desktop: 60px;
  --cell-size-tablet: 45px;
  --cell-size-mobile: 36px;
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --border-radius-sm: 8px;
}

body {
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  background: var(--background);
  color: var(--light);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.game-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
}

/* === HEADER STYLES === */
#game-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 1.5rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-lg);
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  overflow: hidden;
  position: relative;
}

#game-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255,255,255,0.1) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.1) 75%, transparent 75%, transparent);
  background-size: 20px 20px;
  opacity: 0.3;
  z-index: 0;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}

#game-header h1 {
  font-weight: 800;
  font-size: 28px;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-level {
  background: rgba(255,255,255,0.2);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  font-weight: bold;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  white-space: nowrap;
}

/* Level Journey Map */
.level-journey {
  margin: 1.5rem 0;
  padding: 0.5rem;
  position: relative;
  z-index: 1;
}

.journey-path {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 1rem 0;
}

.journey-path::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255,255,255,0.2);
  transform: translateY(-50%);
  border-radius: 3px;
  z-index: 0;
}

.path-segment {
  flex: 1;
  position: relative;
  z-index: 0;
}

.checkpoint {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--transition);
}

.checkpoint-marker {
  width: 40px;
  height: 40px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 2;
  margin-bottom: 0.5rem;
  border: 3px solid var(--primary);
}

.checkpoint[data-level="1"] .checkpoint-marker {
  background: linear-gradient(to bottom, #ffdd00, #fbb034);
  color: #333;
}

.checkpoint[data-level="2"] .checkpoint-marker {
  background: linear-gradient(to bottom, #bdc3c7, #8e9eab);
  color: #333;
}

.checkpoint[data-level="3"] .checkpoint-marker {
  background: linear-gradient(to bottom, #cd7f32, #a0522d);
  color: white;
}

.checkpoint-time {
  font-size: 0.85rem;
  background: rgba(255,255,255,0.15);
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
}

.checkpoint.active .checkpoint-marker {
  transform: scale(1.2);
  box-shadow: 0 0 0 5px rgba(255,255,255,0.3), var(--shadow-lg);
}

.checkpoint.completed .checkpoint-marker::after {
  content: '✓';
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--success);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.header-score {
  font-size: 1.25rem;
  font-weight: 500;
  background: rgba(255,255,255,0.15);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  display: inline-block;
  position: relative;
  z-index: 1;
  margin: 28px;
}

.header-score strong {
  color: var(--accent);
  text-shadow: 0 0 5px rgba(255,183,3,0.5);
}

/* Header Toggle Button */
.header-toggle-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  margin-top: -8px;
  margin-bottom: 16px;
  z-index: 10;
}

.toggle-btn {
  width: 48px;
  height: 24px;
  border: none;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  border-radius: 0 0 24px 24px;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.toggle-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.3);
}

.toggle-btn:hover {
  transform: translateY(2px);
}

.toggle-btn:active {
  transform: translateY(4px);
}

/* Collapsed Bar */
#collapsed-bar, .mp-player {
  background: rgba(30, 30, 60, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
  flex-wrap: nowrap;
  justify-content: space-between;
}

#collapsed-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.05) 75%, transparent 75%, transparent);
  background-size: 10px 10px;
  pointer-events: none;
}

.timer-wrapper {
  position: relative;
  min-width: 110px;
}

.timer {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  padding: 0.4rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-sm);
  position: relative;
  z-index: 1;
}

.timer i {
  color: var(--accent);
  animation: spin 2s linear infinite;
}

.time-bar-container {
  flex: 1;
  position: relative;
  z-index: 1;
}

.time-bar {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
}

.time-progress {
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, var(--accent), var(--warning));
  border-radius: 4px;
  transition: width 0.3s linear;
  position: relative;
  z-index: 1;
}

.opponents-bar {
  margin-top: 8px;
  background: rgba(40, 40, 80, 0.75);
}

#time-fire {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ff9500"><path d="M12 2c-5.33 4.55-8 8.48-8 11.8 0 4.98 3.8 8.2 8 8.2s8-3.22 8-8.2c0-3.32-2.67-7.25-8-11.8zM12 20c-3.35 0-6-2.57-6-6.2 0-2.34 1.95-5.44 6-9.14 4.05 3.7 6 6.79 6 9.14 0 3.63-2.65 6.2-6 6.2zM12 12c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg>');
  background-size: cover;
  background-position: center;
  filter: opacity(0.8) brightness(1.5);
  animation: flicker 0.5s ease-in-out infinite alternate;
  z-index: 2;
}

  .score-mini {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    padding: 0.4rem 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius-sm);
    position: relative;
    z-index: 1;
    animation: zoomBounce 0.4s ease;
  }

  @keyframes zoomBounce {
    0% {
      transform: scale(1);
    }
    50% {
      transform: scale(1.3);
    }
    70% {
      transform: scale(0.9);
    }
    100% {
      transform: scale(1);
    }
  }

.score-mini i {
  color: var(--accent);
  animation: bounceZoom 1s ease-in-out;
}

#score-plus {
  color: var(--success);
  margin-left: 5px;
  font-weight: bold;
  position: relative;
}

/* === GAME BOARD === */
#game-board {
  border-radius: var(--border-radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1rem;
  overflow: hidden;
  position: relative;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--cell-size-mobile), 1fr));
  gap: 8px;
  max-width: 100%;
  margin: 0 auto;
  justify-content: center;
}

.char-cell {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--border-radius-sm);
  color: var(--dark);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 3px 0 rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

.char-cell::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.5), transparent);
  pointer-events: none;
}

.char-cell:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 0 rgba(0,0,0,0.1), var(--shadow-md);
  background: rgba(255, 255, 255, 1);
}

.char-cell:active {
  transform: translateY(0);
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.char-cell.selected {
  background: var(--accent);
  color: var(--dark);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 0 rgba(0,0,0,0.15), 0 0 15px var(--accent);
}

.char-cell.wrong {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
  background: var(--danger);
  color: white;
}

.char-cell.match {
  animation: pulse 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  background: var(--success);
  color: white;
}

.char-cell.hidden {
  visibility: hidden;
  opacity: 0;
  transform: scale(0.8);
}

/* === POPUPS === */
.game-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity var(--transition), visibility var(--transition);
}

.game-popup.hidden {
  opacity: 0;
  visibility: hidden;
}

.popup-content {
  background: rgba(40, 40, 80, 0.95);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  position: relative;
  box-shadow: var(--shadow-xl), 0 0 20px rgba(106, 17, 203, 0.3);
  border: 1px solid rgba(255,255,255,0.1);
  transform: translateY(0);
  transition: transform var(--transition);
  overflow: hidden;
}

.game-popup.hidden .popup-content {
  transform: translateY(20px);
}

.popup-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(to right, var(--primary), var(--secondary));
}

.popup-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  transition: var(--transition-fast);
}

.popup-close:hover {
  background: rgba(255,255,255,0.2);
  color: white;
}

.popup-question h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  color: var(--accent);
  text-align: center;
  text-shadow: 0 0 5px rgba(255,183,3,0.3);
}

.popup-question p {
  margin-bottom: 1.25rem;
  font-size: 1.1rem;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 1rem;
}

.options-grid button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.options-grid button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
  pointer-events: none;
}

.options-grid button:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.options-grid button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.options-grid button.correct {
  background: var(--success);
  border-color: rgba(255,255,255,0.3);
}

.options-grid button.wrong {
  background: var(--danger);
  border-color: rgba(255,255,255,0.3);
}

#popup-feedback {
  margin-top: 1.5rem;
  text-align: center;
  font-weight: bold;
  min-height: 30px;
  color: var(--accent);
}

/* Custom popups */
#timeout-popup .popup-content, 
#level-complete-popup .popup-content {
  text-align: center;
}

#timeout-popup h2, 
#level-complete-popup h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

#timeout-popup h2 {
  color: var(--danger);
}

#level-complete-popup h2 {
  color: var(--success);
}

#timeout-popup p, 
#level-complete-popup p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.popup-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.game-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.primary-btn {
  background: linear-gradient(to right, var(--primary), var(--secondary));
  color: white;
}

.primary-btn:hover {
  box-shadow: var(--shadow-md), 0 0 10px rgba(106, 17, 203, 0.5);
  transform: translateY(-2px);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.secondary-btn {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

.secondary-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.secondary-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Score & Time animations */
.score-animation {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.7);
  color: var(--accent);
  font-weight: bold;
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 100;
  animation: float-up 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  /* Ensure animations are visible in viewport */
  max-width: 90%;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
}

.score-animation .score-value {
  font-size: 1.5rem;
}

.time-bonus-animation {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0,0,0,0.7);
  color: #4caf50;
  font-weight: bold;
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 100;
  animation: float-up 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  /* Ensure animations are visible in viewport */
  max-width: 90%;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
}

.time-bonus-animation .time-value {
  font-size: 1.5rem;
}

/* Updated animation keyframes for better mobile visibility */
@keyframes float-up {
  0% { 
    opacity: 0; 
    transform: translateX(-50%) translateY(20px); 
  }
  20% { 
    opacity: 1; 
  }
  80% { 
    opacity: 1; 
  }
  100% { 
    opacity: 0; 
    transform: translateX(-50%) translateY(-60px); 
  }
}

/* Mobile specific animation styles */
@media (max-width: 576px) {
  .score-animation,
  .time-bonus-animation {
    padding: 6px 12px;
    border-radius: 15px;
    bottom: 30%; /* Position in lower portion of screen */
    left: 50% !important; /* Override inline styles */
    top: auto !important; /* Override inline styles */
    transform: translateX(-50%) !important; /* Center horizontally */
  }
  
  .score-animation .score-value,
  .time-bonus-animation .time-value {
    font-size: 1.2rem;
  }
  
  @keyframes float-up {
    0% { 
      opacity: 0; 
      transform: translateX(-50%) translateY(15px); 
    }
    20% { 
      opacity: 1; 
    }
    80% { 
      opacity: 1; 
    }
    100% { 
      opacity: 0; 
      transform: translateX(-50%) translateY(-40px); 
    }
  }
}

@media (max-width: 375px) {
  .score-animation,
  .time-bonus-animation {
    padding: 5px 10px;
    border-radius: 12px;
    bottom: 35%; /* Position slightly higher on very small screens */
  }
  
  .score-animation .score-value,
  .time-bonus-animation .time-value {
    font-size: 1rem;
  }
  
  @keyframes float-up {
    0% { 
      opacity: 0; 
      transform: translateX(-50%) translateY(10px); 
    }
    100% { 
      opacity: 0; 
      transform: translateX(-50%) translateY(-30px); 
    }
  }
}

/* === FIREWORKS ANIMATION STYLES === */
.fireworks-container {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%);
}

.firework-spark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 20px;
  background: linear-gradient(to top, var(--accent), transparent);
  border-radius: 2px;
  animation: firework-spark 1s ease-out forwards;
  opacity: 0.8;
  transform-origin: bottom center;
}

@keyframes firework-spark {
  0% {
    transform: rotate(0deg) translateY(0);
    opacity: 1;
    height: 5px;
  }
  100% {
    transform: rotate(var(--rotate)) translateY(-40px);
    opacity: 0;
    height: 15px;
  }
}

/* Create multiple colors for the sparks */
.firework-spark:nth-child(1) { --rotate: 0deg; background: linear-gradient(to top, var(--accent), transparent); }
.firework-spark:nth-child(2) { --rotate: 72deg; background: linear-gradient(to top, var(--success), transparent); }
.firework-spark:nth-child(3) { --rotate: 144deg; background: linear-gradient(to top, var(--primary), transparent); }
.firework-spark:nth-child(4) { --rotate: 216deg; background: linear-gradient(to top, var(--secondary), transparent); }
.firework-spark:nth-child(5) { --rotate: 288deg; background: linear-gradient(to top, var(--warning), transparent); }

/* Responsive styling for fireworks */
@media (max-width: 576px) {
  .fireworks-container {
    width: 80px;
    height: 80px;
  }
  
  .firework-spark {
    width: 3px;
    height: 15px;
  }
  
  @keyframes firework-spark {
    0% {
      transform: rotate(0deg) translateY(0);
      opacity: 1;
      height: 4px;
    }
    100% {
      transform: rotate(var(--rotate)) translateY(-30px);
      opacity: 0;
      height: 12px;
    }
  }
}

@media (max-width: 375px) {
  .fireworks-container {
    width: 60px;
    height: 60px;
  }
  
  .firework-spark {
    width: 2px;
    height: 12px;
  }
  
  @keyframes firework-spark {
    0% {
      transform: rotate(0deg) translateY(0);
      opacity: 1;
      height: 3px;
    }
    100% {
      transform: rotate(var(--rotate)) translateY(-20px);
      opacity: 0;
      height: 10px;
    }
  }
}

/* === ANIMATIONS === */
@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
  40%, 60% { transform: translate3d(2px, 0, 0); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes flicker {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

@keyframes flash {
  0%, 100% { background: var(--danger); }
  50% { background: rgba(230, 57, 70, 0.5); }
}

.time-low {
  animation: flash 0.5s infinite;
}

/* Time burning effect */
@keyframes burn {
  0% { background-position: 0% 0%; }
  100% { background-position: -200% 0%; }
}

.burning-effect #time-progress {
  background: linear-gradient(to right, var(--danger), #ff5722, var(--warning), var(--danger));
  background-size: 200% 100%;
  animation: burn 3s linear infinite;
}

/* === RESPONSIVE STYLES === */
@media (min-width: 576px) {
  .char-grid {
    grid-template-columns: repeat(auto-fit, minmax(var(--cell-size-tablet), 1fr));
  }
}

@media (min-width: 768px) {
  .char-grid {
    grid-template-columns: repeat(auto-fit, minmax(var(--cell-size-desktop), 1fr));
    max-width: 95%;
  }
  
  .journey-path {
    max-width: 80%;
    margin: 0 auto;
  }
}

@media (max-width: 576px) {
  #game-header {
    padding: 1rem;
  }
  
  #game-header h1 {
    font-size: 1.5rem;
  }
  
  .header-score {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
  }
  
  .journey-path {
    padding: 0.5rem 0;
  }
  
  .checkpoint-marker {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }
  
  .checkpoint-time {
    font-size: 0.75rem;
  }
  
  .timer, .score-mini {
    font-size: 0.9rem;
    padding: 0.3rem 0.5rem;
  }
  
  #game-board {
    padding: 0.75rem;
  }
  
  .char-cell {
    font-size: 1.2rem;
  }
  
  .popup-content {
    padding: 1.5rem;
  }
  
  .popup-question h2 {
    font-size: 1.5rem;
  }
  
  .popup-question p {
    font-size: 1rem;
  }
  
  .options-grid {
    grid-template-columns: 1fr;
  }
  
  .game-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
}

/* Low-energy mode (prefers-reduced-motion) */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === CHECKPOINT ITEM STYLES (ENHANCED) === */
.checkpoint-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform var(--transition);
  margin: 0 10px;
}

.checkpoint-item .checkpoint-label {
  width: 50px;
  height: 50px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--primary);
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  margin-bottom: 0.4rem;
  border: 3px solid var(--primary);
  transition: all 0.3s ease, box-shadow 0.3s ease;
}

.checkpoint-item .checkpoint-time {
  font-size: 0.8rem;
  background: rgba(255,255,255,0.15);
  padding: 3px 8px;
  border-radius: 12px;
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.5px;
  box-shadow: inset 0 0 5px rgba(255,255,255,0.1);
  transition: background var(--transition-fast);
}

.checkpoint-item.mark .checkpoint-label {
  background: var(--success);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(56, 176, 0, 0.6);
}

.checkpoint-item.active .checkpoint-label {
  transform: scale(1.25);
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: white;
  box-shadow: 0 0 18px rgba(255, 183, 3, 0.8);
  border-color: var(--accent);
}

.checkpoint-item.active .checkpoint-time {
  background: rgba(255,183,3,0.3);
  font-weight: bold;
}

.checkpoint-item:hover .checkpoint-label {
  transform: scale(1.15);
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}


/* === CHECKPOINT COMPLETED STYLE === */
.checkpoint-item.completed .checkpoint-label {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(56, 176, 0, 0.7);
  position: relative;
}

.checkpoint-item.completed .checkpoint-label::after {
  content: '✓';
  position: absolute;
  font-size: 1.2rem;
  font-weight: bold;
  color: white;
  background: rgba(0,0,0,0.2);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  top: -6px;
  right: -6px;
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
}



/* === FOOTER STYLES === */
footer.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: #ccc;
  font-size: 0.7rem;
  text-align: center;
  padding: 2px 5px;
  z-index: 9999;
  overflow: hidden;
  height: 18px;
  line-height: 18px;
}

footer.footer a {
  color: #aaa;
  text-decoration: none;
  font-size: 0.7rem;
  margin: 0 2px;
}

footer.footer img {
  display: inline-block;
  max-height: 14px;
  width: auto;
  vertical-align: middle;
  opacity: 0.8;
}

footer.footer p {
  margin: 0;
  padding: 0;
}


/* === LOGO STYLES === */
.logos {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.logo-pikanhans,
.logo-quizzman {
  border-radius: 50%;
  padding: 4px;
  background: rgba(255, 255, 255, 0.1);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
              box-shadow 0.4s ease,
              filter 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Logo QuizzMan nổi bật hơn */
.logo-quizzman {
  width: 70px;
  height: 70px;
  box-shadow: 0 0 15px rgba(255, 183, 3, 0.8), 0 0 25px rgba(255, 183, 3, 0.5);
  background: rgba(255, 255, 255, 0.15);
  animation: pulse-gold 3s infinite alternate ease-in-out;
  z-index: 2;
  margin: 4px auto;
  justify-self: center;
  align-items: center;
  display: flex;
}

.logo-quizzman::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255, 183, 3, 0.2), transparent 70%);
  opacity: 0.7;
  z-index: -1;
}

/* Logo Pikanhans nhỏ hơn, làm "đàn em" */
.logo-pikanhans {
  width: 60px;
  height: 60px;
  box-shadow: 0 0 10px rgba(106, 17, 203, 0.7);
  animation: pulse-purple 4s infinite alternate ease-in-out;
  z-index: 1;
}

.logo-pikanhans::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(106, 17, 203, 0.3), transparent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* Hover effects cho cả 2 logo */
.logo-pikanhans:hover,
.logo-quizzman:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 0 25px rgba(255,255,255,0.7), 0 0 35px rgba(255,255,255,0.5);
  filter: brightness(1.2);
}

.logo-pikanhans:hover::before,
.logo-quizzman:hover::after {
  opacity: 1;
}

.logo-quizzman:hover {
  box-shadow: 0 0 20px var(--accent), 0 0 40px rgba(255, 183, 3, 0.6);
}

.logo-pikanhans:hover {
  box-shadow: 0 0 20px var(--primary), 0 0 40px rgba(106, 17, 203, 0.6);
}

/* Logo animations */
@keyframes pulse-gold {
  0% { box-shadow: 0 0 15px rgba(255, 183, 3, 0.8), 0 0 25px rgba(255, 183, 3, 0.5); }
  100% { box-shadow: 0 0 20px rgba(255, 183, 3, 0.9), 0 0 30px rgba(255, 183, 3, 0.7); }
}

@keyframes pulse-purple {
  0% { box-shadow: 0 0 10px rgba(106, 17, 203, 0.7); }
  100% { box-shadow: 0 0 15px rgba(106, 17, 203, 0.9), 0 0 25px rgba(106, 17, 203, 0.6); }
}

/* Mobile responsive adjustments */
@media (max-width: 576px) {
  .logos {
    gap: 8px;
  }
  
  .logo-quizzman {
    width: 50px;
    height: 50px;
  }
  
  .logo-pikanhans {
    width: 42px;
    height: 42px;
  }
}

/* Extra small devices */
@media (max-width: 375px) {
  .logos {
    gap: 6px;
  }
  
  .logo-quizzman {
    width: 45px;
    height: 45px;
  }
  
  .logo-pikanhans {
    width: 38px;
    height: 38px;
  }
}

/* Enhanced mobile responsiveness for collapsed bar */
@media (max-width: 768px) {
  #collapsed-bar {
    gap: 0.5rem;
    padding: 0.5rem;
    flex-wrap: nowrap;
  }
  
  .time-bar-container {
    min-width: 80px;
    flex: 0.8;
  }
  
  .timer-wrapper {
    min-width: auto;
  }
  
  .timer, .score-mini {
    padding: 0.3rem 0.5rem;
  }
  
  .current-level {
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
  }
  
  .collapsed-logos {
    display: flex;
    align-items: center;
  }
}

@media (max-width: 576px) {
  #collapsed-bar {
    padding: 0.4rem;
    gap: 0.3rem;
  }
  
  .current-level {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    flex-shrink: 0;
  }
  
  .time-bar-container {
    flex: 1;
    min-width: 60px;
  }
  
  .time-bar {
    height: 8px;
  }
  
  #time-fire {
    width: 20px;
  }
  
  .timer {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
  }
  
  .score-mini {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
    min-width: auto;
  }
  
  .logos.collapsed-logos {
    gap: 4px;
  }
}

@media (max-width: 480px) {
  #collapsed-bar {
    flex-wrap: nowrap;
    justify-content: space-between;
  }
  
  .timer i, .score-mini i {
    font-size: 0.8rem;
  }
  
  .timer, .score-mini {
    gap: 4px;
  }
  
  .timer-wrapper {
    flex-shrink: 0;
  }
  
  .score-mini {
    flex-shrink: 0;
  }
  
  /* Ensure all elements stay visible */
  .logos.collapsed-logos {
    flex-shrink: 1;
  }
  
  .current-level {
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Extra small devices */
@media (max-width: 375px) {
  #collapsed-bar {
    padding: 0.3rem;
    gap: 0.2rem;
  }
  
  .current-level {
    max-width: 60px;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
  }
  
  .time-bar {
    height: 6px;
  }
  
  .timer span, .score-mini span {
    font-size: 0.75rem;
  }
  
  .time-bar-container {
    min-width: 40px;
  }
}
/* === CURRENT PLAYER ICON BELOW ACTIVE CHECKPOINT === */
.checkpoint-item {
  position: relative; /* ensure positioning context */
}

.checkpoint-item .current-player {
  display: none;               /* hidden by default */
  position: absolute;
  top: calc(100% + 6px);       /* 6px gap below checkpoint label */
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: url('/assets/V1.0/user-icon.svg') center/cover no-repeat;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  z-index: 3;
}

/* Only show icon under the checkpoint that has class .active */
.checkpoint-item.active .current-player {
  display: block;
}

/* Responsive tweaks */
@media (max-width: 576px) {
  .checkpoint-item .current-player {
    width: 28px;
    height: 28px;
    top: calc(100% + 4px);
  }
}


/* === USER INFO IN COLLAPSED BAR === */
.user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}

.user-info .user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  margin-top: 10px;
}

.user-info .display-name {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 6px;
  font-weight: 600;
  color: #222;
  background: rgba(255,255,255,0.5);
  padding: 0;
  border-radius: 8px;
  max-width: 50%;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10;
  text-transform: none;
  letter-spacing: 0;
}

.join-room-buttons {
  display: flex;
  gap: 10;
  flex-direction: row;
  flex-wrap: nowrap;
  align-content: center;
  justify-content: center;
  align-items: center;
}

.room-player-item {
  display: flex;
  align-items: center;
  margin: 8px 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: stretch;
  justify-content: space-evenly;
}



.battle-theme {
  background: linear-gradient(to bottom, #2c3e50, #1a1a2e) !important;
  border: 3px solid #ff9800 !important;
}
.battle-theme h2 {
  color: #ff9800;
  text-shadow: 0 0 10px rgba(255, 152, 0, 0.7);
}
.battle-icon {
  animation: flicker 1s infinite alternate;
}
.battle-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 15px 0;
  position: relative;
}
.battle-banner h3 {
  color: #fff;
  background: linear-gradient(to right, rgba(26, 26, 46, 0), rgba(26, 26, 46, 0.8), rgba(26, 26, 46, 0));
  padding: 5px 20px;
  border-radius: 20px;
  text-shadow: 0 0 5px #ff9800;
}
.flame-effect {
  width: 30px;
  height: 60px;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path fill="%23ff9800" d="M16,0c0,0-4,8-4,16c0,8,4,16,4,16s4-8,4-16C20,8,16,0,16,0z"/></svg>') no-repeat;
  position: absolute;
  animation: flame 0.5s infinite alternate;
}
.flame-effect.left {
  left: 10%;
  transform: rotate(-10deg);
}
.flame-effect.right {
  right: 10%;
  transform: rotate(10deg);
}
.battle-player-list {
  margin: 15px 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid rgba(255, 152, 0, 0.5);
  border-radius: 10px;
  padding: 10px;
}
.room-player-item {
  display: flex;
  align-items: center;
  margin: 8px 0;
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}
.room-player-item.self {
  background: rgba(255, 152, 0, 0.2);
  border-left: 3px solid #ff9800;
}
.room-player-item img {
  border: 2px solid #ff9800;
  box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}
.room-player-item.new-player {
  animation: pulse-highlight 2s;
}
.battle-btn {
  background: linear-gradient(to bottom, #ff9800, #e65100) !important;
  border: none !important;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 152, 0, 0.5) !important;
}
.battle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 152, 0, 0.7) !important;
}
.waiting-message {
  color: #ff9800;
  text-align: center;
  font-style: italic;
}
.pulse {
  animation: pulse 1.5s infinite;
}
.code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}
.copy-btn {
  margin-left: 10px;
  background: #ff9800;
  border: none;
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
}
.copy-btn:hover {
  background: #e65100;
  transform: scale(1.1);
}
.copy-feedback {
  font-size: 12px;
  color: #4CAF50;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.copy-feedback.visible {
  opacity: 1;
}
.vs-animation-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.8);
  animation: fade-in 0.5s ease-in-out;
}
.vs-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
}
.vs-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: slide-in 0.5s ease-out;
}
.vs-player.left {
  transform: translateX(-50px);
  animation-name: slide-in-left;
}
.vs-player.right {
  transform: translateX(50px);
  animation-name: slide-in-right;
}
.vs-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid #ff9800;
  box-shadow: 0 0 20px rgba(255, 152, 0, 0.8);
  object-fit: cover;
}
.vs-name {
  margin-top: 10px;
  color: white;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 152, 0, 0.8);
}
.vs-symbol {
  margin: 0 20px;
  font-size: 60px;
  font-weight: bold;
  color: #ff9800;
  text-shadow: 0 0 20px #ff9800;
  animation: pulse-vs 1s infinite alternate;
}
@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}
@keyframes pulse-highlight {
  0% { background: rgba(255, 152, 0, 0.6); }
  100% { background: rgba(255, 255, 255, 0.1); }
}
@keyframes flame {
  0% { transform: scaleY(0.9) translateY(0); }
  100% { transform: scaleY(1.1) translateY(-5px); }
}
@keyframes flicker {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slide-in-left {
  from { transform: translateX(-200px); opacity: 0; }
  to { transform: translateX(-50px); opacity: 1; }
}
@keyframes slide-in-right {
  from { transform: translateX(200px); opacity: 0; }
  to { transform: translateX(50px); opacity: 1; }
}
@keyframes pulse-vs {
  from { transform: scale(1); }
  to { transform: scale(1.2); }
}

.player-name-badge {
  position: absolute;
  bottom: -22px; /* Position below the avatar */
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.6); /* Translucent glass effect */
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 5;
  backdrop-filter: blur(2px); /* Glass effect for modern browsers */
}

.name-overlay-style {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: rgba(255,255,255,0.5);
  backdrop-filter: blur(3px);
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
  border-bottom-left-radius: 50%;
  border-bottom-right-radius: 50%;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
@keyframes zoomBounce {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.3);
  }
  50% {
    transform: scale(0.9);
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes bounceZoom {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.4);
  }
  50% {
    transform: scale(0.95);
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}