:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #0d1b2e;
  --muted: #5b6878;
  --line: #dde3ea;
  --brand: #0b2545;
  --brand-2: #13315c;
  --accent: #c8f031;
  --accent-ink: #0b2545;
  --gold: #f2b705;
  --good: #1a8f55;
  --bad: #c2352b;
  --shadow: 0 1px 2px rgba(13, 27, 46, .06), 0 4px 16px rgba(13, 27, 46, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111d;
    --surface: #111b2b;
    --surface-2: #17233a;
    --ink: #e8edf4;
    --muted: #97a3b4;
    --line: #22314a;
    --brand: #0b2545;
    --brand-2: #1a3a66;
    --good: #3fc585;
    --bad: #ff7a6e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a111d; --surface: #111b2b; --surface-2: #17233a; --ink: #e8edf4; --muted: #97a3b4; --line: #22314a;
  --brand-2: #1a3a66; --good: #3fc585; --bad: #ff7a6e; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Knapper og felter ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 11px 20px; cursor: pointer; font-weight: 650;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.dark { background: var(--brand); color: #fff; }
.btn.small { padding: 6px 12px; font-size: .88rem; }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px currentColor; }
label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 400;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.form { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 0 0 auto; }
.row .grow { flex: 1 1 200px; }
.err { color: var(--bad); font-size: .9rem; min-height: 1.2em; margin: 0; }
.ok { color: var(--good); font-size: .9rem; margin: 0; }

/* ---------- Forside ---------- */
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(120% 90% at 85% 10%, #1f4c86 0%, var(--brand) 55%, #071729 100%);
}
.hero::before {
  content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 610 1340' fill='none' stroke='white' stroke-width='5'%3E%3Crect x='5' y='5' width='600' height='1330'/%3E%3Cline x1='50' y1='5' x2='50' y2='1335'/%3E%3Cline x1='560' y1='5' x2='560' y2='1335'/%3E%3Cline x1='5' y1='670' x2='605' y2='670' stroke-width='9'/%3E%3Cline x1='5' y1='472' x2='605' y2='472'/%3E%3Cline x1='5' y1='868' x2='605' y2='868'/%3E%3Cline x1='5' y1='80' x2='605' y2='80'/%3E%3Cline x1='5' y1='1260' x2='605' y2='1260'/%3E%3Cline x1='305' y1='5' x2='305' y2='472'/%3E%3Cline x1='305' y1='868' x2='305' y2='1335'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 520px auto; background-position: right -80px top -160px;
  transform: rotate(-12deg); transform-origin: 70% 30%;
}
.topbar { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 18px 0; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; text-decoration: none; }
.logo svg { width: 30px; height: 30px; flex: 0 0 auto; }
.logo b { color: var(--accent); font-weight: 800; }
.hero-body { position: relative; display: grid; gap: 32px; padding: 28px 0 56px; grid-template-columns: 1fr; }
@media (min-width: 880px) { .hero-body { grid-template-columns: 1.1fr .9fr; align-items: center; padding: 40px 0 80px; } }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); font-weight: 850; letter-spacing: -.03em; margin-bottom: .35em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { font-size: 1.12rem; color: #d6e2f3; max-width: 34em; }
.hero-count { display: inline-grid; gap: 4px; margin-top: 14px; padding: 12px 16px; border-radius: 12px; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); }
.hero-count span { font-size: .85rem; color: #c3d1e6; }
.hero-count strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.auth-card { background: var(--surface); color: var(--ink); border-radius: 18px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 999px; cursor: pointer; font-weight: 650; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.steps { display: grid; gap: 14px; grid-template-columns: 1fr; padding: 40px 0 8px; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.step b { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--accent); margin-bottom: 8px; }

/* ---------- App ---------- */
.appbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.appbar .topbar { padding: 10px 0; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; text-decoration: none; color: #c3d1e6; font-weight: 600; font-size: .95rem; }
.nav a.on { background: rgba(255,255,255,.12); color: #fff; }
.userbox { display: flex; align-items: center; gap: 8px; }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; }
.iconbtn svg { width: 20px; height: 20px; }
.dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
main.wrap { padding-top: 20px; padding-bottom: 60px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1.35fr 1fr; align-items: start; } }

/* Nedtælling */
.lockbar { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.lockbar h2 { margin: 0; font-size: 1.1rem; }
.lockbar p { margin: 0; color: #c3d1e6; font-size: .9rem; }
.clock { display: flex; gap: 6px; }
.clock div { display: grid; min-width: 52px; text-align: center; padding: 6px 4px; border-radius: 10px; background: rgba(255,255,255,.1); }
.clock b { font-size: 1.35rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.clock span { font-size: .7rem; color: #c3d1e6; text-transform: uppercase; letter-spacing: .06em; }
.lockbar.locked .clock b { color: #fff; }

/* Holdets pladser */
.slots { display: grid; gap: 10px; }
.slot {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1.5px solid transparent; cursor: pointer; text-align: left; width: 100%;
}
.slot:hover { border-color: var(--line); }
.slot.open { border-color: var(--accent); }
.slot.readonly { cursor: default; }
.cat { display: grid; place-items: center; height: 54px; border-radius: 10px; background: var(--brand); color: var(--accent); font-weight: 800; letter-spacing: .03em; }
.who { min-width: 0; }
.who b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who > span { display: block; font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .empty { color: var(--muted); font-weight: 600; }
.cap {
  width: 38px; height: 38px; border-radius: 50%; border: 1.5px dashed var(--line); background: transparent; color: var(--muted);
  font-weight: 800; cursor: pointer; display: grid; place-items: center;
}
.cap.on { background: var(--gold); border: 0; color: #2b1d00; }
.capnote { display: block; margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: .92rem; font-weight: 600;
  background: color-mix(in srgb, var(--gold) 22%, var(--surface)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--gold) 60%, transparent); }
.capnote .cap { display: inline-grid; width: 24px; height: 24px; font-size: .8rem; vertical-align: -6px; margin: 0 2px; }
.slots.nocap .cap:not(:disabled) { border: 2px solid var(--gold); color: var(--ink); animation: puls 1.6s ease-in-out infinite; }
@keyframes puls { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--gold) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { .slots.nocap .cap { animation: none; } }
.vs { font-size: .9rem; margin: 2px 0 4px; }
.cap:disabled { cursor: default; }
.pts { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.tag { display: inline-block; padding: 0 6px; border-radius: 6px; font-size: .72rem; font-weight: 700; background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); vertical-align: 1px; margin-left: 4px; }
.tag.eu { color: #2a62c9; }
.tag.udl { color: #b0520e; }
.tag.c { background: var(--gold); color: #2b1d00; box-shadow: none; }
.savebar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 14px; }
.teamcount { display: flex; flex-wrap: wrap; gap: 6px; }
.teamcount span { font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.teamcount span.full { background: var(--brand); color: var(--accent); }

/* Spillervælger */
.picker-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.picker-head h3 { margin: 0; flex: 1 1 auto; }
.plist { display: grid; gap: 6px; max-height: 560px; overflow: auto; padding-right: 2px; }
.pl {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer;
}
.pl:hover:not(:disabled) { border-color: var(--brand-2); }
.pl.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.pl:disabled { opacity: .45; cursor: not-allowed; }
.pl b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .meta { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.pl .fp { font-weight: 800; font-variant-numeric: tabular-nums; }
.played { color: var(--good); font-weight: 700; }
.notplayed { color: var(--muted); }

/* Tabeller og lister */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
td.r, th.r { text-align: right; }
tr.me td { background: color-mix(in srgb, var(--accent) 16%, transparent); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }
.rank { width: 34px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.nm b { display: block; }
.nm > span { font-size: .82rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 0; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: .9rem; }
.chip.on { background: var(--brand); color: #fff; }

/* Kampe */
.round h3 { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.match { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.match:hover { background: var(--surface-2); }
.match .h { text-align: right; font-weight: 650; }
.match .u { font-weight: 650; }
.match .res { min-width: 74px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); }
.match .sub { grid-column: 1 / -1; text-align: center; font-size: .8rem; color: var(--muted); margin-top: -4px; }
.games { display: grid; gap: 8px; }
.game { display: grid; grid-template-columns: 56px minmax(0,1fr) auto minmax(0,1fr); gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; }
.game .g-h { text-align: right; }
.game .w { font-weight: 750; }
.game .sets { font-variant-numeric: tabular-nums; text-align: center; font-size: .82rem; white-space: nowrap; }
.game small { color: var(--muted); display: block; font-size: .75rem; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 12, 24, .55); display: grid; place-items: end center; padding: 0; }
@media (min-width: 700px) { .modal { place-items: center; padding: 24px; } }
.modal-box { background: var(--surface); width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
@media (min-width: 700px) { .modal-box { border-radius: 18px; } }
.modal-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 8px; }
.x { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; flex: 0 0 auto; }

/* Regler */
.rules dl { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 0; margin: 0 0 14px; }
.rules dt { padding: 8px 0; border-bottom: 1px solid var(--line); }
.rules dt small { display: block; color: var(--muted); font-size: .85rem; }
.rules dd { margin: 0; padding: 8px 0 8px 12px; border-bottom: 1px solid var(--line); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.rules ol, .rules ul { padding-left: 1.2em; margin: 0 0 1em; }
.rules li { margin-bottom: .4em; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.msg { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.msg.unread b::after { content: " •"; color: var(--good); }
.stat { display: grid; gap: 2px; padding: 14px; border-radius: 12px; background: var(--surface-2); }
.stat b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: .12em; font-size: 1.1rem; padding: 2px 10px; border-radius: 8px; background: var(--surface-2); }
footer.foot { padding: 30px 0 40px; color: var(--muted); font-size: .85rem; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 80; font-weight: 600; max-width: calc(100% - 32px); }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
