/* Basic CSS Reset & Body Styling */
body {
  font-family: sans-serif;
  line-height: 1.6;
  margin: 20px;
  background-color: #f4f4f4;
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1,
h2 {
  text-align: center;
  color: #1a4d2e; /* Dark Green */
}

/* Setup Section */
#setup {
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  width: 90%;
  max-width: 500px;
  text-align: center;
}

#setup label,
#setup select,
#setup input {
  display: block;
  margin: 10px auto;
  padding: 8px;
  width: 80%;
  max-width: 300px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
#setup label {
  font-weight: bold;
  border: none;
  padding-bottom: 0;
  margin-bottom: 2px;
  text-align: center;
}

#setup button {
  background-color: #4caf50; /* Green */
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
  margin-top: 15px;
}

#setup button:hover {
  background-color: #45a049;
}

/* Game Section */
#game {
  /* display: none; */ /* Controlled by JS now, but keep for initial state idea */
  width: 95%;
  max-width: 900px;
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  display: flex; /* Use flexbox for layout */
  flex-wrap: wrap; /* Allow wrapping on smaller screens */
  gap: 20px;
  display: none; /* Hide initially, JS will show it */
}

/* Scoreboard Section */
#scoreboard-container {
  flex: 1 1 250px; /* Flex properties: grow, shrink, basis */
  min-width: 200px;
}

#scoreboard {
  list-style: none;
  padding: 0;
  margin: 0;
}

#scoreboard li {
  background-color: #e9e9e9;
  margin-bottom: 8px;
  padding: 10px 15px;
  border-radius: 4px;
  border: 1px solid #ccc;
  transition: background-color 0.3s ease, border-left 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
}
#scoreboard li span:first-child {
  font-weight: bold;
  margin-right: 10px;
}

#scoreboard li.active {
  background-color: #a8dadc; /* Light blue for active player */
  border-left: 5px solid #1d3557; /* Dark blue border */
  font-weight: bold;
}

/* Game Info & Input Section */
#game-main {
  flex: 2 1 400px; /* Takes more space */
}

#game-info {
  background-color: #f0f8ff; /* AliceBlue */
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 15px;
  border: 1px solid #b0e0e6; /* PowderBlue */
  text-align: center;
}
#game-info h3 {
  margin-top: 0;
  color: #1a4d2e;
}
#game-info p {
  font-size: 1.1em;
  margin: 5px 0;
}
#game-info strong {
  font-size: 1.3em;
  color: #d9534f; /* Reddish */
}

#score-input > div {
  display: none; /* Hide all input methods initially */
  padding: 15px;
  border: 1px dashed #ccc;
  border-radius: 5px;
  margin-top: 15px;
}

#score-input > div.active {
  display: block; /* Show only the active one */
}

/* --- Text Input --- */
#text-input-area label {
  display: inline-block;
  width: 60px;
  font-weight: bold;
}
#text-input-area input[type="text"] {
  padding: 8px;
  margin: 5px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: calc(100% - 90px); /* Adjust width */
  max-width: 150px;
}
#text-input-area button {
  /* Refers to Submit button here */
  margin-top: 10px;
  padding: 10px 15px;
}

/* --- Button Input (Revised) --- */
#button-input-area .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  margin-bottom: 10px;
}
#button-input-area .button-group-label {
  width: 100%;
  font-weight: bold;
  text-align: center;
  margin-bottom: 5px;
  color: #555;
}

#button-input-area button {
  /* General button style for this area */
  padding: 8px 10px;
  min-width: 40px;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #f8f8f8;
  transition: background-color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
  font-size: 14px; /* Ensure readable */
}
#button-input-area button:hover:not(:disabled) {
  /* Add :not(:disabled) */
  background-color: #e0e0e0;
  border-color: #aaa;
}

/* Specific button types */
#button-input-area button.score-btn-number {
  background-color: #ffffff;
  border: 1px solid #aaa;
}
#button-input-area button.score-btn-bull {
  background-color: #add8e6;
} /* Light Blue */
#button-input-area button.score-btn-miss {
  background-color: #d3d3d3;
} /* Light Grey */
#button-input-area button.score-btn-modifier {
  background-color: #fffacd;
} /* Lemon Chiffon */

/* Style for ACTIVE modifier buttons */
#button-input-area button.score-btn-modifier.modifier-active {
  background-color: #f0ad4e; /* Orange */
  color: white;
  border-color: #eea236;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

#current-turn-display {
  margin-top: 15px;
  font-size: 1.1em;
  font-weight: bold;
  min-height: 25px; /* Reserve space */
  text-align: center;
  background-color: #eee;
  padding: 5px;
  border-radius: 4px;
}
/* Control buttons styling moved to general .action-buttons section below */
#button-controls {
  margin-top: 15px; /* Ensure spacing */
  text-align: center; /* Center buttons */
}

/* --- Dartboard Input --- */
#dartboard-input-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}
#dartboard-svg {
  width: 100%;
  max-width: 400px; /* Size for numbers */
  height: auto;
  cursor: pointer;
  margin-bottom: 10px;
  background-color: transparent; /* Let page bg show through */
  position: relative;
}
#dartboard-svg path,
#dartboard-svg circle {
  stroke: #333;
  stroke-width: 0.5;
  transition: opacity 0.1s ease-in-out, stroke 0.1s ease-in-out,
    stroke-width 0.1s ease-in-out;
  vector-effect: non-scaling-stroke;
}
#dartboard-svg path:hover,
#dartboard-svg circle:hover {
  opacity: 0.8;
  stroke: black;
  stroke-width: 1;
}
/* Bullseye explicit colors */
#bull-outer {
  fill: #228b22;
} /* Green Bull */
#bull-inner {
  fill: #dc143c;
} /* Red Bullseye */

/* Dartboard Numbers Styling */
.dartboard-number {
  font-family: sans-serif;
  font-size: 12px; /* Adjust as needed */
  font-weight: bold;
  fill: #000000; /* BLACK fill */
  text-anchor: middle; /* Center horizontally */
  dominant-baseline: middle; /* Center vertically */
  pointer-events: none; /* Numbers should not be clickable */
}

/* Message Area */
#message-area {
  width: 100%;
  margin-top: 15px;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  border-radius: 4px;
  min-height: 40px; /* Reserve space */
}
.message-info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}
.message-bust {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}
.message-win {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

/* Action Buttons (Unified Styling) */
.action-buttons {
  margin-top: 15px;
  width: 100%;
  text-align: center;
}
/* Style ALL action buttons (Submit, Undo, Confirm, Reset) */
.action-buttons button,
#button-controls button {
  /* Include buttons in #button-controls */
  color: white;
  padding: 10px 15px; /* Consistent padding */
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
  margin: 5px;
}

/* Specific colors for different actions */
#confirm-turn-btn,
#undo-dart-btn,
#confirm-turn-btn-db,
#undo-dart-btn-db,
#submit-text-turn-btn {
  background-color: #5bc0de; /* Info blue */
}
#confirm-turn-btn:hover:not(:disabled),
#undo-dart-btn:hover:not(:disabled),
#confirm-turn-btn-db:hover:not(:disabled),
#undo-dart-btn-db:hover:not(:disabled),
#submit-text-turn-btn:hover:not(:disabled) {
  background-color: #31b0d5;
}

#reset-game-btn {
  background-color: #d9534f; /* Red for reset */
}
#reset-game-btn:hover {
  background-color: #c9302c;
}

/* Disabled state for Confirm buttons */
#confirm-turn-btn:disabled,
#confirm-turn-btn-db:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Winner Display */
#winner-display {
  display: none; /* Hidden initially */
  position: fixed; /* Overlay */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  text-align: center;
  flex-direction: column;
}

#winner-box {
  background-color: #fff;
  padding: 40px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#winner-box h2 {
  color: #4caf50;
  margin-bottom: 20px;
}

#winner-box button {
  background-color: #4caf50; /* Green */
  color: white;
  padding: 12px 25px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  margin-top: 20px;
}
#winner-box button:hover {
  background-color: #45a049;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  #game {
    flex-direction: column;
  }
  #scoreboard-container,
  #game-main {
    flex-basis: auto; /* Reset basis */
    width: 100%;
  }
  #dartboard-svg {
    max-width: 350px;
  }
  .dartboard-number {
    font-size: 10px;
  }
}
@media (max-width: 480px) {
  #button-input-area button,
     #button-controls button, /* Ensure control buttons are also adjusted */
     .action-buttons button {
    padding: 6px 8px;
    min-width: 35px;
    font-size: 11px;
  }
  #text-input-area input[type="text"] {
    width: calc(100% - 80px);
  }
  #dartboard-svg {
    max-width: 300px;
  }
  .dartboard-number {
    font-size: 9px;
  }
  #button-input-area .button-row {
    margin-bottom: 5px;
    gap: 3px;
  } /* Tighter spacing on small screens */
  #button-controls {
    margin-top: 10px;
  } /* Reduce top margin slightly */
}
