:root {
  --bg: #f3f4f7;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b91c1c;
  --card: #ffffff;
  --line: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: radial-gradient(circle at top, #dff4ef 0%, var(--bg) 35%);
  color: var(--text);
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.04);
}

.hidden {
  display: none !important;
}

h1, h2 {
  margin-top: 0;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
}

input, button {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary {
  background: #475569;
}

button.secondary:hover {
  background: #334155;
}

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

.room-gate {
  max-width: 520px;
  margin: 2.5rem auto 0;
}

#joinRoomBtn {
  margin-top: 0.8rem;
}

.room-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

#participantsList {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#participantsList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 10px;
  background: #ffffff;
}

#participantsList li:last-child {
  border-bottom: 1px solid var(--line);
}

.participant-name {
  font-weight: 600;
}

.participant-voted {
  border-left-color: #10b981;
  background: #f0fdf4;
}

.participant-waiting {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.participant-offline {
  border-left-color: #94a3b8;
  background: #f8fafc;
}

.participant-me {
  box-shadow: inset 0 0 0 1px #14b8a6;
}

.badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
  background: #eef2ff;
  color: #3730a3;
}

.badge.offline {
  background: #fff1f2;
  color: #9f1239;
}

.badge.host {
  background: #ecfdf5;
  color: #065f46;
}

.vote-chip {
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  border: 1px solid transparent;
  font-weight: 600;
}

.vote-chip.is-voted {
  background: #d1fae5;
  border-color: #10b981;
  color: #065f46;
}

.vote-chip.is-waiting {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

.vote-deck {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.vote-card {
  background: #f8fafc;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  font-size: 1.15rem;
  font-weight: 700;
  min-height: 3rem;
}

.vote-card.selected {
  background: #d1fae5;
  border-color: #059669;
  color: #065f46;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.vote-progress {
  margin: 0 0 0.8rem;
  color: #475569;
  font-weight: 600;
}

.host-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
}

.round-stats {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.round-stats h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.stat-tile {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
}

.stat-label {
  display: block;
  color: #475569;
  font-size: 0.78rem;
}

.stat-value {
  display: block;
  margin-top: 0.15rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.stat-footnote {
  margin: 0.55rem 0 0;
  color: #64748b;
  font-size: 0.83rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  width: min(420px, 100%);
}

.modal-actions {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

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

  .vote-deck {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .room-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
