:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --opt-a: #4f46e5;
  --opt-b: #7c3aed;
  --correct: #10b981;
  --wrong: #ef4444;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
}

.screen { display: none; width: 100%; max-width: 480px; animation: fadeIn 0.2s ease; }
.screen.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card);
  border-radius: 1rem;
  padding: 2rem 1.5rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / .07), 0 2px 4px -2px rgb(0 0 0 / .05);
}

.scroll-card {
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}

/* Typography */
h1 { font-size: 2.25rem; font-weight: 800; color: var(--primary); text-align: center; margin-bottom: .25rem; }
h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: .5rem; }
h4 { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .5rem; }

.subtitle { text-align: center; color: var(--muted); margin-bottom: 1.5rem; font-size: .95rem; }
.hint { font-size: .85rem; color: var(--muted); text-align: center; margin-top: .75rem; }
.label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; }
.hidden { display: none !important; }

/* Inputs */
input[type="text"] {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--border);
  border-radius: .5rem;
  font-size: 1rem;
  margin-bottom: .75rem;
  outline: none;
  transition: border-color .15s;
  background: var(--bg);
}
input[type="text"]:focus { border-color: var(--primary); background: #fff; }

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: .875rem 1.5rem;
  border: none;
  border-radius: .5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.btn + .btn { margin-top: .625rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary { background: var(--bg); color: var(--text); border: 2px solid var(--border); }
.btn-secondary:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }

.divider { text-align: center; color: var(--muted); margin: 1rem 0; font-size: .875rem; }

/* Room code */
.code { font-size: 3rem; font-weight: 800; letter-spacing: .25em; color: var(--primary); text-align: center; margin-bottom: .25rem; }

/* Player list */
.player-list { margin: 1.25rem 0; display: flex; flex-direction: column; gap: .5rem; }

.player-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .875rem;
  background: var(--bg);
  border-radius: .5rem;
  font-weight: 500;
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  color: #fff;
  flex-shrink: 0;
}

.badge {
  margin-left: auto;
  font-size: .65rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-you { background: var(--primary); color: #fff; }
.badge-host { background: #f59e0b; color: #fff; }

/* Progress bar */
.progress-wrap { height: 4px; background: var(--border); border-radius: 999px; margin-bottom: 1rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width .4s ease; }

.counter { text-align: center; font-size: .875rem; color: var(--muted); margin-bottom: 1rem; }

/* Answer options */
.question-text {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}

.options { display: flex; gap: .625rem; margin-bottom: 1rem; }

.btn-option {
  flex: 1;
  padding: 1.125rem .75rem;
  border: none;
  border-radius: .75rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: all .15s;
  line-height: 1.3;
}
.btn-option[data-choice="a"] { background: var(--opt-a); }
.btn-option[data-choice="b"] { background: var(--opt-b); }
.btn-option:not(:disabled):hover { transform: scale(1.02); box-shadow: 0 4px 12px rgb(0 0 0 / .18); }
.btn-option:disabled { opacity: .45; }
.btn-option.selected { box-shadow: 0 0 0 3px #fff, 0 0 0 5px currentColor; transform: scale(1.03); }

/* Guessing */
.question-small { font-size: .875rem; color: var(--muted); font-style: italic; margin-bottom: 1.25rem; line-height: 1.4; }

.guess-list { display: flex; flex-direction: column; gap: .875rem; margin: .75rem 0 1.25rem; }

.guess-item { background: var(--bg); border-radius: .75rem; padding: .875rem; }
.guess-item-name { font-weight: 600; font-size: .9rem; margin-bottom: .625rem; display: flex; align-items: center; gap: .5rem; }

.guess-btns { display: flex; gap: .5rem; }
.guess-btn {
  flex: 1;
  padding: .625rem .5rem;
  border: 2px solid var(--border);
  border-radius: .5rem;
  background: #fff;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.guess-btn:hover { border-color: var(--primary); color: var(--primary); }
.guess-btn.sel-a { background: var(--opt-a); border-color: var(--opt-a); color: #fff; }
.guess-btn.sel-b { background: var(--opt-b); border-color: var(--opt-b); color: #fff; }

/* Results */
.results-list { display: flex; flex-direction: column; gap: .5rem; margin: .75rem 0; }

.result-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .625rem .875rem;
  background: var(--bg);
  border-radius: .5rem;
}

.result-label {
  margin-left: auto;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: .375rem;
  font-size: .8rem;
}
.label-a { background: #ede9fe; color: var(--opt-a); }
.label-b { background: #f3e8ff; color: var(--opt-b); }

.guess-icon { font-size: 1rem; margin-left: .25rem; min-width: 1.1rem; text-align: center; }

.round-score {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  padding: .75rem;
  background: #eef2ff;
  border-radius: .5rem;
  margin: .75rem 0;
}

/* Leaderboard */
.leaderboard { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1rem; }

.lb-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .875rem;
  background: var(--bg);
  border-radius: .5rem;
}
.lb-rank { font-weight: 700; width: 1.5rem; text-align: center; color: var(--muted); }
.lb-score { margin-left: auto; font-weight: 700; color: var(--primary); }

.lb-item.winner { background: #fef9c3; border: 2px solid #f59e0b; }
.lb-item.winner .lb-rank { color: #d97706; font-size: 1.1rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: .75rem 1.25rem;
  border-radius: .5rem;
  font-size: .9rem;
  font-weight: 500;
  z-index: 999;
  box-shadow: 0 4px 12px rgb(0 0 0 / .25);
  white-space: nowrap;
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(8px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);  opacity: 1; }
}

/* Agreement overview */
.agreement-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .75rem;
  background: var(--bg);
  border-radius: .5rem;
  margin-bottom: .375rem;
}
.agreement-name { flex: 1; font-weight: 500; font-size: .9rem; }
.agreement-count {
  font-weight: 700;
  font-size: .9rem;
  color: var(--primary);
  white-space: nowrap;
}

