:root {
  --ink: #140e0c;
  --paper: #f4ead7;
  --muted: #cbbba6;
  --gold: #f0b429;
  --gold-fill: #f0b429;
  --line: rgba(244, 234, 215, 0.18);
  --surface: rgba(255, 255, 255, 0.05);
  --field: #241c18;
  --field-border: #5c4b3e;
  --time-track: #3a2c24;
  --glow: rgba(240, 180, 41, 0.16);
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --q-scale: 1.5;
  --a-scale: 1;
  color-scheme: dark;
}

html[data-theme="light"] {
  --ink: #f7f1e6;
  --paper: #1c1410;
  --muted: #6e5b4c;
  --gold: #8a5a08;
  --gold-fill: #e0a31a;
  --line: rgba(28, 20, 16, 0.14);
  --surface: rgba(28, 20, 16, 0.05);
  --field: #fffdf8;
  --field-border: #ddcfc0;
  --time-track: #e6d9c8;
  --glow: rgba(138, 90, 8, 0.14);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --ink: #f7f1e6;
    --paper: #1c1410;
    --muted: #6e5b4c;
    --gold: #8a5a08;
    --gold-fill: #e0a31a;
    --line: rgba(28, 20, 16, 0.14);
    --surface: rgba(28, 20, 16, 0.05);
    --field: #fffdf8;
    --field-border: #ddcfc0;
    --time-track: #e6d9c8;
    --glow: rgba(138, 90, 8, 0.14);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 50% -10%, var(--glow), transparent 55%),
    var(--ink);
  color: var(--paper);
  font-family: "Segoe UI", sans-serif;
}

body[data-role="host"] #app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body[data-role="host"] #app > .center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.banner {
  margin: 0;
  padding: 10px 16px;
  background: #8c2f2f;
  text-align: center;
}

.banner.lost {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: 26px 28px;
  background: #d01212;
  color: #fff;
  font-size: clamp(1.7rem, 4.5vw, 4rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  animation: lost-pulse 1.1s ease-in-out infinite;
}

@keyframes lost-pulse {
  0%, 100% { background: #d01212; }
  50% { background: #7d0c0c; }
}

@media (prefers-reduced-motion: reduce) {
  .banner.lost { animation: none; }
}

.banner[hidden] { display: none; }

.center {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  text-align: center;
}

.kicker {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 0.82rem;
}

h1, h2, .q {
  font-family: "Segoe UI", sans-serif;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.q {
  margin: 12px 0 18px;
  font-size: clamp(calc(1.8rem * var(--q-scale)), calc(4vw * var(--q-scale)), calc(3.3rem * var(--q-scale)));
  line-height: 1.12;
}

.qr {
  display: block;
  width: min(240px, 36vw);
  height: auto;
  margin: 14px auto 2px;
  background: #fff;
  border-radius: 12px;
}

body.display .qr {
  width: min(420px, 48vh);
  margin-top: 18px;
}

.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background: rgba(20, 14, 12, 0.78);
}

.qr-card {
  width: min(680px, 100%);
  padding: 28px 24px 12px;
  border-radius: 24px;
  background: var(--ink);
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.qr-overlay .qr {
  width: min(460px, 62vh);
  margin-top: 0;
}

.qr rect { fill: #000; }
.qr rect:first-child { fill: #fff; }

.join-url {
  margin: 8px auto 18px;
  max-width: 40rem;
  font-size: clamp(1.5rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--gold);
  overflow-wrap: anywhere;
}

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

.note {
  margin: 8px auto 18px;
  max-width: 36rem;
  color: var(--muted);
}

.urls {
  display: grid;
  gap: 10px;
  text-align: left;
  margin: 0 auto 18px;
  max-width: 34rem;
}

.url-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}

.url-row span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.url-row input {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--paper);
  font-size: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  background: var(--gold-fill);
  color: #1a1208;
  font-weight: 700;
}

.btn.ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.chips li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.chips li.in { border-color: rgba(240, 180, 41, 0.7); }
.chips li.you { box-shadow: inset 0 0 0 1px var(--gold); }
.chips .emo { font-size: 1.3rem; }
.chips b { font-variant-numeric: tabular-nums; }
.chips small { color: var(--gold); }
.trend { font-style: normal; font-size: 0.8rem; margin-left: 2px; }
.trend.up { color: #2f9e44; }
.trend.down { color: #e03131; }

.host-q {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 22px 72px;
}

.toprow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
}

.timewrap {
  height: 12px;
  border-radius: 99px;
  background: var(--time-track);
  overflow: hidden;
}

.timebar {
  height: 100%;
  width: 100%;
  background: var(--gold);
  transform-origin: left center;
}

.timebar.paused { background: var(--muted); }

.phone-status.paused { color: var(--gold); }

.q-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.host-q.has-rail {
  flex-direction: row;
  align-items: stretch;
  padding: 0;
  min-height: 100dvh;
}

.host-q.has-rail .q-main {
  padding: 18px 16px 72px 22px;
}

.host-q.lobby {
  flex: 1 1 auto;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.host-q.has-rail .q-main > .center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

body.display .host-q,
body.display .q-main,
body.display .host-q.has-rail .q-main {
  padding-bottom: 18px;
}

.answer-rail {
  width: 64px;
  flex: 0 0 64px;
  margin: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: 0;
  box-sizing: border-box;
  border-radius: 0;
  background: var(--surface);
  border: 0;
}

.rail-count {
  margin: 0;
  padding: 12px 0 8px;
  flex: 0 0 auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rail-slots {
  container-type: size;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
  border: 0;
}

.rail-slots li {
  --slot: 52px;
  --slot: min(52px, 100cqw, max(8px, calc((100cqh - 8px * (var(--n) - 1)) / var(--n))));
  position: relative;
  box-sizing: border-box;
  width: var(--slot);
  height: var(--slot);
  flex: 0 0 var(--slot);
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--slot) * 0.66);
  line-height: 1;
  background: var(--field);
}

.rail-slots li.waiting {
  opacity: 0.28;
  filter: grayscale(1);
}

.rail-slots li.right { box-shadow: inset 0 0 0 3px #2f9e44; }
.rail-slots li.wrong { box-shadow: inset 0 0 0 3px #e03131; }

.rail-slots .rail-time {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 0 3px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
}

.answers {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  min-height: 46vh;
}

.answers.n-2 { grid-template-rows: 1fr; }
.answers.n-3 { grid-template-rows: 1fr 1fr; }
.answers.n-3 > :last-child { grid-column: 1 / -1; }
.answers.n-5,
.answers.n-6 { grid-template-rows: 1fr 1fr 1fr; }

.prompt {
  flex: 1;
  min-height: 46vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.scale,
.solution {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5rem);
  font-weight: 700;
  line-height: 1.1;
}

.tile {
  min-height: 0;
  height: 100%;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  color: var(--paper);
  background: var(--field);
  border: 1px solid var(--field-border);
  text-align: left;
  container-type: size;
}

.tile svg { width: 54px; height: 54px; flex: 0 0 auto; }
.tile.plain { justify-content: center; text-align: center; }
.tile span {
  font-size: clamp(calc(1.7rem * var(--a-scale)), calc(16cqmin * var(--a-scale)), calc(4.8rem * var(--a-scale)));
  font-weight: 700;
  line-height: 1.12;
  text-wrap: balance;
}
.tile.dim { filter: saturate(0.4) brightness(0.55); }
.tile.correct { box-shadow: 0 0 0 5px var(--gold); }

body:not(.colors) .tile.dim { filter: none; opacity: 0.42; }

body.colors .tile.red { background: var(--red); color: white; border-color: transparent; }
body.colors .tile.blue { background: var(--blue); color: white; border-color: transparent; }
body.colors .tile.yellow { background: var(--yellow); color: #1a1208; border-color: transparent; }
body.colors .tile.green { background: var(--green); color: white; border-color: transparent; }

.count { text-align: center; font-size: 1.15rem; }

.bars {
  list-style: none;
  margin: 28px auto;
  padding: 0;
  width: min(920px, 100%);
  display: grid;
  gap: 14px;
  align-content: center;
  flex: 1;
}

.bars li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bars .who { flex: 0 0 auto; font-size: 1.5rem; line-height: 1; }
.bars .now,
.bars .plus {
  flex: 0 0 auto;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.bars .now { min-width: 4.4rem; }
.bars .plus { min-width: 4.6rem; color: var(--gold); }
.bars li.is-moving .now { color: var(--gold-fill); }

.bars .move {
  flex: 0 0 auto;
  min-width: 3.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.bars .move .tri {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}

.bars .move.up { color: #2f9e44; }
.bars .move.up .tri { border-bottom: 11px solid #2f9e44; }
.bars .move.down { color: #e03131; }
.bars .move.down .tri { border-top: 11px solid #e03131; }

.bars .who.is-winner {
  display: inline-block;
  transform-origin: center;
  animation: winner-pulse 0.9s ease-in-out infinite;
}

@keyframes winner-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.85); }
}

@media (prefers-reduced-motion: reduce) {
  .bars .who.is-winner { animation: none; font-size: 2.2rem; }
}

body[data-role="play"] .stand-view {
  max-width: none;
  width: min(640px, 100%);
  box-sizing: border-box;
}

body[data-role="play"] .stand-view .bars {
  width: 100%;
  margin: 18px 0 0;
  text-align: left;
}

.track {
  flex: 1;
  height: 36px;
  border-radius: 0;
  background: var(--time-track);
  overflow: hidden;
}

.track .fill {
  display: block;
  height: 100%;
  border-radius: 0;
  background: var(--gold-fill);
}

.card {
  width: min(440px, calc(100% - 28px));
  margin: 28px auto;
  padding: 22px 18px 24px;
}

.card h1 { margin: 6px 0 16px; font-size: 2.4rem; }

label { display: block; text-align: left; margin: 12px 0 6px; color: var(--muted); }

input[type="text"],
input[type="number"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--field-border);
  background: var(--field);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}

body[data-role="play"] #app:has(#join-form) {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

main.card:has(#join-form) {
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

#join-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.icons {
  --icon-gap: 6px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--icon-gap);
  align-content: start;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.icons button {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  background: var(--field);
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
  container-type: size;
  touch-action: manipulation;
}

.icons button span {
  font-size: 62cqmin;
  line-height: 1;
}

.icons button.on {
  border-color: var(--gold);
  background: rgba(240, 180, 41, 0.14);
}

.icon-tip {
  position: fixed;
  z-index: 40;
  margin: 0;
  pointer-events: none;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  line-height: 1.3;
  white-space: nowrap;
}

.icon-tip[hidden] { display: none; }

.icons button.taken,
.icons button:disabled {
  opacity: 0.28;
  filter: grayscale(1);
  cursor: not-allowed;
}

.join-error {
  min-height: 1.3em;
  color: #ffb4b4;
}

.card .btn { width: 100%; margin-top: 8px; }

.wait-icon { font-size: 5rem; margin: 10px 0; }

.you-badge {
  position: fixed;
  top: 14px;
  left: 6px;
  z-index: 20;
  margin: 0;
  font-size: 2.4rem;
  line-height: 1;
  pointer-events: none;
}

body[data-role="play"]:has(#you-badge) .center { padding-top: 64px; }
body[data-role="play"]:has(#you-badge) .phone-q { padding-top: 60px; }

.phone-q {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 14px 12px 72px;
}

.phone-status {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.phone-clock {
  margin: 8px 0 2px;
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.phone-q .timewrap { margin-top: 4px; }

.phone-question {
  margin: 6px 6px 12px;
  text-align: center;
  font-size: clamp(calc(1.2rem * var(--q-scale)), calc(4.8vw * var(--q-scale)), calc(1.7rem * var(--q-scale)));
  line-height: 1.25;
}

.pad {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: 0;
}

.pad.n-2 { grid-template-rows: 1fr; }
.pad.n-3 { grid-template-rows: 1fr 1fr; }
.pad.n-3 > :last-child { grid-column: 1 / -1; }
.pad.n-5,
.pad.n-6 { grid-template-rows: 1fr 1fr 1fr; }

.range-box,
.select-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 8px 6px 12px;
}

.range-value {
  margin: 0;
  text-align: center;
  font-size: 4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.range-box input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 72px;
  margin: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.range-box input[type="range"]:active { cursor: grabbing; }
.range-box input[type="range"]:disabled { cursor: default; }

.range-box input[type="range"]::-webkit-slider-runnable-track {
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-fill) var(--pct, 0%), var(--time-track) var(--pct, 0%));
}

.range-box input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 64px;
  height: 64px;
  margin-top: -21px;
  border-radius: 50%;
  background: var(--gold-fill);
  border: 5px solid var(--ink);
  box-shadow: 0 0 0 3px var(--gold-fill);
}

.range-box input[type="range"]::-moz-range-track {
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-fill) var(--pct, 0%), var(--time-track) var(--pct, 0%));
}

.range-box input[type="range"]::-moz-range-thumb {
  width: 64px;
  height: 64px;
  border: 5px solid var(--ink);
  border-radius: 50%;
  background: var(--gold-fill);
  box-shadow: 0 0 0 3px var(--gold-fill);
}

.range-ends {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.range-box .btn,
.select-box .btn { width: 100%; }

.select-box select {
  width: 100%;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--paper);
  border-radius: 16px;
  padding: 16px;
  font: inherit;
  font-size: 1.2rem;
}

.quiz-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px auto 0;
  color: var(--muted);
}

.quiz-pick select,
.edit select,
.edit input[type="text"],
.edit input[type="number"] {
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--paper);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
}

.pad button {
  border-radius: 18px;
  color: var(--paper);
  background: var(--field);
  border: 1px solid var(--field-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  touch-action: manipulation;
  container-type: size;
}

.pad button svg { width: 42px; height: 42px; flex: 0 0 auto; }
.pad button span {
  font-size: clamp(calc(1.15rem * var(--a-scale)), calc(14cqmin * var(--a-scale)), calc(2.6rem * var(--a-scale)));
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}
body.colors .pad button.red { background: var(--red); color: white; border-color: transparent; }
body.colors .pad button.blue { background: var(--blue); color: white; border-color: transparent; }
body.colors .pad button.yellow { background: var(--yellow); color: #1a1208; border-color: transparent; }
body.colors .pad button.green { background: var(--green); color: white; border-color: transparent; }
.pad button.off { opacity: 0.38; }
.pad button.picked { transform: scale(0.98); }

.answers.pictures .tile.pic,
.pad.pictures button.pic {
  padding: 8px;
  overflow: hidden;
}

.tile.pic img,
.pad button.pic img,
.preview-screen .pad button.pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  pointer-events: none;
}

.reveal-pic {
  display: block;
  width: min(320px, 78vw);
  max-height: 42vh;
  margin: 8px auto 0;
  object-fit: contain;
  border-radius: 16px;
  background: #fff;
}

.answer-row.image-row { align-items: center; }
.answer-row.image-row .drag,
.answer-row.image-row input[type="radio"],
.answer-row.image-row .tiny.trash { margin-top: 0; }
.image-row img {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}

.slim {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}

.result-mark {
  width: 6.5rem;
  height: 6.5rem;
  margin: 0 auto;
}
.result-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.result-mark.ok { color: var(--green); }
.result-mark.bad { color: var(--red); }
.result-points { font-size: 2.4rem; margin: 0; color: var(--gold); font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .answers { grid-template-columns: 1fr; grid-template-rows: none; }
  .tile { min-height: 12vh; height: auto; container-type: normal; }
  .tile span { font-size: clamp(calc(1.35rem * var(--a-scale)), calc(5vw * var(--a-scale)), calc(2rem * var(--a-scale))); }
  .icons { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .host-q { padding: 12px; }
  .host-q.has-rail { padding: 0; }
  .host-q.has-rail .q-main { padding: 12px 12px 72px; }
  .answer-rail { width: 64px; flex-basis: 64px; }
}

.gear {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 20;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0 0 5px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0.62;
  display: grid;
  place-items: end start;
}

.gear:hover,
.gear:focus-visible { opacity: 1; }

.gear .settings-icon {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sheet {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 18px;
  background: var(--ink);
  color: var(--paper);
  width: min(420px, calc(100% - 28px));
}

.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }

.sheet.sheet-full {
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0 28px 32px;
  overflow: auto;
}

.sheet-top {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -28px 8px;
  padding: 14px 14px 12px 28px;
  background: var(--ink);
}

.sheet-top h2 { margin: 0; }

.sheet-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.sheet-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
}

.sheet.sheet-full .checks {
  grid-template-columns: 1fr 1fr;
  max-width: 720px;
}

.sheet h2 {
  margin: 0 0 8px;
  font-weight: 500;
}

.sheet .seconds {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet input[type="number"] { width: 6rem; }

.sheet .points {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sheet .points label {
  margin: 0;
  font-size: 0.85rem;
}

.sheet .points input[type="number"] {
  width: 100%;
  margin-top: 4px;
}

.sheet .score-help {
  margin: 8px 0 4px;
  text-align: left;
}

.sheet .score-help p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.sheet .font-size {
  display: grid;
  gap: 12px;
}

.sheet .font-size-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.sheet .font-size-top span,
.sheet .font-size output {
  color: var(--paper);
  font-size: 0.95rem;
}

.sheet .tempo {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.sheet .tempo span {
  color: var(--muted);
  font-size: 0.85rem;
}

.sheet input[type="range"] {
  width: 100%;
  accent-color: var(--gold-fill);
}

.themes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.themes label {
  position: relative;
  margin: 0;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 6px;
  color: var(--paper);
}

.themes input { position: absolute; opacity: 0; }

.themes label:has(input:checked) {
  border-color: var(--gold);
  background: var(--surface);
}

.sheet .actions { margin-top: 16px; }

.sheet .resets {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.sheet .resets .btn,
.sheet #open-display,
.sheet a.btn { width: 100%; margin-top: 8px; }

.quiz-choice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 12px;
}

.quiz-choice-name { font-weight: 700; }

.sheet .quiz-choice a.btn { width: auto; margin: 0; }

.quiz-list {
  list-style: none;
  margin: 8px 0 18px;
  padding: 0;
}

.quiz-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.quiz-list .name { flex: 1 1 12rem; font-weight: 700; }

.edit-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 18px 72px;
}

.edit-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.edit-top select { min-width: 14rem; }

.edit-page.is-editor {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0 0 40px;
}

.edit-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 52px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
  position: sticky;
  top: 0;
  z-index: 5;
}

.edit-bar .btn {
  width: auto;
  padding: 8px 14px;
}

.edit-bar #quiz-title {
  flex: 1 1 16rem;
  width: auto;
  min-width: 10rem;
  margin: 0;
}

.edit-note { margin: 0; padding: 10px 16px 0; }

.q-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  align-items: start;
  gap: 10px;
  padding: 12px;
}

.q-card {
  min-width: 0;
  margin: 0;
  padding: 6px 8px 8px;
  border: 0;
  border-radius: 12px;
  background: var(--field);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.q-card.dragging,
.answer-row.dragging {
  opacity: 0.35;
  outline: 2px dashed var(--gold);
  outline-offset: 2px;
}

#drop-line {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  border-radius: 4px;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.45);
}

.q-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.q-head strong { font-size: 0.82rem; font-weight: 700; }
.q-head select { margin-left: auto; padding: 2px 6px; border-radius: 8px; font-size: 0.85rem; }

.q-card input[type="text"],
.q-card input[type="number"],
.q-card select {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.92rem;
}

.q-card textarea.grow {
  display: block;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--paper);
  border-radius: 8px;
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
  resize: none;
  overflow: hidden;
  field-sizing: content;
}

.q-card > textarea.grow { margin-top: 4px; }

.answer-list { margin-top: 2px; }

.answer-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin-top: 4px;
  border-radius: 8px;
}

.answer-row .drag,
.answer-row input[type="radio"],
.answer-row .tiny.trash { margin-top: 3px; }

.answer-row input[type="radio"] { width: auto; margin-left: 0; margin-right: 0; flex: 0 0 auto; }
.answer-row textarea.grow { width: auto; flex: 1; min-width: 0; }

.range-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  margin-top: 6px;
}
.range-fields label { margin: 0; font-size: 0.82rem; }
.range-fields input[type="number"] { width: 4.6rem; }
.edit-error { color: #ffb4b4; min-height: 1.3em; }

.q-card .tiny {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 8px;
}

.drag {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.drag:active { cursor: grabbing; }
.drag svg { width: 14px; height: 14px; display: block; fill: currentColor; }

.q-card .tiny.plus,
.q-card .tiny.eye,
.q-card .tiny.trash {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--muted);
}

.q-card .tiny.plus { margin-top: 4px; }

.q-card .tiny.plus svg,
.q-card .tiny.eye svg,
.q-card .tiny.trash svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.q-card .tiny.plus:hover,
.q-card .tiny.eye:hover { color: var(--paper); }
.q-card .tiny.trash:hover { color: #e03131; }
.q-card .tiny.plus:disabled,
.q-card .tiny.eye:disabled,
.q-card .tiny.trash:disabled { opacity: 0.35; }

.confirm-dialog {
  width: min(440px, calc(100% - 32px));
  margin: auto;
  padding: 22px 20px 16px;
  border: 0;
  border-radius: 18px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.confirm-dialog::backdrop {
  background: rgba(20, 14, 12, 0.72);
}

.confirm-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.confirm-detail {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.confirm-actions .btn {
  width: auto;
  padding: 10px 16px;
}

.btn.danger {
  background: #e03131;
  color: #fff;
}

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(20, 14, 12, 0.72);
}

.preview-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--field);
  color: var(--paper);
  font-size: 1.6rem;
  line-height: 1;
}

.preview-phone {
  width: min(390px, 100%);
  height: min(780px, calc(100dvh - 48px));
  display: flex;
  border: 10px solid #2a211c;
  border-radius: 32px;
  background: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.preview-screen {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background:
    radial-gradient(420px 220px at 50% -10%, var(--glow), transparent 55%),
    var(--ink);
}

.preview-screen .phone-q {
  flex: 1;
  min-height: 0;
  height: auto;
  padding: 18px 12px 16px;
}

.preview-screen .phone-question {
  font-size: 1.65rem;
}

.checks { display: grid; gap: 8px; margin: 4px 0 8px; }
.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--paper);
}

/* Anmeldung Spielleitung (auth.php) */
.login-page {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 22px 18px;
  text-align: center;
}

.login-page h1 { margin: 0 0 18px; font-size: 2rem; }
.login-form .btn { width: 100%; margin-top: 16px; }
.login-error { color: var(--red); margin: 10px 0 0; font-weight: 700; }
.login-hint { margin-top: 28px; color: var(--muted); }
.login-hint a { color: var(--gold); }
