* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  padding: 0;
  margin: 0;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  /* background: linear-gradient(-45deg, #a6f4e5 0%, #23e6bf 47%); */
  /* background-color: rgb(44, 75, 255); */
  background-color: #fff;
  color: #1A2634;
  text-align: center;
}

body,
input,
button {
  font-size: 1em;
}

p {
  margin: 2em 0;
}

ol {
  text-align: left;
}

li {
  margin: 0.5em 0;
}

.hidden {
  display: none;
}

header {
  background-color: #fff;
}

.logo {
  width: 100%;
  max-width: 310px;
  max-height: 120px;
  padding: 1em 0;
}

.container {
  width: 100%;
  max-width: 1200px;
  padding: 1em;
  margin: 0 auto;
}

.view button:last-child {
  margin-bottom: 0;
}

.buzzer-mode {
  background-color: rgb(16, 21, 78);
  color: rgb(243, 175, 185);
}

input[type="text"],
input[type="number"],
button {
  display: block;
  padding: 0.8em 1.4em;
  margin: 1em 0;
  width: 100%;
  border-radius: 5px;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  font-weight: 500;
}

input[type="text"],
input[type="number"] {
  border: 1px solid #B8B8B8;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="text"]:active,
input[type="number"]:active {
  border-color: #2c4bff;
  box-shadow: 0 0 0 3px #ABB7FF;
  outline: none;
}

button {
  padding: 1.4em 1.4em;
  font-size: 1.2em;
  background-color: #161D99;
  color: #fff;
  cursor: pointer;
  border: 0;
}

button:hover {
  background-color: rgb(22, 29, 153);
}

button:active {
  box-shadow: rgb(171, 183, 255) 0px 0px 0px 3px;
  outline: 0px;
  transform: translateY(  1px);
}
button:focus {
  box-shadow: 0 0 0 3px #ABB7FF;
}

.main-image {
  width: 90%;
  max-width: 500px;
}

.buzzer {
  height: 10em;
  font-size: 2em;
  background-color: rgb(243, 175, 185);
  color: rgb(18, 30, 102);
}
.buzzer:focus {
  box-shadow: 0 0 0 3px #ABB7FF;
}
.buzzer:hover,
.buzzer:active {
  background-color: #e97284;
}

.secondary {
  background-color: #fff;
  color: rgb(16, 21, 78);
}

.secondary:hover {
  background-color: rgb(44, 75, 255);
}

/* Host Page Styles */
.host-page header {
  padding: 1em 0;
  border-bottom: 1px solid #efefef;
}

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

.mb-4 {
  margin-bottom: 2rem;
}

.card {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
}

.section-title {
  font-size: 1.5rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: #161D99;
}

.subsection-title {
  font-size: 1.2rem;
  margin: 1rem 0;
  color: #1A2634;
}

.game-code {
  font-weight: 500;
}

.code {
  font-weight: 700;
  color: #161D99;
  background-color: #f5f5f5;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.qr-container {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 200px;
  margin: 1rem auto;
}

.qr-container #qrcode {
  width: 100%;
  display: flex;
  justify-content: center;
}

.qr-container #qrcode img {
  max-width: 100%;
  height: auto;
}

.qr-container p {
  color: #666;
  margin: 0.5rem 0 0 0;
}

.full-width {
  width: 100%;
}

.game-stats-table {
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.game-stats-table th {
  padding: 0.75rem;
  background-color: #f5f5f5;
  font-weight: 600;
  border-bottom: 2px solid #ddd;
}

.game-stats-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #eee;
}

.team-name {
  font-weight: 500;
}

.team-score {
  font-weight: 700;
  color: #161D99;
}

.divider {
  border-top: 2px solid #eee;
}

.buzz-list {
  list-style-position: inside;
  padding-left: 0;
}

.buzz-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: #f9f9f9;
  border-radius: 4px;
}

.buzz-name {
  font-weight: 500;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  width: auto;
  margin: 0;
}

.btn-large {
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
  width: auto;
}

.award-point-btn {
  background-color: #22c55e;
}

.award-point-btn:hover {
  background-color: #16a34a;
}

.actions {
  margin-top: 2rem;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .buzz-item {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .award-point-btn {
    margin-top: 0.5rem;
    width: 100%;
  }
}

.game-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 768px) {
  .game-layout {
    flex-direction: row;
  }
  
  .game-stats {
    flex: 1;
  }
  
  .buzzer-container {
    flex: 1;
  }
}

/* NEW CSS FOR HOMEPAGE LAYOUT */
.home-layout {
  display: flex;
  flex-direction: column; /* Mobile-first: stacked */
  align-items: center; /* Center items when stacked */
  gap: 2rem; /* Space between image and form when stacked */
}

.home-image-container,
.home-form-container {
  width: 100%; /* Full width when stacked */
}

.home-form-container {
  display: flex;
  flex-direction: column;
  align-items: center; /* Center form elements */
}

/* Ensure the form itself and the create game button take up a reasonable width */
.home-form-container .js-join,
.home-form-container .js-create-game {
  width: 100%;
  max-width: 400px; /* Max width for form elements, adjust as needed */
}


@media (min-width: 768px) { /* Desktop breakpoint */
  .home-layout {
    flex-direction: row; /* Side-by-side */
    align-items: flex-start; /* Align items to the top */
    justify-content: center; /* Center the whole layout if it doesn't fill the container */
  }

  .home-image-container {
    flex: 0 0 40%; /* Example: Image takes up 40% of the width, doesn't grow, doesn't shrink */
    /* Or use flex: 1; if you want it to grow equally with the form */
    /* padding-right: 1rem; Removed as gap on parent is better */
    display: flex; /* To center the image if it's smaller than the container */
    justify-content: center;
    align-items: center;
  }

  .home-form-container {
    flex: 0 0 50%; /* Example: Form takes up 50% of the width */
    /* Or use flex: 1; */
    /* padding-left: 1rem; Removed as gap on parent is better */
    align-items: stretch; /* Stretch form elements to fill container width */
  }

  .home-form-container .js-join,
  .home-form-container .js-create-game {
    max-width: none; /* Allow form elements to use the full width of the form container on desktop */
  }
}

/* Dark Mode Styles */
:root {
  --light-bg: #fff;
  --light-text: #1A2634;
  --light-card-bg: #fff;
  --light-input-bg: #fff;
  --light-input-border: #B8B8B8;
  --light-input-focus-border: #2c4bff;
  --light-input-focus-shadow: #ABB7FF;
  --light-btn-bg: #161D99;
  --light-btn-text: #fff;
  --light-btn-hover-bg: rgb(22, 29, 153);
  --light-btn-active-shadow: rgb(171, 183, 255);
  --light-secondary-btn-bg: #fff;
  --light-secondary-btn-text: rgb(16, 21, 78);
  --light-secondary-btn-hover-bg: rgb(230, 230, 230); /* Adjusted for better visibility */
  --light-buzzer-bg: rgb(243, 175, 185);
  --light-buzzer-text: rgb(18, 30, 102);
  --light-buzzer-hover-bg: #e97284;
  --light-header-border: #efefef;
  --light-section-title: #161D99;
  --light-subsection-title: #1A2634;
  --light-code-bg: #f5f5f5;
  --light-code-text: #161D99;
  --light-table-header-bg: #f5f5f5;
  --light-table-border: #ddd;
  --light-table-row-border: #eee;
  --light-buzz-item-bg: #f9f9f9;
  --light-award-btn-bg: #22c55e;
  --light-award-btn-hover-bg: #16a34a;


  --dark-bg: #222831;
  --dark-surface: #393E46;
  --dark-text: #DFD0B8;
  --dark-accent: #948979; /* For borders, secondary text */
  --dark-primary-action: #948979; /* Or a brighter color from palette if needed for main buttons */
  --dark-primary-action-text: #222831;
}

body.dark-mode {
  background-color: var(--dark-bg);
  color: var(--dark-text);
}

body.dark-mode header {
  background-color: var(--dark-surface); /* Or var(--dark-bg) if header should blend more */
  border-bottom-color: var(--dark-accent);
}

body.dark-mode .logo {
  /* If logo has transparency or needs adjustment for dark mode */
  /* filter: invert(1) hue-rotate(180deg); /* Example filter */
}

body.dark-mode input[type="text"],
body.dark-mode input[type="number"] {
  background-color: var(--dark-surface);
  color: var(--dark-text);
  border: 1px solid var(--dark-accent);
}

body.dark-mode input[type="text"]:focus,
body.dark-mode input[type="number"]:focus,
body.dark-mode input[type="text"]:active,
body.dark-mode input[type="number"]:active {
  border-color: var(--dark-primary-action); /* Using accent for focus, or a brighter color */
  box-shadow: 0 0 0 3px var(--dark-accent); /* Adjust shadow color */
}

body.dark-mode button {
  background-color: var(--dark-primary-action);
  color: var(--dark-primary-action-text); /* Text color for buttons */
}

body.dark-mode button:hover {
  background-color: #a59a8a; /* Slightly lighter/darker version of --dark-primary-action */
}

body.dark-mode button:active,
body.dark-mode button:focus {
  box-shadow: 0 0 0 3px var(--dark-surface); /* Adjust shadow color */
}

body.dark-mode .buzzer {
  background-color: var(--dark-primary-action);
  color: var(--dark-primary-action-text);
}
body.dark-mode .buzzer:hover,
body.dark-mode .buzzer:active {
  background-color: #a59a8a; /* Slightly lighter/darker version of --dark-primary-action */
}

body.dark-mode .secondary {
  background-color: var(--dark-surface);
  color: var(--dark-text);
  border: 1px solid var(--dark-accent);
}

body.dark-mode .secondary:hover {
  background-color: #4a5058; /* Slightly lighter version of --dark-surface */
}

body.dark-mode .host-page header {
  border-bottom: 1px solid var(--dark-accent);
}

body.dark-mode .card {
  background-color: var(--dark-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); /* Darker shadow for dark mode */
}

body.dark-mode .section-title {
  color: var(--dark-text); /* Or a specific accent color from your palette */
}

body.dark-mode .subsection-title {
  color: var(--dark-text);
}

body.dark-mode .code {
  color: var(--dark-bg); /* Text on code block */
  background-color: var(--dark-accent); /* Background of code block */
  border: 1px solid var(--dark-surface);
}

body.dark-mode .game-stats-table th {
  background-color: var(--dark-surface); /* Darker header for table */
  color: var(--dark-text);
  border-bottom: 2px solid var(--dark-accent);
}

body.dark-mode .game-stats-table td {
  border-bottom: 1px solid var(--dark-accent);
}

body.dark-mode .team-score {
  color: var(--dark-text); /* Or a brighter highlight color if needed */
}

body.dark-mode .divider {
  border-top: 2px solid var(--dark-accent);
}

body.dark-mode .buzz-list {
  /* Potentially no change needed if items are styled individually */
}

body.dark-mode .buzz-item {
  background-color: var(--dark-surface); /* Slightly different from card for depth */
  border: 1px solid var(--dark-accent);
  color: var(--dark-text);
}

body.dark-mode .award-point-btn {
  background-color: #7a7060; /* Muted version of an award color, from palette */
  color: var(--dark-bg);
}

body.dark-mode .award-point-btn:hover {
  background-color: #6b6253;
}

/* Adjusting colors for the primary action button on the buzzer page */
body.dark-mode .js-join button[type='submit'] {
  background-color: var(--dark-primary-action); /* Use the main accent from the palette */
  color: var(--dark-primary-action-text);
}
body.dark-mode .js-join button[type='submit']:hover {
  background-color: #a59a8a; /* Slightly lighter/darker for hover */
}

/* Adjusting colors for the create game button on the buzzer page */
body.dark-mode .js-create-game {
  background-color: var(--dark-surface); /* A more subdued button */
  color: var(--dark-text);
  border: 1px solid var(--dark-accent);
}
body.dark-mode .js-create-game:hover {
   background-color: #4a5058;
}

body.dark-mode .js-error-message {
  color: #ff6b6b; /* A light red for errors in dark mode */
}

/* Ensure default browser styles for placeholder text are overridden if needed */
body.dark-mode input::placeholder {
  color: var(--dark-accent);
  opacity: 0.7;
}
body.dark-mode input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
  color: var(--dark-accent);
  opacity: 0.7;
}
body.dark-mode input::-moz-placeholder { /* Firefox 19+ */
  color: var(--dark-accent);
  opacity: 0.7;
}
body.dark-mode input:-ms-input-placeholder { /* IE 10+ */
  color: var(--dark-accent);
  opacity: 0.7;
}
body.dark-mode input:-moz-placeholder { /* Firefox 18- */
  color: var(--dark-accent);
  opacity: 0.7;
}

/* Dark mode styles for QR code */
body.dark-mode .qr-container {
  background: var(--dark-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .qr-container p {
  color: var(--dark-text);
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.header-buttons .btn {
  padding: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background-color: var(--light-btn-bg);
  color: var(--light-btn-text);
  transition: all 0.2s ease;
}

.header-buttons .btn:hover {
  background-color: var(--light-btn-hover-bg);
}

.header-buttons .btn.active {
  background-color: var(--light-btn-hover-bg);
}

/* Dark mode styles for header buttons */
body.dark-mode .header-buttons .btn {
  background-color: var(--dark-primary-action);
  color: var(--dark-primary-action-text);
}

body.dark-mode .header-buttons .btn:hover,
body.dark-mode .header-buttons .btn.active {
  background-color: #a59a8a;
}
