/*
 * Snakes and Ladders Game Styles
 *
 * This CSS file defines the visual theme for the Snakes and Ladders
 * game, including layout, colors, animations and responsive rules.  It
 * is adapted from the original project on GitHub to ensure that
 * splitting the board into two sections does not break styling.  You
 * should link this file from your game pages using a relative path
 * such as ../../assets/css/snakes-game.css.
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Arial', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

/* Login styles */
.login-box {
  background: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
  max-width: 400px;
  margin: 0 auto;
}

.login-box h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 2em;
}

.login-box p {
  color: #666;
  margin-bottom: 30px;
}

.guest-note {
  font-size: 0.85em;
  color: #999;
  margin-top: 20px;
  font-style: italic;
}

/* Character selection */
.character-box {
  background: white;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  max-width: 600px;
  margin: 0 auto;
}

.character-box h2 {
  text-align: center;
  color: #667eea;
  margin-bottom: 30px;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.character-card {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  border: 3px solid transparent;
}

.character-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.character-card.selected {
  border-color: #667eea;
  background: #e8ebff;
}

.character-icon {
  font-size: 3em;
  margin-bottom: 10px;
}

.character-card p {
  font-weight: bold;
  color: #333;
}

/* Buttons */
.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 5px;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-large {
  padding: 15px 40px;
  font-size: 1.2em;
}

/* Game container */
#game-container {
  background: rgba(255, 255, 255, 0.95);
  padding: 24px;
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(15, 15, 35, 0.25);
  width: min(1200px, 95vw);
  height: min(820px, calc(100vh - 40px));
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
}

.player-info h3 {
  color: #667eea;
  margin-bottom: 10px;
}

.player-info p {
  margin: 5px 0;
  color: #666;
}

.game-controls {
  text-align: center;
}

.time-info {
  text-align: right;
}

/* Dice animation */
#dice-animation {
  text-align: center;
  padding: 30px;
  background: #f8f9fa;
  border-radius: 10px;
  margin: 20px 0;
}

.dice-roll {
  font-size: 5em;
  animation: roll 1s ease-in-out;
}

@keyframes roll {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
  50% { transform: rotate(180deg); }
  75% { transform: rotate(270deg); }
}

.dice-result {
  font-size: 1.5em;
  color: #667eea;
  font-weight: bold;
  margin-top: 15px;
}

/* Game board */
.game-board {
  display: flex; /* rows are created dynamically by JS */
  flex-direction: column;
  gap: 4px;
  width: 100%;
  height: 100%;
  position: relative;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  flex: 1;
}

.game-board[data-scale="question"] .board-row {
  gap: 0;
}

.board-row.single-row {
  grid-template-columns: repeat(var(--first-size, 5), 1fr);
}

.small-lesson {
  min-height: 60px;
}

.floating-marker {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffd93d, #f39c12);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  font-size: 1.6em;
  border: 3px solid gold;
  z-index: 9999;
}

.ladder-anim {
  animation: ladderFloat 0.9s ease-out;
}

@keyframes ladderFloat {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-20px) scale(1.2) rotate(-10deg); }
  60% { transform: translateY(-35px) scale(1.3); }
  100% { transform: translateY(0) scale(1); }
}

.snake-anim {
  animation: snakeSlide 0.9s ease-out;
}

@keyframes snakeSlide {
  0% { transform: translateY(0) scale(1) rotate(0deg); }
  30% { transform: translateY(15px) scale(1.1) rotate(20deg); }
  60% { transform: translateY(30px) scale(1.2) rotate(-20deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); }
}

.square {
  aspect-ratio: 1;
  border: 1px solid #ddd;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  position: relative;
  background: white;
  transition: all 0.3s ease;
  cursor: pointer;
}

.square:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.square.visited {
  background: #e8f5e9;
  border-color: #4caf50;
}

/* Completed lesson squares - green with emphasis */
.square.lesson-completed {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  border-color: #2e7d32;
  border-width: 2px;
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.3);
}

.square.lesson-completed:hover {
  background: linear-gradient(135deg, #a5d6a7 0%, #81c784 100%);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
}

/* Visited but not completed lessons - hint to click */
.square.visited:not(.lesson-completed):not(.start) {
  background: #fff3e0;
  border-color: #ff9800;
  cursor: pointer;
}

.square.visited:not(.lesson-completed):not(.start):hover {
  background: #ffe0b2;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.square.current {
  background: #fff3cd;
  border-color: #ffc107;
  animation: pulse 1s infinite;
}

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

.square.ladder {
  background: linear-gradient(135deg, #a8e6cf 0%, #56ab2f 100%);
}

.square.snake {
  background: linear-gradient(135deg, #ff6b6b 0%, #c92a2a 100%);
}

.square.boss {
  background: linear-gradient(135deg, #ffd93d 0%, #ff6b35 100%);
  border: 3px solid #c92a2a;
}

.square.start {
  background: linear-gradient(135deg, #e6f0ff 0%, #ffffff 100%);
  border-color: #4a90e2;
}

.square-number {
  font-size: 0.8em;
  color: #666;
  position: absolute;
  top: 3px;
  left: 5px;
}

.square-icon {
  font-size: 1.5em;
}

.player-marker {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 1.1em;
  animation: playerIdle 2s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
  z-index: 100;
}

/* Idle breathing animation */
@keyframes playerIdle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
}

/* Movement animation when player moves */
.player-marker.moving {
  animation: playerMove 0.6s ease-out;
}

@keyframes playerMove {
  0% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-20px) scale(1.2) rotate(-10deg); }
  50% { transform: translateY(-30px) scale(1.3); }
  75% { transform: translateY(-15px) scale(1.15) rotate(10deg); }
  100% { transform: translateY(0) scale(1); }
}

/* Landing bounce animation */
.player-marker.landing {
  animation: playerLand 0.4s ease-out;
}

@keyframes playerLand {
  0% { transform: translateY(-20px) scale(1.2); }
  50% { transform: translateY(5px) scale(0.9); }
  75% { transform: translateY(-3px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}

/* Ladder climb animation */
.player-marker.climbing {
  animation: playerClimb 0.8s ease-out;
}

@keyframes playerClimb {
  0% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-15px) scale(1.1) rotate(-5deg); }
  50% { transform: translateY(-40px) scale(1.2); }
  75% { transform: translateY(-25px) scale(1.15) rotate(5deg); }
  100% { transform: translateY(0) scale(1); }
}

/* Snake slide animation */
.player-marker.sliding {
  animation: playerSlide 0.8s ease-out;
}

@keyframes playerSlide {
  0% { transform: translateY(0) scale(1) rotate(0deg); }
  25% { transform: translateY(10px) scale(0.95) rotate(15deg); }
  50% { transform: translateY(25px) scale(0.9) rotate(-15deg); }
  75% { transform: translateY(15px) scale(0.95) rotate(10deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); }
}

/* Legacy bounce for compatibility */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.board-shell {
  display: grid;
  grid-template-columns: minmax(230px, 320px) minmax(0, 1fr);
  gap: 24px;
  width: 100%;
  height: 100%;
}

.board-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.info-card {
  background: linear-gradient(155deg, #f8f9ff 0%, #edf1ff 100%);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 15px 35px rgba(15, 20, 65, 0.15);
  border: 1px solid rgba(102, 126, 234, 0.15);
}

#controls button {
  width: 100%;
  margin-top: 12px;
}

.control-hint {
  font-size: 0.9em;
  color: #5c6c93;
  margin-bottom: 10px;
}

.board-main {
  background: linear-gradient(160deg, rgba(255,255,255,0.95) 0%, rgba(246,248,255,0.9) 100%);
  border-radius: 22px;
  padding: 20px;
  box-shadow: inset 0 0 0 1px rgba(102,126,234,0.1);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.board-status {
  background: radial-gradient(circle at top, rgba(102,126,234,0.25), rgba(102,126,234,0));
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #2d2d44;
}

.status-pill {
  background: rgba(255, 255, 255, 0.9);
  color: #5f2eea;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(95, 46, 234, 0.25);
  letter-spacing: 0.3px;
}

.board-stage {
  flex: 0 0 auto;
  height: min(55vh, calc(100% - 200px));
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}

.board-stage[data-scale="lesson"] {
  height: auto;
  min-height: auto;
  align-items: flex-start;
}

.board-stage[data-scale="question"] {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  justify-content: flex-start;
  padding: 8px 0 8px 0;
}

.board-grid-frame {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.board-grid-frame .game-board {
  border-radius: 22px;
  padding: 10px;
  background: linear-gradient(135deg, #ffdf9e 0%, #ffd884 45%, #fec75f 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.05), 0 25px 40px rgba(0,0,0,0.15);
  height: 100%;
}

.board-grid-frame[data-scale="lesson"] {
  max-width: 420px;
  height: auto;
}

.board-grid-frame[data-scale="lesson"] .game-board {
  height: auto;
  max-height: none;
}

.board-grid-frame[data-scale="question"] {
  max-width: min(580px, 100%);
  justify-content: flex-start;
}

.board-grid-frame[data-scale="question"] .game-board {
  padding: 0.5px;
}

.game-board[data-scale="lesson"] {
  max-width: 420px;
  height: auto;
}

.game-board[data-scale="lesson"] .square {
  min-height: 45px;
  font-size: 0.75em;
}

.game-board[data-scale="lesson"] .square-icon {
  font-size: 1.2em;
}

.game-board[data-scale="lesson"] .square-number {
  font-size: 0.65em;
}

.game-board[data-scale="question"] .square {
  font-size: 0.45em;
}

.board-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 900px) {
  #game-container {
    height: auto;
  }
  .board-shell {
    grid-template-columns: 1fr;
    height: auto;
  }
  .board-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .info-card {
    flex: 1 1 240px;
  }
  .board-stage {
    height: auto;
    min-height: 300px;
  }
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-content.large {
  max-width: 800px;
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 2em;
  cursor: pointer;
  color: #999;
}

.close-modal:hover {
  color: #333;
}

/* Boss battle styles */
.boss-info {
  text-align: center;
  margin-bottom: 30px;
}

.boss-info h3 {
  color: #c92a2a;
  font-size: 2em;
  margin-bottom: 15px;
}

.health-bar {
  width: 100%;
  height: 30px;
  background: #f1f3f5;
  border-radius: 15px;
  overflow: hidden;
  margin: 10px 0;
  border: 2px solid #ddd;
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b 0%, #c92a2a 100%);
  transition: width 0.5s ease;
  width: 100%;
}

.active-players {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.active-players h4 {
  color: #667eea;
  margin-bottom: 15px;
}

#players-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.player-card {
  background: white;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid #ddd;
}

.player-card.dead {
  opacity: 0.5;
  background: #fee;
  border-color: #c92a2a;
}

.battle-controls {
  text-align: center;
  margin: 20px 0;
}

.battle-controls p {
  margin: 10px 0;
  font-size: 1.1em;
  font-weight: bold;
}

#battle-log {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 20px;
}

.log-entry {
  padding: 8px;
  margin: 5px 0;
  border-left: 3px solid #667eea;
  background: white;
}

.log-entry.attack {
  border-left-color: #dc3545;
}

.log-entry.death {
  border-left-color: #6c757d;
  background: #fee;
}

/* Leaderboard styles */
#leaderboard-content {
  margin-top: 20px;
}

.leaderboard-entry {
  display: grid;
  grid-template-columns: 50px 1fr 100px;
  gap: 15px;
  padding: 15px;
  margin: 10px 0;
  background: #f8f9fa;
  border-radius: 8px;
  align-items: center;
}

.leaderboard-entry.top-1 {
  background: linear-gradient(135deg, #ffd93d 0%, #f39c12 100%);
}

.leaderboard-entry.top-2 {
  background: linear-gradient(135deg, #c0c0c0 0%, #95a5a6 100%);
}

.leaderboard-entry.top-3 {
  background: linear-gradient(135deg, #cd7f32 0%, #965a38 100%);
}

.rank {
  font-size: 1.5em;
  font-weight: bold;
  text-align: center;
}

.player-details h4 {
  margin-bottom: 5px;
}

.player-stats {
  font-size: 0.9em;
  color: #666;
}

.bullets-count {
  font-size: 1.3em;
  font-weight: bold;
  color: #667eea;
  text-align: right;
}

/* Activity styles (quiz, memory, math) */
.activity-game {
  padding: 20px;
}

.activity-game h3 {
  color: #667eea;
  margin-bottom: 20px;
}

.quiz-option {
  padding: 15px;
  margin: 10px 0;
  background: #f8f9fa;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quiz-option:hover {
  background: #e8ebff;
  border-color: #667eea;
}

.quiz-option.correct {
  background: #d4edda;
  border-color: #28a745;
}

.quiz-option.incorrect {
  background: #f8d7da;
  border-color: #dc3545;
}

.memory-game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.memory-card {
  aspect-ratio: 1;
  background: #667eea;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.memory-card.flipped {
  background: white;
  border: 2px solid #667eea;
}

.memory-card.matched {
  background: #28a745;
  cursor: default;
}

.math-challenge {
  text-align: center;
}

.math-problem {
  font-size: 2em;
  margin: 20px 0;
  color: #667eea;
  font-weight: bold;
}

.math-input {
  padding: 15px;
  font-size: 1.2em;
  border: 2px solid #ddd;
  border-radius: 8px;
  width: 200px;
  text-align: center;
}

.activity-result {
  margin-top: 20px;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  font-size: 1.2em;
  font-weight: bold;
}

.activity-result.success {
  background: #d4edda;
  color: #155724;
}

.activity-result.failure {
  background: #f8d7da;
  color: #721c24;
}

/* Responsive design */
@media (max-width: 768px) {
  .game-header {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .time-info {
    text-align: center;
  }
  .game-board {
    gap: 3px;
  }
  .square-icon {
    font-size: 1em;
  }
  .square-number {
    font-size: 0.6em;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }
  .login-box,
  .character-box,
  .modal-content {
    padding: 20px;
  }
  .game-board {
    gap: 2px;
  }
}
/* ============================================
   ENHANCED LEADERBOARD STYLES
============================================ */

/* Modal overlay for blur effect */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

/* Enhanced leaderboard content */
.leaderboard-content {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0;
    border-radius: 20px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
    z-index: 1001;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Enhanced close button */
.leaderboard-content .close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 35px;
    color: white;
    cursor: pointer;
    z-index: 1002;
    transition: transform 0.2s, color 0.2s;
    line-height: 1;
}

.leaderboard-content .close-modal:hover {
    transform: rotate(90deg) scale(1.1);
    color: #ffd700;
}

/* Leaderboard header */
.leaderboard-header {
    background: rgba(255, 255, 255, 0.1);
    padding: 30px 20px 20px;
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-header h2 {
    margin: 0;
    font-size: 2em;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

.leaderboard-subtitle {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95em;
    font-weight: 300;
}

/* Table container with scroll */
.leaderboard-table-container {
    max-height: 50vh;
    overflow-y: auto;
    background: white;
    margin: 0;
    padding: 0;
}

/* Custom scrollbar */
.leaderboard-table-container::-webkit-scrollbar {
    width: 8px;
}

.leaderboard-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.leaderboard-table-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.leaderboard-table-container::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Enhanced table styles */
#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

/* Sticky header */
#leaderboard-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#leaderboard-table th {
    padding: 15px 10px;
    text-align: left;
    color: white;
    font-weight: 600;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

/* Column widths */
.rank-col {
    width: 15%;
    text-align: center !important;
}

.player-col {
    width: 40%;
}

.bullets-col {
    width: 25%;
    text-align: center !important;
}

.time-col {
    width: 20%;
    text-align: center !important;
}

/* Table rows */
#leaderboard-table tbody tr {
    transition: all 0.3s ease;
    border-bottom: 1px solid #e0e0e0;
}

#leaderboard-table tbody tr:hover {
    background: linear-gradient(90deg, #f8f9ff 0%, #e8ebff 100%);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

#leaderboard-table td {
    padding: 15px 10px;
    color: #333;
    font-size: 0.95em;
}

.rank-col, .bullets-col, .time-col {
    text-align: center;
    font-weight: 600;
}

/* 1st Place - Gold */
#leaderboard-table tbody tr:nth-child(1) {
    background: linear-gradient(90deg, #ffd700 0%, #ffed4e 100%);
    font-weight: bold;
}

#leaderboard-table tbody tr:nth-child(1):hover {
    background: linear-gradient(90deg, #ffed4e 0%, #ffd700 100%);
}

#leaderboard-table tbody tr:nth-child(1) td {
    color: #333;
}

/* 2nd Place - Silver */
#leaderboard-table tbody tr:nth-child(2) {
    background: linear-gradient(90deg, #c0c0c0 0%, #e8e8e8 100%);
    font-weight: bold;
}

#leaderboard-table tbody tr:nth-child(2):hover {
    background: linear-gradient(90deg, #e8e8e8 0%, #c0c0c0 100%);
}

/* 3rd Place - Bronze */
#leaderboard-table tbody tr:nth-child(3) {
    background: linear-gradient(90deg, #cd7f32 0%, #e09856 100%);
    font-weight: bold;
    color: white;
}

#leaderboard-table tbody tr:nth-child(3):hover {
    background: linear-gradient(90deg, #e09856 0%, #cd7f32 100%);
}

#leaderboard-table tbody tr:nth-child(3) td {
    color: white;
}

/* Current user highlight */
.current-user-row {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    font-weight: bold;
    border: 2px solid #ffd700 !important;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

.current-user-row td {
    color: white !important;
}

.current-user-row:hover {
    background: linear-gradient(90deg, #764ba2 0%, #667eea 100%) !important;
    transform: scale(1.03);
}

/* Rank badges */
.rank-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.1em;
    min-width: 35px;
    text-align: center;
}

/* Gold Medal */
.rank-badge.gold {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.rank-badge.gold::after {
    content: " 👑";
}

/* Silver Medal */
.rank-badge.silver {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #333;
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.rank-badge.silver::after {
    content: " 🥈";
}

/* Bronze Medal */
.rank-badge.bronze {
    background: linear-gradient(135deg, #cd7f32, #e09856);
    color: white;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

.rank-badge.bronze::after {
    content: " 🥉";
}

/* Regular ranks */
.rank-badge.regular {
    background: #f0f0f0;
    color: #666;
}

/* Leaderboard footer */
.leaderboard-footer {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
    text-align: center;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-footer p {
    margin: 0;
    color: white;
    font-size: 0.9em;
    font-weight: 300;
}

/* Empty state */
.empty-leaderboard {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-leaderboard-icon {
    font-size: 4em;
    margin-bottom: 15px;
    opacity: 0.3;
}

.empty-leaderboard p {
    font-size: 1.1em;
    color: #999;
}

/* Loading state */
.loading-spinner {
    text-align: center;
    padding: 40px;
    font-size: 1.2em;
    color: #667eea;
}

.loading-spinner::after {
    content: "⏳";
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 10px;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive design for leaderboard */
@media (max-width: 768px) {
    .leaderboard-content {
        width: 95%;
        max-width: none;
    }

    .leaderboard-header h2 {
        font-size: 1.5em;
    }

    #leaderboard-table th,
    #leaderboard-table td {
        padding: 10px 5px;
        font-size: 0.85em;
    }

    .rank-badge {
        font-size: 0.9em;
        min-width: 30px;
        padding: 4px 8px;
    }

    .time-col {
        display: none;
    }
}

@media (max-width: 480px) {
    .leaderboard-header h2 {
        font-size: 1.3em;
    }

    .bullets-col {
        width: 30%;
    }

    .player-col {
        width: 55%;
    }
}

/* ============================================
   MULTIPLAYER - OTHER PLAYERS ON BOARD
============================================ */

.other-players-container {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-width: 70%;
    z-index: 5;
}

.other-player-marker {
    font-size: 0.9em;
    opacity: 0.75;
    cursor: pointer;
    transition: all 0.2s ease;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.other-player-marker:hover {
    opacity: 1;
    transform: scale(1.3) !important;
    z-index: 100;
}

.player-marker {
    z-index: 100;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    border: 2px solid gold;
    border-radius: 50%;
    padding: 1px;
    background: rgba(255, 215, 0, 0.4);
    font-size: 1.1em !important;
}

.player-count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #667eea;
    color: white;
    font-size: 0.6em;
    font-weight: bold;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

/* ============================================
   SQUARE PLAYERS BUTTON - Shows players count
============================================ */

.square-players-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7em;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.5);
    transition: all 0.2s ease;
    padding: 0;
}

.square-players-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.7);
}

/* ============================================
   SQUARE PLAYERS POPUP - List of players
============================================ */

.square-players-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.square-players-popup.active {
    opacity: 1;
}

.square-players-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 16px;
    max-width: 380px;
    width: 90%;
    max-height: 70vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.square-players-popup.active .square-players-content {
    transform: translateY(0);
}

.square-players-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(102, 126, 234, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.square-players-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.square-players-close {
    background: none;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.square-players-close:hover {
    color: #fff;
}

.square-players-list {
    padding: 12px;
    max-height: calc(70vh - 60px);
    overflow-y: auto;
}

.square-player-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.square-player-item:hover {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.4);
    transform: translateX(4px);
}

.square-player-item:last-child {
    margin-bottom: 0;
}

.square-player-icon {
    font-size: 1.8em;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 50%;
}

.square-player-info {
    flex: 1;
}

.square-player-name {
    font-weight: bold;
    color: #fff;
    font-size: 0.95em;
    margin-bottom: 2px;
}

.square-player-stats {
    font-size: 0.8em;
    color: #a0a0c0;
}

.square-player-arrow {
    color: #667eea;
    font-size: 1.4em;
    font-weight: bold;
}

/* Scrollbar for players list */
.square-players-list::-webkit-scrollbar {
    width: 6px;
}

.square-players-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.square-players-list::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 3px;
}

.square-players-list::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* ============================================
   PLAYER INFO POPUP MODAL
============================================ */

.player-info-content {
    max-width: 400px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0;
    border-radius: 20px;
    overflow: hidden;
}

.player-info-header {
    text-align: center;
    padding: 30px 20px 20px;
    background: rgba(255, 255, 255, 0.1);
}

.player-info-character {
    font-size: 4em;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.player-info-header h2 {
    color: white;
    margin: 0;
    font-size: 1.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.player-info-body {
    background: white;
    padding: 25px;
}

.player-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}

.player-stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
    font-weight: 500;
}

.stat-value {
    color: #667eea;
    font-weight: bold;
    font-size: 1.1em;
}

.player-info-content .close-modal {
    color: white;
    z-index: 10;
}

/* ============================================
   3D DICE ANIMATION
============================================ */

.dice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.dice-overlay.hidden {
    display: none;
}

.dice-container {
    text-align: center;
}

.dice-scene {
    width: 120px;
    height: 120px;
    perspective: 600px;
    margin: 0 auto 30px;
}

.dice-cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out;
}

.dice-cube.rolling {
    animation: diceRoll 1.5s ease-out;
}

@keyframes diceRoll {
    0% {
        transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }
    20% {
        transform: rotateX(180deg) rotateY(90deg) rotateZ(45deg);
    }
    40% {
        transform: rotateX(360deg) rotateY(180deg) rotateZ(90deg);
    }
    60% {
        transform: rotateX(540deg) rotateY(270deg) rotateZ(135deg);
    }
    80% {
        transform: rotateX(720deg) rotateY(360deg) rotateZ(180deg);
    }
    100% {
        transform: rotateX(720deg) rotateY(360deg) rotateZ(180deg);
    }
}

.dice-face {
    position: absolute;
    width: 120px;
    height: 120px;
    background: linear-gradient(145deg, #ffffff 0%, #f0f0f0 100%);
    border: 3px solid #d4af37;
    border-radius: 12px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 15px;
    box-sizing: border-box;
}

.dice-face-1 { transform: rotateY(0deg) translateZ(60px); }
.dice-face-6 { transform: rotateY(180deg) translateZ(60px); }
.dice-face-2 { transform: rotateY(-90deg) translateZ(60px); }
.dice-face-5 { transform: rotateY(90deg) translateZ(60px); }
.dice-face-3 { transform: rotateX(90deg) translateZ(60px); }
.dice-face-4 { transform: rotateX(-90deg) translateZ(60px); }

.dice-dot {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 30% 30%, #333 0%, #111 100%);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dice-dot.center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.dice-dot.top-left { top: 20%; left: 20%; }
.dice-dot.top-right { top: 20%; right: 20%; }
.dice-dot.bottom-left { bottom: 20%; left: 20%; }
.dice-dot.bottom-right { bottom: 20%; right: 20%; }
.dice-dot.middle-left { top: 50%; left: 20%; transform: translateY(-50%); }
.dice-dot.middle-right { top: 50%; right: 20%; transform: translateY(-50%); }

.dice-result-display {
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s ease;
}

.dice-result-display.show {
    opacity: 1;
    transform: scale(1);
}

.dice-result-text {
    display: block;
    color: white;
    font-size: 1.2em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.dice-result-number {
    display: inline-block;
    font-size: 4em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    animation: resultPop 0.5s ease;
}

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

/* ============================================
   AUTOFILL / DEMO MODE BUTTON STYLES
   ============================================ */

/* Per-square autofill button (inside modals) */
.autofill-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.autofill-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.5);
    background: linear-gradient(135deg, #e67e22, #d35400);
}

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

.autofill-btn .icon {
    font-size: 1.1em;
}

/* Section autofill button (in control panel) */
.autofill-section-btn {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(155, 89, 182, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.autofill-section-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(155, 89, 182, 0.5);
    background: linear-gradient(135deg, #8e44ad, #7d3c98);
}

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

/* Question modal autofill button specific styling */
.question-autofill {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    margin-top: 0.75rem;
}

.question-autofill:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

/* Demo mode indicator (optional - shows when in demo mode) */
.demo-mode-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}
