/* Design system tokens */
:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --accent: #e040fb;
  --error: #ef4444;
  --text: #f0f0f0;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 16px;
  --sp-lg: 24px;
  --sp-xl: 32px;
  --sp-2xl: 48px;
  --sp-3xl: 64px;

  /* Game state tokens */
  --correct: #22c55e;
  --wrong: #ef4444;
  --timer-urgent: #ef4444;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Player join screen ── */

.join-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 320px;
  margin: 0 auto;
  padding: var(--sp-3xl) var(--sp-lg);
}

.game-title {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--sp-2xl);
  text-align: center;
}

.join-input {
  width: 100%;
  height: 44px;
  padding: 0 var(--sp-md);
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 8px;
  outline: none;
}

.join-input:focus {
  border-color: var(--accent);
}

.join-input::placeholder {
  color: rgba(240, 240, 240, 0.5);
}

.join-btn {
  width: 100%;
  height: 44px;
  margin-top: var(--sp-md);
  font-size: 18px;
  font-weight: 600;
  background: var(--accent);
  color: var(--text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.join-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.error-msg {
  font-size: 14px;
  color: var(--error);
  margin-top: var(--sp-sm);
  min-height: 20px;
}

/* ── Player waiting screen ── */

.waiting-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-3xl) var(--sp-lg);
}

.waiting-name {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: var(--sp-md);
}

.waiting-msg {
  font-size: 16px;
  opacity: 0.8;
}

.waiting-sub {
  font-size: 14px;
  opacity: 0.6;
  margin-top: var(--sp-sm);
}

/* ── Host lobby screen ── */

.host-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-xl);
}

.host-title {
  font-size: 48px;
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: var(--sp-xl);
}

.lobby-layout {
  display: flex;
  gap: var(--sp-2xl);
  align-items: flex-start;
  width: 100%;
  max-width: 900px;
}

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
  flex-shrink: 0;
}

.qr-label {
  font-size: 24px;
  font-weight: 400;
}

.player-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  flex: 1;
}

.player-chip {
  background: var(--surface);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: 8px;
  font-size: 20px;
  animation: pop-in 300ms ease-out;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.player-count {
  font-size: 36px;
  font-weight: 600;
  color: var(--accent);
  margin-top: var(--sp-lg);
}

.empty-state {
  font-size: 20px;
  opacity: 0.6;
}

/* ── Host game views ── */

.fade-transition {
  transition: opacity 300ms ease-in-out;
}

.host-round-label {
  font-size: 20px;
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: var(--sp-md);
}

.host-word {
  font-size: 96px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  text-align: center;
}

.host-timer {
  font-size: 96px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
}

.host-answer-count {
  font-size: 28px;
  font-weight: 400;
  line-height: 1.4;
}

/* Round view layout */
#round-view {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--sp-xl);
}

.round-top {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.round-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: var(--sp-xl);
}

/* Reveal view */
#reveal-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl);
}

.reveal-heading {
  font-size: 48px;
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: var(--sp-lg);
  text-align: center;
}

.reveal-word {
  font-size: 96px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  text-align: center;
  margin-bottom: var(--sp-lg);
}

.reveal-funfact {
  font-size: 28px;
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  max-width: 800px;
  margin-bottom: var(--sp-2xl);
}

.scoreboard-heading {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: var(--sp-md);
  align-self: flex-start;
}

.scoreboard-list {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}

.scoreboard-row {
  display: flex;
  align-items: center;
  font-size: 28px;
  font-weight: 400;
  padding: var(--sp-sm) 0;
}

.scoreboard-rank {
  width: 48px;
  font-weight: 400;
}

.scoreboard-rank-top {
  color: var(--accent);
  font-weight: 600;
}

.scoreboard-name {
  flex: 1;
}

.scoreboard-score {
  font-weight: 600;
  text-align: right;
}

/* Final view */
#final-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl);
}

.final-heading {
  font-size: 48px;
  font-weight: 600;
  margin-bottom: var(--sp-2xl);
}

/* ── Player game views ── */

.answer-btn {
  width: 100%;
  min-height: 64px;
  padding: 0 var(--sp-md);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: var(--sp-md);
}

.answer-btn.selected {
  background: var(--accent);
  color: #fff;
}

.answer-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.answer-btn.unselected-locked {
  opacity: 0.4;
}

/* Answer view */
#answer-view {
  display: flex;
  flex-direction: column;
  padding: var(--sp-3xl) var(--sp-md) var(--sp-md);
  min-height: 100vh;
}

.answer-prompt {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  margin-bottom: var(--sp-sm);
}

.answer-round-label {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.7;
  margin-bottom: var(--sp-2xl);
}

.answer-buttons {
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: center;
}

/* Locked view */
#locked-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-3xl) var(--sp-md) var(--sp-md);
  min-height: 100vh;
}

.locked-buttons {
  width: 100%;
  margin-bottom: var(--sp-xl);
}

.locked-msg {
  font-size: 18px;
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
}

.locked-sub {
  font-size: 16px;
  font-weight: 400;
  opacity: 0.7;
  text-align: center;
  margin-top: var(--sp-sm);
}

/* Result view */
#result-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-3xl) var(--sp-md);
  text-align: center;
}

.result-correct {
  color: var(--correct);
  font-size: 28px;
  font-weight: 600;
}

.result-wrong {
  color: var(--wrong);
  font-size: 28px;
  font-weight: 600;
}

.result-timeout {
  color: var(--text);
  font-size: 28px;
  font-weight: 400;
  opacity: 0.8;
}
