/* Maze Game Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Quicksand', sans-serif;
  background-color: #f5f5f5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%231a1a2e' stroke-width='1' opacity='0.15'%3E%3Cpath d='M0 0h20v20H0zM20 0v40h20V20h20v20h20V0M60 40h20M0 40h20v20H0M40 40v20M20 60h20v20M60 60v20M40 80h20'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
  color: #1a1a2e;
}

.game-container {
  max-width: 650px;
  margin: 0 auto;
  padding: 20px;
}

/* Screen Management */
.screen {
  display: none;
  text-align: center;
}

.screen.active {
  display: block;
}

/* Start Screen */
.game-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 10px;
}

.game-subtitle {
  color: #666;
  font-size: 1.2rem;
  margin-bottom: 30px;
}


/* Difficulty Selector */
.difficulty-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 25px 0;
  flex-direction: column;
  text-align: center;
}

.difficulty-btn {
  padding: 10px 25px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid;
  background: transparent;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Quicksand', sans-serif;
  width: 200px;
  margin-inline: auto;
}

.difficulty-btn[data-difficulty="easy"] {
  border-color: #82e0aa;
  color: #82e0aa;
}

.difficulty-btn[data-difficulty="easy"]:hover {
  background: rgba(130, 224, 170, 0.15);
}

.difficulty-btn[data-difficulty="easy"].active {
  background: #82e0aa;
  color: #145a32;
}

.difficulty-btn[data-difficulty="medium"] {
  border-color: #27ae60;
  color: #27ae60;
}

.difficulty-btn[data-difficulty="medium"]:hover {
  background: rgba(39, 174, 96, 0.15);
}

.difficulty-btn[data-difficulty="medium"].active {
  background: #27ae60;
  color: #fff;
}

.difficulty-btn[data-difficulty="hard"] {
  border-color: #145a32;
  color: #145a32;
}

.difficulty-btn[data-difficulty="hard"]:hover {
  background: rgba(20, 90, 50, 0.15);
}

.difficulty-btn[data-difficulty="hard"].active {
  background: #145a32;
  color: #fff;
}

.difficulty-btn.dimmed {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Buttons */
.btn {
  padding: 14px 35px;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Quicksand', sans-serif;
  margin: 10px;
}

.btn.primary {
  background: #1a1a2e;
  color: #fff;
}

.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(26, 26, 46, 0.3);
}

.btn.secondary {
  background: #666;
  color: #fff;
}

.btn.secondary:hover {
  background: #555;
}

/* Game Screen */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  gap: 5px;
  
}

.game-header h2 {
  font-size: 1.3rem;
  color: #1a1a2e;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #1a1a2e;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-btn:hover {
  background: rgba(26, 26, 46, 0.1);
}

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

.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid #1a1a2e;
  background: #fff;
  color: #1a1a2e;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Quicksand', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
}

.share-btn:hover {
  background: #1a1a2e;
  color: #fff;
}

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

.share-btn.copied {
  background: #27ae60;
  border-color: #27ae60;
  color: #fff;
}

.share-btn-text {
  white-space: nowrap;
}

.stats {
  font-size: 0.95rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-pill {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid #1a1a2e;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
}

.sound-toggle {
  font-size: 0.75rem;
  border: 1px solid #1a1a2e;
  background: #fff;
  color: #1a1a2e;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.sound-toggle:hover {
  background: #eee;
}

.sound-toggle.on {
  background: #1a1a2e;
  color: #fff;
}

/* Canvas Container */
.canvas-container {
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
  overflow-x: auto;
}

#mazeCanvas {
  border: none;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  width: 100%;
  height: auto;
}

/* Entry Points */
.entry-points {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 15px 0;
}

.entry-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  border: 3px solid #1a1a2e;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.entry-btn .color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.entry-btn:hover:not(:disabled) {
  background: #1a1a2e;
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.entry-btn.selected {
  background: #1a1a2e;
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 0 0 4px rgba(26, 26, 46, 0.2), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.entry-btn.dimmed {
  opacity: 0.35;
}

.entry-btn.winner {
  background: #27ae60 !important;
  border-color: #1e874b !important;
  color: #fff !important;
}

.entry-btn.wrong {
  background: #e74c3c !important;
  border-color: #c0392b !important;
  color: #fff !important;
}

.entry-btn.correct {
  background: #27ae60 !important;
  border-color: #1e874b !important;
  color: #fff !important;
  animation: pulse-correct 1s ease-in-out infinite;
}

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

.entry-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.entry-btn.winner:disabled,
.entry-btn.wrong:disabled,
.entry-btn.correct:disabled,
.entry-btn.selected:disabled {
  opacity: 1;
}

.hint-text {
  color: #666;
  font-size: 0.95rem;
  margin-top: 10px;
}

.legend {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: #555;
}

.legend.hidden {
  display: none;
}

.legend-item {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #1a1a2e;
  background: #fff;
}

.legend-item.success {
  border-color: #27ae60;
  color: #1e874b;
}

.legend-item.fail {
  border-color: #e74c3c;
  color: #c0392b;
}

/* Result Screen */
#result-screen {
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  margin-top: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

#result-screen h2 {
  font-size: 2.2rem;
  margin-bottom: 15px;
}

#result-message {
  color: #666;
  font-size: 1.1rem;
  margin-bottom: 25px;
}

#result-stats {
  margin-bottom: 30px;
  font-size: 1rem;
  color: #888;
}

.result-difficulty {
  margin-bottom: 20px;
}

.result-label {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 8px;
}

.result-difficulty-selector {
  margin: 0;
}

.result-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* Player Colors */
:root {
  --player-1: #e74c3c;
  --player-2: #3498db;
  --player-3: #27ae60;
  --player-4: #9b59b6;
  --player-5: #f39c12;
  --player-6: #1abc9c;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
}

.mode-btn {
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid #1a1a2e;
  background: transparent;
  color: #1a1a2e;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Quicksand', sans-serif;
}

.mode-btn:hover {
  background: #eee;
}

.mode-btn.active {
  background: #1a1a2e;
  color: #fff;
}

/* Name Screen */
.name-input-container {
  margin: 30px 0;
}

.name-input {
  width: 250px;
  padding: 14px 20px;
  font-size: 1.2rem;
  font-family: 'Quicksand', sans-serif;
  border: 2px solid #1a1a2e;
  border-radius: 25px;
  text-align: center;
  outline: none;
  transition: box-shadow 0.2s ease;
}

.name-input:focus {
  box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.15);
}

/* Lobby Screen */
.lobby-section {
  background: #fff;
  border: 2px solid #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin: 15px 0;
}

.lobby-label {
  font-size: 0.95rem;
  color: #666;
  margin-bottom: 10px;
}

.share-link-container {
  display: flex;
  gap: 10px;
}

.share-link-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-family: 'Quicksand', sans-serif;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f9f9f9;
}

.btn-icon {
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid #1a1a2e;
  background: #1a1a2e;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Quicksand', sans-serif;
}

.btn-icon:hover {
  background: #333;
}

.status-text {
  font-size: 0.9rem;
  color: #888;
}

.players-section {
  background: #fff;
  border: 2px solid #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin: 15px 0;
}

.players-section h3 {
  margin-bottom: 15px;
  font-size: 1.1rem;
}

#player-count {
  font-weight: normal;
  color: #888;
}

.players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 40px;
}

.player-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #f5f5f5;
  border-radius: 20px;
  font-size: 0.95rem;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.player-tag.host .player-name::after {
  content: ' (Host)';
  font-size: 0.8rem;
  color: #888;
}

/* Lobby Leaderboard */
.lobby-leaderboard {
  background: #fff;
  border: 2px solid #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin: 15px 0;
}

.lobby-leaderboard h3 {
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.scores-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f9f9f9;
  border-radius: 8px;
}

.score-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-value {
  font-weight: 700;
  font-size: 1.1rem;
}

.host-badge {
  font-size: 0.75rem;
  color: #888;
  font-weight: normal;
}

.lobby-controls {
  margin: 20px 0;
}

.lobby-difficulty {
  margin-bottom: 15px;
}

.waiting-text {
  color: #888;
  font-size: 0.95rem;
}

/* Game Layout for Multiplayer */
.game-layout {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.main-game-area {
  flex: 1;
  max-width: 450px;
}

/* Timer */
.game-timer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  flex: 1;
}

.timer-bar {
  flex: 1;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: #27ae60;
  border-radius: 4px;
  transition: width 1s linear, background-color 0.3s ease;
}

.timer-fill.warning {
  background: #f39c12;
}

.timer-fill.danger {
  background: #e74c3c;
}

#timer-text {
  font-weight: 600;
  font-size: 1rem;
  min-width: 40px;
  text-align: right;
  display: none;
}

/* Score Display */
.score-pill {
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid #1a1a2e;
  color: #1a1a2e;
  padding: 4px 12px;
  border-radius: 999px;
  background: #fff;
}

/* Round Display */
.round-pill {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid #27ae60;
  color: #27ae60;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
}

/* Player Indicators */
.player-indicators {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 10px 0;
  flex-wrap: wrap;
}

.player-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 20px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.player-indicator.locked {
  opacity: 0.6;
}

.player-indicator.locked::after {
  content: '✓';
  margin-left: 4px;
  color: #27ae60;
}

.indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Mini Leaderboard Sidebar */
.mini-leaderboard {
  width: 150px;
  background: #fff;
  border: 2px solid #1a1a2e;
  border-radius: 12px;
  padding: 15px;
  height: fit-content;
}

.mini-leaderboard h4 {
  margin-bottom: 12px;
  font-size: 0.95rem;
  text-align: center;
}

.mini-scores {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: #f9f9f9;
  border-radius: 6px;
  font-size: 0.85rem;
}

.mini-score-player {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.mini-score-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

.mini-score-value {
  font-weight: 700;
}

/* Countdown Overlay */
.countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 46, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.countdown-number {
  font-size: 8rem;
  font-weight: 700;
  color: #fff;
  animation: countdownPulse 1s ease-in-out infinite;
}

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

/* Entry Button Claimed State */
.entry-btn.claimed {
  opacity: 0.5;
  cursor: not-allowed;
  position: relative;
}

.entry-btn.claimed::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 3px solid var(--claimed-color, #888);
}

/* Multiplayer Round Results */
.mp-round-results {
  background: #fff;
  border: 2px solid #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
}

.mp-round-results h3 {
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.round-results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f9f9f9;
  border-radius: 8px;
}

.result-row.correct {
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid #27ae60;
}

.result-row.wrong {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid #e74c3c;
}

.result-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-choice {
  font-weight: 600;
}

.result-points {
  font-weight: 700;
  font-size: 1.1rem;
}

.result-points.gained {
  color: #27ae60;
}

.next-round-msg {
  color: #888;
  font-size: 0.95rem;
  text-align: center;
}

/* Session End Screen */
.final-leaderboard {
  background: #fff;
  border: 2px solid #1a1a2e;
  border-radius: 12px;
  padding: 25px;
  margin: 20px 0;
}

.final-standings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.standing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f9f9f9;
  border-radius: 10px;
}

.standing-row.first {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%);
}

.standing-row.second {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
}

.standing-row.third {
  background: linear-gradient(135deg, #cd7f32 0%, #e6a35e 100%);
}

.standing-rank {
  font-size: 1.3rem;
  font-weight: 700;
  width: 30px;
}

.standing-player {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.standing-score {
  font-size: 1.4rem;
  font-weight: 700;
}

.session-stats {
  margin: 20px 0;
  font-size: 0.95rem;
  color: #666;
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 650px) {
  #game-screen {
    padding-bottom: 110px;
  }

  .game-container {
    padding: 15px;
  }

  .entry-btn {
    width: 52px;
    height: 52px;
    border-radius: 8px;
  }

  .entry-btn .color-dot {
    width: 22px;
    height: 22px;
  }

  .entry-points {
    gap: 14px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 8px;
    z-index: 10;
    padding: 12px 0 16px;
    background: rgba(245, 245, 245, 0.95);
    border-top: 1px solid #ddd;
    backdrop-filter: blur(6px);
  }

  .game-title {
    font-size: 2rem;
  }

  .difficulty-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
  }

  .canvas-container {
    margin: 0 -15px 15px;
    padding: 0 15px;
  }

  /* Multiplayer mobile styles */
  .mode-btn {
    padding: 10px 20px;
    font-size: 0.9rem;
  }

  .name-input {
    width: 200px;
    font-size: 1rem;
  }

  .game-layout {
    flex-direction: column;
  }

  .mini-leaderboard {
    width: 100%;
    order: -1;
    margin-bottom: 10px;
  }

  .mini-scores {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .mini-score-row {
    flex: 0 0 auto;
  }

  .player-indicators {
    gap: 8px;
  }

  .player-indicator {
    padding: 4px 10px;
    font-size: 0.8rem;
  }

  .countdown-number {
    font-size: 5rem;
  }
}
