/* Heilander-Pokal – Gestaltung nach Plakat/Urkunde: Pergament, Braun, Oliv, Medaillen-Metall */
:root {
  --paper: #f8f2e4;
  --paper-2: #f1e7d0;
  --paper-3: #e8dbbd;
  --line: #d6c6a3;
  --ink: #3a2414;
  --ink-soft: #6b5440;
  --brown: #6e3b1c;
  --brown-2: #8b4f26;
  --olive: #3e5229;
  --olive-2: #5b7339;
  --leaf: #7c8f4a;
  --red: #a63a24;
  --ok: #3e7a3a;
  --copper: #b06b3c;
  --copper-2: #e2a272;
  --silver: #7d8792;
  --silver-2: #d6dbe0;
  --gold: #b88a1e;
  --gold-2: #f0cf68;
  --accent: var(--copper);
  --accent-2: var(--copper-2);
  --shadow: 0 2px 0 rgba(58, 36, 20, .08), 0 8px 24px rgba(58, 36, 20, .12);
  --radius: 14px;
  --slab: "Roboto Slab", "Zilla Slab", Rockwell, "Rockwell Nova", "DejaVu Serif", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.l2 { --accent: var(--silver); --accent-2: var(--silver-2); }
body.l3 { --accent: var(--gold); --accent-2: var(--gold-2); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.45;
  background: var(--paper) radial-gradient(ellipse at 50% 0%, #fffaf0 0%, var(--paper) 55%, var(--paper-2) 100%) fixed;
  min-height: 100vh;
}
h1, h2, h3, h4, .slab { font-family: var(--slab); color: var(--brown); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); letter-spacing: .01em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.7rem); }
h3 { font-size: 1.15rem; }
a { color: var(--brown-2); }
small, .muted { color: var(--ink-soft); }
.hidden { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  background: linear-gradient(180deg, #fffaf0, var(--paper-2));
  border-bottom: 3px double var(--line);
}
.topbar .medal { width: 46px; height: 46px; flex: none; }
.topbar .t1 { font-family: var(--slab); font-weight: 700; color: var(--brown); font-size: 1.15rem; line-height: 1.1; }
.topbar .t2 { font-size: .82rem; color: var(--ink-soft); letter-spacing: .03em; }
.topbar .spacer { flex: 1; }
.topbar .back-btn { white-space: nowrap; flex: none; }
.topbar a.home { text-decoration: none; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .titles { min-width: 0; }
.topbar .t1, .topbar .t2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 640px; }

/* ---------- Karten / Flächen ---------- */
.card {
  background: #fffdf7; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card + .card { margin-top: 14px; }
.card h2, .card h3 { margin-top: 0; }
.banner {
  font-family: var(--slab); color: #fff8ea; background: var(--brown-2);
  padding: 4px 18px; display: inline-block; border-radius: 4px; letter-spacing: .04em;
  clip-path: polygon(0 0, 100% 0, 97% 50%, 100% 100%, 0 100%, 3% 50%);
}
.ribbon { text-transform: uppercase; font-family: var(--slab); letter-spacing: .12em; font-size: .8rem; color: var(--olive); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--paper-3); color: var(--ink); white-space: nowrap; }
.pill.ok { background: #dbe8cf; color: #2f5524; }
.pill.warn { background: #f6dfc4; color: #7a3e10; }
.pill.bad { background: #f2d2c8; color: #8c2a17; }
.pill.metal { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #2a1a0c; }

/* ---------- Buttons & Formulare ---------- */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; border: 1px solid var(--brown);
  background: var(--brown); color: #fff8ea; padding: 10px 16px; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; min-height: 44px; touch-action: manipulation;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: default; }
.btn.alt, button.alt { background: #fffdf7; color: var(--brown); }
.btn.olive, button.olive { background: var(--olive); border-color: var(--olive); }
.btn.danger, button.danger { background: #fffdf7; color: var(--red); border-color: var(--red); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--brown); }
.btn.big, button.big { font-size: 1.15rem; padding: 14px 22px; min-height: 56px; }
.btn.small, button.small { padding: 4px 10px; min-height: 32px; font-size: .88rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
label { display: block; font-weight: 600; font-size: .9rem; color: var(--olive); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
input[type=checkbox] { width: auto; min-height: 0; }
.field { margin-bottom: 12px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--olive); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: transparent; color: var(--ink-soft); border: none; border-bottom: 4px solid transparent;
  border-radius: 0; padding: 10px 14px; min-height: 44px;
}
.tabs button.active { color: var(--brown); border-bottom-color: var(--accent); }

/* ---------- Tabellen ---------- */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--olive); color: #fff8ea; font-weight: 600; font-size: .85rem; letter-spacing: .03em; position: sticky; top: 0; }
tbody tr:nth-child(even) td { background: rgba(241, 231, 208, .45); }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); background: #fffdf7; }

/* ---------- Start: Kacheln ---------- */
.hero { text-align: center; padding: 22px 12px 8px; }
.hero .club { font-family: var(--slab); letter-spacing: .08em; color: var(--brown); font-weight: 700; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.6rem); margin: .1em 0; }
.hero p { margin: 0; color: var(--ink-soft); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; padding: 18px 0 8px; }
.tile {
  display: block; text-decoration: none; color: inherit; border-radius: 16px; overflow: hidden;
  background: #fffdf7; border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover, .tile:focus-visible { transform: translateY(-4px) rotate(-.4deg); box-shadow: 0 14px 34px rgba(58, 36, 20, .25); }
.tile img { width: 100%; display: block; aspect-ratio: 896 / 1200; object-fit: cover; }
.tile .cap { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .cap b { font-family: var(--slab); color: var(--brown); font-size: 1.15rem; }

/* ---------- Rollenwahl ---------- */
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.role {
  display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; padding: 16px;
  border-radius: var(--radius); background: #fffdf7; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.role:hover { border-color: var(--accent); }
.role .ico { font-size: 2rem; width: 54px; height: 54px; flex: none; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.role b { font-family: var(--slab); color: var(--brown); font-size: 1.1rem; display: block; }
.role small { display: block; }
.role.locked { opacity: .55; }

/* ---------- Toast / Overlay ---------- */
#toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: var(--ink); color: #fff8ea; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: 90vw; }
#toast div.err { background: var(--red); }
dialog { border: none; border-radius: 16px; padding: 0; max-width: min(720px, 96vw); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.35); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(40, 24, 10, .45); }
dialog .dhead { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; background: var(--paper-2); }
dialog .dhead h3 { margin: 0; flex: 1; }
dialog .dbody { padding: 16px 18px; max-height: 70vh; overflow: auto; }
dialog .dfoot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Bewertungsformular (Smartphone) ---------- */
.scorebox { position: sticky; bottom: 0; z-index: 10; background: linear-gradient(180deg, rgba(248,242,228,0), var(--paper) 30%); padding: 14px 0 10px; }
.scorebox .inner { display: flex; align-items: center; gap: 12px; background: var(--brown); color: #fff8ea; border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); }
.scorebox .pts { font-family: var(--slab); font-size: 2.2rem; font-weight: 700; line-height: 1; min-width: 2.4ch; text-align: center; }
.scorebox .info { flex: 1; font-size: .85rem; line-height: 1.25; }
.scorebox button { background: var(--olive); border-color: #fff3; }
.f-count { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.f-count .lbl { flex: 1; font-weight: 600; }
.f-count .lbl small { display: block; font-weight: 400; }
.f-count .val { font-family: var(--slab); font-size: 1.6rem; min-width: 2ch; text-align: center; }
.f-count button { width: 52px; height: 52px; padding: 0; font-size: 1.6rem; border-radius: 50%; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; background: #fffdf7; color: var(--ink); border-color: var(--line); min-height: 48px; padding: 6px 10px; font-weight: 600; }
.seg button.on { background: var(--olive); color: #fff; border-color: var(--olive); }
.seg button.on.zero { background: var(--red); border-color: var(--red); }
.round { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.round .rl { font-weight: 700; color: var(--brown); margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.timer { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.timer .clock { font-family: var(--slab); font-size: 2.4rem; font-variant-numeric: tabular-nums; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.timer input { font-size: 1.4rem; text-align: center; }
.boolrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); font-weight: 600; }
.toggle { position: relative; width: 64px; height: 36px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: var(--paper-3); border-radius: 99px; transition: .15s; border: 1px solid var(--line); }
.toggle span::after { content: ""; position: absolute; width: 28px; height: 28px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle input:checked + span { background: var(--olive); }
.toggle input:checked + span::after { transform: translateX(28px); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fffdf7; margin-bottom: 8px; cursor: pointer; text-decoration: none; color: inherit; width: 100%; text-align: left; font-weight: 400; min-height: 60px; }
.list-item:hover { border-color: var(--accent); filter: none; }
.list-item .no { font-family: var(--slab); font-weight: 700; font-size: 1.3rem; width: 2.2em; height: 2.2em; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #2a1a0c; flex: none; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .main b { display: block; font-family: var(--slab); color: var(--brown); }
.list-item .main small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .score { font-family: var(--slab); font-size: 1.4rem; font-weight: 700; color: var(--olive); min-width: 2ch; text-align: right; }
.list-item.done { background: #f1f5e9; }
.joker-star { color: var(--gold); font-weight: 900; }

/* ---------- Prüfungsordnung ---------- */
.po-search { position: sticky; top: 64px; z-index: 5; background: var(--paper); padding: 8px 0; }
.po-search input { font-size: 1.1rem; padding-left: 40px; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236e3b1c' stroke-width='2.4'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>") 12px center no-repeat; }
.po-station { scroll-margin-top: 130px; }
.po-station .head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.po-station .stno { font-family: var(--slab); font-size: 1rem; color: #fff8ea; background: var(--olive); padding: 2px 10px; border-radius: 6px; }
.po-station .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .po-station .cols { grid-template-columns: 1fr; } }
.po-station h4 { font-family: var(--sans); text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; color: var(--olive); margin: 8px 0 4px; }
.po-station ul { margin: 0; padding-left: 1.1em; }
mark { background: #ffe58a; color: inherit; padding: 0 2px; border-radius: 3px; }
.po-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.po-toc a { text-decoration: none; padding: 4px 10px; border-radius: 99px; background: #fffdf7; border: 1px solid var(--line); font-size: .9rem; }

/* ---------- Live-Anzeige ---------- */
body.live { font-size: clamp(16px, 1.35vw, 26px); overflow-x: hidden; }
.live-head { display: flex; align-items: center; gap: 18px; padding: 12px 24px; border-bottom: 3px double var(--line); background: linear-gradient(180deg, #fffaf0, var(--paper-2)); }
.live-head img.medal { width: 4.2em; height: 4.2em; }
.live-head h1 { margin: 0; font-size: 2em; }
.live-head .sub { color: var(--ink-soft); font-size: .95em; }
.live-head .clock { font-family: var(--slab); font-size: 1.8em; color: var(--brown); margin-left: auto; font-variant-numeric: tabular-nums; }
.live-nav { display: flex; gap: 8px; padding: 10px 24px; flex-wrap: wrap; }
.live-nav button { font-size: 1em; min-height: 2.6em; background: #fffdf7; color: var(--brown); border-color: var(--line); }
.live-nav button.active { background: var(--brown); color: #fff8ea; border-color: var(--brown); }
.live-main { padding: 8px 24px 24px; }
.rank { width: 100%; border-collapse: separate; border-spacing: 0 .35em; }
.rank th { background: transparent; color: var(--olive); font-size: .75em; text-transform: uppercase; letter-spacing: .08em; border: none; position: static; }
.rank td { background: #fffdf7 !important; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .45em .6em; }
.rank td:first-child { border-left: 1px solid var(--line); border-radius: 12px 0 0 12px; }
.rank td:last-child { border-right: 1px solid var(--line); border-radius: 0 12px 12px 0; }
.rank .place { font-family: var(--slab); font-weight: 700; font-size: 1.6em; text-align: center; width: 2.4em; color: var(--brown); }
.rank tr.p1 .place { color: #8a6510; } .rank tr.p1 td { background: #fff6d8 !important; }
.rank tr.p2 td { background: #f2f4f6 !important; } .rank tr.p3 td { background: #f8eadf !important; }
.rank .team b { font-family: var(--slab); color: var(--brown); font-size: 1.1em; }
.rank .team small { display: block; }
.rank .st { text-align: center; width: 2.3em; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.rank .st.empty { color: #c9b896; }
.rank .st.jk { background: #fff1b8 !important; color: #6b4a00; position: relative; }
.rank .st.jk::after { content: "★"; position: absolute; top: -2px; right: 2px; font-size: .6em; color: var(--gold); }
.rank .total { font-family: var(--slab); font-size: 1.7em; font-weight: 700; text-align: center; color: var(--olive); width: 3em; }
.rank tr.flash td { animation: flash 2.2s ease; }
@keyframes flash { 0% { background: #ffe58a !important; } 100% { } }
.progress { height: 6px; border-radius: 3px; background: var(--paper-3); overflow: hidden; margin-top: 4px; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--olive-2), var(--olive)); }
.bigbingo { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(40, 24, 10, .55); z-index: 200; animation: pop .3s ease; }
.bigbingo .box { background: var(--paper); border-radius: 24px; padding: 1.2em 2.4em; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.4); border: 6px double var(--brown); }
.bigbingo .box h1 { font-size: 4em; margin: 0; color: var(--red); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.qrbox { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.qrbox img { width: min(320px, 70vw); background: #fff; border-radius: 12px; padding: 8px; border: 1px solid var(--line); }

/* ---------- Bingo ---------- */
.bingo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.bingo .head { text-align: center; font-family: var(--slab); font-weight: 700; color: #fff8ea; background: var(--olive); border-radius: 8px; padding: 4px 0; }
.bingo button.cell { aspect-ratio: 1; min-height: 0; padding: 4px; font-size: clamp(.62rem, 2.9vw, .9rem); line-height: 1.15; font-weight: 600; background: #fffdf7; color: var(--ink); border: 2px solid var(--line); border-radius: 10px; position: relative; hyphens: auto; overflow-wrap: anywhere; }
.bingo button.cell.on { background: #e6efd8; border-color: var(--olive); }
.bingo button.cell.on::after { content: "✗"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 3.4em; color: rgba(166, 58, 36, .55); font-family: var(--slab); pointer-events: none; }
.bingo button.cell.win { border-color: var(--red); box-shadow: 0 0 0 2px var(--red) inset; }
.excuse { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.excuse .q { flex: 1; font-family: var(--slab); color: var(--brown); }
.excuse .q small { display: block; font-family: var(--sans); color: var(--ink-soft); }
.votebar { height: 8px; background: var(--paper-3); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.votebar div { height: 100%; background: var(--brown-2); }

/* ---------- Medaillen-Badge ---------- */
.medal { border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.footer-note { text-align: center; color: var(--ink-soft); font-size: .8rem; padding: 18px 0 26px; }
.footer-note img { height: 60px; opacity: .9; display: block; margin: 0 auto 6px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .scorebox .inner { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .scorebox .info { order: 3; flex-basis: 100%; }
  .scorebox .info:empty { display: none; }
  .scorebox .save { flex: 1; }
  .scorebox button.big { min-height: 48px; padding: 8px 12px; font-size: 1.05rem; }
  .wrap { padding: 12px; }
  .topbar { padding: 6px 10px; }
  .topbar .medal { width: 38px; height: 38px; }
  .hide-sm { display: none !important; }
  .topbar .back-btn { padding: 4px 0; width: 40px; font-size: 1.2rem; flex: none; }
  .topbar .back-txt { display: none; }
}
@media print {
  .no-print { display: none !important; }
}
