/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #eceef3;
  --border: #d1d5e0;
  --primary: #6c63ff;
  --primary-hover: #574fd6;
  --secondary: #e2e4ed;
  --secondary-hover: #d1d4e0;
  --text: #1a1d27;
  --text-muted: #6b7080;
  --card-back: #eceef3;
  --card-selected: #6c63ff;
  --card-revealed: #dde8f7;
  --green: #2d9e5f;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

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

/* ── Landing ── */
.landing {
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 4rem;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 90%;
}

.landing-card h1 { font-size: 2.2rem; margin-bottom: 1rem; }
.landing-card p  { color: var(--text-muted); margin-bottom: 2rem; line-height: 1.6; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--secondary); color: var(--text); }
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-large { padding: 0.85rem 2.4rem; font-size: 1.1rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 90%; max-width: 400px;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin-bottom: 0.5rem; }
.modal-card p  { color: var(--text-muted); margin-bottom: 1.5rem; }

#name-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
#name-form > .btn {
  align-self: flex-start;
}
#name-input {
  flex: 1;
  padding: 0.6rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}
#name-input:focus { border-color: var(--primary); }

.spectator-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.spectator-label input { cursor: pointer; accent-color: var(--primary); }

/* ── Room layout ── */
.hidden { display: none !important; }

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.room-header h1 { font-size: 1.4rem; }
.room-id {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.room-id span {
  font-family: monospace;
  color: var(--text);
  font-size: 0.8rem;
  word-break: break-all;
}

.room-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  padding: 2.5rem 1.5rem;
  max-width: 860px;
  margin: 0 auto;
}

/* ── Players ── */
.players-section, .vote-section, .controls {
  width: 100%;
}

.players-section h2,
.vote-section h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.player-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.player-item {
  padding: 0.4rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.player-item:last-child { border-bottom: none; }
.player-item:hover { background: var(--surface2); }
.player-item.voted { border-left: 3px solid var(--green); padding-left: calc(1.2rem - 2px); }

.player-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.player-info { display: flex; flex-direction: column; flex: 1; }
.player-name { font-weight: 600; font-size: 0.9rem; }
.player-vote {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 38px;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}
.player-vote.revealed {
  background: var(--primary);
  color: #fff;
}
.player-vote.hidden-vote {
  background: var(--green);
  color: #fff;
}
.player-vote.hidden-vote::before { content: "✓"; }
.player-vote.waiting {
  background: var(--surface2);
  color: var(--text-muted);
}
.player-vote.waiting::before { content: "–"; }

.vote-average {
  margin-top: 0.75rem;
  padding: 0.75rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  text-align: right;
}

.player-vote.spectator-badge {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 1rem;
}

.player-item.you .player-name::after {
  content: " (you)";
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
}

/* ── Vote cards ── */
.card-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.vote-card {
  width: 64px; height: 90px;
  border-radius: 10px;
  background: var(--card-back);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
}
.vote-card:hover { border-color: var(--primary); background: var(--surface2); transform: translateY(-3px); }
.vote-card.selected { background: var(--card-selected); border-color: var(--card-selected); color: #fff; transform: translateY(-5px); }
.vote-card:active { transform: translateY(0); }

/* ── Controls ── */
.controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .room-header { padding: 0.75rem 1rem; }
  .room-main { padding: 1.5rem 1rem; }
  .vote-card { width: 54px; height: 76px; font-size: 1rem; }
}
