/* PubQuiz – ein Stylesheet für alle Seiten.
   Layout: eine schmale Spalte für Smartphones (max. 520px, Admin 760px),
   dunkle Kneipen-Optik mit Bernstein-Akzent. */

:root {
  --bg: #090D12;
  --bg-rgb: 9, 13, 18;
  --surface: #121820;
  --card: #1A2030;
  --border: #2C3545;
  --line: rgba(44, 53, 69, .55);
  --fg: #EBF0F6;
  --muted: #8A97A8;
  --accent: #F5A623;
  --accent-dk: #CA8A1D;
  --ac-rgb: 245, 166, 35;
  --on-accent: #090D12;
  --ok: #4CAF7C;
  --ok-rgb: 76, 175, 124;
  --err-fg: #F08A8A;
  --err-rgb: 224, 82, 82;
  --display: "Bebas Neue", "Avenir Next Condensed", "HelveticaNeue-CondensedBold", "Roboto Condensed", "Arial Narrow", sans-serif-condensed, Impact, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

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

[hidden] { display: none !important; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--text);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  padding: 0 16px;
  padding: env(safe-area-inset-top, 0px) 16px env(safe-area-inset-bottom, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- Grundgerüst ---------- */

.wrap {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 0 28px;
}
.admin .wrap { max-width: 760px; }
.wrap > * + * { margin-top: 16px; }
.wrap > .foot { margin-top: auto; padding-top: 28px; }

.stack { display: grid; grid-gap: 16px; gap: 16px; align-content: start; }
.stack > * { min-width: 0; }

.flow > * { margin-top: 0; margin-bottom: 0; }
.flow > * + * { margin-top: 14px; }

h1, h2 { margin: 0; font-size: 1.375rem; line-height: 1.25; }
p { margin: 0; }
.lead { color: var(--muted); }
.center { text-align: center; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Logo & Titel ---------- */

.brand { text-align: center; }
.brand-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 260px;
  max-width: min(260px, 80%);
  max-height: 110px;
  margin: 0 auto;
  border-radius: 8px;
}
.brand-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.5rem;
  font-size: clamp(2.1rem, 10vw, 3rem);
  line-height: 1;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
}
.brand-logo + .brand-title { margin-top: 12px; }

.brand-compact .brand-logo { max-height: 48px; max-width: 200px; max-width: min(200px, 70%); }
.brand-compact .brand-title { font-size: 1.75rem; }

/* ---------- Karten ---------- */

.card {
  margin: 0;
  padding: 22px 20px;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.donate {
  padding: 18px 20px;
  background: rgba(var(--ac-rgb), .07);
  border: 1px solid rgba(var(--ac-rgb), .35);
  border-radius: 14px;
}
.donate-title { font-weight: 700; color: var(--accent); }
.donate p + p { margin-top: 4px; color: var(--muted); }
.donate .btn { width: 100%; margin-top: 14px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 22px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s, opacity .15s, transform .08s;
}
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 3px solid rgba(var(--ac-rgb), .55); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

.btn-primary { width: 100%; background: var(--accent); color: var(--on-accent); }
.btn-primary.is-waiting { opacity: .55; }
.btn-ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn-danger {
  min-height: 42px;
  padding: 8px 16px;
  font-size: .875rem;
  background: transparent;
  color: var(--err-fg);
  box-shadow: inset 0 0 0 1.5px rgba(var(--err-rgb), .45);
}

@media (hover: hover) {
  .btn-primary:not(:disabled):hover { background: var(--accent-dk); }
  .btn-ghost:not(:disabled):hover { background: rgba(var(--ac-rgb), .1); }
  .btn-danger:hover { background: rgba(var(--err-rgb), .08); }
}

/* ---------- Formulare ---------- */

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
}

.input, .file {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  color: var(--fg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: 1.0625rem; /* ab 16px zoomt iOS beim Tippen nicht */
  line-height: 1.3;
  transition: border-color .15s, box-shadow .15s;
}
.input { -webkit-appearance: none; appearance: none; }
.input:focus, .file:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--ac-rgb), .18); }
.input::placeholder { color: var(--muted); opacity: .8; }
textarea.input { min-height: 76px; resize: vertical; }
.file { border-style: dashed; color: var(--muted); font-size: 1rem; }

.msg { padding: 12px 14px; border-radius: 12px; font-size: .9375rem; }
.msg-err { background: rgba(var(--err-rgb), .1); color: var(--err-fg); border: 1px solid rgba(var(--err-rgb), .3); }
.msg-ok { background: rgba(var(--ok-rgb), .1); color: var(--ok); border: 1px solid rgba(var(--ok-rgb), .3); }
.msg-info { background: rgba(var(--ac-rgb), .06); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Fragen ---------- */

.bar { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.q-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.q-label {
  flex: none;
  white-space: nowrap;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.who {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 12px;
  text-align: right;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: .875rem;
  color: var(--muted);
}
.q-text { margin: 0 0 18px; font-size: 1.25rem; line-height: 1.35; overflow-wrap: break-word; word-wrap: break-word; }

.opt { position: relative; }
.opt + .opt { margin-top: 10px; }
.opt input { position: absolute; top: 50%; left: 28px; width: 1px; height: 1px; margin: 0; opacity: 0; }
.opt label {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color .15s, background-color .15s;
}
.opt input:checked + label { border-color: var(--accent); background: rgba(var(--ac-rgb), .12); }
.opt input:focus-visible + label { outline: 3px solid rgba(var(--ac-rgb), .55); outline-offset: 2px; }

.letter {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-right: 14px;
  border-radius: 8px;
  background: var(--border);
  color: var(--fg);
  font-size: .875rem;
  font-weight: 800;
  transition: background-color .15s, color .15s;
}
.opt input:checked + label .letter { background: var(--accent); color: var(--on-accent); }
.opt-text { flex: 1; min-width: 0; font-size: 1.0625rem; line-height: 1.35; overflow-wrap: break-word; word-wrap: break-word; }

/* ---------- Ergebnis ---------- */

.result { text-align: center; }
.result-icon { font-size: 2.75rem; line-height: 1; }
.score { padding: 18px 12px; background: var(--surface); border-radius: 12px; }
.score-label, .stat-l, .winner-label, th {
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.score-label { margin-bottom: 4px; font-size: .75rem; }
.score-num {
  font-family: var(--display);
  font-weight: 700;
  font-size: 4.5rem;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.score-num small { font-size: 1.75rem; color: var(--muted); }

/* ---------- Fußzeile ---------- */

.foot { text-align: center; font-size: .8125rem; }
.foot a { margin: 0 8px; color: var(--muted); text-underline-offset: 2px; }

/* ---------- Admin ---------- */

.admin-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.admin-logo { flex: none; width: auto; height: auto; max-height: 48px; max-width: 160px; border-radius: 6px; }
.logout { margin-left: auto; color: var(--muted); font-size: .875rem; text-underline-offset: 2px; }
.admin-id { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.admin-title {
  margin-right: 4px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-admin { background: rgba(var(--ac-rgb), .18); color: var(--accent); }
.badge-live { background: rgba(var(--ok-rgb), .15); color: var(--ok); }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: 12px; }
.tab {
  flex: 1;
  padding: 10px 6px;
  border-radius: 9px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  font-size: .9375rem;
  text-decoration: none;
}
.tab[aria-current="page"] { background: var(--card); color: var(--fg); box-shadow: 0 0 0 1px var(--border); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px 6px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; text-align: center; }
.stat-n {
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.25rem;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-l { margin-top: 4px; font-size: .66rem; }

.row { display: flex; flex-wrap: wrap; gap: 10px; }
.row > * { flex: 1 1 220px; }

.winner {
  padding: 22px 16px;
  text-align: center;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: rgba(var(--ac-rgb), .06);
}
.winner-label { font-size: .75rem; }
.winner-name {
  margin: 6px 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 2.75rem;
  line-height: 1.05;
  letter-spacing: .04em;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.winner-meta { color: var(--muted); font-size: .875rem; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 1rem; }
.panel-head span { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { padding: 9px 12px; text-align: left; font-size: .68rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { font-weight: 600; overflow-wrap: anywhere; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .8125rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill-hi { background: rgba(var(--ok-rgb), .15); color: var(--ok); }
.pill-mid { background: rgba(var(--ac-rgb), .15); color: var(--accent); }
.pill-lo { background: rgba(var(--err-rgb), .15); color: var(--err-fg); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* Fragen bearbeiten */
.qedit .q-head { margin-bottom: 10px; }
.qedit-err { margin-left: 12px; text-align: right; font-size: .8125rem; font-weight: 600; color: var(--err-fg); }
.qedit.has-error { border-color: rgba(var(--err-rgb), .6); }
.qedit textarea.input { margin-bottom: 12px; }
.opt-edit { display: flex; align-items: center; gap: 10px; }
.opt-edit + .opt-edit { margin-top: 8px; }
.opt-mark { position: relative; flex: none; cursor: pointer; }
.opt-mark input { position: absolute; top: 50%; left: 50%; width: 1px; height: 1px; margin: 0; opacity: 0; }
.opt-mark .letter { width: 44px; height: 44px; margin: 0; font-size: .95rem; }
.opt-mark input:checked + .letter { background: var(--ok); color: var(--on-accent); }
.opt-mark input:focus-visible + .letter { outline: 3px solid rgba(var(--ok-rgb), .6); outline-offset: 2px; }
.opt-edit .input { flex: 1; min-width: 0; padding: 11px 12px; font-size: 1rem; }
.legend-ok { color: var(--ok); font-weight: 700; }

.savebar {
  position: -webkit-sticky;
  position: sticky;
  bottom: 0;
  padding: 16px 0 calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, rgba(var(--bg-rgb), 0), var(--bg) 40%);
}

.logo-preview { display: flex; justify-content: center; padding: 16px; background: var(--surface); border-radius: 12px; }
.logo-preview img { max-width: 100%; max-height: 160px; width: auto; height: auto; }

/* ---------- Kleine Displays ---------- */

@media (max-width: 360px) {
  .card { padding: 18px 16px; }
  .q-text { font-size: 1.125rem; }
  .admin-title { font-size: 1.8rem; }
  .stat-n { font-size: 1.8rem; }
}
@media (max-width: 420px) {
  th, td { padding-left: 8px; padding-right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .btn:active { transform: none; }
}
