:root {
  --bg: #060a2c;
  --bg-2: #0c1250;
  --panel: #0f1760;
  --panel-2: #172280;
  --panel-3: #1f2c9a;
  --board: #0a1bc4;
  --board-deep: #06108a;
  --gold: #ffcc00;
  --gold-2: #ffb300;
  --gold-ink: #1d1500;
  --text: #f3f5ff;
  --muted: #a9b2e8;
  --line: rgba(255, 255, 255, 0.13);
  --good: #16a34a;
  --good-2: #22c55e;
  --bad: #dc2626;
  --bad-2: #ef4444;
  --radius: 14px;
  --font-display: 'Oswald', Impact, 'Arial Narrow', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-clue: Georgia, 'Times New Roman', 'Noto Serif', serif;
  --pc: var(--gold);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(ellipse 120% 70% at 50% -10%, #1b2690 0%, var(--bg) 62%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--gold);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.15;
  margin: 0;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

kbd {
  font: 600 0.72em/1 var(--font-body);
  padding: 0.25em 0.45em;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.25);
  opacity: 0.85;
}

/* ---- buttons & inputs ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.62em 1.05em;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: 600 1rem/1.15 var(--font-body);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s, filter 0.15s;
  user-select: none;
}
.btn:hover {
  background: var(--panel-3);
}
.btn:active {
  transform: translateY(2px);
}
.btn:focus-visible,
.icon-btn:focus-visible,
.cell:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn-primary {
  background: linear-gradient(#ffdc55, var(--gold-2));
  color: var(--gold-ink);
  border-color: transparent;
  box-shadow: 0 4px 0 #a86f00;
}
.btn-primary:hover {
  background: linear-gradient(#ffe57a, #ffc21a);
}
.btn-primary:active {
  box-shadow: 0 2px 0 #a86f00;
}
.btn-good {
  background: var(--good);
  border-color: transparent;
  box-shadow: 0 4px 0 #0c5d2a;
}
.btn-good:hover {
  background: var(--good-2);
}
.btn-bad {
  background: var(--bad);
  border-color: transparent;
  box-shadow: 0 4px 0 #7f1414;
}
.btn-bad:hover {
  background: var(--bad-2);
}
.btn-ghost {
  background: transparent;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}
.btn-sm {
  font-size: 0.85rem;
  padding: 0.45em 0.75em;
}
.btn-lg {
  font-size: 1.2rem;
  padding: 0.8em 1.4em;
  border-radius: 12px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.input,
textarea.input {
  width: 100%;
  background: #080e42;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.68em 0.85em;
  font: inherit;
}
textarea.input {
  resize: vertical;
  min-height: 5.5em;
}
.input::placeholder {
  color: #7079b6;
}
.input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 0;
  border-color: transparent;
}

.field {
  display: grid;
  gap: 6px;
}
.field > label,
.field-label {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.check input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.1rem;
  accent-color: var(--gold);
  flex: none;
}

/* ---- top bar & language switch ------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(3, 6, 28, 0.55);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 5;
}
.topbar .spacer {
  flex: 1;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.05em;
  color: var(--gold);
  text-decoration: none;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #000;
  white-space: nowrap;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  flex: none;
}
.lang-switch button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0.38em 0.72em;
  font: 700 0.78rem/1 var(--font-body);
  letter-spacing: 0.06em;
  cursor: pointer;
}
.lang-switch button[aria-pressed='true'] {
  background: var(--gold);
  color: var(--gold-ink);
}

/* ---- cards, toasts, dialogs -------------------------------------------------------- */

.card {
  background: linear-gradient(180deg, rgba(27, 38, 140, 0.55), rgba(12, 18, 80, 0.7));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 30px);
  opacity: 0;
  pointer-events: none;
  background: #111a6b;
  border: 1px solid var(--line);
  padding: 0.75em 1.2em;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: calc(100vw - 32px);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.good {
  border-color: var(--good-2);
}
.toast.bad {
  border-color: var(--bad-2);
}

dialog.modal {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0d1454;
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
dialog.modal[open] {
  display: flex;
  flex-direction: column;
  animation: pop-in 0.18s ease-out;
}
dialog.modal::backdrop {
  background: rgba(2, 4, 20, 0.72);
  backdrop-filter: blur(3px);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 14px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}
.modal-body {
  padding: 18px 20px;
  display: grid;
  gap: 16px;
  overflow: auto;
}
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.modal-foot:empty {
  display: none;
}
.modal-confirm .modal-head {
  border: 0;
  padding-bottom: 0;
}
.confirm-text {
  margin: 0;
  font-size: 1.1rem;
}

.conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background: #b45309;
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 6px 12px;
}

/* ---- home page -------------------------------------------------------------------- */

.home {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 28px 16px 60px;
  display: grid;
  gap: 22px;
}
.hero {
  text-align: center;
  padding: 18px 0 6px;
}
.hero h1 {
  font-size: clamp(2.8rem, 10vw, 5.2rem);
  color: var(--gold);
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #000;
  letter-spacing: 0.04em;
}
.hero p {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 1.1rem;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.card-head h2 {
  font-size: 1.5rem;
}

.join-form {
  display: flex;
  gap: 10px;
}
.join-form .input {
  font: 700 1.5rem/1 var(--font-display);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
  max-width: 220px;
}
.join-form .input::placeholder,
.play-join .code-input::placeholder {
  letter-spacing: 0.04em;
  font-size: 1.1rem;
  text-transform: none;
}

.board-list {
  display: grid;
  gap: 10px;
}
.board-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(4, 8, 40, 0.45);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}
.board-item .info {
  flex: 1 1 240px;
  min-width: 0;
}
.board-item h3 {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}
.board-item .meta {
  color: var(--muted);
  font-size: 0.9rem;
}
.board-item .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.progress {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  margin-top: 8px;
  overflow: hidden;
  max-width: 280px;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--gold);
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 26px 10px;
}
.pw-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pw-form .input {
  flex: 1 1 200px;
}

/* ---- editor ------------------------------------------------------------------------ */

.editor {
  padding: 18px 16px 60px;
  display: grid;
  gap: 14px;
  max-width: 1500px;
  margin: 0 auto;
}
.title-input {
  font: 700 clamp(1.4rem, 4vw, 2.1rem) / 1.2 var(--font-display);
  background: transparent;
  border: 1px dashed transparent;
  color: var(--gold);
  padding: 0.2em 0.35em;
  border-radius: 10px;
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.title-input:hover {
  border-color: var(--line);
}
.title-input:focus {
  outline: 2px solid var(--gold);
  border-color: transparent;
}
.editor-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.editor-toolbar .spacer {
  flex: 1;
}
.save-status {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.save-status.error {
  color: var(--bad-2);
  font-weight: 700;
}
.save-status.unsaved {
  color: var(--gold);
}
.editor-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
}
.editor-grid {
  display: grid;
  grid-template-columns: 96px repeat(var(--cols), minmax(160px, 1fr));
  gap: 6px;
  min-width: min-content;
}
.editor-grid .corner {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 8px;
}
.cat-head {
  position: relative;
  background: var(--board);
  border-radius: 8px;
  padding: 8px 30px 8px 8px;
  display: flex;
}
.cat-head textarea {
  width: 100%;
  resize: none;
  border: 0;
  background: transparent;
  color: #fff;
  font: 700 1.05rem/1.15 var(--font-display);
  text-transform: uppercase;
  text-align: center;
  padding: 4px;
  border-radius: 6px;
  field-sizing: content;
  min-height: 2.6em;
}
.cat-head textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}
.cat-head textarea:focus {
  outline: 2px solid var(--gold);
  background: rgba(0, 0, 0, 0.2);
}
.cat-head .icon-btn,
.row-head .icon-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}
.row-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
}
.row-head .input {
  font: 700 1.2rem/1 var(--font-display);
  color: var(--gold);
  text-align: center;
  padding: 0.45em 0.2em;
  width: 70px;
}
.row-head .icon-btn {
  top: auto;
  bottom: 0;
  right: 50%;
  transform: translateX(50%);
  opacity: 0;
}
.row-head:hover .icon-btn,
.row-head:focus-within .icon-btn {
  opacity: 1;
}
.edit-cell {
  position: relative;
  min-height: 118px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--board-deep);
  color: #fff;
  text-align: left;
  padding: 10px 10px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}
.edit-cell:hover {
  border-color: var(--gold);
  background: #0a1aa6;
}
.edit-cell .v {
  font: 700 1rem/1 var(--font-display);
  color: var(--gold);
}
.edit-cell .q {
  font-size: 0.86rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.edit-cell .a {
  font-size: 0.78rem;
  color: #8ff0b0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: auto;
}
.edit-cell .a.missing {
  color: #ffb4a8;
}
.edit-cell .thumb {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.edit-cell.has-thumb .q {
  padding-right: 44px;
}
.edit-cell.blank {
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: rgba(6, 16, 138, 0.35);
  border: 2px dashed rgba(255, 255, 255, 0.18);
}
.edit-cell.blank .v {
  position: absolute;
  left: 10px;
  top: 10px;
  opacity: 0.6;
}
.edit-cell.incomplete::after {
  content: '';
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff8a65;
}
.editor-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.clue-modal {
  width: min(640px, calc(100vw - 24px)) !important;
}
.clue-modal .modal-head h2 {
  font-size: 1.1rem;
  text-transform: uppercase;
}
.clue-modal .modal-head .val {
  color: var(--gold);
}
.dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  justify-items: center;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag {
  border-color: var(--gold);
  background: rgba(255, 204, 0, 0.08);
}
.dropzone img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  object-fit: contain;
  background: #000;
}
.dropzone .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.dropzone small {
  color: var(--muted);
}
.clue-modal .modal-foot .spacer {
  flex: 1;
}

/* ---- game screens (host + public display) ---------------------------------------------- */

.game-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.game-page .topbar {
  padding: 8px 14px;
}
.game-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  color: #fff;
}
.join-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  flex: none;
}
.join-chip .code {
  font: 700 1.35rem/1 var(--font-display);
  letter-spacing: 0.14em;
  color: var(--gold);
}
.join-chip img {
  width: 40px;
  height: 40px;
  background: #fff;
  border-radius: 4px;
  padding: 2px;
  image-rendering: pixelated;
}
.join-chip .lbl {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  line-height: 1.1;
  text-align: right;
}

.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: clamp(6px, 1.2vw, 16px);
  padding-bottom: 0;
}

.board-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.board {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: minmax(0, 0.95fr) repeat(var(--rows), minmax(0, 1fr));
  gap: clamp(3px, 0.5vw, 7px);
  padding: clamp(3px, 0.5vw, 7px);
  background: #000;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.board .cat {
  background: var(--board);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.25em;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.05;
  text-shadow: 2px 2px 0 #000;
  overflow-wrap: anywhere;
  overflow: hidden;
  font-size: clamp(0.7rem, min(calc(22cqh / (var(--rows) + 1)), calc(10.5cqw / var(--cols))), 3rem);
  border-bottom: 3px solid #000;
}
.board .cell {
  background: radial-gradient(ellipse at 50% 40%, #1430ff 0%, var(--board) 65%);
  border: 0;
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.9rem, min(calc(52cqh / (var(--rows) + 1)), calc(26cqw / var(--cols))), 6rem);
  text-shadow: 3px 3px 0 #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-width: 0;
}
button.cell {
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}
button.cell:hover {
  filter: brightness(1.3);
}
.board .cell.used {
  color: transparent;
  text-shadow: none;
  background: var(--board-deep);
}
.board .cell.empty {
  background: #050c5c;
  color: transparent;
}
.board-info {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 1.4em;
}
.board-info .chooser {
  color: #fff;
  font-weight: 700;
}
.board-info .chooser::before {
  content: '';
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: var(--pc);
  margin-right: 0.4em;
}

.question-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vh, 14px);
  background: radial-gradient(ellipse at 50% 40%, #1731ff 0%, var(--board) 55%, var(--board-deep) 100%);
  border: clamp(3px, 0.5vw, 7px) solid #000;
  border-radius: 10px;
  padding: clamp(10px, 1.6vw, 28px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  animation: zoom-in 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.q-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: clamp(1rem, 2.4vw, 2rem);
  text-shadow: 2px 2px 0 #000;
}
.q-head .q-val {
  color: var(--gold);
}
.q-body {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2cqh;
}
.q-img-wrap {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}
.q-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.55));
}
.q-text {
  font-family: var(--font-clue);
  text-transform: uppercase;
  text-align: center;
  text-shadow: 3px 3px 0 #000;
  line-height: 1.22;
  max-width: 94%;
  overflow-wrap: anywhere;
  white-space: pre-line;
  font-size: min(9cqh, 5.2cqw);
}
.q-text.len-m {
  font-size: min(7cqh, 4.2cqw);
}
.q-text.len-l {
  font-size: min(5.4cqh, 3.3cqw);
}
.q-text.len-xl {
  font-size: min(4.2cqh, 2.6cqw);
}
.q-body.has-image .q-text {
  flex: none;
  font-size: min(6cqh, 3.2cqw);
  max-height: 40cqh;
  overflow: hidden;
}
.q-body.has-image .q-text.len-l,
.q-body.has-image .q-text.len-xl {
  font-size: min(4cqh, 2.4cqw);
}

.q-answer {
  align-self: center;
  max-width: 100%;
  padding: 0.45em 1em;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: clamp(1rem, 2vw, 1.6rem);
  text-align: center;
  overflow-wrap: anywhere;
}
.q-answer .lbl {
  color: var(--muted);
  font-size: 0.7em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-right: 0.6em;
  font-weight: 700;
}
.q-answer .txt {
  font-weight: 700;
  color: var(--gold);
}
.q-answer.revealed {
  background: rgba(0, 0, 0, 0.55);
  border-color: var(--gold);
  font-size: clamp(1.4rem, 3.4vw, 3rem);
  font-family: var(--font-display);
  animation: pop-in 0.3s ease-out;
}

.q-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 2.8em;
  justify-content: center;
  text-align: center;
}
.status-line {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: clamp(1rem, 2.3vw, 1.9rem);
  text-shadow: 2px 2px 0 #000;
}
.status-line.open {
  color: #6dffa3;
  animation: pulse 0.9s ease-in-out infinite;
}
.status-line.good {
  color: #6dffa3;
}
.status-line.bad {
  color: #ffb4a8;
}
.also-buzzed {
  color: var(--muted);
  font-size: clamp(0.8rem, 1.2vw, 1rem);
}
.also-buzzed b {
  color: var(--text);
}

.q-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.q-controls .btn-lg {
  font-size: clamp(0.95rem, 1.5vw, 1.2rem);
}

.flash {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 3;
}
.flash > span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 8vw, 7rem);
  text-transform: uppercase;
  padding: 0.1em 0.6em;
  border-radius: 18px;
  text-shadow: 4px 4px 0 #000;
  animation: flash-out 1.6s ease-out forwards;
}
.flash.good > span {
  background: rgba(22, 163, 74, 0.92);
}
.flash.bad > span {
  background: rgba(220, 38, 38, 0.92);
}

/* players bar */
.players-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(6px, 1vw, 12px);
  padding: clamp(10px, 1.6vh, 18px) 12px clamp(8px, 1.4vh, 14px);
}
.pcard {
  position: relative;
  min-width: clamp(96px, 10vw, 150px);
  padding: 6px 14px 8px;
  background: linear-gradient(#1a2690, #0b1260);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top: 5px solid var(--pc);
  border-radius: 10px;
  text-align: center;
  color: var(--text);
  font: inherit;
  transition: transform 0.25s, box-shadow 0.25s, background 0.25s, opacity 0.25s;
}
button.pcard {
  cursor: pointer;
}
button.pcard:hover {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: var(--pc);
}
.pname {
  font-weight: 700;
  font-size: clamp(0.85rem, 1.2vw, 1.1rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14ch;
  margin: 0 auto;
}
.pscore {
  font: 700 clamp(1.2rem, 2vw, 1.9rem) / 1.1 var(--font-display);
}
.pscore.neg {
  color: #ff8f8f;
}
.pcard .tag {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--pc);
  color: #0a0a1a;
  white-space: nowrap;
}
.pcard.offline {
  opacity: 0.5;
}
.pcard.offline .tag {
  background: #6b7280;
  color: #fff;
}
.pcard.locked {
  opacity: 0.4;
  filter: grayscale(0.7);
}
.pcard.answering {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 0 16px 2px rgba(255, 204, 0, 0.35);
  z-index: 2;
  opacity: 1;
  filter: none;
}
.pcard.answering .pname {
  color: var(--gold);
}
.pcard.winner {
  border-color: var(--good-2);
  box-shadow: 0 0 14px 2px rgba(34, 197, 94, 0.35);
}
.pdelta {
  position: absolute;
  right: 6px;
  top: -4px;
  font: 700 1.3rem/1 var(--font-display);
  text-shadow: 2px 2px 0 #000;
  animation: float-up 1.8s ease-out forwards;
  pointer-events: none;
}
.pdelta.up {
  color: #6dffa3;
}
.pdelta.down {
  color: #ff8f8f;
}

/* lobby */
.lobby {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 30px);
  text-align: center;
  padding: 10px;
  overflow: auto;
}
.lobby-join {
  display: flex;
  gap: clamp(18px, 4vw, 56px);
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(14px, 3vh, 32px) clamp(18px, 3vw, 44px);
  flex-wrap: wrap;
}
.qr {
  display: block;
  background: #fff;
  border-radius: 14px;
  padding: 10px;
  image-rendering: pixelated;
  aspect-ratio: 1;
}
.lobby .qr {
  width: min(34vh, 62vw);
}
.lobby-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: clamp(0.8rem, 1.6vh, 1rem);
}
.lobby-url {
  font-size: clamp(1.1rem, 3.2vh, 2.2rem);
  font-weight: 700;
  margin-bottom: 1.5vh;
  overflow-wrap: anywhere;
}
.lobby-code {
  font: 700 clamp(3.2rem, 13vh, 9rem) / 1 var(--font-display);
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow: 5px 5px 0 #000;
}
.lobby h2 {
  font-size: clamp(1.4rem, 4vh, 2.6rem);
  text-transform: uppercase;
}
.lobby-players {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 1000px;
  min-height: 2.8em;
}
.chip {
  padding: 0.45em 1em;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 8px solid var(--pc);
  font-weight: 700;
  font-size: clamp(1rem, 2.2vh, 1.4rem);
  animation: pop-in 0.35s ease-out;
}
.chip.offline {
  opacity: 0.5;
}
.lobby-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.waiting-dots::after {
  content: '';
  animation: dots 1.4s steps(4) infinite;
}

/* results */
.results {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 3vh, 28px);
  text-align: center;
  position: relative;
  overflow: hidden;
  padding: 10px;
}
.results h2 {
  font-size: clamp(2rem, 7vh, 4.5rem);
  color: var(--gold);
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #000;
}
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(8px, 2vw, 22px);
}
.podium .spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: clamp(110px, 16vw, 220px);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.podium .spot:nth-child(1) {
  animation-delay: 0.5s;
}
.podium .spot:nth-child(3) {
  animation-delay: 0.25s;
}
.podium .medal {
  font-size: clamp(2rem, 6vh, 3.6rem);
  line-height: 1;
}
.podium .who {
  font-weight: 800;
  font-size: clamp(1rem, 2.6vh, 1.6rem);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium .block {
  width: 100%;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(var(--board), var(--board-deep));
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top: 6px solid var(--pc);
  display: grid;
  place-items: center;
  font: 700 clamp(1.4rem, 4.5vh, 3rem) / 1 var(--font-display);
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
}
.podium .p1 .block {
  height: clamp(110px, 24vh, 240px);
}
.podium .p2 .block {
  height: clamp(80px, 17vh, 170px);
}
.podium .p3 .block {
  height: clamp(60px, 12vh, 120px);
}
.rest-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: center;
  color: var(--muted);
  font-size: 1.05rem;
}
.rest-list b {
  color: var(--text);
}
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  background: var(--c);
  left: var(--x);
  opacity: 0.9;
  animation: fall var(--d) linear var(--delay) infinite;
}

.sound-hint {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
}

/* The lobby and results screens list players themselves. */
body[data-phase='lobby'] .players-bar,
body[data-phase='ended'] .players-bar {
  display: none;
}

/* public display: bigger players, no host-only bits */
.screen-mode .pcard {
  min-width: clamp(110px, 12vw, 190px);
}

.fatal {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
}
.fatal p {
  font-size: 1.3rem;
}

.settings-modal .link-row {
  display: flex;
  gap: 8px;
}
.settings-modal .link-row .input {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
}
.settings-modal .remote-qr {
  width: 220px;
  justify-self: center;
}
.settings-modal hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.shortcut-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 0.9rem;
  color: var(--muted);
  align-items: center;
}
.join-modal .modal-body {
  justify-items: center;
  text-align: center;
}
.join-modal .qr {
  width: min(300px, 70vw);
}

/* ---- player (phone) ------------------------------------------------------------ */

.play-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color 0.25s;
  background-color: var(--bg);
}
.play-page.in-game {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.play-join {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 20px 16px;
  overflow: auto;
}
.play-join .card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}
.play-join h1 {
  font-size: 2.2rem;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
  text-align: center;
}
.play-join .game-name {
  text-align: center;
  color: var(--muted);
  margin-top: -8px;
}
.play-join .code-input {
  font: 700 1.7rem/1 var(--font-display);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
}
.play-join .name-input {
  font-size: 1.3rem;
  text-align: center;
}
.form-error {
  color: #ffb4a8;
  font-weight: 700;
  text-align: center;
  min-height: 1.4em;
  margin: 0;
}

.play-game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.play-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--line);
}
.play-top .me {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.play-top .me::before {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  background: var(--pc);
  margin-right: 0.45em;
  vertical-align: -0.05em;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}
.play-top .score {
  font: 700 1.8rem/1 var(--font-display);
  color: var(--gold);
  text-shadow: 2px 2px 0 #000;
}
.play-top .score.neg {
  color: #ff8f8f;
}
.play-info {
  padding: 14px 18px 0;
  text-align: center;
  min-height: 3.2em;
}
.play-info .cat {
  font: 700 1.05rem/1.2 var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.play-info .cat .val {
  color: var(--gold);
}
.play-info .qtext {
  margin-top: 4px;
  font-size: 0.95rem;
  color: var(--muted);
  max-height: 4.4em;
  overflow: hidden;
  white-space: pre-line;
}
.play-info .answer {
  margin-top: 8px;
  font-size: 1.1rem;
}
.play-info .answer b {
  color: var(--gold);
}
.play-center {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 10px 16px;
}
.buzzer {
  width: min(74vw, 44dvh, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  font: 700 clamp(2rem, 10vw, 3.4rem) / 1 var(--font-display);
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.85);
  background: radial-gradient(circle at 35% 30%, #7c86b8, #3a4380 55%, #232a5c);
  box-shadow: 0 12px 0 #151a40, 0 22px 40px rgba(0, 0, 0, 0.5), inset 0 -10px 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.06s, box-shadow 0.06s, background 0.2s, opacity 0.2s;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.buzzer.pressed {
  transform: translateY(10px);
  box-shadow: 0 2px 0 #151a40, 0 8px 16px rgba(0, 0, 0, 0.5), inset 0 -6px 18px rgba(0, 0, 0, 0.35);
}
.play-status {
  font: 700 clamp(1.3rem, 6vw, 2rem) / 1.2 var(--font-display);
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.03em;
  min-height: 2.4em;
}
.play-status small {
  display: block;
  font: 600 1rem/1.3 var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin-top: 4px;
}
.play-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.9rem;
}

/* player states */
.s-open .buzzer {
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #ff9a9a, #e11d48 55%, #9f1239);
  box-shadow: 0 12px 0 #6b0f24, 0 0 0 12px rgba(255, 70, 100, 0.25), 0 0 70px 24px rgba(255, 40, 80, 0.55);
  animation: buzzer-ready 0.9s ease-in-out infinite;
}
.s-open .buzzer.pressed {
  box-shadow: 0 2px 0 #6b0f24, 0 0 0 12px rgba(255, 70, 100, 0.25), 0 0 70px 24px rgba(255, 40, 80, 0.55);
}
.s-open .play-status {
  color: #ff9ab0;
}
.play-page.s-me {
  background-image: none;
  background-color: #ffcc00;
  animation: illuminate 0.7s ease-in-out infinite alternate;
}
.s-me .play-top,
.s-me .play-info .cat,
.s-me .play-status,
.s-me .play-status small,
.s-me .play-foot,
.s-me .play-info .qtext {
  color: var(--gold-ink);
}
.s-me .play-top {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(0, 0, 0, 0.15);
}
.s-me .play-top .score,
.s-me .play-info .cat .val {
  color: var(--gold-ink);
  text-shadow: none;
}
.s-me .buzzer {
  color: var(--gold-ink);
  background: radial-gradient(circle at 35% 30%, #fff, #fff3a6 50%, #ffd23f);
  box-shadow: 0 12px 0 #b88a00, 0 0 0 14px rgba(255, 255, 255, 0.55), 0 0 90px 30px rgba(255, 255, 255, 0.75);
  font-size: clamp(1.7rem, 8.5vw, 2.9rem);
}
.s-me .play-status {
  font-size: clamp(1.6rem, 8vw, 2.6rem);
}
.s-me .lang-switch button,
.s-me .play-foot .btn-ghost {
  color: var(--gold-ink);
}
.s-me .lang-switch,
.s-me .play-foot .btn-ghost {
  border-color: rgba(0, 0, 0, 0.25);
}
.s-other .buzzer,
.s-locked .buzzer,
.s-idle .buzzer {
  opacity: 0.45;
}
.s-other .play-status {
  color: #fff;
}
.buzzer.early {
  animation: shake 0.28s;
  opacity: 0.3;
}
.s-lobby .buzzer,
.s-ended .buzzer,
.s-revealed .buzzer,
.s-idle .buzzer,
.s-locked .buzzer {
  display: none;
}
.big-score {
  display: none;
  text-align: center;
}
.s-idle .big-score,
.s-revealed .big-score,
.s-locked .big-score,
.s-ended .big-score {
  display: grid;
  gap: 4px;
  animation: pop-in 0.3s ease-out;
}
.big-score .lbl {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.big-score .num {
  font: 700 clamp(4.5rem, 26vw, 8rem) / 1 var(--font-display);
  color: var(--gold);
  text-shadow: 4px 4px 0 #000;
}
.big-score .num.neg {
  color: #ff8f8f;
}
.big-emoji {
  font-size: 5rem;
  line-height: 1;
}

.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  text-align: center;
  padding: 20px;
}
.result-overlay.show {
  display: flex;
  animation: pop-in 0.28s ease-out;
}
.result-overlay.good {
  background: radial-gradient(circle at 50% 40%, #4ade80, #15803d 70%);
}
.result-overlay.bad {
  background: radial-gradient(circle at 50% 40%, #f87171, #b91c1c 70%);
}
.result-overlay .icon {
  font: 700 min(42vw, 30dvh) / 1 var(--font-display);
  text-shadow: 6px 6px 0 rgba(0, 0, 0, 0.25);
}
.result-overlay .title {
  font: 700 clamp(2.6rem, 14vw, 4.5rem) / 1 var(--font-display);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}
.result-overlay .delta {
  font: 700 clamp(2rem, 10vw, 3.2rem) / 1 var(--font-display);
}
.result-overlay .total {
  font: 700 clamp(1.4rem, 7vw, 2rem) / 1.2 var(--font-display);
  margin-top: 10px;
}
.result-overlay .dismiss {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  opacity: 0.7;
  font-size: 0.9rem;
}

/* ---- animations -------------------------------------------------------------------- */

@keyframes pop-in {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
@keyframes zoom-in {
  from {
    transform: scale(0.12);
    opacity: 0.2;
  }
}
@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}
@keyframes buzzer-ready {
  50% {
    transform: scale(1.04);
  }
}
@keyframes illuminate {
  from {
    background-color: #ffcc00;
  }
  to {
    background-color: #fff2a8;
  }
}
@keyframes shake {
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}
@keyframes float-up {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-46px);
    opacity: 0;
  }
}
@keyframes flash-out {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  15% {
    transform: scale(1.05);
    opacity: 1;
  }
  75% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}
@keyframes rise {
  from {
    transform: translateY(60px);
    opacity: 0;
  }
}
@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
  }
}
@keyframes dots {
  0% {
    content: '';
  }
  25% {
    content: '.';
  }
  50% {
    content: '..';
  }
  75% {
    content: '...';
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- small screens ------------------------------------------------------------------ */

@media (max-width: 640px) {
  .topbar {
    padding: 8px 12px;
    gap: 8px;
  }
  .brand {
    font-size: 1.15rem;
  }
  .game-title {
    display: none;
  }
  .join-chip .lbl,
  .join-chip img {
    display: none;
  }
  .join-form .input {
    max-width: none;
  }
  .card {
    padding: 16px;
  }
  .board-item .actions {
    width: 100%;
  }
  .board-item .actions .btn-primary {
    flex: 1;
  }
  .pcard {
    min-width: 84px;
    padding: 5px 10px 6px;
  }
}
