:root {
  --felt: #0f5132;
  --felt-2: #157347;
  --felt-soft: #e6f2ec;
  --bg: #f4f5f2;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #69736e;
  --line: #dde2de;
  --gold: #c99a2e;
  --bad: #b42318;
  --live: #d9480f;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --card: #1b211e;
    --ink: #e8ece9;
    --muted: #9aa59f;
    --line: #2d3531;
    --felt-soft: #18392a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--felt-2); }
h1 { font-size: 1.6rem; margin: .3em 0; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 0 0 .5em; }
h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 .5em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* topp */
.top {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--felt); color: #fff; padding: 10px 16px;
}
.top a { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.ball {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 44%, #111 46%); color: #111; font-size: .72rem; font-weight: 800;
}
.top-right { display: flex; gap: 14px; align-items: center; font-size: .9rem; }
.who { opacity: .85; }
.lang { font-weight: 700; font-size: .8rem; letter-spacing: .04em; border: 1px solid currentColor; border-radius: 4px; padding: 1px 5px; text-decoration: none; opacity: .85; }
.lang:hover { opacity: 1; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 640px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* knappar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover { border-color: var(--felt-2); }
.btn.primary { background: var(--felt-2); border-color: var(--felt-2); color: #fff; }
.btn.primary:hover { background: var(--felt); }
.btn.bad { color: var(--bad); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn.big { padding: 14px 22px; font-size: 1.1rem; }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--felt-2); font: inherit; cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* kort och boxar */
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.box.err { border-color: var(--bad); color: var(--bad); }
.box.me { border-color: var(--felt-2); background: var(--felt-soft); }
.box.danger { border-color: #e7c3bf; }
.box.winner { display: flex; align-items: center; gap: 16px; border-color: var(--gold); }
.trophy { font-size: 2.4rem; }
.big { font-size: 1.5rem; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; color: inherit; text-decoration: none;
}
.card:hover { border-color: var(--felt-2); }
.card-top { display: flex; justify-content: space-between; align-items: center; }
.card-title { font-weight: 700; font-size: 1.1rem; margin: 6px 0 2px; }

.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--line); }
.badge.st-Anmalan { background: #fff3cd; color: #7a5b00; }
.badge.st-Pagar { background: #d1f0df; color: #0f5132; }
.badge.st-Avslutad { background: var(--line); color: var(--muted); }
.badge.bad { background: #fde2e0; color: var(--bad); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: .8rem; padding: 2px 9px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); }

.turn-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.me-tag { font-size: .9rem; }
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -2px 0 var(--line); margin: 16px 0 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--felt-2); border-bottom-color: var(--felt-2); }

/* formulär */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid [hidden] { display: none; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select {
  font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink); min-height: 40px; max-width: 100%;
}
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; }
.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit input { width: 110px; }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-inline input[name=pin] { width: 130px; letter-spacing: .2em; text-align: center; }

/* bord */
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; border-left: 6px solid var(--line); }
.tcard.busy { border-left-color: var(--felt-2); }
.tcard.free { border-left-color: var(--gold); }
.thead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.free-tag { font-size: .8rem; font-weight: 700; color: var(--gold); }
.sugg { margin: 4px 0; }
.sugg-names { font-weight: 600; }
.pick { display: flex; gap: 6px; margin-top: 8px; }
.pick select { flex: 1; min-width: 0; font-size: .85rem; min-height: 32px; padding: 4px 6px; }
.timer { font-variant-numeric: tabular-nums; }

.srow { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.srow b { font-variant-numeric: tabular-nums; min-width: 1.5em; text-align: right; }
.srow.win .nm { font-weight: 700; }
.srow.win b { color: var(--felt-2); }

.mlist { list-style: none; padding: 0; margin: 0; }
.mlist li { display: flex; gap: 10px; align-items: baseline; padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer; flex-wrap: wrap; }
.mlist li:last-child { border-bottom: 0; }
.mlist li:hover { background: var(--felt-soft); }
.mlist .nr { color: var(--muted); font-size: .85rem; min-width: 2.5em; }
.mlist .res { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.wn { font-weight: 700; }
.plist { columns: 2 200px; padding-left: 1.2em; margin: 0 0 10px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .78rem; color: var(--muted); text-transform: uppercase; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.box:has(.tbl) { overflow-x: auto; }

/* cup-schema */
.bracket { display: flex; gap: 32px; overflow-x: auto; padding: 6px 2px 14px; align-items: stretch; position: relative; }
.round { display: flex; flex-direction: column; min-width: 190px; flex: 0 0 190px; position: relative; z-index: 1; }
.bracket > svg.blines { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; overflow: visible; }
.blines path { fill: none; stroke: var(--muted); stroke-opacity: .45; stroke-width: 1.5; }
.blines path.done { stroke: var(--felt-2); stroke-opacity: .9; stroke-width: 2; }
.round-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.match {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px;
  cursor: pointer; font-size: .88rem; position: relative;
}
.match:hover { border-color: var(--felt-2); }
.match .mhead { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-bottom: 2px; }
.match.st-Pagar { border-color: var(--felt-2); box-shadow: 0 0 0 2px var(--felt-soft); }
.match.st-Redo { border-left: 4px solid var(--gold); }
.match.bye { opacity: .55; }
.match .srow { padding: 1px 0; }
.live { color: var(--live); font-weight: 700; }
.rr { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.rr .box { margin: 0; display: flex; flex-direction: column; gap: 8px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); color: var(--ink); border-radius: 14px; padding: 20px; width: 100%; max-width: 420px; max-height: 92vh; overflow: auto; position: relative; }
.modal-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.mscore { margin: 12px 0; font-size: 1.05rem; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 12px 0; }
.qr-wrap img, .qr-code img { background: #fff; padding: 8px; border-radius: 6px; }
.pin { font-size: 2.6rem; font-weight: 800; letter-spacing: .3em; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60;
  transition: all .25s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }

/* rapporteringssidan */
.rep { max-width: 640px; margin: 0 auto; padding: 12px 16px 40px; }
.rep-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rep-meta { text-align: center; color: var(--muted); margin: 14px 0 10px; font-size: .9rem; }
.rep-board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rep-side { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; gap: 8px; }
.rep-side.mine { border-color: var(--felt-2); }
.rep-side.win { border-color: var(--gold); background: #fff8e6; }
@media (prefers-color-scheme: dark) { .rep-side.win { background: #2e2716; } }
.rep-name { font-weight: 700; font-size: 1.05rem; min-height: 2.6em; display: grid; place-items: center; }
.rep-score { font-size: 4.5rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.rep-btns { display: flex; flex-direction: column; gap: 8px; }
.rep-btns .plus { background: var(--felt-2); color: #fff; border-color: var(--felt-2); font-size: 1.6rem; min-height: 64px; }
.rep-btns .minus { min-height: 40px; }
.rep-info { text-align: center; margin: 16px 0; }
.rep-info.done { font-size: 1.2rem; }
.rep-empty { text-align: center; padding: 60px 0; }

/* QR-ark */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 16px; }
.qr-card { background: #fff; color: #111; border: 2px dashed #bbb; border-radius: 12px; padding: 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; break-inside: avoid; }
.qr-title { font-size: 2rem; font-weight: 800; }
@media print {
  .noprint, .top { display: none !important; }
  body { background: #fff; }
  .qr-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  h1 { font-size: 1.35rem; }
  .rep-score { font-size: 3.6rem; }
  .bracket .round { min-width: 170px; flex-basis: 170px; }
}

/* arrangör utan konto, inbjudan */
.arr-fields { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; margin: 0; }
.arr-fields legend { font-weight: 600; padding: 0 4px; }
.invite { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.invite > div:last-child { flex: 1; min-width: 220px; }
.invite .copy { width: 100%; font-size: .85rem; }
.kod { font-family: ui-monospace, Consolas, monospace; letter-spacing: .12em; font-size: 1.1em; }
.err-text { color: var(--bad); font-weight: 600; }

/* markerad spelare i spelschemat */
.mark-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.mark-bar select { margin-left: 6px; }
[data-p] { transition: background-color .12s; }
.srow.hl { background: color-mix(in srgb, var(--gold) 28%, transparent); border-radius: 4px; margin: 0 -4px; padding-left: 4px; padding-right: 4px; }
.srow.hl .nm { font-weight: 700; }
tr.hl td { background: color-mix(in srgb, var(--gold) 22%, transparent); }
.hl-on .match:not(.hl-m) { opacity: .45; }
.hl-on .match.hl-m { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent); }

/* dubbelcup sida vid sida */
.side-head { display: flex; justify-content: space-between; gap: 12px; }
.bracket.side .round-S { min-width: 200px; flex-basis: 200px; }
.bracket.side .round-S .round-matches { justify-content: center; gap: 28px; }
.bracket.side { padding-bottom: 30px; padding-right: 24px; }
.wrap:has(.bracket.side) { max-width: none; }

/* startsidans presentation */
.intro { background: linear-gradient(135deg, var(--felt), var(--felt-2)); color: #fff; border-radius: var(--radius); padding: 22px 22px 14px; margin: 8px 0 22px; }
.intro h1 { margin: 0 0 6px; font-size: 1.5rem; }
.intro .lead { margin: 0 0 16px; max-width: 70ch; opacity: .95; }
.kofi { text-align: center; color: var(--muted); margin: 18px 0 8px; }
.kofi a { font-weight: 700; }
.intro .free { margin: -8px 0 16px; font-weight: 700; }
.intro .steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 10px; }
.intro .step { display: flex; gap: 10px; background: rgba(255, 255, 255, .1); border-radius: 8px; padding: 10px 12px; }
.intro .step p { margin: 2px 0 0; font-size: .9rem; opacity: .9; }
.intro .step-n { flex: 0 0 26px; height: 26px; border-radius: 50%; background: #fff; color: var(--felt); font-weight: 800; display: grid; place-items: center; }
.intro .muted { color: rgba(255, 255, 255, .8); }
.intro .contact { margin: 4px 0 0; color: rgba(255, 255, 255, .85); }
.intro .contact a { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.intro .contact a:hover { color: #ffe08a; }

sup.seed { font-size: .68em; font-weight: 700; color: var(--felt); margin-left: 2px; }
.tbl select[data-seed] { padding: 2px 4px; min-width: 3.2em; }

/* Prispall */
.podium-box { text-align: center; }
.podium-box h2 { text-align: left; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; margin: 8px auto 0; max-width: 560px; }
.pod { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: stretch; }
.pod-names { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 4px 8px; }
.pod-icon { font-size: 1.9rem; line-height: 1.2; }
.pod-1 .pod-icon { font-size: 2.6rem; }
.pod-name { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.pod-1 .pod-name { font-size: 1.25rem; }
.pod-step { border-radius: 8px 8px 0 0; display: flex; justify-content: center; padding-top: 10px; color: #fff; font-weight: 800; font-size: 2rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12); }
.pod-1 .pod-step { height: 150px; background: linear-gradient(180deg, #e7c065, var(--gold)); font-size: 2.6rem; }
.pod-2 .pod-step { height: 110px; background: linear-gradient(180deg, #c9d0d4, #9aa3a8); }
.pod-3 .pod-step { height: 80px; background: linear-gradient(180deg, #d79a66, #a8683a); }
.pod-empty .pod-step { opacity: .35; }
.podium + .pod-4, .pod-4 { margin: 0; padding: 10px 0 0; border-top: 3px solid var(--line); color: var(--muted); }
.pod-4 b { color: var(--ink); margin-right: 6px; }
@media (max-width: 480px) {
  .pod-1 .pod-step { height: 110px; } .pod-2 .pod-step { height: 80px; } .pod-3 .pod-step { height: 58px; }
  .pod-name { font-size: .9rem; } .pod-1 .pod-name { font-size: 1rem; } .pod-step { font-size: 1.5rem; } .pod-1 .pod-step { font-size: 1.9rem; }
}

/* startsidans guidelänkar och guidesidorna (tools_guides.py) */
.guides { margin: 26px 0 8px; }
.guides h2 { font-size: 1.1rem; margin: 0 0 8px; }
.guides ul { margin: 0; padding-left: 20px; columns: 2 280px; }
.guides li { margin: 0 0 6px; break-inside: avoid; }
.guide { max-width: 760px; line-height: 1.6; }
.guide .crumbs { font-size: .88rem; color: var(--muted); margin: 6px 0 4px; }
.guide .crumbs a { color: inherit; }
.guide h1 { font-size: 1.7rem; line-height: 1.25; margin: 6px 0 14px; }
.guide h2 { font-size: 1.2rem; margin: 26px 0 8px; }
.guide .lead-text { font-size: 1.08rem; }
.guide .tbl-wrap { overflow-x: auto; margin: 12px 0; }
.guide .cta { margin: 30px 0 18px; }
.guide .cta h2 { margin-top: 0; }
.guide .guide-more ul { padding-left: 20px; }
