/* ============ PartyQuiz — shared styles (host + player + landing) ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #1b1035;
  --bg2: #2d1460;
  --bg3: #4a1d96;
  --card: rgba(255, 255, 255, 0.08);
  --card-solid: #271347;
  --text: #f4efff;
  --muted: #b9a8e0;
  --accent: #ff4d8d;
  --accent2: #ffd166;
  --good: #2ed573;
  --bad: #ff4757;
  --a0: #ff4757;
  --a1: #3d5afe;
  --a2: #ffa502;
  --a3: #2ed573;
  --radius: 18px;
  font-size: 16px;
}

html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, var(--bg3), transparent 60%),
              radial-gradient(1000px 700px at 110% 110%, #6a2bd9aa, transparent 55%),
              linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3 { font-weight: 800; letter-spacing: 0.2px; }
button { font-family: inherit; cursor: pointer; border: none; color: inherit; background: none; }
input, select {
  font-family: inherit; font-size: 1.05rem; color: var(--text);
  background: rgba(0, 0, 0, 0.3); border: 2px solid #ffffff26; border-radius: 12px;
  padding: 0.7rem 0.9rem; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); }
select option { color: #222; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.7rem 0 0.25rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

.hidden { display: none !important; }
.accent { color: var(--accent); }
.plus { color: var(--good); }
.minus { color: var(--bad); }
.hint { color: var(--muted); font-size: 0.95rem; }
.hint.big { font-size: 1.3rem; margin-top: 1rem; }

.card {
  background: var(--card);
  border: 1px solid #ffffff1f;
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.btn-primary {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), #ff7eb6);
  color: #fff; font-weight: 800; font-size: 1.15rem;
  border-radius: 14px; padding: 0.85rem 1.6rem;
  box-shadow: 0 6px 20px #ff4d8d66, inset 0 -3px 0 #00000033;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.2s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.btn-primary:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn-primary:disabled { filter: grayscale(0.8) brightness(0.7); cursor: not-allowed; }
.btn-ghost { color: var(--muted); font-weight: 700; padding: 0.6rem 1rem; border-radius: 10px; border: 2px solid #ffffff2a; margin-top: 0.6rem; }

.logo { font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 900; }
.logo span { color: var(--accent); }
.logo-sm { font-size: 2rem; text-align: center; margin: 0.8rem 0 0.4rem; }

.screen { display: none; }
.screen.active { display: block; }

.spinner {
  width: 64px; height: 64px; margin: 0 auto 1.2rem;
  border-radius: 50%; border: 6px solid #ffffff22; border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================= LANDING ============================= */
.page-landing .landing { max-width: 900px; margin: 0 auto; padding: 8vh 1.5rem 3rem; text-align: center; }
.page-landing .tagline { color: var(--muted); font-size: 1.25rem; margin: 0.5rem 0 3rem; }
.lang-switch { position: absolute; top: 1rem; right: 1rem; display: flex; gap: 0.5rem; }
.lang-switch button { background: var(--card); border: 1px solid #ffffff22; border-radius: 10px; padding: 0.4rem 0.7rem; font-weight: 700; }
.landing-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.landing-card {
  background: var(--card); border: 1px solid #ffffff1f; border-radius: 22px;
  padding: 2.2rem 1.6rem; text-decoration: none; color: inherit; display: block;
  transition: transform 0.15s, background 0.2s;
}
.landing-card:hover { transform: translateY(-4px); background: rgba(255, 255, 255, 0.12); }
.landing-card-title { font-size: 1.7rem; font-weight: 900; }
.landing-card-sub { color: var(--muted); margin-top: 0.4rem; }
.join-row { display: flex; gap: 0.6rem; margin-top: 1.2rem; }
.join-row input { text-transform: uppercase; letter-spacing: 0.25em; font-weight: 800; text-align: center; }
.join-row button { background: var(--accent); border-radius: 12px; padding: 0 1.4rem; font-weight: 800; color: white; }

/* ============================= HOST ============================= */
.page-host { overflow: hidden; }

#screen-lang { text-align: center; padding-top: 16vh; }
.choose-lang { color: var(--muted); font-size: 1.3rem; margin: 1rem 0 2.5rem; }
.lang-cards { display: flex; gap: 2rem; justify-content: center; }
.lang-card {
  font-size: 4rem; background: var(--card); border: 2px solid #ffffff22; border-radius: 26px;
  padding: 2.2rem 3.2rem; display: flex; flex-direction: column; gap: 0.8rem; align-items: center;
  transition: transform 0.15s, border-color 0.15s;
}
.lang-card span { font-size: 1.4rem; font-weight: 800; }
.lang-card:hover { transform: translateY(-6px) scale(1.04); border-color: var(--accent); }

#screen-lobby { padding: 3vh 3vw; }
.lobby-grid { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 1.5rem; max-width: 1400px; margin: 0 auto; }
.lobby-join { text-align: center; }
.lobby-join h2 { font-size: 1.6rem; margin-bottom: 1rem; }
.qr { width: min(320px, 70%); border-radius: 16px; background: #fff; padding: 8px; }
.join-url { color: var(--muted); margin-top: 0.8rem; font-size: 1.05rem; }
.join-url b { color: var(--text); }
.big-code { font-size: 1.4rem; margin-top: 0.8rem; color: var(--muted); }
.big-code b { font-size: 3.2rem; color: var(--accent2); letter-spacing: 0.3em; display: block; font-weight: 900; }
.lobby-right { display: flex; flex-direction: column; gap: 1.5rem; }
.players-card h2 { margin-bottom: 0.8rem; }
.player-chips { display: flex; flex-wrap: wrap; gap: 0.6rem; min-height: 3rem; }
.player-chip {
  background: linear-gradient(135deg, #ffffff1c, #ffffff0d);
  border: 1px solid #ffffff2c; border-radius: 999px; padding: 0.5rem 1.1rem 0.5rem 0.7rem;
  font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 0.5rem;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.player-chip span { font-size: 1.5rem; }
.player-chip.offline { opacity: 0.4; filter: grayscale(1); }
.topic-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.6rem; }
.chip { background: #ffffff14; border: 1px solid #ffffff24; border-radius: 999px; padding: 0.35rem 0.9rem; font-size: 0.9rem; font-weight: 700; transition: background 0.15s; }
.chip:hover { background: var(--accent); }
.settings-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1.2rem; }
.settings-card .btn-primary { width: 100%; margin-top: 0.5rem; }
.settings-card .hint { text-align: center; margin-top: 0.6rem; }
.demo-badge {
  position: fixed; bottom: 0.8rem; left: 50%; transform: translateX(-50%);
  background: #ffa50226; border: 1px solid #ffa502; color: #ffd166;
  padding: 0.45rem 1.1rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
}
.resume-overlay {
  position: fixed; inset: 0; z-index: 300; background: #1b1035ee;
  display: flex; align-items: center; justify-content: center;
}

#screen-game { height: 100vh; display: flex; flex-direction: column; padding: 1.2rem 2rem; }
.game-top { display: flex; justify-content: space-between; align-items: center; font-weight: 900; font-size: 1.2rem; color: var(--muted); }
.game-top-left { font-size: 1.4rem; color: var(--text); }
.game-progress { font-size: 1.3rem; color: var(--accent2); }
.game-top-right b { color: var(--accent2); letter-spacing: 0.18em; }
.game-layout { flex: 1; display: grid; grid-template-columns: minmax(300px, 30%) 1fr; gap: 1.5rem; align-items: stretch; min-height: 0; padding-top: 1rem; }
.stage-left { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.quizzy-box { width: 100%; max-width: 420px; }
.quizzy-svg { width: 100%; height: auto; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.4)); }
.bubble {
  position: relative; background: #fff; color: #2d1460; font-weight: 700; font-size: 1.25rem;
  border-radius: 18px; padding: 1rem 1.2rem; margin-top: 0.6rem; width: 100%; max-width: 460px;
  min-height: 4.2rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: popIn 0.25s ease-out;
}
.bubble::before {
  content: ''; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent; border-bottom-color: #fff;
}
.panel { min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
/* Safe centering: auto margins collapse to 0 when content overflows. */
.panel > * { margin-top: auto; margin-bottom: auto; }

.center-panel { text-align: center; padding: 2rem; }
.center-panel h2 { font-size: 2rem; }
.topic-big { font-size: 2.6rem; font-weight: 900; color: var(--accent2); margin-top: 1rem; }
.intro-title { font-size: 4.5rem; font-weight: 900; }
.intro-players { display: flex; flex-wrap: wrap; gap: 0.8rem; justify-content: center; margin-top: 2rem; }
.intro-p { background: var(--card); border: 1px solid #ffffff22; padding: 0.6rem 1.3rem; border-radius: 999px; font-size: 1.4rem; font-weight: 800; animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; }
.intro-p:nth-child(2) { animation-delay: 0.1s; } .intro-p:nth-child(3) { animation-delay: 0.2s; }
.intro-p:nth-child(4) { animation-delay: 0.3s; } .intro-p:nth-child(5) { animation-delay: 0.4s; }

.countdown-bar { height: 12px; background: #00000055; border-radius: 999px; overflow: hidden; margin: 0.8rem 0; }
.countdown-fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.1s linear; }

.question-panel, .reveal-panel { padding: 0.5rem 1rem; }
.q-head { display: flex; justify-content: space-between; align-items: center; }
.q-category { background: var(--accent); border-radius: 999px; padding: 0.35rem 1.2rem; font-weight: 800; font-size: 1.05rem; }
.q-timer { font-size: 2.6rem; font-weight: 900; color: var(--accent2); min-width: 2ch; text-align: center; }
.q-text { font-size: clamp(1.6rem, 3.2vw, 2.6rem); margin: 1rem 0; min-height: 2.4em; }
.q-text-sm { font-size: 1.5rem; margin-bottom: 0.8rem; color: var(--muted); }
.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.5rem; }
.answer-card {
  border-radius: 16px; padding: 1.2rem 1.3rem; font-size: 1.45rem; font-weight: 800;
  display: flex; align-items: center; gap: 0.9rem; color: #fff;
  box-shadow: inset 0 -4px 0 #00000040, 0 6px 18px #00000040;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  transition: filter 0.3s, transform 0.3s, opacity 0.3s;
}
.answer-card:nth-child(2) { animation-delay: 0.07s; }
.answer-card:nth-child(3) { animation-delay: 0.14s; }
.answer-card:nth-child(4) { animation-delay: 0.21s; }
.a0 { background: var(--a0); } .a1 { background: var(--a1); } .a2 { background: var(--a2); } .a3 { background: var(--a3); }
.answer-shape { font-size: 1.2rem; opacity: 0.9; }
.answer-text { flex: 1; }
.answer-count { font-size: 1.2rem; opacity: 0.9; font-weight: 900; }
.answers-grid.reveal .correct { transform: scale(1.04); box-shadow: 0 0 0 4px #fff, 0 0 40px #2ed57399; }
.answers-grid.reveal .dimmed { filter: grayscale(0.75) brightness(0.55); }
.answered-line { text-align: center; color: var(--muted); font-size: 1.2rem; margin-top: 1rem; font-weight: 700; }
.answered-line span { color: var(--accent2); font-weight: 900; }

.reveal-events { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 1rem; }
.reveal-event {
  background: #00000045; border: 1px solid #ffffff22; border-left: 5px solid var(--accent2);
  border-radius: 10px; padding: 0.5rem 0.9rem; font-weight: 700; font-size: 1.1rem;
  animation: slideIn 0.35s ease-out backwards;
}
.reveal-event:nth-child(2) { animation-delay: 0.15s; } .reveal-event:nth-child(3) { animation-delay: 0.3s; }
.reveal-bottom { display: grid; grid-template-columns: 1fr minmax(240px, 36%); gap: 1rem; margin-top: 1rem; align-items: start; }
.reveal-results { display: flex; flex-direction: column; gap: 0.35rem; }
.rr { display: flex; align-items: center; gap: 0.7rem; background: #00000030; border-radius: 10px; padding: 0.4rem 0.8rem; font-weight: 700; font-size: 1.05rem; }
.rr > span:first-child { flex: 1; }
.rr.ok { border-left: 4px solid var(--good); }
.rr.ko { border-left: 4px solid var(--bad); }
.rr-score { color: var(--muted); min-width: 4ch; text-align: right; }
.rr-streak { color: var(--accent2); }
.funfact { background: #ffd16618; border: 1px solid #ffd16660; border-radius: 12px; padding: 0.8rem 1rem; font-size: 1.05rem; line-height: 1.4; }

.sabotage-panel { text-align: center; padding: 1rem 2rem; }
.sabotage-title { font-size: 3.2rem; animation: wobble 1.2s ease-in-out infinite; }
.sabotage-feed { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; min-height: 200px; }
.sabotage-item {
  background: #00000045; border: 1px solid #ffffff22; border-radius: 12px;
  padding: 0.7rem 1rem; font-size: 1.35rem; font-weight: 800;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lb-panel { padding: 1rem 2rem; }
.lb-panel h1 { text-align: center; font-size: 2.6rem; margin-bottom: 1.4rem; }
.lb-rows { display: flex; flex-direction: column; gap: 0.7rem; max-width: 900px; margin: 0 auto; width: 100%; }
.lb-row { display: flex; align-items: center; gap: 1rem; font-size: 1.35rem; font-weight: 800; }
.lb-rank { width: 2.2ch; text-align: right; color: var(--accent2); font-weight: 900; }
.lb-name { min-width: 200px; }
.lb-bar-wrap { flex: 1; background: #00000045; height: 26px; border-radius: 999px; overflow: hidden; }
.lb-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 999px; transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.lb-score { min-width: 5ch; text-align: right; }
.lb-val { color: var(--muted); min-width: 8ch; text-align: right; }

.minigame-badge { display: inline-block; background: var(--accent); border-radius: 999px; padding: 0.4rem 1.4rem; font-weight: 900; font-size: 1.1rem; letter-spacing: 0.1em; }
.minigame-title { font-size: 3.4rem; margin-top: 1rem; }
.mg-panel { padding: 1rem 2rem; }
.mg-panel h2 { text-align: center; font-size: 2.2rem; margin-bottom: 1.2rem; }
.tap-race { display: flex; flex-direction: column; gap: 0.8rem; }
.tap-row { display: flex; align-items: center; gap: 1rem; font-size: 1.3rem; font-weight: 800; }
.tap-name { min-width: 220px; }
.tap-bar-wrap { flex: 1; background: #00000045; height: 30px; border-radius: 999px; overflow: hidden; }
.tap-bar { height: 100%; width: 0; background: linear-gradient(90deg, #4dd2ff, #7dff8a); border-radius: 999px; transition: width 0.25s ease-out; }
.tap-n { min-width: 3ch; text-align: right; color: var(--accent2); }

.qd-panel { display: flex; align-items: center; justify-content: center; height: 100%; }
.qd-circle {
  width: min(46vh, 480px); height: min(46vh, 480px); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem; font-weight: 900; text-align: center;
  background: radial-gradient(circle at 35% 30%, #ff6b6b, #c0392b);
  box-shadow: 0 0 80px #c0392b88;
}
.qd-panel.armed .qd-circle { background: radial-gradient(circle at 35% 30%, #7dff8a, #1e8f4d); box-shadow: 0 0 100px #2ed573aa; animation: popIn 0.2s; }

.podium-panel { text-align: center; padding: 0.5rem; }
.podium-panel h1 { font-size: 2.8rem; margin-bottom: 1rem; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1.2rem; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; animation: riseIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
.podium-col.rank-1 { animation-delay: 0.5s; } .podium-col.rank-2 { animation-delay: 0.25s; } .podium-col.rank-3 { animation-delay: 0s; }
.podium-emoji { font-size: 3.4rem; }
.podium-name { font-size: 1.4rem; font-weight: 900; }
.podium-block {
  width: 160px; border-radius: 14px 14px 0 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.2rem; font-size: 1.5rem; font-weight: 900;
  background: linear-gradient(180deg, #ffffff2e, #ffffff10); border: 1px solid #ffffff2e; border-bottom: none;
}
.podium-col.rank-1 .podium-block { height: 190px; background: linear-gradient(180deg, #ffd16650, #ffd16615); }
.podium-col.rank-2 .podium-block { height: 140px; }
.podium-col.rank-3 .podium-block { height: 105px; }
.podium-block span { font-size: 2.2rem; }
.podium-rest { margin: 1.2rem 0; display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); font-weight: 700; }
.suspense-dots span { font-size: 5rem; font-weight: 900; color: var(--accent2); animation: blinkDot 1s infinite; display: inline-block; }
.suspense-dots span:nth-child(2) { animation-delay: 0.2s; }
.suspense-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ============================= PLAYER ============================= */
.page-player { overflow: hidden; }
#app { min-height: 100vh; display: flex; flex-direction: column; transition: transform 0.55s cubic-bezier(0.34, 1.3, 0.64, 1); }
.player-header {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 1rem;
  background: #00000038; border-bottom: 1px solid #ffffff1a;
  font-weight: 800; font-size: 1.1rem; position: sticky; top: 0; z-index: 5;
}
#ph-emoji { font-size: 1.5rem; }
#ph-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-header .score { color: var(--accent2); font-size: 1.35rem; font-weight: 900; }
.player-header .streak { color: var(--accent2); }

#screen-join { padding: 0 1.2rem 2rem; max-width: 460px; margin: 0 auto; width: 100%; }
.join-card input { text-transform: none; }
.join-card #code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 900; text-align: center; font-size: 1.4rem; }
.join-card .btn-primary { width: 100%; margin-top: 1.4rem; }
.join-error { color: var(--bad); font-weight: 700; margin-top: 0.8rem; text-align: center; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.4rem; }
.emoji-opt { font-size: 1.7rem; padding: 0.35rem 0; border-radius: 10px; border: 2px solid transparent; background: #ffffff10; transition: transform 0.1s; }
.emoji-opt.sel { border-color: var(--accent); background: #ff4d8d33; transform: scale(1.12); }

#screen-play { flex: 1; display: flex; flex-direction: column; }
#screen-play.active { display: flex; }
.p-panel { flex: 1; display: flex; flex-direction: column; padding: 1rem; }
.p-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.7rem; padding: 1.5rem 1rem; position: relative; }
.p-big-emoji { font-size: 5rem; }
.p-big-emoji.bounce { animation: bounce 1.6s ease-in-out infinite; }
.p-rank-big { font-size: 4rem; font-weight: 900; color: var(--accent2); }
.p-top-list { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.6rem; }
.p-top-row { display: flex; justify-content: space-between; background: #00000038; border-radius: 10px; padding: 0.55rem 0.9rem; font-weight: 700; }
.p-top-row.me { border: 2px solid var(--accent); background: #ff4d8d22; }

.pq-wrap { flex: 1; display: flex; flex-direction: column; }
.pq-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.pq-num { color: var(--muted); font-weight: 800; }
.pq-question { font-size: 1.15rem; font-weight: 700; margin: 0.6rem 0 1rem; line-height: 1.35; }
.p-answers { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 0.8rem; }
.p-answer {
  border-radius: 16px; font-size: 1.05rem; font-weight: 800; color: #fff; padding: 0.8rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
  box-shadow: inset 0 -4px 0 #00000040; transition: transform 0.1s, opacity 0.25s, filter 0.25s;
  min-height: 5.2rem;
}
.p-answer:active { transform: scale(0.96); }
.p-answer.faded { opacity: 0.35; filter: grayscale(0.6); }
.p-answer.locked { outline: 4px solid #fff; transform: scale(1.03); opacity: 1; filter: none; }
.p-answer .answer-shape { font-size: 1.4rem; }
.p-answer-text { line-height: 1.2; word-break: break-word; }
.p-answer.blackout { color: transparent; text-shadow: none; }
.p-answer.blackout .answer-shape { color: transparent; }
.p-answer.blackout .p-answer-text {
  color: #ffffff18;
  background: repeating-linear-gradient(0deg, #00000055 0 3px, #ffffff0d 3px 6px);
  border-radius: 6px; padding: 0.2rem 0.5rem;
  animation: staticFlicker 0.4s steps(2) infinite;
}
.pq-status { text-align: center; font-weight: 800; color: var(--accent2); min-height: 1.6rem; margin-top: 0.7rem; font-size: 1.1rem; }

.sab-wrap { flex: 1; display: flex; flex-direction: column; position: relative; }
.sab-title { text-align: center; font-size: 1.5rem; margin-bottom: 0.5rem; }
.pu-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; align-content: start; margin-top: 0.6rem; }
.pu-card {
  background: var(--card); border: 2px solid #ffffff24; border-radius: 16px; padding: 0.8rem 0.6rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem; text-align: center;
  transition: transform 0.12s, border-color 0.15s; position: relative; overflow: hidden;
}
.pu-card:active:not(.used) { transform: scale(0.95); }
.pu-card:not(.used):hover { border-color: var(--accent); }
.pu-icon { font-size: 2.1rem; }
.pu-name { font-weight: 900; font-size: 1.05rem; }
.pu-desc { font-size: 0.75rem; color: var(--muted); line-height: 1.25; }
.pu-card.used { opacity: 0.35; filter: grayscale(1); }
.pu-used { position: absolute; top: 8px; right: -26px; background: var(--bad); color: #fff; font-size: 0.7rem; font-weight: 900; padding: 0.15rem 2rem; transform: rotate(35deg); }
.sab-modal {
  position: absolute; inset: 0; background: #1b1035f5; border-radius: 16px; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1.2rem;
  animation: popIn 0.2s ease-out;
}
.sab-modal h3 { font-size: 1.35rem; text-align: center; }
.target-list { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; max-width: 320px; }
.target-list.stakes { flex-direction: row; justify-content: center; }
.target-btn {
  background: var(--card); border: 2px solid #ffffff2e; border-radius: 14px; padding: 0.9rem;
  font-size: 1.2rem; font-weight: 800; width: 100%; transition: border-color 0.15s, transform 0.1s;
}
.target-btn:active { transform: scale(0.96); }
.target-btn:hover { border-color: var(--accent); }
.target-btn.stake { font-size: 1.5rem; color: var(--accent2); }

.tap-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem; }
.tap-count { font-size: 4.5rem; font-weight: 900; color: var(--accent2); }
.tap-btn {
  width: min(70vw, 320px); height: min(70vw, 320px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff7eb6, var(--accent));
  color: #fff; font-size: 2.4rem; font-weight: 900;
  box-shadow: 0 12px 0 #a1275c, 0 20px 50px #00000066;
  user-select: none; touch-action: manipulation;
}
.tap-btn:active, .tap-btn.pulse { transform: translateY(7px); box-shadow: 0 5px 0 #a1275c, 0 12px 30px #00000066; }
.qd-pad {
  flex: 1; margin: 1rem; border-radius: 24px; font-size: 2.6rem; font-weight: 900; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ff6b6b, #c0392b);
  user-select: none; touch-action: manipulation; min-height: 60vh;
}
.qd-pad.armed { background: radial-gradient(circle at 35% 30%, #7dff8a, #1e8f4d); }

.reveal-mark { font-size: 4.5rem; }
.reveal-title { font-size: 2.2rem; }
.reveal-delta { font-size: 2.4rem; font-weight: 900; }
.reveal-streak { font-size: 1.3rem; font-weight: 800; color: var(--accent2); }
.reveal-correct-was { color: var(--muted); font-size: 1.05rem; }
.reveal-correct-was b { color: var(--text); }
.reveal-ev { background: #00000045; border-left: 4px solid var(--accent2); border-radius: 10px; padding: 0.5rem 0.8rem; font-weight: 700; font-size: 0.98rem; animation: slideIn 0.3s ease-out backwards; }
.p-center.reveal-good .reveal-title { color: var(--good); }
.p-center.reveal-bad .reveal-title { color: var(--bad); }

.toasts { position: fixed; top: 0.7rem; left: 50%; transform: translateX(-50%); z-index: 250; display: flex; flex-direction: column; gap: 0.4rem; width: min(92vw, 420px); pointer-events: none; }
.toast {
  background: #271347f2; border: 1px solid #ffffff30; border-radius: 12px; padding: 0.7rem 1rem;
  font-weight: 800; text-align: center; box-shadow: 0 8px 30px #00000066;
  animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.4s, transform 0.4s;
}
.toast.out { opacity: 0; transform: translateY(-10px); }
.toast.bad { border-color: var(--bad); background: #4a1420f2; }
.toast.good { border-color: var(--good); background: #14401ff2; }

/* ============================= FX ============================= */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 200; }
.fx-emoji {
  position: absolute; font-size: 1.8rem; pointer-events: none; z-index: 210;
  animation: emojiFly 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes emojiFly {
  0% { transform: translate(0, 0) rotate(0) scale(0.6); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1.3); opacity: 0; }
}
.fx-shake { animation: shakeAnim 0.55s; }
@keyframes shakeAnim {
  10%, 90% { transform: translate(-2px, 1px); } 20%, 80% { transform: translate(4px, -2px); }
  30%, 50%, 70% { transform: translate(-7px, 3px); } 40%, 60% { transform: translate(7px, -3px); }
}
.fx-explosion {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 9rem; z-index: 220; pointer-events: none;
  animation: explodeAnim 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes explodeAnim {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.6); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.4); opacity: 0; }
}
.fx-ice {
  position: fixed; inset: 0; z-index: 120; overflow: hidden; touch-action: manipulation;
  background: linear-gradient(155deg, #bfe8ffd8, #7db8e8e0 45%, #a8d4f5d8);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  border: 6px solid #e2f4ffaa;
}
.fx-ice-cracks { position: absolute; inset: 0; }
.fx-ice-label { font-size: 1.6rem; font-weight: 900; color: #0b3556; text-align: center; text-shadow: 0 2px 0 #ffffff88; animation: bounce 1.2s infinite; }
.fx-ice-count { font-size: 3.2rem; font-weight: 900; color: #0b3556; text-shadow: 0 2px 0 #ffffff88; }
.fx-ice-hit { animation: iceHit 0.15s; }
@keyframes iceHit { 50% { transform: scale(1.012); } }
.fx-ice-broken { animation: iceFade 0.6s forwards; }
@keyframes iceFade { to { opacity: 0; } }
.fx-shard {
  position: absolute; width: 34px; height: 44px; background: #cfeaffcc;
  clip-path: polygon(50% 0, 100% 40%, 65% 100%, 0 55%);
  animation: shardFly 0.65s cubic-bezier(0.5, 0, 1, 1) forwards;
}
@keyframes shardFly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
.fx-fog { position: fixed; inset: 0; z-index: 120; touch-action: none; }
.fx-fog canvas { position: absolute; inset: 0; }
.fx-fog-label {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  font-size: 1.4rem; font-weight: 900; color: #33415c; text-align: center; width: 90%;
  text-shadow: 0 1px 0 #ffffffcc; transition: opacity 0.4s; pointer-events: none;
}
.fx-fog-done { animation: iceFade 0.5s forwards; }
.fx-float {
  position: absolute; left: 50%; top: 40%; transform: translateX(-50%);
  font-size: 2.2rem; font-weight: 900; z-index: 230; pointer-events: none;
  animation: floatUp 1.5s ease-out forwards;
}
@keyframes floatUp { to { transform: translate(-50%, -90px); opacity: 0; } }

/* ============================= topic theming ============================= */
.quizzy-name {
  background: linear-gradient(135deg, #ffffff26, #ffffff10);
  border: 1px solid #ffffff33; border-radius: 999px;
  padding: 0.3rem 1.1rem; font-weight: 900; font-size: 1.05rem;
  margin-top: 0.3rem; color: var(--accent2);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.floaties { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.floaty {
  position: absolute; bottom: -70px; opacity: 0;
  animation: floatyRise linear infinite;
}
@keyframes floatyRise {
  0% { transform: translateY(0) rotate(-8deg); opacity: 0; }
  8% { opacity: 0.22; }
  90% { opacity: 0.18; }
  100% { transform: translateY(-115vh) rotate(10deg); opacity: 0; }
}
.q-reading-badge { font-size: 2rem; animation: bounce 1.1s infinite; }
.reading-dots { text-align: center; }
.reading-dots span { font-size: 3rem; }
.pq-reading .pq-question-big { font-size: 1.45rem; font-weight: 800; line-height: 1.35; }

/* ============================= shared keyframes ============================= */
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideIn { 0% { transform: translateX(-24px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes slideDown { 0% { transform: translateY(-18px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes blinkDot { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes riseIn { 0% { transform: translateY(80px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes staticFlicker { 0% { opacity: 0.85; } 100% { opacity: 1; } }

/* ============================= responsive ============================= */
@media (max-width: 980px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .game-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .stage-left { flex-direction: row; justify-content: center; align-items: center; gap: 1rem; }
  .quizzy-box { max-width: 150px; flex-shrink: 0; }
  .q-text { font-size: 1.4rem; min-height: 0; }
  .answer-card { font-size: 1.15rem; padding: 0.9rem 1rem; }
  .bubble { margin-top: 0; }
  .answers-grid { grid-template-columns: 1fr; }
  .reveal-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .settings-row { grid-template-columns: 1fr; }
}
