/* ─── Variables ────────────────────────────────────────────── */
:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --card: #1e1e38;
  --border: #2e2e50;
  --text: #e8e8f4;
  --text-dim: #8888aa;
  --team0: #4361ee;
  --team0-light: #6382ff;
  --team1: #e63946;
  --team1-light: #ff5c68;
  --success: #2dc653;
  --warn: #f7b731;
  --danger: #e63946;
  --radius: 12px;
  --radius-sm: 8px;
}

/* ─── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Screens ──────────────────────────────────────────────── */
.screen {
  display: none;
  width: 100%;
  max-width: 520px;
  padding: 24px 16px 40px;
  flex-direction: column;
  align-items: center;
}
.screen.active { display: flex; }

/* ─── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Inputs ───────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--team0); }
.input::placeholder { color: var(--text-dim); }

.code-input {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  flex: 1;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 20px;
  transition: opacity 0.15s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--team0); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--team0-light); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--text-dim); }
.btn-success { background: var(--success); color: #fff; font-size: 20px; padding: 18px; }
.btn-success:hover:not(:disabled) { opacity: 0.9; }
.btn-block { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 18px; padding: 4px; color: var(--text-dim); }
.btn-icon:hover { color: var(--text); }

/* ─── Divider ──────────────────────────────────────────────── */
.divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  position: relative;
  padding: 4px 0;
}

.join-row { display: flex; gap: 8px; align-items: center; }

/* ─── Error message ────────────────────────────────────────── */
.error-msg {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  padding: 4px 0;
}
.hidden { display: none !important; }

/* ─── HOME SCREEN ──────────────────────────────────────────── */
.home-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding-top: 32px;
}
.home-logo { font-size: 56px; line-height: 1; }
.home-title { font-size: 36px; font-weight: 800; letter-spacing: -1px; }
.home-sub { color: var(--text-dim); font-size: 15px; margin-top: -8px; }

/* ─── LOBBY SCREEN ─────────────────────────────────────────── */
.lobby-header {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  margin-bottom: 20px;
  width: 100%;
  justify-content: center;
}
.room-code-label { color: var(--text-dim); font-size: 13px; }
.room-code-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--team0);
}

.section-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.section-sub { color: var(--text-dim); font-size: 14px; text-align: center; margin-bottom: 16px; }

.player-list { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.player-row.team-0 { border-left: 3px solid var(--team0); }
.player-row.team-1 { border-left: 3px solid var(--team1); }

.player-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.player-row.team-0 .player-avatar { background: var(--team0); }
.player-row.team-1 .player-avatar { background: var(--team1); }

.player-name-wrap { flex: 1; }
.player-display-name { font-weight: 600; font-size: 15px; }
.player-tags { display: flex; gap: 4px; margin-top: 2px; }
.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tag-host { background: #7209b7; color: #fff; }
.tag-you { background: var(--border); color: var(--text-dim); }
.tag-t0 { background: var(--team0); color: #fff; }
.tag-t1 { background: var(--team1); color: #fff; }
.tag-unassigned { background: var(--border); color: var(--text-dim); }

.team-assign-btns { display: flex; gap: 4px; flex-shrink: 0; }
.btn-assign {
  font-size: 11px; font-weight: 700;
  padding: 4px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-assign:hover { border-color: var(--text-dim); color: var(--text); }
.btn-assign.active-t0 { background: var(--team0); border-color: var(--team0); color: #fff; }
.btn-assign.active-t1 { background: var(--team1); border-color: var(--team1); color: #fff; }

.lobby-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guest-msg { color: var(--text-dim); font-size: 14px; padding: 12px; }

/* ─── SUBMIT SCREEN ────────────────────────────────────────── */
.slip-input-row { display: flex; align-items: center; gap: 10px; }
.slip-num {
  width: 28px; height: 28px;
  background: var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
  color: var(--text-dim);
}
.waiting-label { font-size: 16px; font-weight: 600; text-align: center; color: var(--success); }
.submit-status-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.submit-status-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text-dim);
}
.submit-status-item.done { color: var(--text); }
.submit-status-item .check { font-size: 16px; }

/* ─── GAME HEADER ──────────────────────────────────────────── */
#screen-game { padding: 0; }
.game-header {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.team-score-block {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 12px 8px;
}
.team-0-bg { background: rgba(67, 97, 238, 0.15); border-right: 1px solid var(--border); }
.team-1-bg { background: rgba(230, 57, 70, 0.15); border-left: 1px solid var(--border); }
.team-score-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.team-score-num { font-size: 28px; font-weight: 800; line-height: 1; margin-top: 2px; }
.team-0-bg .team-score-num { color: var(--team0); }
.team-1-bg .team-score-num { color: var(--team1); }

.game-center-info { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 4px; gap: 2px; }
.round-badge {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--border);
  padding: 3px 10px; border-radius: 999px; color: var(--text-dim);
}
.pile-display { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

/* ─── GAME MAIN AREA ───────────────────────────────────────── */
.game-main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* Pre-turn view */
.pre-turn-view { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.pre-turn-up-label { font-size: 14px; color: var(--text-dim); text-align: center; }
.pre-turn-player {
  font-size: 28px; font-weight: 800; text-align: center;
  line-height: 1.1;
}
.pre-turn-team-badge {
  font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.pre-turn-team-badge.team-0 { background: rgba(67,97,238,0.2); color: var(--team0); }
.pre-turn-team-badge.team-1 { background: rgba(230,57,70,0.2); color: var(--team1); }

.round-rule-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  width: 100%;
  text-align: center;
}
.round-rule-icon { font-size: 28px; margin-bottom: 6px; }
.round-rule-name { font-size: 16px; font-weight: 700; }
.round-rule-desc { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.your-turn-msg {
  font-size: 18px; font-weight: 700;
  color: var(--success);
  text-align: center;
}
.waiting-turn-msg { font-size: 14px; color: var(--text-dim); text-align: center; }

/* Clue giver view */
.clue-giver-view { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }

.round-type-chip {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; padding: 4px 12px; border-radius: 999px;
  background: var(--border); color: var(--text-dim);
}

.celebrity-card {
  width: 100%;
  background: var(--card);
  border: 2px solid var(--team0);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}
.celebrity-name {
  font-size: clamp(24px, 7vw, 40px);
  font-weight: 900;
  line-height: 1.15;
  word-break: break-word;
}

.timer-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.timer-display {
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  color: var(--success);
  transition: color 0.3s;
  font-variant-numeric: tabular-nums;
}
.timer-display.warn { color: var(--warn); }
.timer-display.danger { color: var(--danger); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }
.timer-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.slip-progress { font-size: 14px; color: var(--text-dim); text-align: center; }

.action-btns { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.btn-got-it {
  width: 100%;
  padding: 20px;
  font-size: 22px;
  font-weight: 800;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-got-it:active { transform: scale(0.97); opacity: 0.9; }

.btn-skip {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-skip:hover { color: var(--text); border-color: var(--text-dim); }

/* Watching view */
.watching-view { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.watching-player-card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  display: flex; flex-direction: column; gap: 8px;
}
.watching-player-name { font-size: 24px; font-weight: 800; }
.watching-team-label { font-size: 13px; font-weight: 700; }
.watching-team-label.team-0 { color: var(--team0); }
.watching-team-label.team-1 { color: var(--team1); }
.watching-instruction { font-size: 15px; }
.watching-instruction.shout { color: var(--success); font-weight: 700; }
.watching-instruction.silent { color: var(--text-dim); }

.watching-slips-count {
  font-size: 48px; font-weight: 900;
  color: var(--warn);
}
.watching-slips-label { font-size: 14px; color: var(--text-dim); }

/* Flash animation for correct guess */
.flash-correct {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(45, 198, 83, 0.15);
  pointer-events: none;
  animation: flash-fade 0.4s ease-out forwards;
  z-index: 999;
}
@keyframes flash-fade { from { opacity: 1; } to { opacity: 0; } }

/* ─── OVERLAYS ─────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.88);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay.active { display: flex; }

.overlay-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

/* Round intro overlay */
.oi-round-num { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: var(--text-dim); }
.oi-round-name { font-size: 32px; font-weight: 900; }
.oi-round-desc { font-size: 15px; color: var(--text-dim); line-height: 1.5; }
.oi-prev-scores { width: 100%; }
.oi-score-row { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.oi-score-team { font-size: 14px; font-weight: 700; }
.oi-score-val { font-size: 14px; font-weight: 700; }

/* Turn recap overlay */
.tr-team-label { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.tr-count { font-size: 36px; font-weight: 900; }
.tr-slips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; width: 100%; }
.tr-slip-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
}
.tr-score-row { display: flex; gap: 24px; width: 100%; justify-content: center; }
.tr-score-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tr-score-team { font-size: 13px; font-weight: 700; }
.tr-score-val { font-size: 32px; font-weight: 900; }
.team-0-color { color: var(--team0); }
.team-1-color { color: var(--team1); }

/* Round end overlay */
.re-title { font-size: 28px; font-weight: 900; }
.re-last-slips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; width: 100%; }
.re-scores { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.re-score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.re-score-round { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.re-score-values { display: flex; gap: 16px; font-size: 15px; font-weight: 700; }
.overlay-waiting { font-size: 13px; color: var(--text-dim); }

/* Game end overlay */
.game-end-trophy { font-size: 64px; line-height: 1; }
.ge-winner { font-size: 32px; font-weight: 900; }
.ge-scores { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.ge-score-row {
  display: flex; justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.ge-score-team { font-size: 15px; font-weight: 700; }
.ge-score-total { font-size: 18px; font-weight: 900; }
.ge-winner-row { border: 2px solid; }
.ge-winner-t0 { border-color: var(--team0); }
.ge-winner-t1 { border-color: var(--team1); }

/* ─── Responsive ───────────────────────────────────────────── */
@media (min-width: 520px) {
  .screen { padding: 32px 24px 48px; }
  .game-main { padding: 24px; }
}
