:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --good: #22c55e;
  --border: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

header h1 { margin: 0; font-size: 2rem; }
.tagline { color: var(--muted); margin: 0.25rem 0 0; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card.panel { max-width: 380px; margin: 2rem auto; }

label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="text"] {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

button {
  cursor: pointer;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

button:hover { background: var(--accent-hover); }
button.secondary { background: var(--panel-2); }
button.secondary:hover { background: #475569; }
button.danger { background: #7f1d1d; }
button.danger:hover { background: #991b1b; }

.error { color: #f87171; min-height: 1.2em; margin: 0.5rem 0 0; }

.hidden { display: none !important; }

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.room-header h2 { margin: 0; }
.topic { color: var(--muted); margin: 0.25rem 0 0; font-style: italic; }

.host-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.poker-card {
  width: 64px;
  height: 92px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.poker-card:hover { transform: translateY(-6px); }
.poker-card.selected {
  border-color: var(--accent);
  background: var(--accent);
  transform: translateY(-6px);
}

.players { list-style: none; padding: 0; margin: 0; }

.players li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.players li:last-child { border-bottom: none; }

.badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  margin-left: 0.5rem;
}

.badge.host { background: var(--accent); color: white; }
.vote-chip {
  font-weight: 700;
  min-width: 2rem;
  text-align: center;
}
.vote-chip.pending { color: var(--muted); }
.vote-chip.ready { color: var(--good); }

.summary { color: var(--muted); margin-top: 1rem; }

/* ----- header / misc ----- */
header { position: relative; }
.logout {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.logout:hover { color: var(--text); }
.muted { color: var(--muted); }

/* ----- lobby ----- */
.lobby {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.lobby #lobby-error { grid-column: 1 / -1; }

fieldset.deck-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 1rem;
  padding: 0.75rem;
}
fieldset.deck-picker legend { color: var(--muted); font-size: 0.85rem; padding: 0 0.4rem; }

.preset-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.chip {
  background: var(--panel-2);
  color: var(--text);
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 999px;
}
.chip.active { background: var(--accent); }

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}
label.checkbox input { width: auto; margin: 0; }

/* ----- room layout ----- */
.room-actions { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

/* ----- stats ----- */
.stat-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.stat {
  flex: 1 1 90px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
}
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; }
.stat-label { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }

/* ----- distribution ----- */
.dist { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.dist-row { display: flex; align-items: center; gap: 0.6rem; }
.dist-card { width: 2rem; font-weight: 700; text-align: right; }
.dist-bar {
  height: 14px;
  background: var(--accent);
  border-radius: 6px;
  min-width: 4px;
}
.dist-count { color: var(--muted); font-size: 0.85rem; }

/* ----- history ----- */
.history { display: flex; flex-direction: column; gap: 0.75rem; }
.history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
}
.history-head { margin-bottom: 0.2rem; }
.history-meta { font-size: 0.85rem; color: var(--text); }
.history-votes { font-size: 0.8rem; margin-top: 0.25rem; }

@media (max-width: 700px) {
  .lobby, .grid { grid-template-columns: 1fr; }
}
