:root {
  --bg: #10201a;
  --surface: #1a2f27;
  --surface-2: #24402f;
  --line: #3a5a49;
  --text: #f7f3e8;
  --muted: #b9c6bb;
  --gold: #f0c24f;
  --gold-text: #1c1600;
  --red: #e3665c;
  --red-bg: #4a1f1c;
  --radius: 14px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.45 var(--sans);
}
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; margin: 0; }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap;
}
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: .85rem; letter-spacing: .04em; }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 10px 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  font-weight: 600; text-decoration: none; color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--gold-text); }
.btn-danger { background: var(--red-bg); border-color: var(--red); color: #ffd9d5; }
.btn-large { min-height: 60px; width: 100%; font-size: 1.1rem; }
.btn-small { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
.link-btn {
  padding: 4px 0; background: none; border: 0; color: var(--gold);
  text-decoration: underline; cursor: pointer;
}

.notice { margin: 12px 16px; padding: 12px 14px; border-radius: 10px; }
.notice-error { background: var(--red-bg); border: 1px solid var(--red); }

.center-page {
  max-width: 420px; min-height: 100vh; margin: 0 auto; padding: 32px 16px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px; text-align: center;
}
.center-page .notice { margin: 0; }
.center-page form { text-align: left; }

/* --- Tisch-Ansicht ------------------------------------------------------ */
.group-header { padding: 24px 16px 12px; max-width: 640px; margin: 0 auto; }
.group-header h1 { font-size: 2rem; overflow-wrap: anywhere; }
.progress-line { margin: 8px 0 0; color: var(--muted); }
.progress-line:empty { display: none; }
.group-main {
  max-width: 640px; margin: 0 auto; padding: 4px 16px 48px;
  display: flex; flex-direction: column; gap: 12px;
}
.phase-card {
  padding: 24px 20px; background: var(--surface);
  border: 1px solid var(--gold); border-radius: var(--radius);
}
.phase-card h2 { font-size: 1.5rem; color: var(--gold); margin-bottom: 8px; }
.phase-card p { margin: 0; }

.task { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.task-open { border-color: var(--gold); }
.task-head {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px;
  padding: 12px 14px; background: none; border: 0; text-align: left; cursor: pointer;
}
.task-number {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface-2); font-weight: 700;
}
.task-done .task-number { background: var(--gold); color: var(--gold-text); }
.task-title { flex: 1; font-family: var(--serif); font-size: 1.15rem; overflow-wrap: anywhere; }
.task-count { flex: none; color: var(--muted); font-size: .85rem; }
.task-body { padding: 0 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.task-description { margin: 0; white-space: pre-line; }
.upload-buttons { display: grid; gap: 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tile {
  position: relative; aspect-ratio: 1; padding: 0; overflow: hidden;
  background: var(--surface-2); border: 0; border-radius: 10px; cursor: pointer;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile-pending { cursor: default; }
.tile-overlay {
  position: absolute; inset: 0; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(10, 20, 16, .78); font-size: .78rem; line-height: 1.2; text-align: center;
}
.tile-overlay progress { width: 90%; height: 8px; accent-color: var(--gold); }
.tile-error { outline: 2px solid var(--red); }
.tile-overlay .link-btn { font-size: .75rem; }
.tile-overlay .btn-small { min-height: 30px; padding: 3px 8px; font-size: .78rem; }

dialog { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
dialog::backdrop { background: rgba(0, 0, 0, .8); }
.photo-dialog { width: min(96vw, 1000px); max-height: 94vh; padding: 10px; }
.photo-dialog img { width: 100%; max-height: 76vh; object-fit: contain; border-radius: 8px; }
.form-dialog { width: min(92vw, 420px); padding: 18px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* --- Admin -------------------------------------------------------------- */
.admin-page { font-size: 16px; }
.admin-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1200px; margin: 0 auto; padding: 18px 16px 10px;
}
.admin-header h1 { font-size: 1.6rem; }
.admin-header-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tabs {
  display: flex; gap: 4px; max-width: 1200px; margin: 0 auto; padding: 0 16px;
  overflow-x: auto; border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: none; min-height: 46px; padding: 8px 14px; background: none; cursor: pointer;
  border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600;
}
.tabs button[aria-current] { color: var(--text); border-bottom-color: var(--gold); }
.admin-main {
  max-width: 1200px; margin: 0 auto; padding: 16px 16px 60px;
  display: flex; flex-direction: column; gap: 16px;
}
.panel { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { font-size: 1.25rem; }
.panel h3 { font-size: 1.15rem; color: var(--gold); margin-bottom: 10px; }
.panel > .muted { margin: 8px 0 12px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.phase-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.phase-btn { padding-inline: 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody th { font-weight: 600; white-space: normal; min-width: 130px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.link-cell { display: flex; gap: 14px; align-items: center; }
.score-table tfoot th, .total { font-weight: 700; color: var(--gold); font-size: 1.1rem; border-bottom: 0; }
.points-input { width: 76px; min-height: 40px; padding: 6px 8px; text-align: right; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; }
.filter { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; font-weight: 600; }
.photo-group { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 12px; }
.photo-group:first-of-type { margin-top: 0; }
.photo-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.photo-group-head h4 { font-size: 1.05rem; overflow-wrap: anywhere; }
.points-label { display: flex; align-items: center; gap: 8px; }
.admin-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.admin-tile { margin: 0; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.admin-tile.is-hidden img { opacity: .3; }
.tile-open { display: block; width: 100%; padding: 0; background: none; border: 0; cursor: zoom-in; }
.tile-open img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.admin-tile figcaption { display: flex; gap: 6px; padding: 6px; }
.chip {
  flex: 1; min-height: 36px; padding: 4px 6px; font-size: .8rem; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.chip-on { background: var(--gold); border-color: var(--gold); color: var(--gold-text); font-weight: 700; }
.chip-warn { background: var(--red-bg); border-color: var(--red); }
.empty { padding: 32px 0; text-align: center; }

.edit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.edit-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; padding-top: 12px; border-top: 1px solid var(--line); }
.edit-number { flex: none; width: 28px; padding-top: 10px; font-weight: 700; color: var(--gold); }
.edit-fields { flex: 1 1 260px; min-width: 0; }
.edit-fields-row { display: flex; flex-wrap: wrap; gap: 8px; }
.edit-fields-row input { flex: 1 1 180px; width: auto; min-width: 0; }
.edit-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Beamer ------------------------------------------------------------- */
.beamer-page { background: #050a08; overflow: hidden; font-size: 20px; }
.beamer-page.cursor-idle { cursor: none; }
.stage { height: 100vh; overflow-y: auto; padding: 3vh 3vw; }
.stage-heading { font-size: clamp(2rem, 4.5vw, 4rem); color: var(--gold); text-align: center; margin-bottom: 3vh; }
.stage-empty { text-align: center; font-size: 1.5rem; color: var(--muted); }
.stage-hint { text-align: center; color: var(--muted); margin-top: 3vh; }
.beamer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 44vw), 1fr)); gap: 12px; padding-bottom: 90px; }
.beamer-tile { position: relative; padding: 0; background: #000; border: 0; border-radius: 8px; overflow: hidden; cursor: pointer; }
.beamer-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.beamer-tile-name {
  position: absolute; left: 8px; bottom: 8px; padding: 3px 10px; font-size: .9rem;
  background: rgba(0, 0, 0, .75); border-radius: 6px;
}
.beamer-single { margin: -3vh -3vw; height: 100vh; display: flex; flex-direction: column; background: #000; }
.beamer-single img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.beamer-single figcaption {
  display: flex; justify-content: space-between; gap: 24px; padding: 12px 24px;
  font-family: var(--serif); font-size: clamp(1.1rem, 2.2vw, 2rem); background: #0b1612;
}
.beamer-count { flex: none; color: var(--muted); font-family: var(--sans); font-size: .8em; align-self: center; }
.beamer-controls {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  width: max-content; max-width: calc(100vw - 16px); padding: 8px;
  background: rgba(16, 32, 26, .94); border: 1px solid var(--line); border-radius: 12px;
  font-size: 15px; transition: opacity .25s;
}
.beamer-controls select { width: 220px; }
.controls-idle { opacity: 0; pointer-events: none; }

.ranking { list-style: none; margin: 0 auto; padding: 0 0 90px; max-width: 1100px; display: flex; flex-direction: column; gap: 1.4vh; }
.rank-row {
  display: grid; grid-template-columns: 3em minmax(0, 15em) 1fr 3.5em; align-items: center; gap: 16px;
  padding: 1.4vh 18px; background: var(--surface); border-radius: 12px;
  font-size: clamp(1.1rem, 2.3vw, 2rem);
}
.rank-hidden { opacity: .35; }
.rank-first { background: var(--surface-2); outline: 3px solid var(--gold); }
.rank-place { font-weight: 700; color: var(--gold); }
.rank-name { font-family: var(--serif); overflow-wrap: anywhere; }
.rank-track { height: .7em; background: var(--bg); border-radius: 99px; overflow: hidden; }
.rank-bar { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width .8s ease-out; }
.rank-points { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .rank-row { grid-template-columns: 2.4em minmax(0, 1fr) 3em; }
  .rank-track { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* --- QR-Seiten ---------------------------------------------------------- */
.qr-page { background: #e9e6dc; color: #10201a; }
.qr-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto; padding: 16px;
}
.qr-toolbar p { margin: 0; }
.qr-card {
  max-width: 640px; margin: 0 auto 16px; padding: 32px 16px; text-align: center;
  background: #fff; border-radius: 12px;
}
.qr-event { margin: 0; font-size: 1.1rem; }
.qr-card h1 { font-size: 3rem; margin: 6px 0 18px; }
.qr-code svg { width: min(100%, 420px); height: auto; margin: 0 auto; display: block; }
.qr-hint { font-size: 1.2rem; margin: 18px 0 6px; }
.qr-url { margin: 0; font-size: .8rem; color: #4d5c54; overflow-wrap: anywhere; }

@media print {
  .qr-toolbar { display: none; }
  .qr-page { background: #fff; }
  .qr-card { max-width: none; margin: 0; padding-top: 60px; border-radius: 0; break-after: page; }
  .qr-code svg { width: 110mm; }
}
