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

:root {
  --red:    #e21b3c;
  --blue:   #1368ce;
  --yellow: #d89e00;
  --green:  #26890c;
  --bg:     #46178f;
  --card:   #ffffff;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(0,0,0,.3);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

h1 { font-size: 2.4rem; font-weight: 900; letter-spacing: -1px; }
h2 { font-size: 1.6rem; font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }

.card {
  background: var(--card);
  color: #222;
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
}

input[type=text], input[type=number], select, textarea {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid #ddd;
  border-radius: var(--radius);
  font-size: 1rem;
  margin-top: .4rem;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--bg); }

label { font-weight: 600; font-size: .9rem; }

.btn {
  display: inline-block;
  padding: .85rem 1.8rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  text-decoration: none;
  text-align: center;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--bg); color: #fff; box-shadow: 0 4px 0 #2a0a66; }
.btn-secondary { background: #eee; color: #333; box-shadow: 0 4px 0 #bbb; }
.btn-danger    { background: var(--red); color: #fff; box-shadow: 0 4px 0 #900e22; }
.btn-success   { background: var(--green); color: #fff; box-shadow: 0 4px 0 #145006; }
.btn-full      { width: 100%; display: block; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

.gap { margin-top: 1rem; }
.gap-sm { margin-top: .5rem; }

/* answer grid */
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  width: 100%;
  max-width: 600px;
}

.answer-btn {
  border: none;
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  transition: transform .1s, opacity .2s;
  box-shadow: 0 6px 0 rgba(0,0,0,.3);
}
.answer-btn:active { transform: scale(.96); }
.answer-btn.a0 { background: var(--red); }
.answer-btn.a1 { background: var(--blue); }
.answer-btn.a2 { background: var(--yellow); }
.answer-btn.a3 { background: var(--green); }
.answer-btn.dimmed { opacity: .4; pointer-events: none; }

.answer-icon { font-size: 1.6rem; }

/* timer bar */
.timer-wrap {
  width: 100%;
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  margin: .8rem 0;
}
.timer-bar {
  height: 100%;
  background: #fff;
  border-radius: 999px;
  transition: width 1s linear;
}

/* leaderboard */
.leaderboard { list-style: none; }
.leaderboard li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .4rem;
  background: var(--bg);
  color: #fff;
  font-weight: 700;
}
.leaderboard li:nth-child(1) { background: #c0922a; font-size: 1.1rem; }
.leaderboard li:nth-child(2) { background: #7a7a7a; }
.leaderboard li:nth-child(3) { background: #7a4a1e; }
.lb-rank { font-size: 1.4rem; min-width: 2rem; text-align: center; }
.lb-name { flex: 1; }
.lb-score { font-size: 1.1rem; }

/* result feedback */
.result-icon { font-size: 5rem; text-align: center; }
.result-delta { font-size: 2.5rem; font-weight: 900; text-align: center; color: var(--green); }
.result-delta.wrong { color: var(--red); }

/* room code display */
.room-code {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: .3rem;
  color: var(--bg);
  text-align: center;
  padding: 1rem;
  background: #fff;
  border-radius: var(--radius);
  margin: 1rem 0;
}

/* player list chips */
.player-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.chip {
  background: var(--bg);
  color: #fff;
  padding: .35rem .9rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: .9rem;
}

/* spinner */
.spinner {
  width: 48px; height: 48px;
  border: 5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* question card on host */
.question-display {
  background: #fff;
  color: #222;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

/* answer count bar */
.answer-bar-wrap { margin: 1rem 0; }
.answer-bars {
  display: flex;
  align-items: flex-end;
  gap: .4rem;
  height: 100px;
}
.answer-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.answer-bar-fill {
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: height .4s ease;
  min-height: 4px;
}
.answer-bar-fill.a0 { background: var(--red); }
.answer-bar-fill.a1 { background: var(--blue); }
.answer-bar-fill.a2 { background: var(--yellow); }
.answer-bar-fill.a3 { background: var(--green); }
.answer-bar-num { font-weight: 700; font-size: .9rem; }
.bar-icon { font-size: 1.2rem; }
.bar-correct { outline: 3px solid gold; outline-offset: 2px; border-radius: var(--radius); }

/* quiz builder */
.question-card {
  background: #f5f5f5;
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border: 2px solid #ddd;
}
.option-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .5rem;
}
.option-row input[type=radio] { width: auto; margin: 0; }
.option-row input[type=text] { margin: 0; }
.option-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
}
.option-dot.a0 { background: var(--red); }
.option-dot.a1 { background: var(--blue); }
.option-dot.a2 { background: var(--yellow); }
.option-dot.a3 { background: var(--green); }

/* toast */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: .7rem 1.5rem;
  border-radius: 999px; font-weight: 600; z-index: 999;
  animation: fadein .3s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* confetti container */
#confetti-canvas {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 100;
}

/* center layout helper */
.center { text-align: center; }
.page { padding: 1.5rem; width: 100%; max-width: 700px; }

.nav-back {
  position: fixed; top: 1rem; left: 1rem;
  background: rgba(255,255,255,.15); color: #fff;
  border: none; border-radius: var(--radius);
  padding: .5rem 1rem; cursor: pointer; font-size: .95rem;
  text-decoration: none;
}

@media (max-width: 480px) {
  h1 { font-size: 1.8rem; }
  .answer-btn { padding: 2rem .5rem; font-size: 1rem; }
  .room-code { font-size: 2.8rem; }
}
