:root {
  color-scheme: dark;
  --bg: #14121f;
  --bg-alt: #1e1b2e;
  --card: #262240;
  --text: #f5f3ff;
  --muted: #a79fc9;
  --primary: #ff5da2;
  --primary-dark: #d63f82;
  --accent: #6ee7b7;
  --danger: #ff8080;
  --border: #3a3560;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px;
  text-align: center;
  gap: 14px;
}

.view.active {
  display: flex;
}

h1, h2 {
  margin: 0 0 4px;
}

.logo {
  font-size: 2.4rem;
}

.tagline {
  color: var(--muted);
  max-width: 320px;
  margin: 0 0 12px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--border);
  cursor: pointer;
  width: 100%;
  max-width: 320px;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #1a0d14;
}

.btn-huge {
  padding: 28px 20px;
  font-size: 1.4rem;
}

.btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.btn-random {
  background: var(--bg-alt);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-okay {
  background: var(--card);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-confirm {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c2b20;
}

.hidden {
  display: none !important;
}

.text-input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  font-size: 1.1rem;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  text-align: center;
}

.code-input {
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 700;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.category-card {
  padding: 16px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--card);
  cursor: pointer;
  text-align: left;
}

.category-card:active {
  border-color: var(--primary);
}

.category-card .cat-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.category-card .cat-count {
  color: var(--muted);
  font-size: 0.85rem;
}

.room-code {
  color: var(--primary);
  letter-spacing: 0.2em;
}

.muted {
  color: var(--muted);
}

.hint {
  color: var(--muted);
  max-width: 300px;
  font-size: 0.95rem;
}

.player-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-list li {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--border);
}

.waiting-msg {
  color: var(--muted);
  font-style: italic;
}

.countdown-number {
  font-size: 8rem;
  font-weight: 800;
  color: var(--primary);
}

.view-display {
  padding: 16px;
  justify-content: space-between;
  position: relative;
}

.rotate-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  color: var(--text);
}

.word-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  transition: transform 0.2s ease;
}

.word-stage.flipped {
  transform: rotate(180deg);
}

.word-emoji {
  font-size: 5rem;
}

.word-text {
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.15;
}

.confirm-zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}

.standings {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.standing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.standing-rank {
  font-weight: 800;
  color: var(--accent);
  width: 2.5em;
}

.standing-name {
  flex: 1;
  text-align: left;
  padding: 0 8px;
}

.standing-score {
  color: var(--muted);
}

.error {
  color: var(--danger);
  min-height: 1.2em;
}

.host-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: rgba(20, 18, 31, 0.9);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

body.host-bar-visible #app {
  padding-top: 52px;
}

.host-control-btn {
  appearance: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 12px;
}

.host-control-warn {
  border-color: var(--danger);
  color: var(--danger);
}

.rank-dnf {
  color: var(--muted);
}

.btn-danger-link {
  color: var(--danger);
  margin-top: 4px;
}
