:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.7);
  --panel-light: rgba(248, 250, 252, 0.9);
  --accent: #f97316;
  --text: #f1f5f9;
  --text-dark: #0f172a;
  --border: rgba(255, 255, 255, 0.2);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1d4ed8, #020617 60%);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.hero {
  padding: 2.5rem 5vw;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.layout {
  flex: 1;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  padding: 2rem 5vw 3rem;
}

.panel {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 1.25rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.panel h2 {
  margin-top: 0;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
  gap: 0.4rem;
}

input,
select,
button {
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  font-family: inherit;
}

input,
select {
  background: rgba(2, 6, 23, 0.6);
  color: var(--text);
}

button {
  background: var(--accent);
  color: #1b1b1b;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.status p {
  margin: 0.2rem 0;
}

.status-grid {
  display: grid;
  gap: 0.5rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.buzzer {
  background: transparent;
  border: none;
  padding: 0;
  width: 200px;
  height: 200px;
  max-width: 60vw;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

.buzzer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 1rem;
  transition: filter 0.2s ease;
}

.buzzer img.grayscale {
  filter: grayscale(0.7);
}

.mute-btn {
  min-width: 140px;
  background: rgba(248, 250, 252, 0.15);
  color: var(--text);
  border: 1px solid rgba(248, 250, 252, 0.4);
}

.audio-controls {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

.audio-controls .mute-btn {
  min-width: 160px;
}

.current-answer {
  margin: 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.queue-table-wrapper {
  margin-top: 1rem;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(248, 250, 252, 0.8);
}

td.placeholder,
.placeholder {
  text-align: center;
  opacity: 0.7;
  font-style: italic;
}

.participants ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.participants li {
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--border);
  display: flex;
  justify-content: space-between;
}

#messages {
  margin-top: 1rem;
  min-height: 1.5rem;
  font-size: 0.95rem;
  color: #fde68a;
}

#messages[data-tone='error'] {
  color: #fecdd3;
}

.penalty {
  min-height: 1.25rem;
  font-size: 0.9rem;
  color: #bfdbfe;
  margin-top: 0.5rem;
}

.hint {
  font-size: 0.85rem;
  opacity: 0.8;
}

.host-only {
  display: none;
}

body.is-host .host-only {
  display: block;
}

.host-only-col {
  display: none;
}

body.is-host .host-only-col {
  display: table-cell;
}

.host-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.host-control-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.host-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.scoreboard table,
.history-list {
  margin-top: 0.5rem;
}

.history-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 0.75rem;
  padding: 0.75rem;
}

.history-entry {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-entry:last-child {
  border-bottom: none;
}

.history-entry h4 {
  margin: 0;
  font-size: 0.95rem;
}

.history-entry small {
  color: rgba(248, 250, 252, 0.7);
}

button.success {
  background: #22c55e;
  color: #042f2e;
}

button.danger {
  background: #ef4444;
  color: #fff;
}

.messages,
.penalty,
.history-entry {
  word-break: break-word;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.7);
}

@media (max-width: 600px) {
  .actions,
  .host-control-row,
  .host-buttons {
    flex-direction: column;
    align-items: stretch;
  }
  button,
  input,
  select {
    font-size: 1.05rem;
  }
}
