/* ==========================================================================
   1. Resets & Base Styles
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: #0f172a; /* Slate 900 */
  color: #f8fafc;            /* Slate 50 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   2. Layout & Containers
   ========================================================================== */

.players-container {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 1.5rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
}

.players-card {
  flex: 1 1 250px;
  max-width: 350px;
  background-color: #1e293b; /* Slate 800 */
  border: 1px solid #334155;   /* Slate 700 */
  border-radius: 12px;
  box-sizing: border-box;
  padding: 1.25rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 
              0 4px 6px -4px rgba(0, 0, 0, 0.3);
  font-family: inherit;
  color: #cbd5e1;             /* Slate 300 */
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.players-card strong {
  display: block;
  font-size: 1.25rem;
  color: #f8fafc;             /* Slate 50 */
  border-bottom: 2px solid #334155; /* Slate 700 */
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   3. Grid Item Rows (.target-item & .add-points)
   ========================================================================== */

.target-item,
.add-points {
  display: grid;
  /* Col 1: Fixed 80px label | Col 2: Hits/Input fill space | Col 3: Fixed 60px button */
  grid-template-columns: 80px 1fr 60px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  margin-top: 0.15rem;
  border-radius: 6px;
  background-color: #0f172a; /* Slate 900 inset */
  border: 1px solid #1e293b;
  font-size: 0.9rem;
  font-weight: 500;
  color: #e2e8f0;             /* Slate 200 */
}

/* Closed/Completed Row State */
.target-item[data-closed="true"] {
  background-color: #064e3b; /* Emerald 900 */
  border-color: #047857;     /* Emerald 700 */
  color: #6ee7b7;             /* Emerald 300 */
}

/* Labels */
.target-label,
.label-points {
  display: block;
  width: 100%;
  padding: 0.15rem 0.25rem;
  background-color: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
  color: #38bdf8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Middle Column Content */
.target-hits {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.85rem;
}

.textbox-points {
  width: 100%;
  padding: 0.2rem 0.4rem;
  background-color: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
  color: #38bdf8;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textbox-points:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Action Container */
.target-action {
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   4. Buttons
   ========================================================================== */

/* Shared Button Styles */
.hit-btn,
.btn-points,
.miss-btn button {
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease;
}

/* Primary / Hit Buttons */
.hit-btn,
.btn-points {
  background-color: #2563eb; /* Blue 600 */
  color: #ffffff;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.hit-btn:hover,
.btn-points:hover {
  background-color: #1d4ed8; /* Blue 700 */
}

.hit-btn:active,
.btn-points:active {
  transform: scale(0.97);
}

/* Miss Button Block */
.miss-btn {
  display: block;
  margin-top: 0.75rem;
}

.miss-btn button {
  width: 100%;
  background-color: #dc2626; /* Red 600 */
  color: #ffffff;
  padding: 0.5rem;
}

.miss-btn button:hover {
  background-color: #b91c1c; /* Red 700 */
}

.miss-btn button:active {
  transform: scale(0.98);
}

.winner-box {
  position: relative;
  display: inline-block;
  padding: 1rem 2rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a; /* Deep navy blue text */
  background: linear-gradient(135deg, #e0f2fe 0%, #38bdf8 50%, #0284c7 100%); /* Light blue to vivid blue gradient */
  border: 3px solid #0369a1; /* Darker blue border */
  border-radius: 16px;
  box-shadow: 
    0 10px 25px -5px rgba(14, 165, 233, 0.5), /* Cyan-blue glow shadow */
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
}

.winner-box::before {
  content: "🏆 ";
  font-size: 1.6rem;
}

.winner-box::after {
  content: " 🥳✨";
  font-size: 1.6rem;
  display: inline-block;
  animation: pulseEmoji 1.2s infinite ease-in-out alternate;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulseEmoji {
  0% {
    transform: scale(1) rotate(0deg);
  }
  100% {
    transform: scale(1.25) rotate(12deg);
  }
}


/* Container Card */
.form-container {
  background-color: #1e293b; /* Slate 800 */
  border: 1px solid #334155;  /* Slate 700 */
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
  margin: 2rem auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.form-container h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: #f8fafc;
  font-size: 1.5rem;
  text-align: center;
}

/* Inputs Layout */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-bottom: 1.5rem;
}

.input-group input {
  background-color: #0f172a; /* Slate 900 */
  border: 1px solid #475569;  /* Slate 600 */
  border-radius: 8px;
  color: #f8fafc;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  min-height: 44px; /* Mobile touch friendly target */
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.input-group input::placeholder {
  color: #94a3b8; /* Slate 400 */
}

.input-group input:focus {
  border-color: #38bdf8; /* Sky 400 */
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Submit Button */
.submit-btn {
  width: 100%;
  background-color: #2563eb; /* Blue 600 */
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.submit-btn:hover {
  background-color: #1d4ed8; /* Blue 700 */
}

.submit-btn:active {
  transform: scale(0.98);
}

/* Cancel Link */
.cancel-link {
  text-align: center;
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.cancel-link a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.cancel-link a:hover {
  color: #f8fafc;
  text-decoration: underline;
}

/* Centered Card Container */
.menu-container {
  background-color: #1e293b; /* Slate 800 */
  border: 1px solid #334155;  /* Slate 700 */
  border-radius: 12px;
  padding: 2.5rem 2rem;
  max-width: 420px;
  margin: 3rem auto;
  text-align: center;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

/* Headings */
.menu-container h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: #f8fafc; /* Slate 50 */
  font-size: 1.875rem;
  font-weight: 700;
}

.menu-container h2 {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: #38bdf8; /* Sky 400 accent */
  font-size: 1.325rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Action Links / Buttons Stack */
.menu-links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Base Button Style */
.btn {
  display: block;
  padding: 0.875rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px; /* Mobile touch friendly target */
  box-sizing: border-box;
  transition: background-color 0.2s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

/* Primary Action ("Create new game") */
.btn-primary {
  background-color: #2563eb; /* Blue 600 */
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #1d4ed8; /* Blue 700 */
}

/* Secondary Action ("View active and past games") */
.btn-secondary {
  background-color: #334155; /* Slate 700 */
  color: #f8fafc;
  border: 1px solid #475569;  /* Slate 600 */
}

.btn-secondary:hover {
  background-color: #475569; /* Slate 600 */
}

/* Container Card */
.history-container {
  background-color: #1e293b; /* Slate 800 */
  border: 1px solid #334155;  /* Slate 700 */
  border-radius: 12px;
  padding: 2rem;
  max-width: 550px;
  margin: 2rem auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.history-container h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: #f8fafc; /* Slate 50 */
  font-size: 1.5rem;
  text-align: center;
}

/* History List Layout */
.game-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Individual Game Row */
.game-item {
  background-color: #0f172a; /* Slate 900 */
  border: 1px solid #334155;  /* Slate 700 */
  border-radius: 8px;
  padding: 0.875rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.game-item:hover {
  border-color: #475569; /* Slate 600 */
  background-color: #172554; /* Tinted Slate/Blue hover */
}

/* Game ID Link */
.game-id-link {
  color: #38bdf8; /* Sky 400 */
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
}

.game-id-link:hover {
  text-decoration: underline;
}

/* Status Badges */
/* Status Badges */
.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  display: inline-block;
  white-space: nowrap; /* Prevents "IN PROGRESS" from wrapping into two lines */
}

/* IN_PROGRESS: Amber/Yellow Theme */
.status-badge.in_progress {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24; /* Amber 400 */
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* COMPLETED: Green Theme */
.status-badge.completed {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80; /* Green 400 */
  border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Home Link */
.home-link {
  text-align: center;
  margin: 0;
}

.home-link a {
  color: #94a3b8; /* Slate 400 */
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.home-link a:hover {
  color: #f8fafc;
  text-decoration: underline;
}

/* Container Layout */
.detail-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* Top Navigation Bar */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.btn-back,
.btn-action {
  background-color: #334155; /* Slate 700 */
  color: #f8fafc;
  border: 1px solid #475569;  /* Slate 600 */
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  box-sizing: border-box;
  transition: background-color 0.2s ease;
}

.btn-action {
  background-color: #2563eb; /* Blue 600 */
  border: none;
}

.btn-back:hover { background-color: #475569; }
.btn-action:hover { background-color: #1d4ed8; }

/* Game Meta Summary Card */
.game-meta-card {
  background-color: #1e293b; /* Slate 800 */
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.game-meta-card h2 {
  margin: 0 0 1rem 0;
  color: #f8fafc;
  font-size: 1.75rem;
  word-break: break-all;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.meta-pill {
  background-color: #0f172a; /* Slate 900 */
  color: #94a3b8;             /* Slate 400 */
  border: 1px solid #334155;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Winner Banner */
.winner-banner {
  margin-top: 1.25rem;
  background-color: rgba(234, 179, 8, 0.15); /* Gold tint */
  border: 1px solid rgba(234, 179, 8, 0.4);
  color: #facc15;                             /* Yellow 400 */
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1.1rem;
}

/* Player Cards Grid */
.players-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .players-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Individual Player Card */
.player-summary-card {
  background-color: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #334155;
}

.player-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f8fafc;
}

.player-score {
  font-size: 1rem;
  font-weight: 600;
  color: #38bdf8; /* Sky 400 */
}

/* Stats 4-Column Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.stat-box {
  background-color: #0f172a;
  border-radius: 8px;
  padding: 0.5rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 700;
}

.stat-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  margin-top: 0.2rem;
}

.stat-value.highlight {
  color: #38bdf8;
}

/* Targets Detailed List */
.targets-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.target-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #0f172a;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.target-name {
  font-weight: 600;
  color: #e2e8f0;
}

.target-hits {
  color: #94a3b8;
}

.target-status {
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

.target-status.closed {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.target-status.open {
  background-color: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

.alert-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background-color: #ef4444; /* Red 500 */
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  transition: opacity 0.3s ease;
}

.alert-banner.hidden {
  display: none;
}
