*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --accent: #f59e0b;
  --card-bg: #1e293b;
  --card-selected: #6366f1;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Home */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  gap: 16px;
}

.logo {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 0 24px rgba(99, 102, 241, 0.4));
}

.logo-sm {
  font-size: 28px;
}

.home h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.home-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
}

.divider {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-code-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.join-code-form input {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  text-align: center;
  letter-spacing: 0.1em;
}

.join-code-form input:focus {
  border-color: var(--primary);
}

/* Buttons */

.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: var(--success);
  color: white;
}

.btn-secondary:hover {
  opacity: 0.9;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--surface-hover);
}

.btn-lg {
  padding: 14px 40px;
  font-size: 1.15rem;
  border-radius: var(--radius);
}

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

/* Overlay (join) */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay-card {
  background: var(--surface);
  padding: 48px;
  border-radius: var(--radius);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 400px;
  margin: 16px;
}

.overlay-card h1 {
  font-size: 1.5rem;
}

.overlay-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.overlay-card input {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  text-align: center;
}

.overlay-card input:focus {
  border-color: var(--primary);
}

/* Room layout */

.room {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.room-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  width: 100%;
}

.room-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-title h1 {
  font-size: 1.3rem;
  font-weight: 600;
}

.room-share {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-code {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--surface);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  letter-spacing: 0.1em;
  color: var(--primary-hover);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.room-actions {
  display: flex;
  gap: 8px;
}

/* Participants */

.participants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
  width: 100%;
}

.participant {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s;
}

.participant.is-me {
  border-color: var(--primary);
}

.participant-name {
  font-weight: 500;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-vote {
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Vote groups (revealed state) */

.vote-group {
  width: 100%;
  margin-bottom: 16px;
}


.vote-group-members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.participant-vote.voted {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.participant-vote.revealed {
  background: var(--primary);
  color: white;
}

.participant-vote.waiting {
  color: var(--text-muted);
}


/* Cards */

.card-section {
  padding-top: 24px;
  border-top: 1px solid var(--border);
  width: 100%;
}

.pick-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.cards {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 24px;
}

.card {
  width: 64px;
  height: 88px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.card:hover:not(.disabled) {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}

.card.selected {
  background: var(--card-selected);
  border-color: var(--primary-hover);
  color: white;
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.3);
}

.card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Mobile */

@media (max-width: 480px) {
  .room-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .card {
    width: 52px;
    height: 72px;
    font-size: 1.2rem;
  }

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