:root {
  --bg1: #3b1d8f;
  --bg2: #1d4f91;
  --card: #ffffff;
  --ink: #1f1b2e;
  --muted: #6b6880;
  --line: #e4e1ef;
  --primary: #5b2be0;
  --primary-ink: #ffffff;
  --danger: #c62842;
  --ok: #1f9d55;
  --bad: #d63a3a;
  --c0: #e8730c; /* ★ orange */
  --c1: #12917f; /* ● teal */
  --c2: #7d3fc4; /* ▲ purple */
  --c3: #d0306f; /* ◆ pink */
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1), var(--bg2)) fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
.muted { color: var(--muted); }
.center { text-align: center; }
.logo { font-weight: 900; letter-spacing: -.02em; color: #fff; font-size: 2.6rem; margin-bottom: 1rem; }
.logo span { color: #ffd23f; }

.screen {
  min-height: 100vh;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.screen.centered { justify-content: center; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
.card.wide { max-width: 960px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }
.big-input { font-size: 1.4rem; text-align: center; font-weight: 700; }

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  background: #ece9f6;
  color: var(--ink);
  cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(.96); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: #fde7ea; color: var(--danger); }
.btn.dark { background: #1f1b2e; color: #fff; }
.btn.lg { font-size: 1.2rem; padding: 14px 22px; }
.btn.block { width: 100%; }
.btn.small { padding: 6px 10px; font-size: .9rem; }

.error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 0; }

/* ---------- Topbar ---------- */
.topbar {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  margin-bottom: 16px;
  gap: 12px;
}
.topbar .logo { font-size: 1.8rem; margin: 0; }
.pill {
  background: rgba(255,255,255,.18);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
}

/* ---------- Library ---------- */
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  width: 100%;
}
.quiz-card {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-card h3 { word-break: break-word; }
.quiz-card .row { margin-top: auto; }

/* ---------- Editor ---------- */
.q-edit {
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.q-edit select { width: auto; }
.choice-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.choice-edit {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 6px 8px;
  color: #fff;
}
.choice-edit input[type="text"] { border: 0; padding: 8px 10px; }
.choice-edit input[type="radio"] { width: 22px; height: 22px; accent-color: #fff; flex: none; cursor: pointer; }
.choice-edit .shape { font-size: 1.2rem; width: 1.4rem; text-align: center; flex: none; }

.c0 { background: var(--c0); }
.c1 { background: var(--c1); }
.c2 { background: var(--c2); }
.c3 { background: var(--c3); }

/* ---------- Lobby ---------- */
.pin-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 28px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.pin-box .label { font-weight: 700; color: var(--muted); }
.pin-box .pin { font-size: clamp(3rem, 10vw, 5.5rem); font-weight: 900; letter-spacing: .08em; line-height: 1; }
.pin-box .url { font-weight: 600; word-break: break-all; }

.players {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 1000px;
  margin: 24px 0;
}
.chip {
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 999px;
  border: 0;
  font-size: 1.05rem;
  animation: pop .25s ease-out;
}
button.chip { cursor: pointer; }
button.chip:hover { text-decoration: line-through; background: #fde7ea; }
.chip.off { opacity: .45; }

@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Question (host) ---------- */
.question-text {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  font-size: clamp(1.4rem, 3.5vw, 2.4rem);
  font-weight: 800;
  text-align: center;
  width: 100%;
  max-width: 1200px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  word-break: break-word;
}
.q-middle {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0;
  color: #fff;
}
.timer {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--primary);
  border: 6px solid #fff;
  color: #fff;
  font-size: 2.6rem;
  font-weight: 900;
  display: grid;
  place-items: center;
}
.timer.low { background: var(--bad); animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.stat { text-align: center; font-weight: 800; font-size: 1.1rem; }
.stat b { display: block; font-size: 2.4rem; }

.answer-grid {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.answer {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  font-weight: 800;
  font-size: clamp(1.1rem, 2.5vw, 1.7rem);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-height: 90px;
  border: 0;
  text-align: left;
  word-break: break-word;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18);
}
.answer .shape { font-size: 2.2rem; flex: none; width: 2.4rem; text-align: center; }
.answer.dim { opacity: .3; }
.answer .tick { margin-left: auto; font-size: 2rem; }

/* ---------- Ready ---------- */
.ready-count {
  font-size: 7rem;
  font-weight: 900;
  color: #fff;
  animation: pop .4s ease-out;
}

/* ---------- Result ---------- */
.result-wrap {
  width: 100%;
  max-width: 1200px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 12px;
  height: 260px;
  padding-top: 30px;
}
.bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.bar .fill {
  width: 100%;
  border-radius: 10px 10px 0 0;
  min-height: 8px;
  transition: height .6s ease-out;
}
.bar .count { font-weight: 900; font-size: 1.5rem; }
.bar .lbl { font-size: 1.6rem; color: #fff; border-radius: 8px; width: 100%; text-align: center; padding: 4px 0; }
.bar.dim .fill, .bar.dim .lbl { opacity: .3; }

.leader { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.leader li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: #f3f1fa;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 1.15rem;
}
.leader li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Podium ---------- */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 30px 0;
  width: 100%;
  max-width: 720px;
}
.podium .place {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  animation: rise .8s ease-out both;
}
.podium .place .who { font-weight: 900; font-size: 1.3rem; text-align: center; word-break: break-word; }
.podium .place .pts { opacity: .85; font-weight: 700; margin-bottom: 6px; }
.podium .block {
  width: 100%;
  border-radius: 12px 12px 0 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  font-weight: 900;
}
.podium .p1 .block { height: 220px; background: #f5b700; }
.podium .p2 .block { height: 160px; background: #b9c2cf; }
.podium .p3 .block { height: 120px; background: #cd7f32; }
.podium .p1 { order: 2; animation-delay: .9s; }
.podium .p2 { order: 1; animation-delay: .5s; }
.podium .p3 { order: 3; animation-delay: .1s; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Power-up ---------- */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  background: rgba(255,255,255,.15);
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
  cursor: pointer;
}
.toggle input { width: 20px; height: 20px; accent-color: #ffd23f; }

.power-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 800px;
  margin-bottom: 10px;
}
.power-btn {
  flex: 1;
  font: inherit;
  font-weight: 800;
  font-size: .9rem;
  border: 2px solid rgba(255,255,255,.6);
  background: rgba(255,255,255,.15);
  color: #fff;
  border-radius: 12px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.power-btn span { font-size: 1.4rem; }
.power-btn.on { background: #ffd23f; border-color: #ffd23f; color: #1f1b2e; box-shadow: 0 0 16px #ffd23f; }
.power-btn:disabled:not(.on) { opacity: .35; cursor: not-allowed; }
.power-btn:disabled.on { cursor: default; }

@media (max-width: 560px) {
  .power-bar { grid-template-columns: repeat(3, 1fr); }
}

.freeze-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #0b3954;
  text-align: center;
  background: rgba(190, 230, 255, .82);
  backdrop-filter: blur(4px);
  animation: pop .2s ease-out;
}

.answer.removed { opacity: .15; filter: grayscale(1); cursor: not-allowed; }

.power-feed {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  z-index: 10;
}
.power-item {
  background: #ffd23f;
  color: #1f1b2e;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  animation: pop .25s ease-out;
}

/* ---------- Player ---------- */
.player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  font-weight: 800;
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
  z-index: 5;
}
.player-bar .score { background: #1f1b2e; color: #fff; border-radius: 8px; padding: 2px 10px; }

.play-screen { padding-bottom: 70px; }
.play-q {
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 12px;
  max-width: 800px;
}
.play-timer { color: #fff; font-weight: 900; font-size: 1.4rem; margin-bottom: 10px; }
.play-grid {
  flex: 1;
  width: 100%;
  max-width: 800px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 60vh;
}
.play-grid .answer {
  flex-direction: column;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  font-size: 1.05rem;
  padding: 12px;
}
.play-grid .answer .shape { font-size: 3rem; width: auto; }
.play-grid .answer:active { transform: scale(.97); }

.big-emoji { font-size: 5rem; line-height: 1; margin-bottom: 8px; }
.feedback { color: #fff; text-align: center; }
.feedback h2 { font-size: 2.2rem; }
.feedback .points {
  display: inline-block;
  background: rgba(0,0,0,.25);
  padding: 8px 20px;
  border-radius: 10px;
  font-size: 1.6rem;
  font-weight: 900;
  margin: 10px 0;
}
body.good { background: linear-gradient(135deg, #1f9d55, #138a6e) fixed; }
body.bad { background: linear-gradient(135deg, #d63a3a, #a3214a) fixed; }

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

.toast {
  position: fixed;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  background: #1f1b2e;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  z-index: 20;
  max-width: calc(100% - 32px);
}

@media (max-width: 760px) {
  .result-wrap { grid-template-columns: 1fr; }
  .choice-edit-grid { grid-template-columns: 1fr; }
  .timer { width: 80px; height: 80px; font-size: 2rem; border-width: 4px; }
  .answer-grid { grid-template-columns: 1fr; }
}

/* =================== Extra features =================== */
.small-label { font-size: .85rem; }
.note { background: #fff6d6; border-radius: 10px; padding: 10px 14px; margin: 0; font-weight: 600; }
.btn.ai { background: linear-gradient(135deg, #ffd23f, #ff9f43); color: #1f1b2e; }
.spinner.dark { border-color: rgba(0,0,0,.12); border-top-color: var(--primary); }

/* Sound */
.sound-btn {
  position: fixed; top: 12px; right: 12px; z-index: 30;
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.2); color: #fff; font-size: 1.3rem; cursor: pointer;
}
.sound-btn:hover { background: rgba(255,255,255,.35); }

/* Connection status banner */
.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 25;
  background: #ffd23f; color: #1f1b2e; font-weight: 800; text-align: center; padding: 8px 16px;
}

/* Avatar */
.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatar-opt {
  font-size: 1.5rem; border: 2px solid var(--line); background: #fff; border-radius: 10px;
  padding: 4px 0; cursor: pointer; line-height: 1.3;
}
.avatar-opt.on { border-color: var(--primary); background: #efe9ff; transform: scale(1.08); }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.chip-avatar { font-size: 1.3rem; }
@media (max-width: 400px) { .avatar-grid { grid-template-columns: repeat(4, 1fr); } }

/* Lobby */
.lobby-head { display: flex; gap: 16px; align-items: stretch; flex-wrap: wrap; justify-content: center; }
.qr { width: 170px; height: 170px; background: #fff; border-radius: var(--radius); padding: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.qr.small { width: 120px; height: 120px; box-shadow: none; border: 2px solid var(--line); }
.settings { justify-content: center; margin-top: 16px; }
.settings .toggle { margin-bottom: 0; }
.toggle select { width: auto; padding: 4px 8px; }
.team-col {
  background: rgba(255,255,255,.12); border-radius: var(--radius); padding: 12px;
  min-width: 200px; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.team-col h3 { color: #fff; }
.team-badge {
  display: inline-block; background: rgba(0,0,0,.25); padding: 6px 14px; border-radius: 999px; font-weight: 800;
}

/* Reactions */
.react-bar {
  position: fixed; bottom: 58px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px;
  padding: 6px; flex-wrap: wrap;
}
.react-btn {
  font-size: 1.5rem; background: rgba(255,255,255,.2); border: 0; border-radius: 50%;
  width: 44px; height: 44px; cursor: pointer;
}
.react-btn.sent { animation: bump .35s ease-out; }
@keyframes bump { 50% { transform: scale(1.4); } }
.reaction-layer { position: fixed; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.float-react {
  position: absolute; bottom: -60px; display: flex; flex-direction: column; align-items: center;
  animation: floatUp 3.2s ease-out forwards;
}
.float-react span { font-size: 3rem; }
.float-react small { color: #fff; font-weight: 700; background: rgba(0,0,0,.3); border-radius: 999px; padding: 0 8px; }
@keyframes floatUp {
  0% { transform: translateY(0) scale(.6); opacity: 0; }
  15% { opacity: 1; transform: translateY(-15vh) scale(1); }
  100% { transform: translateY(-85vh) scale(1.1); opacity: 0; }
}

/* Bonus question */
.bonus-badge {
  display: inline-block; background: #ffd23f; color: #1f1b2e; font-weight: 900;
  padding: 4px 12px; border-radius: 999px; margin: 0;
}
.bonus-badge.big { font-size: 1.4rem; padding: 8px 20px; margin-top: 12px; animation: pulse .6s infinite alternate; }

/* Question on the host screen */
.q-img { max-height: 30vh; max-width: 50%; border-radius: var(--radius); background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.big-note {
  background: rgba(255,255,255,.15); color: #fff; border-radius: var(--radius);
  font-size: clamp(1.4rem, 3vw, 2.2rem); font-weight: 800; text-align: center; padding: 30px 20px;
}
.range-note { font-size: 1.4em; margin-top: 8px; }
.type-note { color: #fff; font-weight: 800; text-align: center; font-size: 1.2rem; }
.correct-line { font-weight: 800; font-size: 1.2rem; text-align: center; background: #e8f8ee; color: var(--ok); border-radius: 10px; padding: 10px; }
.leader li.good { background: #e8f8ee; color: var(--ok); }
.leader.teams li { background: #fff6d6; }
.leader.hard li .nm { white-space: normal; }
.final-grid {
  width: 100%; max-width: 1200px; display: grid; gap: 16px; margin-top: 8px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* Question on the player phone */
.play-top { width: 100%; max-width: 800px; margin-bottom: 8px; }
.play-timer.low { color: #ffd23f; animation: pulse .5s infinite alternate; }
.play-img { max-width: 100%; max-height: 22vh; border-radius: 12px; margin-bottom: 8px; background: #fff; }
.play-hint { color: #fff; opacity: .85; font-weight: 600; margin-bottom: 8px; text-align: center; }
.answer-area { width: 100%; max-width: 800px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.answer-area .play-grid { flex: 1; min-height: 45vh; }
.answer.picked { outline: 5px solid #fff; outline-offset: -5px; }
.answer.picked::after { content: '✔'; font-size: 1.6rem; }
.submit-btn { margin-top: 4px; }
.slider-box { background: #fff; border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.slider-value { font-size: 3rem; font-weight: 900; text-align: center; color: var(--primary); }
input[type="range"] { padding: 0; border: 0; accent-color: var(--primary); height: 36px; flex: 1; }
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-item {
  display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800;
  border-radius: 12px; padding: 10px 12px; font-size: 1.05rem;
}
.order-item .btn { background: rgba(255,255,255,.9); }
.order-num {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.25);
  display: grid; place-items: center; flex: none; color: #fff; font-weight: 900;
}

/* Editor */
.q-edit.is-bonus { border-color: #ffd23f; background: #fffbea; }
.bonus-check { display: flex; align-items: center; gap: 4px; font-weight: 700; cursor: pointer; }
.bonus-check input { width: 18px; height: 18px; }
.slider-edit { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
@media (max-width: 760px) { .slider-edit { grid-template-columns: 1fr 1fr; } }
.img-preview { display: flex; align-items: center; gap: 10px; }
.img-preview img { max-height: 90px; max-width: 160px; border-radius: 8px; border: 2px solid var(--line); }
.choice-edit input[type="checkbox"] { width: 22px; height: 22px; accent-color: #fff; flex: none; cursor: pointer; }

/* Assignments */
.assign-row {
  display: flex; align-items: center; gap: 12px; border: 2px solid var(--line);
  border-radius: 10px; padding: 8px 12px; flex-wrap: wrap;
}
.code { font-family: Consolas, monospace; font-weight: 900; font-size: 1.1rem; letter-spacing: .1em; background: #efe9ff; border-radius: 6px; padding: 2px 8px; }
.url-box { font-family: Consolas, monospace; background: #f3f1fa; border-radius: 8px; padding: 6px 10px; word-break: break-all; }

.screen:has(.react-bar) { padding-bottom: 140px; }

/* Viewer mode */
.watch-line { color: #fff; font-size: .9rem; opacity: .9; word-break: break-all; text-align: center; margin: 4px 0 0; }
.watch-line #watch-url { font-weight: 800; color: #ffd23f; }
.float-react.viewer span { font-size: 2.2rem; opacity: .9; }
.float-react.viewer small { background: rgba(255,210,63,.35); }
body.watching .watch-react { bottom: 8px; z-index: 11; }
body.watching .screen { padding-bottom: 80px; }
body.watching #s-enter .card { max-width: 420px; }

/* Avatar picker (many avatars) */
.avatar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.avatar-current { font-size: 1.8rem; vertical-align: middle; }
.avatar-grid {
  position: relative; max-height: 196px; overflow-y: auto; padding: 4px; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 12px;
}
.avatar-opt.taken { opacity: .25; filter: grayscale(1); cursor: not-allowed; }
.avatar-opt:disabled { pointer-events: none; }

/* Lobby with many players */
.players.many { max-height: 42vh; overflow-y: auto; gap: 6px; }
.players.many .chip { font-size: .8rem; padding: 3px 9px; }
.players.many .chip-avatar { font-size: 1rem; }

/* ================= Game modes ================= */
.mode-label {
  color: #1f1b2e; background: #ffd23f; font-weight: 800; border-radius: 999px; padding: 6px 16px; margin: 8px 0 0;
}
.mode-pill { background: #ffe1e1 !important; color: #a3122a !important; }

/* Boss Raid */
.boss-card {
  position: relative; width: 100%; max-width: 900px; margin: 8px auto; padding: 14px 18px;
  background: linear-gradient(135deg, #2b1055, #7a1f5c); color: #fff; border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.boss-card.small { padding: 8px 14px; max-width: 700px; }
.boss-head { display: flex; align-items: center; gap: 16px; }
.boss-icon { font-size: 4rem; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.boss-card.small .boss-icon { font-size: 2.4rem; }
.boss-icon.shake { animation: bossShake .6s ease-in-out 2; }
.boss-icon.dead { filter: grayscale(1); transform: rotate(90deg); opacity: .6; transition: all .8s; }
@keyframes bossShake {
  20% { transform: translateX(-10px) rotate(-8deg); } 40% { transform: translateX(10px) rotate(8deg); }
  60% { transform: translateX(-6px) rotate(-4deg); } 80% { transform: translateX(6px) rotate(4deg); }
}
.boss-name { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.3rem; flex-wrap: wrap; }
.combo { background: #ff6b35; border-radius: 999px; padding: 2px 10px; font-size: .85rem; animation: pulse .5s ease-in-out infinite alternate; }
.hp-bar { height: 18px; background: rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; margin: 6px 0 2px; }
.hp-fill { height: 100%; background: linear-gradient(90deg, #ff3b3b, #ff9f1c); border-radius: 999px; transition: width 1.2s cubic-bezier(.2,.8,.2,1); }
.hp-text { font-size: .85rem; opacity: .9; font-weight: 700; }
.hp-bar.mini { height: 10px; background: rgba(255,255,255,.25); max-width: 260px; margin: 8px auto 2px; }
.boss-float { position: absolute; right: 18px; top: 8px; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.boss-float span { font-weight: 900; font-size: 2rem; animation: dmgFloat 2.4s ease-out .5s both; text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.boss-float .dmg { color: #ffd23f; }
.boss-float .heal { color: #7dffa1; font-size: 1.3rem; }
@keyframes dmgFloat { 0% { opacity: 0; transform: translateY(10px) scale(.6); } 20% { opacity: 1; transform: scale(1.2); } 100% { opacity: 0; transform: translateY(-40px); } }
.boss-lines { margin-top: 8px; font-weight: 800; display: flex; flex-direction: column; gap: 2px; }

/* Battle Royale */
#r-royale:not(:empty) { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.royale-head { font-weight: 900; font-size: 1.2rem; text-align: center; }
.royale-note { text-align: center; font-weight: 700; color: var(--muted); }
.royale-label { font-weight: 800; margin: 8px 0 4px; }
.royale-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.royale-chips .chip { font-size: .9rem; padding: 6px 12px; background: #f3f1fa; }
.out-chip { background: #ffe1e1 !important; color: #a3122a; animation: knockOut .7s ease-in both; }
@keyframes knockOut { 0% { transform: scale(1.2); opacity: 0; } 60% { transform: scale(1); opacity: 1; } 100% { text-decoration: line-through; opacity: .75; } }
.saved-chip { background: #e8f8ee !important; color: var(--ok); }
.leader li.out { opacity: .55; text-decoration: line-through; }

/* Racing leaderboard */
.leader li.race { will-change: transform; }
.leader li .right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.leader .move { font-size: .8rem; font-weight: 900; padding: 1px 6px; border-radius: 999px; }
.leader .move.up { background: #e8f8ee; color: var(--ok); }
.leader .move.down { background: #ffe9ec; color: var(--bad); }
.leader .gain { font-size: .8rem; font-weight: 800; color: var(--primary); }
.leader .sc { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }

/* Polling & Word Cloud */
.correct-line.neutral { background: #eef0ff; color: var(--primary); }
.cloud {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 18px;
  min-height: 180px; padding: 16px; background: #fff; border-radius: var(--radius);
}
.cloud.empty { color: var(--muted); font-weight: 700; font-size: 1.3rem; }
.cloud .word { font-weight: 900; line-height: 1.1; animation: pop .35s ease-out; border: 0; background: none; font-family: inherit; padding: 2px 4px; }
.cloud.moderated .word { cursor: pointer; border-radius: 8px; }
.cloud.moderated .word:hover { background: #ffe9ec; text-decoration: line-through; }

/* Badges */
.podium-title { text-align: center; }
.badges-card { margin: 0 auto 16px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.badge-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff8e1;
  border: 2px solid #ffd23f; border-radius: 12px; animation: badgePop .5s cubic-bezier(.2,1.6,.4,1) both; text-align: left; color: var(--ink);
}
@keyframes badgePop { from { transform: scale(.3) rotate(-10deg); opacity: 0; } to { transform: none; opacity: 1; } }
.badge-icon { font-size: 2.2rem; }
.badge-label { font-weight: 900; }
.badge-desc { font-size: .8rem; color: var(--muted); }
.badge-who { font-size: .85rem; font-weight: 700; margin-top: 2px; }
.my-badges { display: flex; flex-direction: column; gap: 8px; margin: 12px auto 0; max-width: 360px; }
.my-badges h3 { color: #fff; margin: 0; }

/* Mode info on the player phone */
.mode-box { margin: 10px auto; max-width: 360px; background: rgba(0,0,0,.2); border-radius: 12px; padding: 10px; }
.mode-line { font-weight: 800; margin: 2px 0; }
.mode-line.bad { color: #ffd1d1; font-size: 1.15rem; }
.mode-line.small { font-size: .85rem; opacity: .9; }
/* Cards inside the player feedback screen (white text) keep the ink colour. */
.feedback .card { color: var(--ink); text-align: left; }
.feedback .card h3 { text-align: center; }

/* ================= More power-ups ================= */
.power-bar { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 560px) {
  .power-bar { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .power-btn { font-size: .68rem; padding: 4px 2px; }
  .power-btn span { font-size: 1.1rem; }
}

/* Fog: answers are blurred but still clickable */
#answer-area { transition: filter .4s; }
#answer-area.fogged { filter: blur(7px) saturate(.4); }
.fog-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 9; display: flex; align-items: center; justify-content: space-around;
  background: radial-gradient(circle, rgba(255,255,255,.25), rgba(255,255,255,.05));
}
.fog-layer span { font-size: 6rem; opacity: .75; animation: fogDrift 4s ease-in-out infinite alternate; }
.fog-layer span:nth-child(2) { animation-delay: -1.5s; }
@keyframes fogDrift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }

/* Mystery Box */
.mystery-pop {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(20, 10, 50, .6); pointer-events: none; color: #fff;
}
.mystery-box { font-size: 7rem; animation: boxShake .6s ease-in-out; }
.mystery-pop.open .mystery-box { animation: boxOpen .4s ease-in forwards; }
@keyframes boxShake { 25% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } 75% { transform: rotate(-8deg); } }
@keyframes boxOpen { to { transform: scale(1.6); opacity: 0; } }
.mystery-prize { display: flex; flex-direction: column; align-items: center; opacity: 0; transform: scale(.4); margin-top: -4rem; }
.mystery-pop.open .mystery-prize { animation: badgePop .5s cubic-bezier(.2,1.6,.4,1) .2s forwards; }
.mystery-prize span { font-size: 5rem; }
.mystery-prize b { font-size: 1.8rem; text-shadow: 0 2px 8px rgba(0,0,0,.5); }

/* Steal Points events on the host/viewer result screen */
.r-events:not(:empty) { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.r-event { font-weight: 800; background: #fff1e6; color: #b4470b; border-radius: 10px; padding: 8px 12px; animation: pop .4s ease-out both; }
.r-event.blocked { background: #e8f8ee; color: var(--ok); }

/* ================= Shop, cards & new power-ups ================= */
.power-bar { grid-template-columns: repeat(7, 1fr); }
.power-btn { position: relative; }
.power-btn[data-count]:not([data-count=""])::after {
  content: attr(data-count);
  position: absolute; top: -8px; right: -6px;
  background: #ffd23f; color: #1f1b2e; border-radius: 999px;
  font-size: .72rem; padding: 1px 6px; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.power-empty { grid-column: 1 / -1; margin: 0; color: #fff; font-weight: 700; text-align: center; opacity: .85; }
@media (max-width: 560px) {
  /* 14 power-ups: scroll horizontally on phones */
  .power-bar { display: flex; overflow-x: auto; padding-top: 8px; scrollbar-width: thin; }
  .power-btn { flex: 0 0 62px; }
  .power-empty { flex: 1; }
}
.coins { background: #ffd23f; color: #1f1b2e; border-radius: 999px; padding: 2px 10px; font-weight: 800; }
#play-timer.paused { background: #4aa3ff; color: #fff; animation: pulse .5s ease-in-out infinite alternate; }

.quick-ring {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #ff4f7b; color: #fff; font-weight: 900; font-size: 1.6rem;
  padding: 8px 22px; border-radius: 999px; box-shadow: 0 0 24px rgba(255,79,123,.7);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.answer .peek-pct {
  position: absolute; top: 6px; right: 8px; background: rgba(0,0,0,.45); color: #fff;
  border-radius: 999px; padding: 2px 8px; font-size: .9rem;
}
.play-grid .answer { position: relative; }
.answer.peek-top { box-shadow: 0 0 0 4px #ffd23f, 0 0 20px #ffd23f; }

.shop { width: 100%; max-width: 560px; margin: 14px auto 0; background: rgba(255,255,255,.12); border-radius: 16px; padding: 12px; color: #fff; }
.shop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 1.05rem; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.shop-item {
  position: relative; font: inherit; text-align: center; cursor: pointer;
  background: #fff; color: var(--ink); border: 0; border-radius: 12px; padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .1s;
}
.shop-item:not(:disabled):active { transform: scale(.95); }
.shop-item:disabled { opacity: .45; cursor: not-allowed; }
.shop-item.owned { box-shadow: 0 0 0 3px #ffd23f; }
.shop-icon { font-size: 1.5rem; }
.shop-name { font-weight: 800; font-size: .9rem; }
.shop-desc { font-size: .7rem; color: var(--muted); line-height: 1.2; }
.shop-price { font-weight: 800; font-size: .85rem; color: #a46b00; }
.shop-have { position: absolute; top: -6px; right: -6px; background: #ffd23f; color: #1f1b2e; border-radius: 999px; padding: 1px 7px; font-size: .75rem; font-weight: 800; }

.power-picker { background: rgba(255,255,255,.14); border-radius: 16px; padding: 12px; margin: 0 auto 12px; max-width: 900px; color: #fff; }
.power-picker-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.power-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.power-chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.35); border-radius: 999px; padding: 5px 12px; font-weight: 700;
}
.power-chip input { accent-color: #ffd23f; }
.power-chip.on { background: #ffd23f; color: #1f1b2e; border-color: #ffd23f; }

/* ================= Language switch ================= */
.lang-switch {
  position: fixed; right: 10px; bottom: 10px; z-index: 90;
  display: flex; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,.35); backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,.35);
}
.lang-switch button {
  font: inherit; font-size: .75rem; font-weight: 800; letter-spacing: .04em;
  background: transparent; color: #fff; border: 0; padding: 4px 10px; cursor: pointer;
}
.lang-switch button.on { background: #ffd23f; color: #1f1b2e; }

/* Keep the fixed sound button from covering topbar buttons. */
.topbar { padding-right: 52px; }
/* During a game the player bar and reactions own the bottom edge; players pick the language on the join screen. */
body:has(#player-bar:not([hidden])) .lang-switch { display: none; }

/* Special power-ups */
#play-hint.hint-on {
  background: #ffd23f; color: #1f1b2e; font-weight: 800;
  border-radius: 12px; padding: 6px 12px; letter-spacing: .04em;
}
.play-grid.scrambled .answer { animation: scramble-shake .35s ease-in-out infinite alternate; }
@keyframes scramble-shake { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
.power-bar.jammed { position: relative; filter: grayscale(1); }
.power-bar.jammed::after {
  content: '📵'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 2rem; pointer-events: none;
}
/* Many power-ups on a phone: two rows that scroll sideways. */
@media (max-width: 560px) {
  .power-bar {
    grid-template-columns: none; grid-auto-flow: column; grid-template-rows: repeat(2, auto);
    grid-auto-columns: 68px; overflow-x: auto; padding-top: 8px; scrollbar-width: thin;
  }
}

/* Hero avatars (inline SVG portraits) */
.av { display: inline-block; width: 1.6em; height: 1.6em; border-radius: 50%; overflow: hidden; vertical-align: middle; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.av svg { display: block; width: 100%; height: 100%; }
.av.av-text { width: auto; height: auto; border-radius: 0; overflow: visible; box-shadow: none; }
.av.big-av { width: 120px; height: 120px; box-shadow: 0 0 0 5px #fff, 0 10px 30px rgba(0,0,0,.35); }
.with-av { display: inline-flex; align-items: center; gap: 6px; }
.chip .av.chip-avatar { width: 1.9em; height: 1.9em; margin-right: 4px; }
.podium-av { width: 64px; height: 64px; display: block; margin: 0 auto 6px; }
.place .who { display: flex; flex-direction: column; align-items: center; }
.float-react small .av { width: 1.4em; height: 1.4em; }
#bar-avatar .av { width: 1.5em; height: 1.5em; }
/* Hero picker */
.avatar-grid { display: block; }
.avatar-team { margin-bottom: 10px; }
.avatar-team-name { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #5b4b8a; margin: 4px 2px; }
.avatar-team-name.villain { color: #a4243b; }
.avatar-team-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.avatar-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: inherit; }
.avatar-opt .av { width: 46px; height: 46px; box-shadow: none; }
.avatar-opt-name { font-size: .62rem; font-weight: 700; line-height: 1.1; text-align: center; color: #333; }
.avatar-opt.recolor .av { outline: 2px dashed #f0a500; outline-offset: 1px; }
.avatar-current .av { width: 2.2em; height: 2.2em; }
.avatar-current { display: inline-flex; align-items: center; font-size: 1rem; }
@media (max-width: 400px) { .avatar-team-grid { grid-template-columns: repeat(4, 1fr); } }
