:root {
  --bg: #f2ecdb;
  --card: #fffdf7;
  --card-2: #f2e6d0;
  --accent: #cc8a4c;
  --accent-2: #7e9163;
  --danger: #b5504c;
  --good: #7e9163;
  --warn: #b8860b;
  --text: #3a2e22;
  --text-dim: #8a7a63;
  --border: #e3d5b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #f8f2e2, var(--bg));
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 16px;
}

.hidden { display: none !important; }

.screen {
  max-width: 720px;
  margin: 0 auto;
}

.top-nav {
  max-width: 720px;
  margin: 0 auto 8px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 0;
  text-decoration: underline;
}
.link-btn:hover { color: var(--text); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}

h1, h2, h3 { margin-top: 0; }
h3 { font-size: 1.1rem; }

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}
.logo h1 { font-size: 2rem; margin: 0; }
.mascot { flex-shrink: 0; }
.tagline { text-align: center; color: var(--text-dim); margin-top: 0; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

input, select {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-size: 1rem;
}

input::placeholder { color: var(--text-dim); }

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a7a63' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
}

.btn-primary, .btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}

.btn-secondary {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.error { color: var(--danger); font-size: 0.9rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.room-code {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.room-code span { color: var(--accent-2); font-size: 1.4rem; }

.round-badge { color: var(--text-dim); font-size: 0.9rem; }

.player-list { list-style: none; padding: 0; margin: 0 0 12px; }
.player-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.player-list li:last-child { border-bottom: none; }
.tag-host { color: var(--accent-2); font-size: 0.75rem; margin-left: 6px; }
.tag-offline { color: var(--danger); font-size: 0.75rem; margin-left: 6px; }
.tag-team { font-size: 0.75rem; padding: 2px 8px; border-radius: 8px; background: var(--card-2); margin-left: 6px; }
.tag-eliminated { color: white; background: var(--danger); font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 8px; margin-left: 6px; letter-spacing: 0.5px; }
.player-list li.eliminated { opacity: 0.55; }
.player-list li.eliminated span:first-child { text-decoration: line-through; }

.elimination-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--danger);
  background: var(--card-2);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 0 12px;
}

.golden-note {
  text-align: center;
  font-size: 0.9rem;
  color: var(--warn);
  background: var(--card-2);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 0 12px;
  font-weight: 600;
}

.value-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 8px;
  margin-left: 6px;
  white-space: nowrap;
}
.value-badge.golden { background: var(--warn); color: white; }
.value-badge.speed { background: var(--accent-2); color: white; }

#btn-auto-assign-teams { margin-top: 4px; }

.hint { color: var(--text-dim); font-size: 0.9rem; }

.team-buttons { display: flex; gap: 8px; }
.team-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
.team-btn.selected { background: var(--accent); border-color: var(--accent); color: white; }

.row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; }
.row-inline { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.row-inline input { margin-bottom: 0; }

.duration-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.duration-row label { font-weight: 600; font-size: 1.1rem; }
.duration-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.duration-field input {
  width: 80px;
  margin-bottom: 0;
  text-align: center;
}
.duration-field span { color: var(--text-dim); font-size: 0.95rem; }

.team-mode-section {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.team-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.team-mode-header h3 { margin-bottom: 4px; }
.team-mode-header .hint { margin: 0; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.15s ease;
}
.switch input:checked + .switch-track { background: var(--accent-2); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }

.timer {
  font-size: 2.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.timer.warn { color: var(--danger); }

.prompt-banner {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.answer-input-row { display: flex; gap: 8px; }
.answer-input-row input { margin-bottom: 4px; }
.answer-input-row button { width: auto; padding: 0 20px; }

.feedback { min-height: 1.2em; font-size: 0.9rem; margin: 4px 0 14px; color: var(--text-dim); }
.feedback.ok { color: var(--good); }
.feedback.bad { color: var(--danger); }

.round-body {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.feed-panel, .score-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  flex: 1;
  min-width: 240px;
}

.count-badge {
  background: var(--accent);
  color: white;
  border-radius: 10px;
  padding: 2px 9px;
  font-size: 0.8rem;
}

.answer-feed { list-style: none; margin: 10px 0 0; padding: 0; max-height: 320px; overflow-y: auto; }
.answer-feed li {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.95rem;
}
.answer-feed li:last-child { border-bottom: none; }
.answer-feed .who { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.strike-btn {
  background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.8rem; padding: 0 4px;
}

.mini-scoreboard { list-style: none; margin: 10px 0 0; padding: 0; }
.mini-scoreboard li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.mini-scoreboard li:last-child { border-bottom: none; }

.winner-banner { text-align: center; font-size: 1.4rem; }

.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 50;
  font-size: 0.9rem;
}

.suggestion-box {
  max-width: 720px;
  margin: 40px auto 12px;
  text-align: center;
}
.suggestion-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px;
  opacity: 0.75;
}
.suggestion-toggle:hover { opacity: 1; color: var(--text); }
.suggestion-form {
  margin-top: 10px;
  text-align: left;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.suggestion-form .row-inline { margin-bottom: 6px; }
.suggestion-form input { flex: 1; font-size: 0.85rem; padding: 10px 12px; margin-bottom: 0; }
.suggestion-form button { width: auto; padding: 0 16px; margin-top: 0; font-size: 0.85rem; }
.suggestion-form .feedback { text-align: center; font-size: 0.8rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(58, 46, 34, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.modal-header h3 { margin-bottom: 0; }

.suggestions-list { list-style: none; margin: 8px 0 0; padding: 0; }
.suggestions-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.suggestions-list li:last-child { border-bottom: none; }
.suggestion-text { font-size: 0.92rem; }
.suggestion-text .who { color: var(--text-dim); font-size: 0.8rem; }

.bump-btn {
  flex-shrink: 0;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
.bump-btn:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: white; }
.bump-btn.bumped, .bump-btn:disabled {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: white;
  opacity: 0.85;
  cursor: default;
}

@media (max-width: 480px) {
  .logo h1 { font-size: 1.6rem; }
  .mascot { width: 40px; height: 40px; }
  .timer { font-size: 2rem; }
}
