:root {
  --ink: #101411;
  --muted: #5d675f;
  --line: #b8c8b8;
  --line-strong: #8eaa92;
  --panel: #edf4eb;
  --panel-deep: #dfeadd;
  --page: #ffffff;
  --button: #f8faf7;
  --good: #1f6f3b;
  --good-bg: #edf7ef;
  --bad: #8c2d2d;
  --bad-bg: #fbefef;
  --focus: #265f38;
  --shadow: 0 1px 0 rgba(16, 20, 17, .08);
}

* { box-sizing: border-box; }
html { background: #fff; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.35;
}
button, select, input { font: inherit; }
button { color: inherit; }

.page-shell {
  width: min(760px, calc(100% - 28px));
  margin: 18px auto 28px;
}

.topbar {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  box-shadow: var(--shadow);
}
.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 18px;
}
.history-button,
.button,
.settings-toggle {
  border: 1px solid #8f9690;
  background: var(--button);
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 #fff;
  transition: background-color .12s ease, border-color .12s ease, transform .12s ease;
}
.history-button:hover,
.button:hover,
.settings-toggle:hover { background: #fff; border-color: #707b72; }
.history-button:active,
.button:active,
.settings-toggle:active { transform: translateY(1px); }
.button.primary { background: #f4f8f3; border-color: #6d8e73; }

.masthead {
  margin: 10px auto 12px;
  min-height: 104px;
  border: 2px solid #49785a;
  box-shadow: inset 0 0 0 5px #e2ede2, 2px 3px 0 #a4b8a5;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  background: #fff;
}
.masthead h1 {
  margin: 0;
  font-size: clamp(42px, 9vw, 72px);
  line-height: .95;
  letter-spacing: -4px;
  font-weight: 900;
}
.question-count {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
}

.quiz { margin-top: 14px; }
.question-meta {
  min-height: 23px;
  background: var(--panel-deep);
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 3px 8px;
  border-block: 1px solid #d2dfd0;
}
.question-wrap { padding-top: 5px; }
.question-wrap.animate { animation: question-in .16s ease both; }
.question {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 500;
}
.answers {
  display: grid;
  gap: 2px;
  margin: 4px 0 8px 22px;
}
.answer {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  width: fit-content;
  max-width: calc(100% - 10px);
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
.answer:hover { background: #f5f7f4; border-color: #d8ded7; }
.answer input {
  margin: 2px 0 0;
  width: 17px;
  height: 17px;
  accent-color: #2e6e42;
  flex: 0 0 auto;
}
.answer.correct { background: var(--good-bg); border-color: #8eb79a; }
.answer.incorrect { background: var(--bad-bg); border-color: #cf9999; }
.answer.disabled { cursor: default; }


.custom-answer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 7px 0 2px 5px;
  max-width: 410px;
}
.custom-answer input {
  min-width: 0;
  flex: 1;
  height: 30px;
  border: 1px solid #8f9690;
  border-radius: 2px;
  background: #fff;
  padding: 4px 7px;
  color: var(--ink);
}
.custom-answer input:focus {
  outline: 2px solid rgba(38,95,56,.18);
  outline-offset: 1px;
  border-color: var(--focus);
}
.custom-answer .button { min-width: 68px; }

.feedback {
  border: 1px solid var(--line);
  padding: 6px 8px;
  margin: 8px 0;
  font-size: 13px;
  animation: fade-in .12s ease both;
}
.feedback.good { color: var(--good); background: var(--good-bg); border-color: #9cc3a6; }
.feedback.bad { color: var(--bad); background: var(--bad-bg); border-color: #d6aaaa; }

.quiz-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 35px;
  margin: 12px 0 8px;
}

.control-panel {
  background: var(--panel);
  padding: 5px 10px 10px;
  margin-top: 4px;
  border: 1px solid #dbe6d9;
}
.scoreline { text-align: center; font-size: 12px; margin-bottom: 4px; }
.settings-toggle { display: block; margin: 0 auto 8px; }
.settings { width: min(480px, 100%); margin: 0 auto; }
.settings[hidden] { display: none; }
.settings-head,
.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  align-items: center;
  gap: 14px;
}
.settings-head {
  font-size: 11px;
  color: #3f4a42;
  padding: 0 2px 3px;
}
.settings-head span:last-child { text-align: left; }
.setting-row { min-height: 28px; padding: 1px 2px; }
.setting-row:hover { background: rgba(255,255,255,.45); }
.setting-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.setting-left input { width: 15px; height: 15px; accent-color: #1775d1; margin: 0; }
.setting-left label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setting-row select {
  width: 100%;
  min-height: 25px;
  border: 1px solid #7c877e;
  background: #fff;
  border-radius: 2px;
  padding: 1px 4px;
}
.settings-divider { height: 1px; background: #cad7c8; margin: 5px 0; }
.mode-row { font-weight: 700; }
.mode-row .setting-left small { font-weight: 400; color: var(--muted); }
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 9px;
  align-items: center;
}
.text-button {
  border: 0;
  background: transparent;
  padding: 3px 1px;
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
}
.text-button:hover { text-decoration-thickness: 2px; }
.text-button.danger { color: #7c2424; }
.footer { text-align: center; margin-top: 8px; font-size: 11px; }

.history-dialog {
  width: min(700px, calc(100% - 24px));
  max-height: min(760px, calc(100vh - 30px));
  border: 1px solid #839184;
  border-radius: 3px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 14px 50px rgba(22,30,23,.18);
}
.history-dialog::backdrop { background: rgba(15, 20, 16, .26); }
.history-dialog[open] { animation: dialog-in .15s ease both; }
.history-shell { padding: 14px; overflow: auto; max-height: inherit; }
.history-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #d9e0d8; padding-bottom: 8px; }
.history-head h2 { margin: 0; font-size: 22px; }
.close-button {
  width: 32px; height: 32px; border: 1px solid #aab2aa; background: #fff; border-radius: 2px; cursor: pointer;
  font-size: 24px; line-height: 1;
}
.history-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 6px;
  margin: 12px 0 14px;
}
.stat-card { border: 1px solid #d7dfd6; background: var(--panel); padding: 8px; text-align: center; min-width: 0; }
.stat-value { display: block; font-weight: 800; font-size: 20px; }
.stat-label { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; }
.history-section { margin-top: 15px; }
.history-section h3 { font-size: 13px; margin: 0 0 5px; }
.stats-row {
  display: grid;
  grid-template-columns: minmax(110px,1fr) 70px 70px 70px;
  gap: 8px;
  padding: 5px 3px;
  border-top: 1px solid #edf0ec;
  font-size: 12px;
}
.stats-row.header { font-weight: 700; border-top: 0; color: #445047; }
.stats-row span:not(:first-child) { text-align: right; }
.recent-list { border-top: 1px solid #e4e8e3; }
.recent-item { padding: 7px 2px; border-bottom: 1px solid #e8ece7; }
.recent-top { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--muted); }
.recent-q { margin-top: 2px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item.correct .recent-result { color: var(--good); }
.recent-item.incorrect .recent-result { color: var(--bad); }
.recent-item.skipped .recent-result { color: #6b6251; }
.empty { padding: 12px 0; color: var(--muted); font-size: 12px; }
.history-footer { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 8px; border-top: 1px solid #e3e8e2; }

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@keyframes question-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 620px) {
  .page-shell { width: min(100% - 16px, 760px); margin-top: 8px; }
  .masthead { min-height: 88px; }
  .masthead h1 { letter-spacing: -2.5px; }
  .answers { margin-left: 4px; }
  .answer { width: 100%; max-width: 100%; }
  .settings-head,
  .setting-row { grid-template-columns: minmax(0,1fr) 135px; gap: 8px; }
  .history-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stats-row { grid-template-columns: minmax(95px,1fr) 55px 55px 55px; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.wrong-dialog {
  width: min(620px, calc(100% - 24px));
  border: 4px solid #b30000;
  border-radius: 3px;
  padding: 0;
  background: #fff;
  color: #c40000;
  box-shadow: 0 18px 60px rgba(85, 0, 0, .34);
}
.wrong-dialog::backdrop { background: rgba(40, 0, 0, .42); }
.wrong-dialog[open] { animation: wrong-pop .16s ease both; }
.wrong-shell { padding: 28px 22px 22px; text-align: center; }
.wrong-stack { display: grid; gap: 2px; }
.wrong-stack strong {
  display: block;
  color: #d00000;
  font-size: clamp(34px, 8vw, 62px);
  line-height: .95;
  letter-spacing: -2px;
  font-weight: 900;
}
.sorry-button {
  margin-top: 24px;
  min-width: 130px;
  min-height: 42px;
  border: 2px solid #b30000;
  border-radius: 2px;
  background: #fff;
  color: #b30000;
  font-weight: 900;
  cursor: pointer;
}
.sorry-button:hover { background: #fff0f0; }
.sorry-button:focus-visible { outline: 3px solid #d00000; outline-offset: 3px; }
@keyframes wrong-pop {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: scale(1); }
}

/* v5 mode navigation + quiz hosting */
[hidden] { display: none !important; }
.brand-button { border: 0; background: transparent; padding: 0; cursor: pointer; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-button { border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 13px; }

.mode-home { padding: 26px 0 18px; }
.mode-grid, .entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card, .entry-card {
  min-height: 122px; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 3px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; text-align: left;
  transition: transform .14s ease, background-color .14s ease, border-color .14s ease;
}
.mode-card:hover, .entry-card:hover { background: #f6faf4; border-color: #66816b; transform: translateY(-1px); }
.mode-title, .entry-card strong { font-size: 24px; letter-spacing: -.5px; }
.mode-arrow { font-size: 28px; font-weight: 700; }
.entry-card { min-height: 96px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 2px; }
.entry-card strong { font-size: 19px; }
.entry-card span { color: var(--muted); font-size: 12px; }

.question-image {
  display: block; width: min(100%, 520px); max-height: 270px; object-fit: contain; margin: 10px auto 12px;
  border: 1px solid #cfd9ce; background: #f7faf6; border-radius: 3px;
}

.quiz-mode { margin-top: 14px; }
.quiz-mode-entry { padding: 10px 0 20px; }
.quiz-pane, .game-stage { border: 1px solid var(--line-strong); background: #fff; padding: 16px; box-shadow: var(--shadow); }
.pane-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e0e7df; padding-bottom: 9px; margin-bottom: 12px; }
.pane-head h2, .players-head h2, .results-pane h2 { margin: 0; font-size: 20px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.setup-grid label, .join-field { display: grid; gap: 4px; font-size: 12px; color: #3f4941; }
.setup-grid select, .join-field input { height: 36px; border: 1px solid #89948b; background: #fff; border-radius: 2px; padding: 5px 8px; color: var(--ink); }
.big-action { min-height: 42px; padding: 8px 16px; font-weight: 700; margin-top: 14px; }
.connection-note { min-height: 18px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.connection-note.error { color: var(--bad); }

.room-code-wrap { text-align: center; padding: 8px 0 16px; }
.room-code-wrap span { display: block; text-transform: uppercase; letter-spacing: 1.2px; font-size: 10px; color: var(--muted); }
.room-code-wrap strong { display: block; font-size: clamp(44px, 10vw, 72px); line-height: 1; letter-spacing: 8px; }
.room-meta { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.players-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e1e7e0; padding-bottom: 6px; }
.player-list { min-height: 130px; padding: 6px 0; }
.player-row { display: grid; grid-template-columns: 28px 1fr 16px; gap: 8px; align-items: center; padding: 8px 4px; border-bottom: 1px solid #edf1ec; }
.player-row > span:first-child { color: var(--muted); font-size: 12px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #2e7c45; justify-self: end; }
.waiting-mark { font-size: 12px; font-weight: 800; color: #496a52; letter-spacing: .5px; }
#playerLobby { text-align: center; padding-block: 44px; }
#playerLobby h2 { font-size: 28px; margin: 8px 0 4px; }

.game-stage { padding: 0; overflow: hidden; }
.game-top, .player-game-head { min-height: 54px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.game-top > div:first-child { display: grid; gap: 1px; }
.game-top span { font-size: 11px; color: var(--muted); }
.game-top strong { font-size: 14px; }
.timer { width: 38px; height: 38px; border: 2px solid #5d765f; border-radius: 50%; display: grid; place-items: center; font-weight: 900; }
.host-question-card { padding: 20px; }
.host-question-card h2 { text-align: center; font-size: 24px; line-height: 1.25; margin: 0 0 14px; }
.host-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.host-option { border: 1px solid #9aa49c; min-height: 72px; display: flex; align-items: center; gap: 10px; padding: 10px; background: #fafcf9; }
.host-option span, .player-answer > span { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border: 1px solid #758178; background: #fff; font-weight: 900; }
.host-option strong { font-size: 14px; }
.game-bottom { border-top: 1px solid #e0e6df; border-bottom: 1px solid #e0e6df; display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; font-size: 12px; }
.leaderboard { padding: 8px 12px; }
.leader-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: center; padding: 9px 3px; border-bottom: 1px solid #edf0ec; }
.leader-row > span:first-child { color: var(--muted); }
.rank-1 { font-size: 17px; }

.player-game-head { font-size: 13px; }
.player-prompt { text-align: center; font-size: 22px; font-weight: 800; padding: 22px 12px 14px; }
.player-answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
.player-answer { min-height: 94px; border: 1px solid #829084; background: #f8faf7; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; }
.player-answer:disabled { opacity: .64; cursor: default; }
.player-answer strong { text-align: left; font-size: 13px; }
.player-result { margin: 8px 12px 12px; padding: 12px; text-align: center; font-weight: 900; border: 1px solid #cfd8ce; }
.player-result.good { background: var(--good-bg); color: var(--good); border-color: #8eb79a; }
.player-result.bad { background: var(--bad-bg); color: var(--bad); border-color: #cf9999; }
.gold-result { background: #fff7d7; color: #604f00; border-color: #c8ad3a; }
.chest-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding: 12px; }
.chest-grid button { min-height: 112px; border: 1px solid #a28a36; background: #fff7d5; cursor: pointer; display: grid; place-items: center; align-content: center; gap: 5px; }
.gold-icon { font-size: 34px; filter: saturate(1.15); }
.test-card { padding: 18px 12px 4px; }
.test-card h2 { font-size: 18px; font-weight: 600; margin: 0 0 10px; }
.test-stage .big-action { margin: 10px 12px 16px; }
.test-score { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 4px; }
.test-score strong { font-size: 44px; }
.test-score span { font-size: 18px; color: var(--muted); }

/* intentionally aggressive joke popup requested by the user */
.wrong-dialog[open] { animation: wrong-flash-bg .42s steps(2,end) infinite; }
.wrong-dialog[open] .wrong-stack strong { animation: wrong-flash-text .28s steps(2,end) infinite; }
@keyframes wrong-flash-bg { 0%,49% { background:#fff; box-shadow:0 0 0 8px #c40000,0 18px 60px rgba(85,0,0,.34);} 50%,100% { background:#ff1717; box-shadow:0 0 0 12px #ff1717,0 18px 70px rgba(120,0,0,.5);} }
@keyframes wrong-flash-text { 0%,49% { color:#d00000; transform:scale(1);} 50%,100% { color:#fff; transform:scale(1.035);} }

@media (max-width: 620px) {
  .mode-grid, .entry-grid, .setup-grid, .host-options, .player-answer-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 82px; }
  .mode-title { font-size: 20px; }
  .room-code-wrap strong { letter-spacing: 5px; }
  .host-question-card h2 { font-size: 19px; }
  .chest-grid { grid-template-columns: repeat(3,1fr); }
  .chest-grid button { min-height: 90px; }
}

/* v8 professional quiz suite */
.quiz-masthead { margin-bottom: 12px; }
.entry-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.entry-card-accent { background: #e8f1e5; border-color: #789179; }
.entry-card-accent:hover { background: #edf5eb; }
.compact { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.library-block { margin-top: 14px; border: 1px solid #c9d5c8; background: #fff; box-shadow: var(--shadow); }
.library-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid #e2e9e1; background: #f6f9f5; }
.library-head > div { display: grid; gap: 1px; }
.library-head h2 { margin: 0; font-size: 17px; }
.library-head span { color: var(--muted); font-size: 11px; }
.my-quiz-list { min-height: 78px; }
.library-empty { min-height: 78px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12px; }
.library-empty strong { color: var(--ink); }
.my-quiz-row { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border-bottom: 1px solid #edf1ec; }
.my-quiz-row:last-child { border-bottom: 0; }
.my-quiz-row:hover { background: #fbfcfa; }
.my-quiz-info { min-width: 0; display: grid; gap: 3px; }
.my-quiz-info strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-quiz-info span { color: var(--muted); font-size: 11px; }
.my-quiz-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }

.setup-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.host-set-summary { margin-top: 12px; min-height: 48px; border: 1px solid #d7e0d6; background: #f8faf7; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; }
.host-set-summary strong { font-size: 13px; }
.host-set-summary span { color: var(--muted); font-size: 11px; }
.join-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room-code-line { display: flex; align-items: center; justify-content: center; gap: 12px; }
.room-code-line strong { display: inline-block; }

.builder-pane { padding: 0; overflow: hidden; }
.builder-head { margin: 0; padding: 11px 14px; background: #f6f9f5; }
.builder-head > div:first-child { display: grid; gap: 1px; }
.builder-head span { color: var(--muted); font-size: 10px; }
.builder-head span.dirty { color: #8a6419; }
.pane-actions { display: flex; align-items: center; gap: 10px; }
.builder-title-row { min-height: 72px; display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 12px 14px; border-bottom: 1px solid #e2e8e1; }
.builder-title-row label { flex: 1; display: grid; gap: 4px; color: #424c44; font-size: 11px; }
.builder-title-row input { height: 38px; border: 1px solid #879289; background: #fff; padding: 6px 9px; font-size: 16px; font-weight: 700; color: var(--ink); }
.builder-count { min-width: 88px; min-height: 38px; display: flex; align-items: baseline; justify-content: center; gap: 5px; padding: 8px; border: 1px solid #d5dfd4; background: #f8faf7; }
.builder-count strong { font-size: 18px; }
.builder-count span { color: var(--muted); font-size: 10px; }
.builder-layout { display: grid; grid-template-columns: 220px minmax(0,1fr); min-height: 520px; }
.builder-sidebar { border-right: 1px solid #dce4db; background: #f8faf7; padding: 10px; }
.builder-list { display: grid; gap: 6px; max-height: 560px; overflow: auto; }
.builder-question-item { width: 100%; display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 8px; align-items: center; min-height: 54px; border: 1px solid #d4ddd3; background: #fff; padding: 7px; text-align: left; cursor: pointer; }
.builder-question-item:hover { border-color: #8ca18e; }
.builder-question-item.active { background: #e8f1e5; border-color: #6e886f; box-shadow: inset 3px 0 0 #557456; }
.builder-question-item > span { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid #b9c5b8; background: #fff; font-size: 11px; font-weight: 800; }
.builder-question-item div { min-width: 0; display: grid; gap: 2px; }
.builder-question-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.builder-question-item small { color: var(--muted); font-size: 9px; }
.add-question-button { width: 100%; margin-top: 8px; }
.builder-editor { padding: 14px; }
.editor-top-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.editor-top-grid label, .answer-editor label { display: grid; gap: 4px; color: #424c44; font-size: 11px; }
.editor-top-grid select, .answer-editor input[type="text"], #typedCorrectAnswer, #typedAliases { height: 35px; border: 1px solid #89948b; background: #fff; padding: 5px 8px; color: var(--ink); }
.editor-question-label { position: relative; display: grid; gap: 4px; margin-top: 11px; color: #424c44; font-size: 11px; }
.editor-question-label textarea { min-height: 84px; resize: vertical; border: 1px solid #89948b; padding: 8px 9px 24px; font: inherit; font-size: 15px; color: var(--ink); background: #fff; }
.char-count { position: absolute; right: 8px; bottom: 6px; color: var(--muted); font-size: 9px; }
.media-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; margin-top: 11px; }
.media-preview { min-height: 94px; border: 1px dashed #b9c5b8; background: #f8faf7; display: grid; place-items: center; overflow: hidden; }
.media-preview span { color: var(--muted); font-size: 11px; }
.media-preview img { width: 100%; height: 160px; object-fit: contain; background: #fff; }
.media-actions { display: grid; gap: 8px; justify-items: stretch; }
.upload-button { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.answer-editor { margin-top: 12px; border-top: 1px solid #e0e7df; padding-top: 12px; }
.answer-editor-head { display: grid; grid-template-columns: 1fr 54px; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.answer-editor-head span:last-child { text-align: center; }
.builder-answer-row { display: grid; grid-template-columns: 30px minmax(0,1fr) 54px; gap: 7px; align-items: center; margin-bottom: 7px; }
.builder-answer-row > span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #849087; background: #f8faf7; font-weight: 800; font-size: 11px; }
.builder-answer-row input[type="text"] { height: 36px; border: 1px solid #89948b; padding: 6px 8px; }
.builder-answer-row input[type="radio"] { justify-self: center; width: 17px; height: 17px; accent-color: #557456; }
.tf-option { min-height: 44px; grid-template-columns: 22px 1fr !important; align-items: center; border: 1px solid #d7e0d6; padding: 8px 10px; margin-bottom: 7px; background: #fafcf9; }
.tf-option input { width: 17px; height: 17px; accent-color: #557456; }
#typeEditor { display: grid; gap: 9px; }
#typeEditor[hidden] { display: none !important; }
.editor-footer-actions { margin-top: 14px; padding-top: 11px; border-top: 1px solid #e0e7df; display: flex; justify-content: space-between; gap: 10px; }
.editor-footer-actions > div { display: flex; gap: 6px; align-items: center; }

.host-option { position: relative; }
.host-option em { margin-left: auto; min-width: 28px; text-align: center; font-style: normal; font-size: 12px; font-weight: 800; }
.host-option.correct { border-color: #4e865d; background: #e9f5e9; box-shadow: inset 4px 0 0 #4e865d; }
.host-option.dim { opacity: .62; }
.host-typed-answer { min-height: 96px; grid-column: 1 / -1; border: 1px solid #9aa49c; display: grid; place-items: center; align-content: center; gap: 4px; background: #fafcf9; }
.host-typed-answer span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.host-typed-answer strong { font-size: 19px; }
.host-typed-answer.correct { border-color: #4e865d; background: #e9f5e9; }
#hostNextQuestion.ready { box-shadow: 0 0 0 3px rgba(86,119,88,.14); }
.player-answer.selected { border-color: #557456; box-shadow: inset 0 0 0 2px #557456; background: #edf4eb; }
.player-type-form, .test-type-form { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 12px; }
.player-type-form input, .test-type-form input { height: 44px; border: 1px solid #839087; background: #fff; padding: 7px 9px; font-size: 15px; }
.test-type-form { padding: 0; margin-top: 8px; grid-template-columns: 1fr; }
.result-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }
.podium-strip { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 6px 0 14px; }
.podium-card { min-height: 116px; border: 1px solid #d4ded3; background: #f8faf7; display: grid; place-items: center; align-content: center; gap: 4px; text-align: center; padding: 10px; }
.podium-card > span { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid #8b998d; background: #fff; font-weight: 900; }
.podium-card strong { font-size: 15px; }
.podium-card em { color: var(--muted); font-style: normal; font-size: 11px; }
.podium-card.rank-1 { background: #eef5eb; border-color: #789179; }
.results-table { border-top: 1px solid #e1e8e0; }

@media (max-width: 780px) {
  .entry-grid-three, .setup-grid-3 { grid-template-columns: 1fr; }
  .builder-layout { grid-template-columns: 1fr; }
  .builder-sidebar { border-right: 0; border-bottom: 1px solid #dce4db; }
  .builder-list { display: flex; overflow-x: auto; max-height: none; }
  .builder-question-item { min-width: 180px; }
  .my-quiz-row { align-items: flex-start; flex-direction: column; }
  .my-quiz-actions { justify-content: flex-start; }
}
@media (max-width: 620px) {
  .join-grid, .editor-top-grid, .podium-strip { grid-template-columns: 1fr; }
  .builder-title-row { align-items: stretch; flex-direction: column; }
  .builder-count { justify-content: flex-start; }
  .media-row { grid-template-columns: 1fr; }
  .media-actions { grid-template-columns: 1fr auto; }
  .editor-footer-actions { align-items: flex-start; flex-direction: column; }
  .room-code-line { flex-direction: column; gap: 8px; }
}


/* Live-room connection polish */
.button.busy { position: relative; padding-right: 38px; cursor: wait; }
.button.busy::after { content: ''; position: absolute; right: 14px; top: 50%; width: 13px; height: 13px; margin-top: -7px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: medicspin .7s linear infinite; opacity: .75; }
@keyframes medicspin { to { transform: rotate(360deg); } }
.connection-note { transition: color .18s ease, opacity .18s ease; }
#playerLobbyTitle { transition: opacity .18s ease; }
@media (prefers-reduced-motion: reduce) { .button.busy::after { animation: none; } }


/* V10 classroom polish + Popcorn mode */
.mode-help {
  margin-top: 8px;
  min-height: 38px;
  border-left: 3px solid #7b947d;
  background: #f7faf6;
  padding: 8px 10px;
  font-size: 12px;
  color: #465047;
}
.game-top-actions { display:flex; align-items:center; gap:8px; }
.host-fullscreen { min-height: 30px; }
.host-timer-track { height: 6px; background:#e4e9e3; overflow:hidden; border-bottom:1px solid #d4dcd3; }
.host-timer-fill { height:100%; width:100%; background:#5f7f63; transform-origin:left center; transition: width .22s linear; }
.host-timer-fill.low { background:#9a3333; }

.popcorn-countdown {
  position:absolute; inset:54px 0 0; z-index:20; background:rgba(255,255,255,.97);
  display:grid; place-items:center; align-content:center; gap:6px; text-align:center;
}
#hostGame { position:relative; }
.popcorn-countdown span { text-transform:uppercase; letter-spacing:1.4px; font-size:12px; color:var(--muted); font-weight:800; }
.popcorn-countdown strong { font-size:clamp(92px,22vw,180px); line-height:.9; letter-spacing:-8px; animation:pop-count .72s cubic-bezier(.2,.8,.2,1) both; }
@keyframes pop-count { from { opacity:.25; transform:scale(.72); } 70% { opacity:1; transform:scale(1.06); } to { opacity:1; transform:scale(1); } }
.popcorn-turn { border-bottom:1px solid #dfe5de; background:#f8faf7; padding:10px 12px; }
.popcorn-student { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.popcorn-student > span { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.7px; }
.popcorn-student > strong { font-size:20px; }
.popcorn-student .text-button { margin-left:auto; }
.popcorn-grade { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; margin-top:9px; }
.popcorn-grade-button { min-height:46px; border:1px solid #89948b; background:#fff; border-radius:3px; cursor:pointer; font-weight:800; transition:transform .12s ease,background-color .12s ease,border-color .12s ease; }
.popcorn-grade-button:hover { transform:translateY(-1px); }
.popcorn-grade-button.correct { border-color:#579069; background:#eef7ef; color:#1c6535; }
.popcorn-grade-button.wrong { border-color:#b66e6e; background:#fbefef; color:#842929; }
.popcorn-grade-button.pass { border-color:#989c98; background:#f8f8f7; color:#555d56; }
.popcorn-grade-button:disabled { opacity:.45; cursor:default; transform:none; }
.popcorn-grade-button b { font-size:16px; }
.popcorn-answer { margin-top:9px; border:1px solid #a7b7a8; background:#fff; padding:8px 10px; text-align:center; font-size:13px; }
.popcorn-answer strong { display:block; margin-top:2px; font-size:17px; }
.popcorn-timeout { color:#8a2c2c; font-weight:900; }

.popcorn-player-stage { min-height:360px; }
.popcorn-device-card { min-height:300px; display:grid; place-items:center; align-content:center; text-align:center; gap:10px; padding:28px 18px; }
.popcorn-device-label { font-size:11px; font-weight:900; letter-spacing:1.4px; color:#5b735e; }
.popcorn-device-card h2 { margin:0; font-size:clamp(27px,8vw,44px); line-height:1.04; letter-spacing:-1.4px; }
.popcorn-device-card p { margin:0; color:var(--muted); font-size:13px; }
.popcorn-device-count { font-size:76px; line-height:1; font-weight:900; animation:pop-count .72s cubic-bezier(.2,.8,.2,1) both; }
.popcorn-device-card.is-selected { background:#eef5eb; }
.popcorn-device-card.is-correct { background:var(--good-bg); }
.popcorn-device-card.is-wrong { background:var(--bad-bg); }
.popcorn-device-card.is-pass { background:#f4f4f2; }

@media (max-width:620px) {
  .game-top-actions .host-fullscreen { display:none; }
  .popcorn-grade { grid-template-columns:1fr; }
  .popcorn-student { justify-content:center; text-align:center; }
  .popcorn-student .text-button { width:100%; margin-left:0; }
}
