:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080b12;
  color: #f7f8fb;
  --yellow: #f7c600;
  --yellow-dark: #bb9400;
  --panel: #151a24;
  --panel-soft: #10141d;
  --line: #2a3242;
  --muted: #a9b1c3;
  --success: #58d68d;
  --danger: #ff7676;
}

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgb(247 198 0 / 12%), transparent 32rem),
    #080b12;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem max(1rem, calc((100vw - 72rem) / 2));
  border-bottom: 1px solid var(--line);
  background: rgb(8 11 18 / 92%);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(12px);
}
.login-overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 50% 20%, #3b3100, #080b12 58%); }
.login-card { width: min(100%, 25rem); padding: 5.5rem 1.5rem 1.5rem; border: 1px solid var(--yellow-dark); border-radius: 1.2rem; background: var(--panel); box-shadow: 0 2rem 6rem rgb(0 0 0 / 55%); text-align: center; position: relative; }
.login-card img { position: absolute; top: -4.5rem; left: 50%; transform: translateX(-50%); width: 10rem; height: 8rem; object-fit: contain; }
.login-card label { text-align: left; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 4vw, 2rem); }
h2 { margin-bottom: .85rem; font-size: clamp(1.2rem, 4vw, 1.65rem); }
.eyebrow, .step { color: var(--yellow); text-transform: uppercase; letter-spacing: .1em; font-weight: 800; font-size: .72rem; margin-bottom: .25rem; }

main {
  width: min(100% - 2rem, 72rem);
  margin: 1rem auto 3rem;
  display: grid;
  gap: 1rem;
}

.card {
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: 0 1rem 3rem rgb(0 0 0 / 18%);
}

.card.accent { border-color: var(--yellow-dark); }
.card.muted { background: var(--panel-soft); color: var(--muted); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.badge, .status { padding: .4rem .65rem; border-radius: 999px; background: #262e3d; color: var(--muted); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge.strong { background: var(--yellow); color: #111; }
.status.ok { color: #08150e; background: var(--success); }
.status.error { color: #210707; background: var(--danger); }
.topbar-actions { display: flex; align-items: center; gap: .65rem; }
.developer-toggle { margin: 0; }
.screen-link { color: var(--yellow); font-size: .85rem; font-weight: 800; text-decoration: none; }
.screen-link:hover, .screen-link:focus-visible { text-decoration: underline; }

label, legend { display: block; margin: 1rem 0 .45rem; font-weight: 750; }
fieldset { border: 0; padding: 0; margin: 0; }

input, textarea, select, button { font: inherit; }
input[type="password"], input[type="text"], textarea, select {
  width: 100%;
  min-height: 3rem;
  padding: .78rem .9rem;
  color: #fff;
  background: #090d14;
  border: 1px solid #3a455a;
  border-radius: .7rem;
}
input[type="number"] {
  width: 100%;
  min-height: 3rem;
  padding: .78rem .9rem;
  color: #fff;
  background: #090d14;
  border: 1px solid #3a455a;
  border-radius: .7rem;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid rgb(247 198 0 / 45%); outline-offset: 2px; }
.hint { color: var(--muted); margin: .55rem 0 0; font-size: .9rem; }
.options { display: grid; gap: .65rem; }
.option-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; }

.button {
  min-height: 3rem;
  border: 0;
  border-radius: .75rem;
  padding: .72rem 1rem;
  font-weight: 850;
  cursor: pointer;
}
.button.primary { width: 100%; background: var(--yellow); color: #111; margin-top: 1rem; }
.button.secondary { background: #2a3344; color: #fff; margin-top: .75rem; }
.button.compact { margin-top: 0; min-height: 2.6rem; }
.button.remove { background: #2a2024; color: #ffb2b2; padding-inline: .8rem; }
.discard-prepared { width: 100%; margin-top: 1rem; }
.button.danger-action { width: 100%; margin-top: .65rem; background: #f7c600; color: #111; border: 2px solid #fff1a8; }
.button:disabled { cursor: wait; opacity: .55; }
.check-row { display: flex; align-items: center; gap: .7rem; min-height: 3rem; }
.check-row input { width: 1.25rem; height: 1.25rem; accent-color: var(--yellow); }
.message { min-height: 1.5rem; margin-top: .75rem; color: var(--muted); }
.message.success { color: var(--success); }
.message.error { color: var(--danger); }
.access-card { grid-column: 1 / -1; }
.game-card { order: 1; }
.voting-card { order: 2; }
.poll-card { order: 5; }
.poll-card > summary { cursor: pointer; list-style: none; }
.poll-card > summary::-webkit-details-marker { display: none; }
.poll-card > summary::after { content: "+"; color: var(--yellow); font-size: 1.6rem; font-weight: 900; }
.poll-card[open] > summary::after { content: "–"; }
.roster-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-top: 1rem; }
.roster-stats div { padding: .75rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--panel-soft); text-align: center; }
.roster-stats strong, .roster-stats span { display: block; }
.roster-stats strong { color: var(--yellow); font-size: 1.55rem; }
.roster-stats span { color: var(--muted); font-size: .78rem; }
.roster-management { margin-top: .75rem; border-top: 1px solid var(--line); }
.roster-management summary { padding: 1rem 0 .25rem; color: var(--yellow); font-weight: 800; cursor: pointer; }
.player-form { display: grid; grid-template-columns: minmax(0, 1fr) 5rem; gap: 0 .75rem; align-items: end; }
.player-active { grid-column: 1 / 2; margin: .5rem 0 0; }
.player-submit { grid-column: 1 / -1; }
.player-list { display: grid; gap: .65rem; margin-top: .75rem; }
.player-row { display: grid; grid-template-columns: 4rem minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .7rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--panel-soft); }
.player-number { color: var(--yellow); font-weight: 900; }
.player-meta { color: var(--muted); font-size: .85rem; }
.photo-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .55rem; }
.photo-controls input[type="file"] { width: min(100%, 15rem); color: var(--muted); font-size: .8rem; }
.player-thumbnail { width: 3rem; height: 4rem; object-fit: cover; border-radius: .4rem; border: 1px solid var(--line); }
.candidate-options { display: grid; gap: .5rem; }
.candidate-row { display: flex; align-items: center; gap: .75rem; min-height: 3rem; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--panel-soft); cursor: pointer; }
.candidate-row input { width: 1.3rem; height: 1.3rem; accent-color: var(--yellow); }
.candidate-row:has(input:checked) { border-color: var(--yellow-dark); background: rgb(247 198 0 / 8%); }
.image-workflow { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.image-workflow h3 { margin: 0 0 .75rem; }
.image-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.image-actions .button { margin-top: 0; }
#voting-image-preview { display: block; width: 100%; margin-top: 1rem; border-radius: .8rem; border: 1px solid var(--line); }
#voting-image-preview[hidden] { display: none; }
.winner-preview-heading { margin-top: 1.25rem !important; }
.winner-previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.winner-previews img { width: 100%; border-radius: .65rem; border: 1px solid var(--line); }
.start-workflow { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.active-voting { margin-top: 1rem; padding: 1rem; border: 1px solid var(--yellow-dark); border-radius: .8rem; background: var(--panel-soft); }
.completed-voting { margin-top: 1rem; padding: 1rem; border: 1px solid var(--yellow-dark); border-radius: .8rem; background: var(--panel-soft); }
.completed-voting h3 { margin: 0 0 .85rem; }
.completed-voting > img { display: block; width: min(100%, 32rem); margin: 0 auto; border: 1px solid var(--line); border-radius: .8rem; background: #fff; }
.voting-history { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.voting-history summary { color: var(--yellow); font-weight: 800; cursor: pointer; }
.history-list { display: grid; gap: .5rem; margin-top: .75rem; }
.history-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; padding: .65rem; background: var(--panel-soft); border-radius: .65rem; }
.history-row p { margin: 0; }
.history-results { margin: .45rem 0 0; padding-left: 1.2rem; color: var(--muted); font-size: .85rem; }
.history-results li + li { margin-top: .2rem; }
.active-voting h3 { margin: 0; }
.active-countdown { color: var(--yellow); font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.duration-stepper { display: grid; grid-template-columns: auto minmax(4rem, 6rem) 1fr auto; gap: .5rem; align-items: center; }
.duration-stepper .button { margin: 0; width: 3rem; padding-inline: 0; font-size: 1.3rem; }
.duration-stepper input { text-align: center; font-weight: 850; }
.duration-stepper span { color: var(--muted); font-weight: 750; }
.active-results { display: grid; gap: .45rem; margin-top: .8rem; }
.active-results div { display: flex; justify-content: space-between; gap: .75rem; padding: .6rem .7rem; border-radius: .55rem; background: #090d14; }
.active-results strong { color: var(--yellow); }
.timer-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; }
.active-actions { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: end; }
.active-actions .button { margin-top: 1rem; }
.developer-area { grid-column: 1 / -1; order: 4; display: grid; gap: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.developer-area > .card { min-width: 0; align-self: start; }
.developer-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.developer-heading h2 { margin-bottom: 0; }
.preview-percentages { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.preview-percentages label { margin-top: 1rem; color: var(--muted); font-size: .85rem; }
.preview-percentages input { margin-top: .35rem; }
.developer-preview-card .section-heading { flex-wrap: wrap; }
.developer-preview-card .screen-link { overflow-wrap: anywhere; }
.preview-mode-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); gap: .5rem; margin-top: 1rem; }
.preview-mode-buttons .button { min-width: 0; margin: 0; white-space: normal; }
.simulation-launcher { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: center; margin: 1rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--panel-soft); }
.simulation-launcher strong, .simulation-launcher span { display: block; }
.simulation-launcher span { margin-top: .25rem; color: var(--muted); font-size: .86rem; line-height: 1.4; }
.simulation-launcher .button { margin: 0; }
.preview-manual-heading { margin: 1.2rem 0 -.35rem; font-weight: 700; }
.screen-timing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: .65rem; margin: 1rem 0; }
.screen-timing-grid label { position: relative; margin: 0; color: var(--muted); font-size: .82rem; }
.screen-timing-grid input { margin-top: .35rem; padding-right: 3.2rem; }
.screen-timing-grid label span { position: absolute; right: .8rem; bottom: .8rem; color: var(--muted); font-size: .75rem; pointer-events: none; }
.developer-clear { width: 100%; min-height: 3rem; margin-top: .75rem; }
.developer-webhook-card { grid-column: 1 / -1; }
.developer-area .poll-card { order: 0; }
.test-voting-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: .75rem; margin: .75rem 0 1rem; }
.test-voting-images figure { margin: 0; }
.test-voting-images img { display: block; width: 100%; max-height: 18rem; object-fit: contain; border: 1px solid var(--line); border-radius: .7rem; background: var(--yellow); }
.test-voting-images figcaption { margin-top: .3rem; color: var(--muted); font-size: .85rem; }
.channel-list { display: grid; gap: .65rem; margin-top: 1rem; }
.channel-option { display: grid; grid-template-columns: 3.25rem minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .75rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--panel-soft); }
.channel-option.selected { border-color: var(--yellow); background: rgb(247 198 0 / 7%); }
.channel-option img, .channel-avatar { width: 3.25rem; height: 3.25rem; object-fit: cover; border-radius: 50%; background: #090d14; }
.channel-avatar { display: grid !important; place-items: center; color: var(--yellow) !important; font-size: 1.2rem !important; font-weight: 900; }
.channel-option strong, .channel-option span { display: block; }
.channel-option span { margin-top: .2rem; color: var(--muted); font-size: .78rem; }
.channel-option p { margin: .4rem 0 0; color: var(--muted); font-size: .82rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.channel-option .button { margin: 0; }
.diagnostics-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin: 1rem 0 0; }
.diagnostics-list div { padding: .7rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--panel-soft); }
.diagnostics-list dt { color: var(--muted); font-size: .78rem; }
.diagnostics-list dd { margin: .3rem 0 0; font-weight: 800; overflow-wrap: anywhere; }
.diagnosis-result { margin: .8rem 0 0; padding: .8rem; border-left: .25rem solid var(--yellow); background: rgb(247 198 0 / 7%); }

@media (min-width: 70rem) {
  .developer-area { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .developer-heading { grid-column: 1 / -1; }
}

@media (max-width: 32rem) {
  .topbar { align-items: flex-start; }
  .topbar .status { margin-top: .2rem; max-width: 9rem; white-space: normal; text-align: center; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; }
  .section-heading { display: block; }
  .badge { display: inline-block; margin-bottom: .7rem; }
  .player-row { grid-template-columns: 3.5rem minmax(0, 1fr); }
  .player-row .button { grid-column: 1 / -1; }
  .timer-control, .active-actions { grid-template-columns: 1fr; }
  .active-actions .button { width: 100%; }
  .winner-previews { grid-template-columns: 1fr; }
  .preview-percentages { grid-template-columns: 1fr; }
  .preview-mode-buttons { grid-template-columns: 1fr 1fr; }
  .simulation-launcher { grid-template-columns: 1fr; }
  .developer-preview-card .screen-link { display: inline-block; margin-top: .35rem; }
  .diagnostics-list { grid-template-columns: 1fr; }
  .channel-option { grid-template-columns: 2.75rem minmax(0, 1fr); }
  .channel-option img, .channel-avatar { width: 2.75rem; height: 2.75rem; }
  .channel-option .button { grid-column: 1 / -1; width: 100%; }
}
