/* General Styles & Custom Design System */
:root {
  --primary-color: #ff6b8b;      /* Cute Coral pink */
  --primary-hover: #ff4771;
  --secondary-color: #4ecdc4;    /* Pastel Mint cyan */
  --secondary-hover: #3bbcb3;
  --accent-gold: #ffbe0b;        /* Star Yellow */
  --bg-gradient-start: #1e1b29;  /* Dark deep violet-blue */
  --bg-gradient-end: #0f0c1b;
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.15);
  --text-primary: #ffffff;
  --text-muted: #cbd5e1;
  --glow-pink: 0 0 15px rgba(255, 107, 139, 0.6);
  --glow-cyan: 0 0 15px rgba(78, 205, 196, 0.6);
  --glow-gold: 0 0 15px rgba(255, 190, 11, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: 'Outfit', 'Gaegu', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Background animated elements */
.stars-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
    radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px),
    radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 40px);
  background-size: 550px 550px, 350px 350px, 250px 250px;
  background-position: 0 0, 40px 60px, 130px 270px;
  opacity: 0.15;
  z-index: 0;
}

.clouds-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
  filter: blur(10px);
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 100px;
}

.cloud-1 {
  width: 250px;
  height: 80px;
  top: 15%;
  left: -260px;
  animation: floatCloud 45s linear infinite;
}

.cloud-2 {
  width: 180px;
  height: 60px;
  top: 30%;
  left: -190px;
  animation: floatCloud 65s linear infinite 15s;
}

.cloud-3 {
  width: 300px;
  height: 100px;
  top: 8%;
  left: -310px;
  animation: floatCloud 55s linear infinite 5s;
}

@keyframes floatCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 320px)); }
}

/* Main Game Wrapper */
.game-wrapper {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1080px; /* 120% of 900px */
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header styling */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  padding: 15px 25px;
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.title-container h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(45deg, var(--primary-color), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 10px rgba(255, 107, 139, 0.2);
  margin-bottom: 2px;
}

.title-container .subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  gap: 10px;
}

/* Common button styles */
.btn {
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), #ff4d6d);
  color: white;
  box-shadow: var(--glow-pink);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(255, 107, 139, 0.9);
}

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

.btn-secondary {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: white;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-icon {
  padding: 10px 15px;
  font-size: 1rem;
}

/* Scoreboard Layout */
.scoreboard-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.score-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.score-card.highlight {
  border-color: rgba(255, 107, 139, 0.4);
  background: rgba(255, 107, 139, 0.05);
  box-shadow: inset 0 0 15px rgba(255, 107, 139, 0.05);
}

.score-card .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.score-card .value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.score-card.highlight .value {
  color: var(--primary-color);
  text-shadow: var(--glow-pink);
}

/* Outs Indicator LED dots */
.outs-indicator {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  max-width: 140px;
  margin-top: 5px;
}

.out-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

.out-dot.active {
  background: #ff4757;
  border-color: #ff6b81;
  box-shadow: 0 0 10px #ff4757, 0 0 20px #ff4757;
}

/* Wind Indicator direction arrow */
.wind-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

#wind-arrow {
  display: inline-block;
  font-size: 1.2rem;
  color: var(--secondary-color);
  transition: transform 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  text-shadow: var(--glow-cyan);
}

/* Main Game Container & Canvas */
.game-container {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-wrapper {
  width: 100%;
  aspect-ratio: 2/1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 960px; /* 120% of 800px */
  max-height: 480px; /* 120% of 400px */
  background: transparent;
  cursor: crosshair;
}

/* Pitch Alert Overlay Text banner */
.pitch-alert-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 10px 25px;
  background: rgba(15, 12, 27, 0.85);
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  border-radius: 30px;
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: var(--glow-gold), inset 0 0 15px rgba(255, 190, 11, 0.2);
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pitch-alert-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Hit Feedback Overlay Text banner (Homerun!) */
.hit-feedback-banner {
  position: absolute;
  top: 150px;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 3.5rem;
  font-weight: 800;
  color: white;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hit-feedback-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hit-feedback-banner.homerun {
  color: var(--accent-gold);
  text-shadow: 0 0 15px rgba(255, 190, 11, 0.8), 0 0 30px rgba(255, 107, 139, 0.6), 0 5px 15px rgba(0,0,0,0.5);
  animation: bounceScale 0.6s infinite alternate;
}

.hit-feedback-banner.great {
  color: var(--secondary-color);
  text-shadow: var(--glow-cyan), 0 5px 15px rgba(0,0,0,0.5);
}

.hit-feedback-banner.foul {
  color: #ffbe0b;
  text-shadow: 0 0 10px rgba(255, 190, 11, 0.6), 0 5px 15px rgba(0,0,0,0.5);
}

.hit-feedback-banner.strike {
  color: #ff4757;
  text-shadow: 0 0 10px rgba(255, 71, 87, 0.6), 0 5px 15px rgba(0,0,0,0.5);
}

@keyframes bounceScale {
  0% { transform: translate(-50%, -50%) scale(1); }
  100% { transform: translate(-50%, -50%) scale(1.15); }
}

/* Mobile swing button (only displays on mobile / narrow screen) */
.mobile-swing-wrapper {
  width: 100%;
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--panel-border);
  display: none;
}

.btn-swing {
  width: 100%;
  height: 60px;
  font-size: 1.4rem;
  border-radius: 16px;
}

/* Controls Guide Footer */
.game-footer {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  padding: 15px 25px;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.controls-guide {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 15px;
}

.control-key {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-key span:first-child {
  background: #374151;
  color: white;
  border: 1px solid #4b5563;
  border-bottom: 3px solid #1f2937;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Modals Overlay & Box */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 8, 20, 0.85);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  visibility: visible; /* Explicitly default to visible */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.modal-content {
  background: linear-gradient(135deg, #2a2538, #151121);
  border: 2px solid var(--panel-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 107, 139, 0.15);
  border-radius: 28px;
  padding: 30px;
  width: 90%;
  max-width: 500px;
  text-align: center;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
  transform: translateY(-50px);
}

.modal-content h2 {
  font-size: 2rem;
  margin-bottom: 20px;
  background: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

/* Leaderboard Table Styles */
.leaderboard-table-container {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 25px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.15);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leaderboard-table th, .leaderboard-table td {
  padding: 12px 15px;
  font-size: 0.95rem;
}

.leaderboard-table th {
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--panel-border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.leaderboard-table tr {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.leaderboard-table tr:hover td {
  background: rgba(255,255,255,0.03);
}

/* Top 3 rank highlights */
.leaderboard-table tr:nth-child(1) td:first-child { color: var(--accent-gold); font-weight: 800; }
.leaderboard-table tr:nth-child(2) td:first-child { color: #e5e7eb; font-weight: 800; }
.leaderboard-table tr:nth-child(3) td:first-child { color: #d97706; font-weight: 800; }

.leaderboard-table tr:nth-child(1) { background: rgba(255, 190, 11, 0.05); }

.leaderboard-table td {
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
}

.modal-actions .btn {
  padding: 12px 25px;
  font-size: 1rem;
}

/* Name Input Modal specifics */
.name-input-content {
  max-width: 420px;
  border-color: rgba(78, 205, 196, 0.3);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(78, 205, 196, 0.15);
}

.mascot-badge {
  font-size: 4rem;
  margin-top: -65px;
  margin-bottom: 10px;
  background: #2a2538;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 3px solid var(--secondary-color);
  box-shadow: var(--glow-cyan);
  animation: spinSlow 10s linear infinite;
}

@keyframes spinSlow {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(10deg) scale(1.05); }
}

.score-congrats {
  font-size: 1.15rem;
  color: var(--accent-gold);
  font-weight: 800;
  margin-bottom: 10px;
}

.prompt-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

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

.input-group input {
  width: 100%;
  padding: 14px 20px;
  border-radius: 16px;
  border: 2px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
  color: white;
  font-family: inherit;
  font-size: 1.3rem;
  text-align: center;
  font-weight: 800;
  letter-spacing: 2px;
  outline: none;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.input-group input:focus {
  border-color: var(--secondary-color);
  box-shadow: var(--glow-cyan);
  background: rgba(0, 0, 0, 0.4);
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 768px) {
  .game-wrapper {
    padding: 10px;
    gap: 12px;
  }

  .game-header {
    padding: 12px 18px;
  }

  .title-container h1 {
    font-size: 1.6rem;
  }

  .title-container .subtitle {
    font-size: 0.8rem;
  }

  .btn-icon {
    padding: 8px 12px;
    font-size: 0.9rem;
  }

  .scoreboard-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .score-card {
    padding: 8px 10px;
  }

  .score-card .value {
    font-size: 1.4rem;
  }

  .mobile-swing-wrapper {
    display: block;
  }

  .hit-feedback-banner {
    font-size: 2.2rem;
  }

  .pitch-alert-banner {
    font-size: 1.2rem;
    padding: 6px 15px;
  }
  
  .game-footer {
    display: none; /* Hide keyboard shortcuts guide on mobile */
  }
}
