/* ==========================================================================
   Liquid glass – frostat glas över en färgstark bakgrund
   ========================================================================== */
:root {
  --bg: #eef0ff;
  --text: #15172b;
  --muted: #5c6080;
  --border: rgba(255, 255, 255, .55);
  --hairline: rgba(21, 23, 43, .08);

  --glass: rgba(255, 255, 255, .52);
  --glass-strong: rgba(255, 255, 255, .8);
  --glass-soft: rgba(255, 255, 255, .34);
  --glass-edge: rgba(255, 255, 255, .85);
  --glass-shadow: 0 10px 34px rgba(60, 40, 140, .16), 0 2px 6px rgba(60, 40, 140, .08);
  --glass-shine: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 rgba(255, 255, 255, .25);
  --blur: blur(22px) saturate(185%);

  --surface: var(--glass);
  --surface-2: rgba(255, 255, 255, .5);

  --primary: #6c4dff;
  --primary-2: #c44dff;
  --primary-grad: linear-gradient(135deg, #5b5bff 0%, #8f4dff 50%, #d84dd8 100%);
  --primary-text: #ffffff;
  --primary-soft: rgba(124, 92, 255, .16);
  --danger: #ff3b6b;
  --success: #12b886;
  --gold: #f5b301;
  --silver: #9aa3bd;
  --bronze: #d07a3c;

  --blob-1: #8b7bff;
  --blob-2: #ff7ac6;
  --blob-3: #3fd3ff;
  --blob-4: #ffc46b;

  --radius: 22px;
  --tabbar-h: 66px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b1d;
  --text: #f1f1fb;
  --muted: #a3a6c6;
  --border: rgba(255, 255, 255, .14);
  --hairline: rgba(255, 255, 255, .08);

  --glass: rgba(34, 32, 66, .5);
  --glass-strong: rgba(30, 28, 62, .84);
  --glass-soft: rgba(255, 255, 255, .06);
  --glass-edge: rgba(255, 255, 255, .22);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
  --glass-shine: inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 -1px 0 rgba(255, 255, 255, .04);

  --surface-2: rgba(255, 255, 255, .07);
  --primary: #a48bff;
  --primary-grad: linear-gradient(135deg, #6a5cff 0%, #a04dff 50%, #e0479f 100%);
  --primary-soft: rgba(164, 139, 255, .2);
  --danger: #ff6b8e;
  --success: #3ddc97;

  --blob-1: #5a3dff;
  --blob-2: #d6338f;
  --blob-3: #0aa5d8;
  --blob-4: #ff8a3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  background: transparent;
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 34px);
}
/* Färgklickar bakom glaset */
body::before {
  content: "";
  position: fixed; inset: -10%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 30% at 12% 8%, var(--blob-1), transparent 70%),
    radial-gradient(34% 28% at 92% 18%, var(--blob-2), transparent 70%),
    radial-gradient(40% 32% at 85% 78%, var(--blob-3), transparent 70%),
    radial-gradient(36% 30% at 8% 92%, var(--blob-4), transparent 70%),
    radial-gradient(30% 24% at 50% 50%, var(--blob-1), transparent 75%),
    var(--bg);
  filter: saturate(120%);
  opacity: .75;
}
:root[data-theme="dark"] body::before { opacity: .55; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }

/* Gemensam glasyta */
.glass, .card, .list, .standings, .topbar, .tabbar, .modal, .toast, .chip, .champion {
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
}

/* ------------------------------------------------------------------ Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px 14px;
  background: var(--glass);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--glass-shine), 0 4px 24px rgba(60, 40, 140, .08);
  color: var(--text);
}
.title-btn {
  display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1;
  background: none; border: 0; color: inherit; padding: 6px 4px;
  font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; text-align: left;
}
.title-btn span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title-btn svg { color: var(--primary); }
.top-actions { display: flex; gap: 4px; }
.top-actions .icon-btn {
  color: var(--primary);
  background: var(--glass-soft); border: 1px solid var(--border); box-shadow: var(--glass-shine);
}
.timer-chip {
  background: var(--primary-grad); color: #fff; border: 0; border-radius: 999px;
  padding: 6px 12px; font-weight: 800; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 14px rgba(124, 77, 255, .4), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.timer-chip.done { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: none; border: 0; color: var(--muted);
  transition: transform .15s;
}
.icon-btn:active { transform: scale(.9); background: var(--primary-soft); }

/* ------------------------------------------------- Svävande glasflikar */
.tabbar {
  position: fixed; z-index: 20;
  left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 12px);
  max-width: 560px; margin: 0 auto;
  display: flex; height: var(--tabbar-h); padding: 6px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge); border-radius: 999px;
  box-shadow: var(--glass-shine), var(--glass-shadow);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: none; border: 0; border-radius: 999px; color: var(--muted);
  font-size: .68rem; font-weight: 700; transition: background .2s, color .2s, transform .15s;
}
.tabbar button svg { width: 23px; height: 23px; }
.tabbar button:active { transform: scale(.92); }
.tabbar button.active {
  color: var(--primary);
  background: linear-gradient(180deg, rgba(255, 255, 255, .7), rgba(255, 255, 255, .3));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .95), 0 2px 10px rgba(108, 77, 255, .22);
}
:root[data-theme="dark"] .tabbar button.active {
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 2px 10px rgba(0, 0, 0, .3);
}

/* ------------------------------------------------------------------ Layout */
.view { max-width: 820px; margin: 0 auto; padding: 14px 12px; }
.card {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--glass-shine), var(--glass-shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 10px; font-size: 1.08rem; letter-spacing: -.01em; }
.card p { margin: 0 0 10px; color: var(--muted); }
.section-title { margin: 22px 8px 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

/* --------------------------------------------------------- Knappar & fält */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 8px 18px; border-radius: 999px;
  border: 1px solid var(--glass-edge); background: var(--glass-soft); color: var(--text);
  box-shadow: var(--glass-shine);
  font-weight: 700; transition: transform .15s, filter .15s;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary {
  background: var(--primary-grad); color: var(--primary-text); border-color: rgba(255, 255, 255, .35);
  box-shadow: 0 6px 20px rgba(124, 77, 255, .38), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn.danger {
  background: linear-gradient(135deg, #ff4d6d, #ff2d87); color: #fff; border-color: rgba(255, 255, 255, .35);
  box-shadow: 0 6px 20px rgba(255, 59, 107, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn.danger-text { color: var(--danger); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: .88rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.96); filter: brightness(.95); }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface-2); outline: none;
  box-shadow: inset 0 1px 3px rgba(20, 20, 60, .06);
  transition: border-color .15s, box-shadow .15s;
}
input[type="search"] { border-radius: 999px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
select option { background: var(--bg); color: var(--text); }
textarea { min-height: 140px; resize: vertical; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin: 0 0 5px 4px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

.seg {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px;
}
.seg button {
  flex: 1; min-width: 60px; min-height: 40px; border-radius: 14px; white-space: nowrap;
  border: 0; background: transparent; font-weight: 800; color: var(--muted);
  transition: background .2s, color .2s;
}
.seg button.on {
  background: var(--primary-grad); color: #fff;
  box-shadow: 0 4px 14px rgba(124, 77, 255, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
}

/* ------------------------------------------------------------------ Listor */
.list {
  list-style: none; margin: 0; padding: 0; overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--glass-edge); border-radius: var(--radius);
  box-shadow: var(--glass-shine), var(--glass-shadow);
}
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--hairline); min-height: 58px; }
.list li:last-child { border-bottom: 0; }
.list li > svg { color: var(--primary); }
.list li.inactive .name { text-decoration: line-through; color: var(--muted); }
.list .num { width: 28px; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.list .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { font-size: .8rem; color: var(--muted); }
.list-head { display: flex; align-items: center; gap: 8px; margin: 16px 2px 10px; }
.list-head .count { font-weight: 800; white-space: nowrap; padding-left: 6px; }
.list-head select { border-radius: 999px; }
.list li.tap { cursor: pointer; }
.list li.tap:active { background: var(--primary-soft); }
.list li.current { background: var(--primary-soft); }

.empty {
  text-align: center; padding: 40px 18px; color: var(--muted);
  background: var(--glass); border: 1px solid var(--glass-edge); border-radius: var(--radius);
  box-shadow: var(--glass-shine), var(--glass-shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.empty svg { width: 60px; height: 60px; color: var(--primary); opacity: .8; filter: drop-shadow(0 6px 14px rgba(124, 77, 255, .35)); }
.empty h3 { color: var(--text); margin: 10px 0 4px; font-size: 1.2rem; }
.empty .btn { margin-top: 16px; }

.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; border-radius: 999px; }

/* ------------------------------------------------------------------ Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--glass-edge); background: var(--glass);
  box-shadow: var(--glass-shine); font-weight: 700; white-space: nowrap;
}
.chip.on {
  background: var(--primary-grad); color: #fff; border-color: rgba(255, 255, 255, .35);
  box-shadow: 0 4px 14px rgba(124, 77, 255, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.chip.add { border-style: dashed; color: var(--primary); border-color: var(--primary); }
.chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); margin-left: 6px; vertical-align: middle; box-shadow: 0 0 6px var(--success); }

/* ------------------------------------------------------------ Poänginmatning */
.score-list li { padding-right: 12px; }
.score-list .score-input {
  width: 92px; text-align: right; font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums;
  border-radius: 14px;
}
.score-list .score-input.filled {
  border-color: rgba(18, 184, 134, .6);
  background: color-mix(in srgb, var(--success) 12%, var(--surface-2));
}
.quick { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.quick button {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 999px;
  min-width: 38px; min-height: 30px; font-weight: 800; font-size: .85rem; color: var(--primary);
  box-shadow: var(--glass-shine);
}
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08); }
.progress > div { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #12b886, #3fd3ff); transition: width .25s; box-shadow: 0 0 10px rgba(63, 211, 255, .6); }

/* ------------------------------------------------------------------ Tabell */
.standings {
  width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--glass-edge); border-radius: var(--radius);
  box-shadow: var(--glass-shine), var(--glass-shadow);
}
.standings th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  text-align: right; padding: 12px 6px; white-space: nowrap; background: var(--glass-soft);
}
.standings th.l, .standings td.l { text-align: left; }
.standings td.l { width: 100%; max-width: 0; }
.standings td { padding: 10px 6px; border-top: 1px solid var(--hairline); text-align: right; font-variant-numeric: tabular-nums; }
.standings tr.tap { cursor: pointer; }
.standings tr.tap:active td { background: var(--primary-soft); }
.standings .rank { width: 46px; font-weight: 800; text-align: center; }
.standings .rank span { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 4px; border-radius: 999px; }
.standings tr.r1 .rank span { background: linear-gradient(135deg, #ffe27a, #f5b301 60%, #e08a00); color: #4a3000; box-shadow: 0 3px 10px rgba(245, 179, 1, .5), inset 0 1px 0 rgba(255, 255, 255, .7); }
.standings tr.r2 .rank span { background: linear-gradient(135deg, #f1f3fa, #aab3cc 60%, #8690ab); color: #262b3d; box-shadow: 0 3px 10px rgba(130, 140, 170, .45), inset 0 1px 0 rgba(255, 255, 255, .8); }
.standings tr.r3 .rank span { background: linear-gradient(135deg, #ffc89a, #d07a3c 60%, #a8571f); color: #fff; box-shadow: 0 3px 10px rgba(208, 122, 60, .45), inset 0 1px 0 rgba(255, 255, 255, .5); }
.standings .pname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings .pclub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; color: var(--muted); font-weight: 500; }
.standings .total {
  font-weight: 900; font-size: 1.08rem;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.standings tr.out td { opacity: .55; }
.standings tr.cutoff td { padding: 0; border-top: 0; }
.standings tr.cutoff td div {
  font-size: .7rem; font-weight: 800; color: #fff; padding: 4px 8px; text-align: center; letter-spacing: .04em;
  background: var(--primary-grad);
}
.move { font-size: .7rem; font-weight: 800; margin-left: 5px; }
.move.up { color: var(--success); }
.move.down { color: var(--danger); }
@media (max-width: 420px) { .hide-narrow { display: none; } }

/* ------------------------------------------------------------ Storbildsläge */
body.big { font-size: 22px; padding-bottom: 20px; }
body.big .tabbar, body.big .topbar { display: none; }
body.big .view { max-width: none; }
body.big .standings td { padding: 14px 12px; }
.big-exit { position: fixed; right: 14px; bottom: 14px; z-index: 30; -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); background: var(--glass) !important; }
.big-title {
  text-align: center; font-size: 1.6em; font-weight: 900; margin: 10px 0 16px; letter-spacing: -.02em;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------------------------------------------------------------- Slutspel */
.bracket-wrap { overflow-x: auto; margin: 0 -12px; padding: 4px 12px 14px; -webkit-overflow-scrolling: touch; }
.bracket { display: flex; gap: 22px; align-items: stretch; width: max-content; }
.b-col { display: flex; flex-direction: column; width: 194px; }
.b-col h4 {
  margin: 0 0 10px; padding: 6px 8px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; text-align: center;
  color: var(--primary); background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 14px; box-shadow: var(--glass-shine);
}
.b-col h4 small { display: block; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); }
.b-matches { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.match {
  display: block; width: 100%; padding: 0; text-align: left; overflow: hidden;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 16px;
  box-shadow: var(--glass-shine), 0 6px 18px rgba(60, 40, 140, .12);
  transition: transform .15s;
}
.match:active { transform: scale(.97); }
.match.ready:not(.done) { border-color: transparent; box-shadow: 0 0 0 2px var(--primary), 0 6px 20px rgba(124, 77, 255, .3); }
.match.bye { opacity: .55; }
.m-row { display: flex; align-items: center; gap: 6px; padding: 8px 10px; min-height: 38px; }
.m-row + .m-row { border-top: 1px solid var(--hairline); }
.m-row .seed { font-size: .7rem; color: var(--muted); width: 20px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.m-row .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.m-row .ps { font-weight: 900; font-variant-numeric: tabular-nums; min-width: 18px; text-align: right; }
.m-row.win { background: linear-gradient(90deg, rgba(124, 92, 255, .2), rgba(216, 77, 216, .1)); }
.m-row.win .pn { font-weight: 800; }
.m-row.win .ps { color: var(--primary); }
.m-row.lose .pn { color: var(--muted); text-decoration: line-through; }
.m-row.tbd .pn { color: var(--muted); font-style: italic; }
.champion {
  position: relative; overflow: hidden;
  text-align: center; padding: 22px 18px; margin-bottom: 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 226, 122, .92), rgba(245, 179, 1, .88) 55%, rgba(255, 122, 198, .8));
  border: 1px solid rgba(255, 255, 255, .7);
  color: #3a2400;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 12px 36px rgba(245, 150, 1, .35);
}
.champion::after {
  content: ""; position: absolute; top: -60%; left: -30%; width: 60%; height: 220%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: rotate(12deg); animation: shine 4s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.champion svg { width: 48px; height: 48px; filter: drop-shadow(0 4px 8px rgba(120, 70, 0, .35)); }
.champion .cname { font-size: 1.6rem; font-weight: 900; letter-spacing: -.02em; }
.podium { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; font-size: .9rem; margin-top: 6px; font-weight: 600; }

/* ---------------------------------------------------------------- Matchdialog */
.mp { display: flex; flex-direction: column; gap: 10px; }
.mp-side {
  display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 18px; background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.mp-side.sel { border-color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.mp-side .grow { font-weight: 800; }
.mp-side input { width: 84px; text-align: center; font-size: 1.3rem; font-weight: 900; }
.mp-side .crown { width: 28px; height: 28px; opacity: .15; }
.mp-side.sel .crown { opacity: 1; fill: var(--gold); filter: drop-shadow(0 2px 6px rgba(245, 179, 1, .6)); }

/* ------------------------------------------------------------------ Dialoger */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 14, 50, .28);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s;
}
.modal {
  width: calc(100% - 16px); max-width: 560px; max-height: 90vh; margin-bottom: 8px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge); border-radius: 30px;
  box-shadow: var(--glass-shine), 0 20px 60px rgba(30, 20, 80, .35);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom); animation: up .28s cubic-bezier(.2, .9, .3, 1.15);
}
@media (min-width: 600px) { .modal-backdrop { align-items: center; } }
.modal-head { display: flex; align-items: center; padding: 12px 8px 0 22px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; }
.modal-head .icon-btn { background: var(--surface-2); width: 36px; height: 36px; margin-right: 6px; }
.modal-head .icon-btn svg { width: 18px; height: 18px; }
.modal-body { padding: 10px 22px 12px; overflow-y: auto; }
.modal-body p { margin-top: 0; }
.modal-actions { display: flex; gap: 8px; padding: 10px 18px 18px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(60px) scale(.96); opacity: 0; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 26px);
  background: rgba(24, 20, 50, .72); color: #fff;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; padding: 10px 18px;
  display: flex; gap: 14px; align-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 10px 30px rgba(0, 0, 0, .3);
  max-width: calc(100% - 24px); font-size: .95rem; font-weight: 600;
  animation: fade .2s;
}
.toast[hidden] { display: none; }
.toast button { background: none; border: 0; color: #c7b5ff; font-weight: 900; text-transform: uppercase; font-size: .85rem; }

/* ------------------------------------------------------------------ Verktyg */
.timer-display {
  font-size: 4.6rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; margin: 4px 0 12px; letter-spacing: -.03em;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.timer-display.done { background: none; color: var(--danger); animation: pulse 1s infinite; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.group { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 12px 14px; box-shadow: var(--glass-shine); }
.group h4 { margin: 0 0 6px; color: var(--primary); }
.group ol { margin: 0; padding-left: 20px; }
.random-name {
  font-size: 2.1rem; font-weight: 900; text-align: center; padding: 26px 0; letter-spacing: -.02em;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 10px; text-align: center; box-shadow: var(--glass-shine); }
.stat b { display: block; font-size: 1.35rem; font-weight: 900; color: var(--primary); }
.stat span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.mini-table { width: 100%; border-collapse: collapse; }
.mini-table td, .mini-table th { padding: 7px 4px; border-bottom: 1px solid var(--hairline); text-align: right; }
.mini-table th { font-size: .75rem; color: var(--muted); }
.mini-table .l { text-align: left; }
.warn {
  background: color-mix(in srgb, var(--gold) 22%, var(--glass)); border: 1px solid rgba(245, 179, 1, .5);
  border-radius: 18px; padding: 12px 14px; font-size: .9rem; margin-bottom: 14px;
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.share-text { min-height: 260px; font-family: ui-monospace, monospace; font-size: .8rem; }
.qual-list { margin: 0; padding-left: 0; list-style: none; max-height: 50vh; overflow: auto; }
.qual-list li { display: flex; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--hairline); }
.qual-list .seedno { width: 30px; color: var(--muted); text-align: right; font-weight: 700; }
.qual-list .pts { margin-left: auto; font-weight: 800; color: var(--primary); }

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

/* ---------------------------------------------------------------------- Lag */
.top-seg { margin-bottom: 14px; background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-color: var(--glass-edge); box-shadow: var(--glass-shine); }
.team-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .6), 0 1px 4px rgba(0, 0, 0, .2); }
.team-tag { display: inline-flex; align-items: center; gap: 6px; }
.team-tag i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.team-swatch {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 3px 10px rgba(0, 0, 0, .15);
  background-image: linear-gradient(160deg, rgba(255, 255, 255, .45), transparent 60%) !important;
}
.team-swatch { background-blend-mode: overlay; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button {
  width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; padding: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 2px 6px rgba(0, 0, 0, .15);
}
.swatches button.on { border-color: var(--text); transform: scale(1.1); }
.member-box { max-height: 40vh; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 4px 12px; }
.member-row { min-height: 44px; border-bottom: 1px solid var(--hairline); }
.member-row:last-child { border-bottom: 0; }

/* ------------------------------------------------------------------ Faser */
.preset-list { display: grid; gap: 8px; }
.preset-list.compact { max-height: 42vh; overflow-y: auto; padding: 2px; }
.preset {
  display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: 18px; background: var(--surface-2); box-shadow: var(--glass-shine);
}
.preset b { font-size: 1rem; }
.preset span { font-size: .84rem; color: var(--muted); }
.preset.on { border-color: var(--primary); background: var(--primary-soft); }
.preset-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.preset-tags i { font-style: normal; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--glass); color: var(--primary); border: 1px solid var(--border); }

.stage-no {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none;
  background: var(--primary-grad); color: #fff; font-weight: 900; box-shadow: 0 4px 12px rgba(124, 77, 255, .35);
}
.pill { font-size: .72rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill.live { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.pill.ready { background: color-mix(in srgb, var(--gold) 25%, transparent); color: color-mix(in srgb, var(--gold) 60%, var(--text)); }
.pill.done { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.stage-card .icon-btn[disabled] { opacity: .3; }

details.cfg { margin-top: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-2); }
details.cfg > summary { cursor: pointer; padding: 10px 14px; font-weight: 800; color: var(--primary); list-style: none; }
details.cfg > summary::-webkit-details-marker { display: none; }
details.cfg > summary::after { content: '▾'; float: right; }
details.cfg[open] > summary::after { content: '▴'; }
.cfg-body { padding: 4px 14px 14px; display: grid; gap: 2px; }
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cfg-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.cfg-grid .field > span { min-height: 2.4em; display: flex; align-items: flex-end; }
.seed-list { list-style: none; margin: 8px 0; padding: 0; max-height: 46vh; overflow-y: auto; }
.seed-list li { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--hairline); min-height: 44px; }
.seed-list .seedno { width: 28px; text-align: right; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.seed-list .icon-btn { width: 34px; height: 34px; font-size: .8rem; }
.seed-list .icon-btn[disabled] { opacity: .25; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 20px;
  background: color-mix(in srgb, var(--success) 16%, var(--glass)); border: 1px solid color-mix(in srgb, var(--success) 45%, transparent);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.banner > svg { color: var(--success); }

.mlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.mlist.compact { grid-template-columns: 1fr; gap: 6px; margin-top: 12px; }
.mline {
  display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 16px; box-shadow: var(--glass-shine);
}
.mline.ready { box-shadow: 0 0 0 2px var(--primary), 0 4px 16px rgba(124, 77, 255, .22); border-color: transparent; }
.mline.pending, .mline.bye { opacity: .6; }
.mlist.compact .mline { padding: 7px 10px; border-radius: 12px; }
.mline-meta { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mline-row { display: flex; gap: 8px; align-items: center; }
.mline-row .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mline-row .ps { font-weight: 900; font-variant-numeric: tabular-nums; min-width: 20px; text-align: right; }
.mline-row.win .pn { font-weight: 800; }
.mline-row.win .ps { color: var(--primary); }
.mline-row.lose .pn { color: var(--muted); }
.mline-note { font-size: .78rem; color: var(--muted); font-style: italic; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.group-card { margin-bottom: 0; }
.gtable td, .gtable th { font-variant-numeric: tabular-nums; }
.gtable tr.advanced td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.gtable tr.advanced td { background: color-mix(in srgb, var(--success) 10%, transparent); }
.gtable tr.out td { color: var(--muted); }
.gtable tr.out td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 8px; }
.heat {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 18px; box-shadow: var(--glass-shine), 0 6px 18px rgba(60, 40, 140, .1);
}
.heat:not(.done) { box-shadow: 0 0 0 2px var(--primary), 0 6px 18px rgba(124, 77, 255, .2); border-color: transparent; }
.heat.final { background: linear-gradient(135deg, rgba(255, 226, 122, .55), var(--glass-strong) 60%); }
.heat-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--hairline); }
.heat-row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; }
.heat-row + .heat-row { border-top: 1px solid var(--hairline); }
.heat-row .hpos { width: 18px; font-weight: 900; color: var(--muted); }
.heat-row .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat-row .ps { font-weight: 800; font-variant-numeric: tabular-nums; }
.heat-row.advanced { background: color-mix(in srgb, var(--success) 14%, transparent); }
.heat-row.advanced .hpos { color: var(--success); }
.heat-row.out .pn { color: var(--muted); text-decoration: line-through; }
.heat-row.final:first-of-type .pn { font-weight: 900; }

.pos-list { display: grid; gap: 8px; }
.pos-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; }
.pos-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-btns button {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--glass); font-weight: 900; font-size: 1rem;
}
.pos-btns button.on { background: var(--primary-grad); color: #fff; border-color: transparent; box-shadow: 0 4px 12px rgba(124, 77, 255, .35); }

.roster { font-weight: 800; font-size: .72rem; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.roster.short { background: color-mix(in srgb, var(--gold) 25%, transparent); color: color-mix(in srgb, var(--gold) 55%, var(--text)); }
.chip[disabled] { opacity: .45; }

/* --------------------------------------------------- Ritat slutspelsträd */
.bc-wrap {
  overflow: auto; margin: 0 -12px 8px; padding: 6px 12px 18px; -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 230px);
}
.bc { position: relative; }
.bc-lines { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.bc-lines path { fill: none; stroke: color-mix(in srgb, var(--muted) 45%, transparent); stroke-width: 2; stroke-linejoin: round; }
.bc-lines path.on { stroke: var(--primary); stroke-width: 2.5; }
.bh { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; }
.bh b { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bh span { font-size: .68rem; color: var(--muted); font-weight: 600; }
.bh.inline { flex-direction: row; justify-content: center; gap: 6px; }
.bm {
  position: absolute; display: flex; flex-direction: column; padding: 0; text-align: left; overflow: hidden;
  background: var(--glass-strong); border: 1px solid var(--glass-edge); border-radius: 14px;
  box-shadow: var(--glass-shine), 0 4px 14px rgba(60, 40, 140, .12);
  transition: transform .12s;
}
.bm:active { transform: scale(.97); }
.bm.ready { border-color: transparent; box-shadow: 0 0 0 2.5px var(--primary), 0 6px 18px rgba(124, 77, 255, .35); }
.bm.pending { opacity: .85; }
.bm.bye { opacity: .45; }
.bm.final { border: 2px solid var(--gold); }
.bm.final.done { box-shadow: 0 0 0 2px var(--gold), 0 8px 24px rgba(245, 179, 1, .35); }
.bm-row { flex: 1; display: flex; align-items: center; gap: 6px; padding: 0 10px; min-height: 0; }
.bm-row + .bm-row { border-top: 1px solid var(--hairline); }
.bm-seed { width: 16px; font-size: .68rem; font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.bm-row .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 600; }
.bm-row .ps { font-weight: 900; font-variant-numeric: tabular-nums; min-width: 16px; text-align: right; }
.bm-row.win { background: linear-gradient(90deg, rgba(124, 92, 255, .2), rgba(216, 77, 216, .08)); }
.bm-row.win .pn { font-weight: 800; }
.bm-row.win .ps { color: var(--primary); }
.bm-row.lose .pn { color: var(--muted); text-decoration: line-through; }
.bm-row.lose .ps { color: var(--muted); }
.bm-row.tbd .pn { color: var(--muted); font-weight: 800; }
.bc-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 4px 12px; }
.bc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 14px; height: 10px; border-radius: 4px; border: 2px solid var(--primary); }
.lg.done { border-color: var(--glass-edge); background: linear-gradient(90deg, rgba(124, 92, 255, .35), rgba(216, 77, 216, .15)); }

/* ------------------------------------------------------------- Statistik */
.tabbar button[hidden] { display: none; }
.tabbar.six button { font-size: .62rem; }
.tabbar.six button svg { width: 21px; height: 21px; }
.tabbar.six button.active svg { width: 44px; padding: 2px 11px; }
.hl-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.stat.hl { text-align: left; padding: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--glass); border-color: var(--glass-edge); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.stat.hl span { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.stat.hl b { font-size: 1.6rem; background: var(--primary-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat.hl em { font-style: normal; font-weight: 700; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.standings.lb { min-width: 100%; width: max-content; }
.standings.lb td.l { width: auto; max-width: 150px; min-width: 110px; }
.standings.lb th.sorted { color: var(--primary); }
.standings.lb td.sorted { font-weight: 900; color: var(--primary); background: var(--primary-soft); }
.sb-image { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.sb-image img { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); background: #000; }
.sb-status { padding: 10px 12px; border-radius: 14px; background: var(--primary-soft); font-size: .9rem; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--primary-soft); border-top-color: var(--primary); display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sb-team { border: 1px solid var(--border); border-radius: 18px; padding: 10px; margin-bottom: 12px; background: var(--surface-2); }
.sb-team > .row { margin-bottom: 8px; }
.sb-score { width: 90px !important; text-align: center; }
.sb-table { border-collapse: collapse; width: max-content; min-width: 100%; }
.sb-table th { font-size: .7rem; color: var(--muted); font-weight: 800; padding: 4px 3px; text-align: center; }
.sb-table th.l { text-align: left; }
.sb-table td { padding: 2px; }
.sb-table input { min-height: 38px; padding: 6px 6px; border-radius: 10px; text-align: center; width: 58px; font-variant-numeric: tabular-nums; }
.sb-table td.l input { width: 130px; text-align: left; }
.sb-table .icon-btn { width: 34px; height: 34px; }
.sb-table .icon-btn svg { width: 16px; height: 16px; }
.sb-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; cursor: pointer;
  padding: 26px 16px; margin-bottom: 12px; border: 2px dashed var(--primary); border-radius: 18px;
  background: var(--primary-soft); color: var(--text);
}
.sb-drop svg { width: 34px; height: 34px; color: var(--primary); }
.sb-drop span { font-size: .85rem; color: var(--muted); }
#sbBody.dragging .sb-drop, #sbBody.dragging { outline: 3px solid var(--primary); outline-offset: 4px; border-radius: 18px; }

/* ------------------------------------------------- Guide: ny turnering */
body.wizard .tabbar { display: none; }
body.wizard { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }
.wizard-head { text-align: center; margin: 8px 6px 18px; }
.wizard-head h2 { margin: 6px 0 6px; font-size: 1.55rem; letter-spacing: -.02em; text-wrap: balance; }
.wizard-head p { margin: 0; }
.wizard-step {
  display: inline-block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
}
.wizard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.wizard-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 16px;
  background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 22px; color: var(--text);
  box-shadow: var(--glass-shine), var(--glass-shadow);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  transition: transform .15s, box-shadow .15s;
}
.wizard-card:hover, .wizard-card:focus-visible { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--primary), var(--glass-shadow); outline: none; }
.wizard-card:active { transform: scale(.98); }
.wizard-card b { font-size: 1.08rem; }
.wizard-desc { font-size: .86rem; color: var(--muted); line-height: 1.4; }
.wizard-icon {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 4px;
  background: var(--primary-grad); color: #fff; box-shadow: 0 4px 14px rgba(124, 77, 255, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.wizard-icon svg { width: 24px; height: 24px; }
