/* ===== DIRECTION GAME STYLES ===== */

:root {
  --ocean-blue: #1a6b8a;
  --deep-ocean: #0d3b4f;
  --sand: #f4e4c1;
  --gold: #ffd700;
  --pirate-brown: #5c3a21;
  --red-flag: #c0392b;
  --green-island: #27ae60;
  --white: #ffffff;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, var(--ocean-blue) 0%, var(--deep-ocean) 100%);
  min-height: 100vh;
  color: var(--white);
  overflow-x: hidden;
}

/* Home Link */
.home-link {
  position: fixed;
  top: 15px;
  right: 20px;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  color: var(--sand);
  padding: 8px 16px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.home-link:hover {
  background: rgba(255, 215, 0, 0.2);
  color: var(--gold);
  border-color: var(--gold);
}

/* Header */
.game-header {
  text-align: center;
  padding: 20px 0;
}

.game-header h1 {
  font-size: 2.4rem;
  color: var(--gold);
  text-shadow: 3px 3px 6px var(--shadow), 0 0 20px rgba(255, 215, 0, 0.3);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.game-header .subtitle {
  font-size: 1.05rem;
  color: var(--sand);
  opacity: 0.9;
}

/* Screens */
.screen {
  display: none;
  animation: fadeIn 0.5s ease;
}

.screen.active {
  display: block;
}

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

/* Setup Screen */
.setup-panel {
  background: rgba(92, 58, 33, 0.85);
  border-radius: 20px;
  padding: 40px;
  max-width: 600px;
  margin: 40px auto;
  box-shadow: 0 10px 40px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 215, 0, 0.3);
}

.setup-panel h2 {
  text-align: center;
  color: var(--gold);
  font-size: 1.8rem;
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 25px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--sand);
  font-size: 1.05rem;
  font-weight: 600;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.3);
  color: var(--white);
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.form-group select option {
  background: var(--pirate-brown);
  color: var(--white);
}

/* Game Mode Cards */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.mode-card {
  background: rgba(0, 0, 0, 0.3);
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 25px 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.mode-card:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px var(--shadow);
}

.mode-card.selected {
  border-color: var(--gold);
  background: rgba(255, 215, 0, 0.15);
}

.mode-card .icon {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--gold);
  font-weight: 700;
}

.mode-card h3 {
  color: var(--gold);
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.mode-card p {
  color: var(--sand);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 16px 40px;
  border: none;
  border-radius: 14px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #ffaa00);
  color: var(--pirate-brown);
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 215, 0, 0.6);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: var(--white);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-center {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* Game Screen */
.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  padding: 15px 25px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.info-item {
  text-align: center;
}

.info-item .label {
  font-size: 0.75rem;
  color: var(--sand);
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.info-item .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}

.timer-warning {
  animation: pulse 1s ease infinite;
  color: var(--red-flag) !important;
}

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

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  margin-bottom: 15px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #ffaa00);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* Prompt Panel */
.prompt-panel {
  background: rgba(92, 58, 33, 0.85);
  border-radius: 16px;
  padding: 20px 25px;
  margin-bottom: 15px;
  box-shadow: 0 8px 30px var(--shadow);
  border: 2px solid rgba(255, 215, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 15px;
}

.prompt-icon {
  font-size: 1.3rem;
  color: var(--gold);
  font-weight: 700;
  flex-shrink: 0;
}

.prompt-text {
  font-size: 1.1rem;
  color: var(--white);
  font-weight: 600;
  line-height: 1.4;
}

.direction-hint {
  font-size: 0.85rem;
  color: var(--gold);
  margin-top: 5px;
  font-style: italic;
}

/* Game Layout Row */
.game-layout-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 15px;
}

/* Left Panel (Compass + Steering) */
.left-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-shrink: 0;
  align-items: center;
}

/* Compass Panel */
.compass-panel {
  background: rgba(92, 58, 33, 0.75);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 30px var(--shadow);
  border: 2px solid rgba(255, 215, 0, 0.2);
  width: 100%;
}

.compass-panel h3 {
  color: var(--gold);
  text-align: center;
  font-size: 1rem;
  margin-bottom: 12px;
}

.compass-grid {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  grid-template-rows: repeat(3, 55px);
  gap: 4px;
}

.compass-cell {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.compass-cell.n { background: rgba(39, 174, 96, 0.3); }
.compass-cell.s { background: rgba(192, 57, 43, 0.3); }
.compass-cell.e { background: rgba(52, 152, 219, 0.3); }
.compass-cell.w { background: rgba(149, 165, 166, 0.3); }

.arrow {
  font-size: 1.3rem;
  line-height: 1;
}

.dir-label {
  font-size: 0.6rem;
  color: var(--sand);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.compass-cell.center {
  background: rgba(255, 215, 0, 0.1);
}

.compass-cell.center .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
}

/* Canvas Wrapper */
.canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 1;
}

#game-canvas {
  border-radius: 16px;
  box-shadow: 0 10px 40px var(--shadow);
  border: 3px solid rgba(255, 215, 0, 0.2);
  background: #2c3e50;
}

/* Steering Wheel Touch Controls */
.steering-wheel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(92, 58, 33, 0.75);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 30px var(--shadow);
  border: 2px solid rgba(255, 215, 0, 0.2);
  width: 100%;
}

.steering-wheel-container h3 {
  color: var(--gold);
  font-size: 0.9rem;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}

.steering-wheel {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(92, 58, 33, 0.6) 0%, rgba(92, 58, 33, 0.85) 70%);
  border: 4px solid rgba(255, 215, 0, 0.3);
  box-shadow: 0 8px 30px var(--shadow), inset 0 0 30px rgba(0, 0, 0, 0.3);
}

.wheel-btn {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(26, 107, 138, 0.7), rgba(13, 59, 79, 0.8));
  border: 3px solid rgba(255, 215, 0, 0.4);
  color: var(--white);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.wheel-btn small {
  font-size: 0.55rem;
  font-weight: 400;
  opacity: 0.8;
  display: block;
}

.wheel-btn.north {
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
}

.wheel-btn.south {
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
}

.wheel-btn.west {
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.wheel-btn.east {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}

.wheel-btn:active {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.4), rgba(255, 170, 0, 0.5));
  border-color: var(--gold);
  transform: translateX(-50%) scale(0.93);
}

.wheel-btn.south:active {
  transform: translateX(-50%) scale(0.93);
}

.wheel-btn.west:active {
  transform: translateY(-50%) scale(0.93);
}

.wheel-btn.east:active {
  transform: translateY(-50%) scale(0.93);
}

.wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.3), rgba(92, 58, 33, 0.6));
  border: 2px solid rgba(255, 215, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* Feedback */

/* Feedback */
.feedback {
  text-align: center;
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1.05rem;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  margin-bottom: 15px;
}

.feedback.correct {
  background: rgba(39, 174, 96, 0.3);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.5);
}

.feedback.wrong {
  background: rgba(192, 57, 43, 0.3);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.5);
}

.feedback.hint {
  background: rgba(255, 215, 0, 0.2);
  color: var(--gold);
  border: 1px solid rgba(255, 215, 0, 0.4);
}

/* Controls Info */
.controls-info {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  margin-bottom: 20px;
}

.controls-info span {
  color: var(--sand);
  font-size: 0.9rem;
}

/* Streak indicator */
.streak-badge {
  display: inline-block;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  animation: streakGlow 1s ease infinite alternate;
}

@keyframes streakGlow {
  from { box-shadow: 0 0 5px rgba(231, 76, 60, 0.5); }
  to { box-shadow: 0 0 15px rgba(231, 76, 60, 0.8); }
}

/* Result Screen */
.result-panel {
  background: rgba(92, 58, 33, 0.9);
  border-radius: 20px;
  padding: 50px 40px;
  max-width: 550px;
  margin: 40px auto;
  text-align: center;
  box-shadow: 0 15px 50px var(--shadow);
  border: 2px solid rgba(255, 215, 0, 0.3);
}

.result-panel .trophy {
  font-size: 5rem;
  margin-bottom: 20px;
}

.result-panel h2 {
  color: var(--gold);
  font-size: 2rem;
  margin-bottom: 15px;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin: 30px 0;
}

.stat-box {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 20px;
}

.stat-box .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}

.stat-box .stat-label {
  font-size: 0.85rem;
  color: var(--sand);
  margin-top: 5px;
}

/* Name Input for Score */
.name-input-section {
  margin: 25px 0;
}

.name-input-section input {
  width: 100%;
  padding: 14px;
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  font-size: 1.1rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  color: var(--white);
  margin-bottom: 15px;
}

.name-input-section input:focus {
  outline: none;
  border-color: var(--gold);
}

/* Leaderboard */
.leaderboard-panel {
  background: rgba(92, 58, 33, 0.85);
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 8px 30px var(--shadow);
  border: 2px solid rgba(255, 215, 0, 0.2);
}

.leaderboard-panel h3 {
  color: var(--gold);
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.3rem;
}

.leaderboard-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--sand);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 215, 0, 0.15);
}

.leaderboard-list {
  list-style: none;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.leaderboard-entry:nth-child(1) {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.leaderboard-entry:nth-child(2) {
  background: rgba(192, 192, 192, 0.15);
  border: 1px solid rgba(192, 192, 192, 0.3);
}

.leaderboard-entry:nth-child(3) {
  background: rgba(205, 127, 50, 0.15);
  border: 1px solid rgba(205, 127, 50, 0.3);
}

.rank {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--gold);
  font-size: 0.9rem;
}

.leaderboard-entry:nth-child(1) .rank {
  background: var(--gold);
  color: var(--pirate-brown);
}

.player-info {
  flex: 1;
}

.player-name {
  font-weight: 600;
  color: var(--white);
}

.player-details {
  font-size: 0.8rem;
  color: var(--sand);
  opacity: 0.7;
}

.player-score {
  font-weight: 700;
  color: var(--gold);
  font-size: 1.1rem;
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to {
    top: 110vh;
    transform: rotate(720deg);
  }
}

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

.countdown-number {
  font-size: 8rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
  animation: countdownPulse 1s ease infinite;
}

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

/* Responsive */
@media (max-width: 900px) {
  .mode-cards {
    grid-template-columns: 1fr;
  }
  
  .info-bar {
    justify-content: center;
  }
  
  .game-layout-row {
    flex-direction: column;
    align-items: center;
  }
  
  .left-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
  
  .compass-panel,
  .steering-wheel-container {
    width: auto;
  }
  
  .compass-grid {
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 48px);
  }
}

@media (max-width: 768px) {
  .compass-grid {
    grid-template-columns: repeat(3, 55px);
    grid-template-rows: repeat(3, 42px);
  }
  
  .arrow {
    font-size: 1.1rem;
  }
  
  .dir-label {
    font-size: 0.5rem;
  }
  
  .left-panel {
    gap: 10px;
  }
  
  .compass-panel,
  .steering-wheel-container {
    padding: 12px;
  }
  
  .steering-wheel {
    width: 180px;
    height: 180px;
  }
  
  .wheel-btn {
    width: 62px;
    height: 62px;
    font-size: 1.1rem;
  }
  
  .wheel-center {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }
}

@media (max-width: 600px) {
  .game-header h1 {
    font-size: 1.4rem;
  }
  
  .setup-panel {
    padding: 25px 20px;
  }
  
  .result-stats {
    grid-template-columns: 1fr;
  }
  
  .controls-info {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .controls-info span {
    font-size: 0.8rem;
  }
  
  .leaderboard-tabs {
    flex-direction: column;
  }
  
  .prompt-panel {
    flex-direction: column;
    text-align: center;
  }
  
  .left-panel {
    flex-direction: column;
    align-items: center;
  }
  
  .compass-panel,
  .steering-wheel-container {
    width: 100%;
    max-width: 240px;
  }
  
  .steering-wheel {
    width: 160px;
    height: 160px;
  }
  
  .wheel-btn {
    width: 54px;
    height: 54px;
    font-size: 1rem;
  }
  
  .wheel-btn small {
    font-size: 0.5rem;
  }
  
  .wheel-center {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}
