* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
  background: #1a0836;
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124,29,111,0.55), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(59,7,100,0.7), transparent 55%),
    linear-gradient(160deg, #1e0a3c 0%, #2c0b4e 45%, #490a52 100%);
  background-attachment: fixed;
}

/* animated background orbs */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-orbs span {
  position: absolute; border-radius: 50%; filter: blur(50px); opacity: 0.35;
  animation: float 18s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { width: 320px; height: 320px; background: #f97316; top: -80px; left: -60px; }
.bg-orbs span:nth-child(2) { width: 280px; height: 280px; background: #ec4899; bottom: -60px; right: -40px; animation-delay: -6s; }
.bg-orbs span:nth-child(3) { width: 240px; height: 240px; background: #6366f1; top: 40%; left: 55%; animation-delay: -12s; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(20px,-30px) scale(1.1); } }

.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: 100vh;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.02em; }
.subtitle { opacity: 0.72; font-size: 0.9rem; margin-bottom: 20px; }
.q-text { margin: 6px 0 18px; font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.01em; }

.card {
  position: relative;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,0.5);
  animation: cardIn 0.35s cubic-bezier(0.2,0.9,0.3,1.2) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

input[type=text], input[type=number], input[type=password], select {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 2px solid transparent;
  font-size: 1rem;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.95);
  color: #1a1a1a;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { outline: none; border-color: #f97316; box-shadow: 0 0 0 4px rgba(249,115,22,0.25); }

button {
  font-size: 1rem;
  font-weight: 700;
  padding: 15px 20px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.2s, opacity 0.2s;
}
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, #fb923c, #f43f5e); color: #fff; width: 100%; box-shadow: 0 10px 24px -8px rgba(244,63,94,0.6); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: rgba(255,255,255,0.14); color: #fff; border: 1px solid rgba(255,255,255,0.28); }
.btn-danger { background: linear-gradient(135deg,#ef4444,#b91c1c); color: #fff; }
.btn-small { padding: 9px 14px; font-size: 0.85rem; }

/* join screen */
.join-card { text-align: center; margin-top: 8vh; }
.join-emoji { font-size: 3.4rem; margin-bottom: 6px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }

.option-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.option-row input { margin-bottom: 0; }

/* player answer options — Kahoot-style tiles */
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
@media (max-width: 380px) { .option-grid { grid-template-columns: 1fr; } }

.big-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  color: #fff;
  font-size: 1.12rem;
  font-weight: 700;
  border: none;
  box-shadow: 0 8px 20px -8px rgba(0,0,0,0.6), inset 0 0 0 2px rgba(255,255,255,0.12);
  transition: transform 0.1s, box-shadow 0.2s, filter 0.2s;
}
.big-option .opt-shape { font-size: 1.3rem; flex-shrink: 0; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.big-option .opt-text { flex: 1; min-width: 0; word-break: break-word; }
.big-option:not(:disabled):active { transform: scale(0.97); }
.opt-0 { background: linear-gradient(135deg,#ef4444,#dc2626); }
.opt-1 { background: linear-gradient(135deg,#3b82f6,#2563eb); }
.opt-2 { background: linear-gradient(135deg,#eab308,#ca8a04); }
.opt-3 { background: linear-gradient(135deg,#22c55e,#16a34a); }
.opt-4 { background: linear-gradient(135deg,#a855f7,#7c3aed); }
.opt-5 { background: linear-gradient(135deg,#ec4899,#db2777); }

.big-option.selected { outline: 4px solid #facc15; outline-offset: 2px; filter: brightness(1.08); }
.big-option.correct { animation: correctPulse 0.6s ease; outline: 4px solid #4ade80; outline-offset: 2px; }
.big-option.wrong { filter: grayscale(0.6) brightness(0.7); }
.big-option:disabled { opacity: 1; }
.big-option:disabled:not(.selected):not(.correct) { opacity: 0.55; }
@keyframes correctPulse { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* quiz top / timer */
.quiz-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.time-badge {
  min-width: 44px; height: 44px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 900; font-size: 1.25rem;
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.35);
}
.time-badge.pop { animation: badgePop 0.4s ease; }
@keyframes badgePop { 0% { transform: scale(1); } 40% { transform: scale(1.35); color: #fecaca; } 100% { transform: scale(1); } }

.timer-track { background: rgba(255,255,255,0.15); border-radius: 999px; height: 14px; overflow: hidden; margin-bottom: 18px; }
.timer-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #eab308, #ef4444); width: 100%; transition: width 0.15s linear; }

.answer-hint { min-height: 1.2em; margin-top: 10px; font-size: 0.92rem; font-weight: 600; opacity: 0.9; }

/* quiz stakes line */
.stakes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.stake { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 0.8rem; font-weight: 800; }
.stake-pos { background: rgba(34,197,94,0.22); color: #86efac; border: 1px solid rgba(34,197,94,0.5); }
.stake-neg { background: rgba(239,68,68,0.2); color: #fca5a5; border: 1px solid rgba(239,68,68,0.5); }
.stake-zero { background: rgba(255,255,255,0.1); color: #cbd5e1; border: 1px solid rgba(255,255,255,0.2); }
.stake-fast { background: rgba(251,146,60,0.2); color: #fdba74; border: 1px solid rgba(251,146,60,0.5); }

/* rules card (player waiting screen) */
.rules-card { animation-delay: 0.05s; }
.rules-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rules-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.98rem; line-height: 1.4; }
.rule-ic { font-size: 1.4rem; flex-shrink: 0; width: 30px; text-align: center; }
.rules-list b { font-weight: 800; }
.txt-pos { color: #4ade80; }
.txt-neg { color: #f87171; }

/* result bars */
.bar-row { margin-bottom: 14px; }
.bar-label { display: flex; justify-content: space-between; font-size: 0.95rem; margin-bottom: 5px; font-weight: 600; }
.bar-track { background: rgba(255,255,255,0.12); border-radius: 999px; height: 26px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #fb923c, #f43f5e); transition: width 0.7s cubic-bezier(0.2,0.9,0.3,1); display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; font-size: 0.82rem; font-weight: 800; min-width: 0; }
.bar-fill.bar-win { background: linear-gradient(90deg, #22c55e, #16a34a); }

/* waiting */
.center-msg { text-align: center; padding: 48px 20px; font-size: 1.1rem; }
.waiting-emoji { font-size: 3rem; margin-bottom: 12px; animation: spin 3s ease-in-out infinite; }
@keyframes spin { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

/* leaderboard */
.leaderboard-row { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-radius: 14px; background: rgba(255,255,255,0.07); margin-bottom: 9px; animation: rowIn 0.4s ease both; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.leaderboard-row.top1 { background: linear-gradient(90deg, rgba(250,204,21,0.42), rgba(250,204,21,0.08)); border: 1px solid rgba(250,204,21,0.6); box-shadow: 0 8px 24px -10px rgba(250,204,21,0.5); }
.leaderboard-row.top2 { background: linear-gradient(90deg, rgba(203,213,225,0.3), rgba(203,213,225,0.05)); border: 1px solid rgba(203,213,225,0.4); }
.leaderboard-row.top3 { background: linear-gradient(90deg, rgba(217,119,6,0.32), rgba(217,119,6,0.05)); border: 1px solid rgba(217,119,6,0.4); }
.leaderboard-row.me { outline: 2px solid #fb923c; }
.lb-rank { font-weight: 900; width: 32px; text-align: center; font-size: 1.1rem; }
.lb-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 900; font-variant-numeric: tabular-nums; }
.off-dot { color: #94a3b8; font-size: 1.4rem; line-height: 0; }

/* winner banner */
.winner-banner { text-align: center; padding: 14px 10px 20px; }
.winner-crown { font-size: 3.4rem; animation: bob 2s ease-in-out infinite; }
.winner-name { font-size: 1.6rem; font-weight: 900; margin-top: 4px; background: linear-gradient(90deg,#facc15,#fb923c); -webkit-background-clip: text; background-clip: text; color: transparent; }
.winner-score { opacity: 0.85; font-weight: 700; margin-top: 2px; }

/* chips / top bar */
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; }
.chip { background: rgba(255,255,255,0.14); padding: 7px 13px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.score-chip { background: linear-gradient(135deg, rgba(250,204,21,0.35), rgba(251,146,60,0.35)); border: 1px solid rgba(250,204,21,0.5); font-variant-numeric: tabular-nums; }

/* points flash */
.points-flash { font-size: 2.4rem; font-weight: 900; text-align: center; margin: 16px 0 4px; animation: flashIn 0.5s cubic-bezier(0.2,0.9,0.3,1.4) both; }
.points-flash.zero { color: #fca5a5; }
.points-flash.pos { color: #86efac; text-shadow: 0 0 24px rgba(74,222,128,0.5); }
@keyframes flashIn { 0% { opacity: 0; transform: scale(0.5) translateY(10px); } 100% { opacity: 1; transform: none; } }

/* tabs (host) */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button { flex: 1; background: rgba(255,255,255,0.08); color: #fff; padding: 12px 8px; font-size: 0.9rem; }
.tabs button.active { background: linear-gradient(135deg, #fb923c, #f43f5e); box-shadow: 0 8px 20px -8px rgba(244,63,94,0.6); }

footer.hint { text-align: center; opacity: 0.5; font-size: 0.75rem; margin-top: 30px; }

/* question bank (host) */
.bank-entry { margin-bottom: 8px; }
.bank-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); }
.bank-item.editing { border-color: rgba(251,146,60,0.7); border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: rgba(251,146,60,0.12); }

.bank-edit-slot { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.bank-edit-slot.open { max-height: 1000px; }
.bank-edit-slot.open > :first-child { margin-top: 0; }
.bank-edit-slot.open { padding: 14px; border: 1px solid rgba(251,146,60,0.7); border-top: none; border-radius: 0 0 14px 14px; background: rgba(251,146,60,0.08); animation: slotIn 0.3s ease; }
@keyframes slotIn { from { opacity: 0.3; } to { opacity: 1; } }
.bank-edit-slot .option-row .removeOpt { padding: 8px 12px; }
.inline-actions { display: flex; gap: 8px; margin-top: 8px; }
.inline-actions .btn-secondary { flex: 0 0 auto; }
.inline-actions .btn-primary { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.bank-item-body { flex: 1; min-width: 0; }
.bank-item-q { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bank-item-meta { font-size: 0.75rem; opacity: 0.65; margin-top: 2px; }
.quiz-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; align-items: center; }
.q-correct { font-weight: 800; color: #86efac; font-size: 0.9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 800; white-space: nowrap; }
.q-time { background: rgba(255,255,255,0.14); color: #e2e8f0; }
.q-plus { background: rgba(34,197,94,0.25); color: #4ade80; border: 1px solid rgba(34,197,94,0.5); }
.q-minus { background: rgba(239,68,68,0.22); color: #f87171; border: 1px solid rgba(239,68,68,0.5); }
.q-zero { background: rgba(255,255,255,0.1); color: #cbd5e1; border: 1px solid rgba(255,255,255,0.2); }
.bank-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.empty-hint { opacity: 0.55; font-size: 0.9rem; padding: 10px 0; text-align: center; }
.icon-btn { background: rgba(255,255,255,0.12); color: #fff; padding: 9px 11px; border-radius: 11px; font-size: 0.9rem; }
