*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1f0a17;
  --surface: #3e1627;
  --primary: #e94560;
  --pink-sheep: #ff79c6;
  --text: #eaeaea;
  --muted: #888;
  --border: #333;
  --radius: 12px;
  --max-width: 560px;
}

/* Light mode — applied when data-theme="light" is set manually */
:root[data-theme="light"] {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --primary: #e94560;
  --pink-sheep: #d63aab;
  --text: #1a1a2e;
  --muted: #666;
  --border: #ddd;
}

/* Light mode — default when system prefers light and user hasn't overridden */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --primary: #e94560;
    --pink-sheep: #d63aab;
    --text: #1a1a2e;
    --muted: #666;
    --border: #ddd;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

main {
  width: 100%;
  max-width: var(--max-width);
}

.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

h1 { font-size: 2.5rem; letter-spacing: -0.5px; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--muted); }

.tagline { color: var(--muted); font-size: 1rem; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* Inputs */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-align: left;
}

input[type="text"],
input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input:focus { border-color: var(--primary); }
input:disabled { opacity: 0.5; }

/* Buttons */
button, .button {
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem 1.5rem;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
  display: inline-block;
}

button:hover, .button:hover { opacity: 0.85; }
button:active, .button:active { transform: scale(0.97); }

/* Divider */
.divider {
  color: var(--muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border);
}

/* Code box */
.code-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.code-box button {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
}

/* Player list */
.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  min-height: 2rem;
}

.player-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}

.player-chip.host { border-color: var(--primary); }

/* Badges */
.badge {
  background: var(--primary);
  border-radius: 999px;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Round label */
.round-label {
  color: var(--muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Answer form */
#answer-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 400px;
}

#answer-input { flex: 1; }

/* Timer bar */
#timer-bar-wrap {
  width: 100%;
  max-width: 400px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: var(--primary);
  border-radius: 999px;
}

/* Answer groups (reveal) */
.answer-group {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.answer-group.majority { border-color: #4ade80; }

.answer-text {
  font-weight: 700;
  font-size: 1.1rem;
  flex: 1;
  text-align: left;
}

.answer-players {
  color: var(--muted);
  font-size: 0.875rem;
}

.majority-badge { background: #4ade80; color: #000; }

/* Scoreboard */
#scoreboard, #final-scoreboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

.score-row.pink-sheep { border-color: var(--pink-sheep); }

/* Winner screen */
.winner-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

/* Voting */
.voting-answers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.answer-chip {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.4rem 1rem;
  transition: border-color 0.15s, background 0.15s;
}

.answer-chip:hover { border-color: var(--primary); }
.answer-chip.selected { background: var(--primary); border-color: var(--primary); }

#voting-proposals, #host-voting-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.proposal-row, .approved-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}

.proposal-row span:first-child,
.approved-row span:first-child { flex: 1; }

.accept-btn, .remove-merge-btn {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 6px;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
}

.accept-btn { color: #4ade80; }
.remove-merge-btn { color: var(--primary); }
.sheep-chosen { border-color: var(--pink-sheep); }

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.4rem 0.6rem;
  z-index: 100;
  transition: border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--primary); opacity: 1; }
.theme-toggle:active { transform: scale(0.95); }

/* Logo */
.logo-lg {
  width: 100%;
  max-width: 420px;
  height: auto;
  display: block;
}

.logo-sm {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  width: 110px;
  height: auto;
  z-index: 99;
  display: block;
}

/* Utility */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--primary); font-size: 0.875rem; }
.submitted-msg { color: #4ade80; }
