/* Global styles */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  /* Use the forest image as the page background */
  background-image: url('assets/bg.png');
  background-size: cover;
  background-position: center;
  /* Provide a subtle white overlay to improve text contrast */
  background-color: rgba(255, 255, 255, 0.85);
  background-blend-mode: lighten;
  color: #214f3d;
}

/* Improve base typography and responsive sizing */
html { font-size: 16px; }
@media (max-width: 480px) {
  html { font-size: 15px; }
}
@media (min-width: 1200px) {
  html { font-size: 17px; }
}

/* ------------------------------------------------------------------
   Global site navigation and layout for landing and other pages
   These styles define a reusable navigation bar, hero sections,
   feature lists, call‑to‑action buttons and footers. They are used
   across index, play, how‑to‑play, print‑buzzers and contact pages.
--------------------------------------------------------------------*/

/* Navigation bar */
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.5rem 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-logo img {
  height: 40px;
}
.nav-links {
  list-style: none;
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
}
.nav-links li a {
  text-decoration: none;
  color: #214f3d;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s ease;
}
.nav-links li a:hover {
  background: rgba(45, 106, 79, 0.1);
}
.nav-links li a.active {
  background: #2d6a4f;
  color: #fff;
}

/* Mobile nav: stack links and allow wrapping */
@media (max-width: 640px) {
  .nav-links { flex-wrap: wrap; gap: 0.5rem; }
}

/* Hero section on landing page */
.hero {
  background-image: url('assets/bg.png');
  background-size: cover;
  background-position: center;
  height: 60vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
}
.hero-overlay {
  background: rgba(0, 0, 0, 0.4);
  padding: 2rem;
  border-radius: 8px;
}
.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.hero p {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}
.cta-button {
  display: inline-block;
  background: #2d6a4f;
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease;
}
.cta-button:hover {
  background: #214f3d;
}

/* Landing page main sections */
.landing-main {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Improve readability on very wide desktops */
@media (min-width: 1400px) {
  .landing-main { max-width: 1200px; }
}
.landing-main h2 {
  margin-top: 0;
  color: #2d6a4f;
}
.feature-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.feature {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.feature h3 {
  margin-top: 0;
  color: #386fa4;
  font-size: 1.1rem;
}
.feature p {
  font-size: 0.9rem;
  color: #214f3d;
}
.cta-section {
  text-align: center;
}

/* Footer styles */
.site-footer {
  background: rgba(33, 79, 61, 0.9);
  color: #fff;
  padding: 1rem;
  text-align: center;
  margin-top: 2rem;
}
.site-footer a {
  color: #e9c46a;
  text-decoration: underline;
}
.site-footer a:hover {
  color: #f4a261;
}

/* Timer display in question modal */
.timer-display {
  font-size: 0.9rem;
  font-weight: bold;
  color: #dc3545;
  margin-top: 0.5rem;
}

/* Summary modal overlay: reuse modal styles */
.summary-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.summary-overlay .modal-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  text-align: center;
}
.summary-overlay ul {
  list-style: none;
  padding-left: 0;
  margin: 1rem 0;
}
.summary-overlay li {
  font-size: 1.1rem;
  margin: 0.25rem 0;
}

header {
  background: rgba(33, 79, 61, 0.8);
  color: #fff;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
}

/* Scoreboard */
#scoreboard {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.team-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 0.5rem 1rem;
  min-width: 100px;
  text-align: center;
  border-left: 6px solid currentColor;
}

/* Highlight the team card when that team buzzes in. We use a bold black
   outline to stand out clearly against the light card background. */
.team-card.highlight {
  outline: 4px solid #000;
  outline-offset: 0;
}

.team-name {
  font-weight: bold;
  margin-bottom: 0.25rem;
  font-size: 1rem;
  letter-spacing: 0.5px;
}

.team-score {
  font-size: 1.5rem;
}

/* Board */
#board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 900px;
}

/* Make board adapt on smaller screens */
@media (max-width: 768px) {
  #board { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  #board { grid-template-columns: repeat(2, 1fr); }
}

/* Board cells */
.cell {
  background: rgba(43, 101, 75, 0.9);
  color: #fff;
  text-align: center;
  padding: 1rem 0.5rem;
  font-size: 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s ease;
}

/* Scale cell font slightly on small devices */
@media (max-width: 480px) {
  .cell { font-size: 1.05rem; padding: 0.9rem 0.4rem; }
}

/* Slight scale on hover to hint interactivity */
.cell:not(.category):hover {
  transform: scale(1.03);
}

.cell.used {
  background: #677a6b;
  pointer-events: none;
  color: transparent;
}

.cell.category {
  /* Distinct colour for category headers */
  background: rgba(210, 233, 210, 0.95);
  color: #214f3d;
  font-weight: bold;
  font-size: 1rem;
  letter-spacing: 0.5px;
  padding: 0.75rem 0.5rem;
  cursor: default;
}

/* Modal */
#modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#modal.hidden {
  display: none;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 650px;
  width: 95%;
}

@media (max-width: 480px) {
  .modal-content { padding: 1rem; }
}

.modal-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

/* Control buttons row within modal actions */
.control-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-start;
}

/* Layout for modal actions: first row (team buttons) and second row (controls) */
#team-select {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* Team selection buttons */
.team-button {
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  flex: 1 1 100px;
}

.team-button.selected {
  /* When a team is selected (e.g. a player buzzes in), make the button
     stand out with a bold black outline. A thicker border improves
     visibility compared to the previous grey outline. */
  outline: 5px solid #000;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

/* Ensure long team names don't overflow buttons */
.team-button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

button {
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  min-width: 90px;
}

/* Burnout button: used to discard a question when no one answers */
#burnout-btn, .burnout {
  background: #ffc107;
  color: #214f3d;
}

#show-answer {
  background: #1b4332;
  color: #fff;
}

#correct-btn {
  background: #28a745;
  color: #fff;
}

#wrong-btn {
  background: #dc3545;
  color: #fff;
}

#close-btn {
  background: #6c757d;
  color: #fff;
}

.hidden {
  display: none !important;
}

/* Setup overlay for choosing number of teams and their names */
.setup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.setup-content {
  background: rgba(255, 255, 255, 0.95);
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  /* Allow overlay contents to scroll on smaller screens. Without a
     max-height and overflow, long content like the joined player
     list would push the modal beyond the viewport and prevent
     scrolling. Setting a relative max-height keeps the modal within
     view and makes it scrollable on mobile. */
  max-height: 90vh;
  overflow-y: auto;
}

#team-names {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#team-names label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

#team-count {
  margin-left: 0.5rem;
  padding: 0.25rem;
}

#start-game-btn {
  margin-top: 1rem;
  background: #2d6a4f;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

/* Buzzer info section in setup overlay */
.buzzer-info {
  margin-top: 1.5rem;
  text-align: left;
}
.buzzer-info h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: #2d6a4f;
}
.buzzer-info p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #214f3d;
}
.buzzer-info a {
  color: #386fa4;
  text-decoration: underline;
}

/* Preview buzzers within the setup overlay. These small coloured cards give
   hosts a quick visual of what each team’s manual buzzer looks like. */
.buzzer-preview-container {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-start;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.buzzer-preview {
  width: 60px;
  height: 90px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  color: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
/* Specific colours for each preview card */
.buzzer-preview.green { background: #2d6a4f; }
.buzzer-preview.blue  { background: #386fa4; }
.buzzer-preview.yellow{ background: #e9c46a; color: #214f3d; }
.buzzer-preview.red   { background: #e76f51; }

/* ======================================================================
   Phone buzzer configuration section on the host setup screen
   These rules style the phone buzzer UI shown on the setup overlay.
====================================================================== */
.phone-section {
  margin-top: 1.5rem;
  text-align: left;
}
.phone-section h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: #2d6a4f;
}
.phone-section p {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #214f3d;
}
#phone-room-info p {
  margin: 0.25rem 0;
}
#phone-room-info canvas {
  margin-top: 0.5rem;
  border: 1px solid #a3b18a;
  border-radius: 4px;
}

/* ======================================================================
   Styles for the buzzer page. These rules customise the join and buzz
   screens shown on players’ phones. They reuse the same forest backdrop
   but simplify layout for smaller screens.
====================================================================== */
.buzzer-body {
  margin: 0;
  font-family: Arial, sans-serif;
  background-image: url('assets/bg.png');
  background-size: cover;
  background-position: center;
  background-color: rgba(255, 255, 255, 0.85);
  background-blend-mode: lighten;
  color: #214f3d;
}
.buzzer-main {
  max-width: 420px;
  margin: 2rem auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-height: 700px) {
  .buzzer-main { margin: 1rem auto; }
}
.card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.card h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.4rem;
}
.row {
  margin-bottom: 0.75rem;
}
.row label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}
.row input,
.row select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 1rem;
  box-sizing: border-box;
}
.cta {
  margin-top: 1rem;
  text-align: center;
}
button.primary {
  background: #386fa4;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  font-size: 1.1rem;
}
button.primary:hover {
  background: #2f5f92;
}
.note {
  font-size: 0.9rem;
  color: #6c757d;
  margin-top: 0.5rem;
}
.big-buzz {
  margin: 1.5rem 0;
  text-align: center;
}
.buzz-btn {
  font-size: 2rem;
  padding: 1rem 2rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  color: #fff;
  width: 100%;
  max-width: 300px;
}

/* Larger buzz button on very small phones */
@media (max-width: 380px) {
  .buzz-btn { font-size: 2.2rem; padding: 1.25rem 2rem; }
}
.buzz-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.ghost {
  background: transparent;
  border: 1px solid #386fa4;
  color: #386fa4;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  font-size: 1rem;
}
button.ghost:hover {
  background: rgba(56, 111, 164, 0.1);
}

/* Styles for the joined players list on the host setup screen */
#player-list {
  /* Constrain the height of the joined players container and allow
     vertical scrolling when there are many names. Increasing the
     max-height slightly accommodates more names before scrolling.
     Overflow-y ensures the list doesn't expand the modal off screen. */
  max-height: 6rem;
  overflow-y: auto;
  margin-top: 0.5rem;
}
#players-ul {
  display: flex;
  flex-wrap: wrap;
  /* Tight gap so player name tags pack more densely */
  gap: 0.2rem;
  list-style: none;
  padding-left: 0;
  margin: 0;
}
#players-ul li {
  /* Style each player name as a compact pill. Smaller font size and
     reduced padding keep the pills narrow and allow more names per
     row. White-space prevents names from wrapping across lines. */
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #fff;
  margin: 2px;
  white-space: nowrap;
}