/* KeiKa-turnausalusta – design-järjestelmä.
   Periaatteet: yksi hiljainen, tiheä mutta ilmava hallinta; näyttävä vain siellä, missä tulos näkyy (pistetaulu,
   suora-merkki). Kaikki värit ovat tokeneita ja molemmat teemat on tarkistettu WCAG AA -kontrasteille. */

:root {
  color-scheme: light;
  --c-bg: #f3f4f6;
  --c-surface: #ffffff;
  --c-surface-2: #eaedf1;
  --c-surface-3: #dfe3e9;
  --c-text: #171c26;
  --c-text-2: #3a4353;
  --c-muted: #5a6474;
  --c-border: #d3d8e0;
  --c-border-strong: #b6bdc9;
  --c-brand: #efe012;
  --c-brand-ink: #0e0e0e;
  --c-black: #0e0e0e;
  --c-primary: #0e0e0e;
  --c-primary-hover: #2a2a2a;
  --c-primary-ink: #ffffff;
  --c-primary-soft: #fbf7c8;
  --c-link: #2453a6;
  --c-accent: #efe012;
  --c-accent-ink: #0e0e0e;
  --c-ok: #1d6f3a;
  --c-ok-bg: #dcf2e3;
  --c-warn: #7a5000;
  --c-warn-bg: #ffefc2;
  --c-error: #b3261e;
  --c-error-bg: #fbe3e1;
  --c-info: #2453a6;
  --c-info-bg: #e3eafb;
  --c-live: #d61f1f;
  --c-focus: #0e0e0e;
  --shadow-1: 0 1px 2px rgba(23, 28, 38, 0.06);
  --shadow-2: 0 8px 24px rgba(23, 28, 38, 0.14);
  --radius: 6px;
  --radius-lg: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 232px;
  --topbar-h: 52px;
  --content-max: 1600px;
  --public-max: 1040px;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --c-bg: #12151b;
    --c-surface: #1a1f27;
    --c-surface-2: #232a35;
    --c-surface-3: #2d3542;
    --c-text: #edf0f4;
    --c-text-2: #c8d0db;
    --c-muted: #a9b3c1;
    --c-border: #323a47;
    --c-border-strong: #46505f;
    --c-brand: #efe012;
    --c-brand-ink: #0e0e0e;
    --c-primary: #efe012;
    --c-primary-hover: #f6ea4a;
    --c-primary-ink: #0e0e0e;
    --c-primary-soft: #2f2c12;
    --c-link: #93b4ff;
    --c-ok: #74d494;
    --c-ok-bg: #16351f;
    --c-warn: #f2c14e;
    --c-warn-bg: #3b2d05;
    --c-error: #ff8f86;
    --c-error-bg: #4a1c18;
    --c-info: #93b4ff;
    --c-info-bg: #1c2a4a;
    --c-focus: #efe012;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #12151b;
  --c-surface: #1a1f27;
  --c-surface-2: #232a35;
  --c-surface-3: #2d3542;
  --c-text: #edf0f4;
  --c-text-2: #c8d0db;
  --c-muted: #a9b3c1;
  --c-border: #323a47;
  --c-border-strong: #46505f;
  --c-brand: #efe012;
  --c-brand-ink: #0e0e0e;
  --c-primary: #efe012;
  --c-primary-hover: #f6ea4a;
  --c-primary-ink: #0e0e0e;
  --c-primary-soft: #2f2c12;
  --c-link: #93b4ff;
  --c-ok: #74d494;
  --c-ok-bg: #16351f;
  --c-warn: #f2c14e;
  --c-warn-bg: #3b2d05;
  --c-error: #ff8f86;
  --c-error-bg: #4a1c18;
  --c-info: #93b4ff;
  --c-info-bg: #1c2a4a;
  --c-focus: #efe012;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* HK Modular on vain KEIKA-sanamerkin kirjasin; sanamerkki on SVG (views/components/brand.tsx), joten fonttia ei
   ladata tekstille lainkaan. Otsikot ja numerot käyttävät järjestelmäfonttia. */

/* ---------- Perusta ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
}
a { color: var(--c-link); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 0.4em; font-weight: 650; letter-spacing: -0.01em; color: var(--c-text); }
h1 { font-size: 1.625rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
h4 { font-size: 0.9375rem; }
p { margin: 0 0 0.9em; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }
small, .muted { color: var(--c-muted); }
small { font-size: 0.8125rem; }
code, pre, .mono { font-family: var(--font-mono); font-size: 0.875em; }
img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: 20px 0; }
ul, ol { padding-left: 1.25rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--c-accent); color: var(--c-accent-ink); padding: 8px 12px; z-index: 100; border-radius: 0 0 6px 0; }
.skip-link:focus { left: 0; top: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Yläpalkki ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px; height: var(--topbar-h); background: var(--c-black); color: #fff;
  border-bottom: 3px solid var(--c-brand); min-width: 0;
}
.topbar > * { min-width: 0; }
/* Sanamerkki ei kutistu; turnauksen nimi käyttää valikolta jäävän tilan ja piiloutuu vasta, kun tilaa ei ole. */
.topbar .brand { flex: 1 1 0; min-width: 140px; container: brand / inline-size; }
.topbar .topnav { flex: 0 1 auto; }
.topbar a { color: inherit; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--c-brand); }
.brand a:hover { text-decoration: none; }
.brand-home { flex: 0 0 auto; display: block; }
.brand .wordmark { height: 20px; width: auto; display: block; }
.brand .emblem { height: 34px; width: auto; display: block; }
.topbar .brand-context { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9375rem; font-weight: 600; color: rgba(255, 255, 255, 0.9); letter-spacing: 0.01em; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.25); line-height: 1.25; }
.topbar a.brand-context:hover { color: #fff; }
@container brand (max-width: 190px) { .topbar .brand > .brand-context { display: none; } }
.wordmark { fill: currentColor; }
.emblem-pair { display: inline-block; line-height: 0; }
.emblem-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .emblem-light { display: none; } :root:not([data-theme="light"]) .emblem-dark { display: inline; } }
:root[data-theme="dark"] .emblem-light { display: none; }
:root[data-theme="dark"] .emblem-dark { display: inline; }
.topnav { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.topnav::-webkit-scrollbar { display: none; }
.topnav > a, .topnav button.link { padding: 6px 10px; border-radius: 6px; color: #fff; font-weight: 500; text-decoration: none; font: inherit; background: none; border: 0; cursor: pointer; }
.topnav > a:hover, .topnav button.link:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.topnav > a[aria-current="page"] { background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 -3px 0 var(--c-brand); }
/* Käyttäjävalikko: <details> toimii ilman JavaScriptia; enhance.ts sulkee sen ulkopuolisesta klikkauksesta ja Esc-näppäimellä. */
.topbar .user-menu, .topbar .theme-toggle { flex: 0 0 auto; }
.user-menu { position: relative; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, 0.25); }
.user-menu > summary { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: #fff; cursor: pointer; list-style: none; user-select: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: rgba(255, 255, 255, 0.12); }
.user-menu .who { color: rgba(255, 255, 255, 0.85); font-weight: 500; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .user-initials { display: none; width: 28px; height: 28px; border-radius: 50%; background: var(--c-brand); color: var(--c-black); font-size: 0.75rem; font-weight: 700; align-items: center; justify-content: center; letter-spacing: 0.02em; }
.user-menu .caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: 0.7; transition: transform 0.15s; }
.user-menu[open] .caret { transform: rotate(180deg); }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 240px; max-width: min(320px, calc(100vw - 24px)); padding: 6px; background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-2); }
.user-menu-id { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--c-border); min-width: 0; }
.user-menu-id > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-id .muted { font-size: 0.8125rem; }
.user-menu-panel a, .user-menu-panel button { display: block; width: 100%; padding: 8px 10px; border-radius: var(--radius); color: var(--c-text); font: inherit; text-align: left; background: none; border: 0; cursor: pointer; }
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--c-surface-2); text-decoration: none; }
.user-menu-panel a[aria-current="page"] { background: var(--c-primary-soft); font-weight: 600; }
.user-menu-panel form { margin: 0; }
.theme-toggle { width: 34px; height: 34px; border-radius: 6px; border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.theme-toggle:hover { background: rgba(255, 255, 255, 0.22); }

/* ---------- Runko ---------- */
.shell { flex: 1; display: flex; width: 100%; min-width: 0; }
.content { flex: 1 1 auto; min-width: 0; padding: 28px 24px 56px; width: 100%; max-width: var(--public-max); margin: 0 auto; }
.shell-admin .content { max-width: var(--content-max); margin: 0; padding: 24px 28px 64px; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--c-surface); border-right: 1px solid var(--c-border);
  padding: 12px 0 24px; position: sticky; top: 0; align-self: flex-start; max-height: 100vh; overflow-y: auto;
  min-height: calc(100vh - var(--topbar-h));
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: block; padding: 7px 18px 7px 22px; color: var(--c-text-2); border-left: 3px solid transparent; font-size: 0.9375rem; }
.sidebar li a:hover { background: var(--c-surface-2); text-decoration: none; color: var(--c-text); }
.sidebar li a[aria-current="page"] { border-left-color: var(--c-brand); background: var(--c-primary-soft); color: var(--c-text); font-weight: 600; }
/* Kaksirivinen valikkokohta ("Ilmoittautumiset / Joukkueet"): rivit tiiviisti yhtenä kohtana. */
.nav-two-line { display: flex; flex-direction: column; line-height: 1.3; }
.nav-two-line .nav-sub { padding-left: 2px; }
/* Turnauksen sisällä ylätason "Turnaukset" on vain sijaintivihje; korostus kuuluu turnauksen omalle valikolle. */
.sidebar:has(.tournament-nav) > nav:first-child:not(.tournament-nav) a[aria-current="page"] { background: transparent; border-left-color: var(--c-border-strong); font-weight: 600; }
.tournament-nav { margin-top: 16px; border-top: 1px solid var(--c-border); padding-top: 12px; }
/* Yhteen turnaukseen rajatulla käyttäjällä turnauksen valikko on sivupalkin ainoa valikko. */
.tournament-nav:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.tournament-nav h2 { font-size: 0.8125rem; font-weight: 600; color: var(--c-muted); padding: 4px 22px 6px; margin: 0; overflow-wrap: anywhere; }
.footer { padding: 14px 20px; text-align: center; color: var(--c-muted); font-size: 0.8125rem; border-top: 1px solid var(--c-border); }
.subnav { display: flex; gap: 2px; flex-wrap: wrap; margin: -8px 0 22px; border-bottom: 1px solid var(--c-border); }
.subnav a { padding: 10px 14px; border-bottom: 3px solid transparent; color: var(--c-text-2); font-weight: 500; margin-bottom: -1px; }
.subnav a:hover { color: var(--c-text); text-decoration: none; }
.subnav a[aria-current="page"] { border-bottom-color: var(--c-accent); color: var(--c-text); font-weight: 600; }

/* ---------- Sivun otsikko ---------- */
.page-header { margin-bottom: 22px; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-header h1 { margin-bottom: 4px; }
body.variant-public .page-header h1, body.variant-bare .page-header h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.subtitle { color: var(--c-muted); margin: 0; }
.crumbs { font-size: 0.8125rem; color: var(--c-muted); margin-bottom: 6px; }
.crumbs a { color: var(--c-muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions-stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------- Kortit ja ruudukot ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); margin-bottom: 20px; min-width: 0; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--c-border); }
.card-header h2 { margin: 0; }
.card-body { padding: 18px 20px; }
.card-body > :last-child { margin-bottom: 0; }
.card-highlight { border-color: var(--c-primary); }
.card.compact .card-body { padding: 12px 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid > .card { margin-bottom: 0; }
/* Ruudukon korteilta puuttuu alamarginaali, joten seuraava kortti tai ruudukko saa saman välin yläpuolelleen. */
.grid + .card, .grid + .grid { margin-top: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 14px 16px; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.stat-label { color: var(--c-muted); font-size: 0.8125rem; margin-top: 2px; }
.stat-warn .stat-value { color: var(--c-warn); }
.stat-error .stat-value { color: var(--c-error); }
.stat-ok .stat-value { color: var(--c-ok); }

/* ---------- Taulukot ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.card-body > .table-wrap:first-child { margin-top: -6px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table th { font-weight: 600; color: var(--c-muted); font-size: 0.8125rem; white-space: nowrap; background: var(--c-surface); }
.table thead th { position: sticky; top: 0; z-index: 1; }
/* break-word (ei anywhere): sana ei katkea kesken, eikä sarake kapene pisintä sanaa kapeammaksi – leveä taulukko vierii. */
.table td { overflow-wrap: break-word; }
.table td.nowrap, .table td.num, .table td.date, .table td.state { white-space: nowrap; }
.table td:first-child { min-width: 9rem; }
.table tbody tr:hover td { background: var(--c-surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table td.actions-cell { text-align: right; }
.table td.actions-cell .actions { justify-content: flex-end; }
.table .actions form { display: inline; }
.table-empty { padding: 14px 0 4px; color: var(--c-muted); }
.table caption { text-align: left; font-weight: 600; padding: 8px 0; caption-side: top; }
.table.table-sm th, .table.table-sm td { padding: 6px 10px; font-size: 0.875rem; }

/* ---------- Lomakkeet ---------- */
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-weight: 600; font-size: 0.875rem; color: var(--c-text); }
.field .req { color: var(--c-error); }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text);
  width: 100%; max-width: 32rem; min-height: 38px; line-height: 1.3;
}
input[type="color"] { width: 56px; padding: 2px; height: 38px; }
input[type="file"] { font: inherit; color: var(--c-text); }
input[type="number"] { max-width: 12rem; }
input[type="date"], input[type="time"] { max-width: 14rem; }
input[type="datetime-local"] { max-width: 18rem; }
input::placeholder, textarea::placeholder { color: var(--c-muted); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 0; border-color: var(--c-focus); }
textarea { max-width: 100%; resize: vertical; }
.form-row input, .form-row select { max-width: 100%; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-error); }
.field .error, p.error, small.error { color: var(--c-error); font-weight: 500; }
.field .help, small.help { color: var(--c-muted); font-size: 0.8125rem; }
.field-check { flex-direction: row; align-items: flex-start; gap: 10px; }
.field-check input { margin-top: 3px; width: 16px; height: 16px; flex: 0 0 auto; }
.field-check label { font-weight: 500; }
.field-check .help { flex-basis: 100%; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 220px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.form-inline, .inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .field, .inline-form .field { margin-bottom: 0; }
.form-inline-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: end; }
.form-inline-grid .field { margin-bottom: 0; }
form.inline { display: inline; }
form.plain { max-width: 36rem; }
fieldset { border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 14px 16px 6px; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 600; padding: 0 6px; font-size: 0.9375rem; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { margin-bottom: 0; flex: 1 1 180px; max-width: 320px; }
.hp { position: absolute; left: -9999px; }
.repeat-item { position: relative; }
.repeat-item .repeat-remove { position: absolute; right: 10px; top: 6px; }

/* ---------- Napit ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 38px; border-radius: var(--radius);
  border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--c-brand); color: var(--c-brand-ink); border-color: var(--c-brand); }
.btn-primary:hover { background: #f6ea4a; border-color: #f6ea4a; }
.btn-dark { background: var(--c-black); color: #fff; border-color: var(--c-black); }
.btn-dark:hover { background: #2a2a2a; }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn-secondary:hover { background: var(--c-surface-2); }
.btn-danger { background: transparent; color: var(--c-error); border-color: var(--c-error); }
.btn-danger:hover { background: var(--c-error-bg); }
.btn-link { background: none; color: var(--c-link); padding: 6px 8px; min-height: 0; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: 0.8125rem; }
.btn-lg { padding: 12px 20px; font-size: 1.0625rem; }
.btn-accent { background: var(--c-brand); color: var(--c-brand-ink); }
.btn-accent:hover { background: #f6ea4a; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.btn[data-armed="true"] { background: var(--c-warn-bg); color: var(--c-warn); border-color: var(--c-warn); }

/* ---------- Merkit ja viestit ---------- */
/* Tilamerkit ovat hillittyjä: neutraali pohja ja värillinen piste kertoo sävyn. Vain varoitus ja virhe saavat
   sävytetyn pohjan, koska ne vaativat toimenpidettä. */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; line-height: 1.5; vertical-align: middle; background: var(--c-surface-2); color: var(--c-text-2); border: 1px solid var(--c-border); }
.badge-ok::before, .badge-info::before, .badge-warn::before, .badge-error::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; background: currentColor; }
.badge-ok::before { background: var(--c-ok); }
.badge-info::before { background: var(--c-info); }
.badge-warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: transparent; }
.badge-error { background: var(--c-error-bg); color: var(--c-error); border-color: transparent; }
.badge-muted { color: var(--c-muted); }
.badge-live { background: var(--c-live); color: #fff; border-color: transparent; }
.badge-live [data-clock] { font-variant-numeric: tabular-nums; }
.badge-live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.flash { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid transparent; font-weight: 500; }
.flash-ok { background: var(--c-ok-bg); color: var(--c-ok); border-color: color-mix(in srgb, var(--c-ok) 30%, transparent); }
.flash-error { background: var(--c-error-bg); color: var(--c-error); border-color: color-mix(in srgb, var(--c-error) 30%, transparent); }
.flash-info { background: var(--c-info-bg); color: var(--c-info); border-color: color-mix(in srgb, var(--c-info) 30%, transparent); }
.empty { padding: 28px 16px; text-align: center; color: var(--c-muted); }
.definition { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: 8px 20px; margin: 0 0 16px; align-items: baseline; }
.definition dt { color: var(--c-muted); }
.definition dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.error-page { text-align: center; padding: 60px 0; }
.error-page h1 { font-size: 3.5rem; color: var(--c-muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--c-border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a, .tabs .tab { padding: 8px 14px; border-bottom: 3px solid transparent; color: var(--c-text-2); font-weight: 500; margin-bottom: -1px; }
.tabs a:hover { text-decoration: none; color: var(--c-text); }
.tabs a[aria-current="page"], .tabs .tab.is-active { border-bottom-color: var(--c-primary); color: var(--c-text); font-weight: 600; }
.pill-list, .inline-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.pill-list li { background: var(--c-surface-2); border-radius: 999px; padding: 2px 10px; font-size: 0.875rem; }
.pill-list li .badge { border-color: transparent; background: var(--c-surface); }
.page-nav { margin: 4px 0 24px; }
.page-nav ul { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.page-nav a[aria-current="page"] { background: var(--c-primary); color: var(--c-primary-ink); border-color: var(--c-primary); }
.page-nav a { display: inline-block; padding: 6px 14px; border: 1px solid var(--c-border-strong); border-radius: 999px; background: var(--c-surface); color: var(--c-text); font-weight: 500; }
.page-nav a:hover { background: var(--c-surface-2); text-decoration: none; }
.page-nav a[aria-current="location"] { background: var(--c-primary); color: var(--c-primary-ink); border-color: var(--c-primary); }
/* Joukkueet-sivun taulukossa lähes kaikki on linkkejä: tekstin väri erottuu paremmin kuin linkkisininen. */
.teams-table a { color: var(--c-text); }
/* Näytä/piilota-valitsimet (Joukkueet-sivun tasoryhmät). Painettu = näkyvissä: täytetty pilleri ja valintamerkki. */
.toggle-filter { margin: 0 0 16px; }
/* Suodatettavat rivit ja ryhmät: hidden-attribuutti voittaa komponenttien display-arvot (esim. .fixture on grid). */
[data-filter-key][hidden], [data-filter-group][hidden], [data-filter-empty][hidden], [data-filter-list][hidden] { display: none; }
.toggle-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 8px 6px 10px; border: 1px solid var(--c-border-strong); border-radius: 999px; background: var(--c-surface); color: var(--c-text-2); font: inherit; font-weight: 600; line-height: 1.2; cursor: pointer; transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
.toggle-chip:hover { background: var(--c-surface-2); color: var(--c-text); }
.toggle-chip[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-ink); }
.toggle-chip[aria-pressed="true"]:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.toggle-chip-check { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border: 1.5px solid var(--c-border-strong); border-radius: 50%; background: var(--c-surface); }
.toggle-chip[aria-pressed="true"] .toggle-chip-check { border-color: var(--c-primary-ink); background: var(--c-primary-ink); }
.toggle-chip[aria-pressed="true"] .toggle-chip-check::after { content: ""; width: 8px; height: 4px; border: solid var(--c-primary); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.toggle-chip-count { min-width: 24px; padding: 2px 7px; border-radius: 999px; background: var(--c-surface-2); color: var(--c-text-2); font-size: 0.8125rem; text-align: center; font-variant-numeric: tabular-nums; }
.toggle-chip[aria-pressed="true"] .toggle-chip-count { background: color-mix(in srgb, var(--c-primary-ink) 20%, transparent); color: var(--c-primary-ink); }
@media (prefers-reduced-motion: reduce) { .toggle-chip { transition: none; } }
/* Sisältösivut allekkain: valintarivi pysyy näkyvissä, ja ankkurihyppy jättää otsikon sen alle. */
.page-nav-sticky { position: sticky; top: 0; z-index: 5; margin: 4px 0 8px; padding: 8px 0; background: var(--c-bg); }
.page-nav-sticky ul { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.page-nav-sticky a { white-space: nowrap; }
.page-section { scroll-margin-top: 64px; padding-top: 16px; }
.page-section + .page-section { margin-top: 24px; border-top: 1px solid var(--c-border); }
.page-section > h2 { font-size: 1.375rem; margin-bottom: 0.6em; }
@media (prefers-reduced-motion: no-preference) { html:has(.page-sections) { scroll-behavior: smooth; } }
.links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.kv { display: flex; gap: 8px; align-items: baseline; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.range-dash { margin-inline: 0.2em; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.meta { color: var(--c-muted); font-size: 0.875rem; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.steps .step { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-surface); font-size: 0.875rem; }
.steps .step::before { counter-increment: step; content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--c-surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.75rem; }
.steps .step.is-active { border-color: var(--c-primary); }
.steps .step.is-active::before, .steps .step.done::before { background: var(--c-primary); color: #fff; }
.highlight { background: var(--c-warn-bg); border-radius: 3px; padding: 0 3px; }
.alert-group { display: grid; gap: 8px; }
.enrollment-code { font-family: var(--font-mono); font-size: 2rem; letter-spacing: 0.18em; font-weight: 700; padding: 12px 16px; background: var(--c-surface-2); border-radius: var(--radius); display: inline-block; }

/* ---------- Modaali ---------- */
dialog.modal { margin: auto; border: 0; border-radius: var(--radius-lg); padding: 0; max-width: min(720px, calc(100vw - 32px)); width: 100%; background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-2); }
dialog.modal::backdrop { background: rgba(10, 14, 22, 0.55); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--c-border); }
.modal-header h2 { margin: 0; }
.modal-body { padding: 18px 20px; max-height: min(70vh, 640px); overflow: auto; }
.modal-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--c-muted); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--c-surface-2); color: var(--c-text); }
/* Selkeä sulkemispainike tekstillä (ikkunat, joissa muutokset ovat jo tallessa eikä alapalkissa ole painiketta). */
.modal-close.modal-close-labeled { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; min-height: 40px; padding: 6px 14px 6px 10px; border: 1px solid var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text); font-family: inherit; font-size: 0.9375rem; font-weight: 600; line-height: 1; }
.modal-close.modal-close-labeled:hover { background: var(--c-surface-2); border-color: var(--c-text-2); }
.modal-close.modal-close-labeled:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.modal-close-x { font-size: 1.5rem; line-height: 0.8; font-weight: 400; }

/* ---------- Peliasujen värit ja logot ---------- */
.kit-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--c-border-strong); vertical-align: -2px; margin-right: 5px; }
.logo-sm { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; margin-right: 6px; border-radius: 4px; background: #fff; }
.logo { max-width: 160px; max-height: 160px; object-fit: contain; background: #fff; border-radius: var(--radius); padding: 6px; border: 1px solid var(--c-border); }

/* ---------- Rikas sisältö (Tiptap) ---------- */
.prose { max-width: var(--measure); font-size: 1rem; }
.prose h2 { margin-top: 1.4em; }
.prose h3 { margin-top: 1.2em; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.prose td, .prose th { border: 1px solid var(--c-border); padding: 6px 10px; }
.prose img { border-radius: var(--radius); }
.prose blockquote { border-left: 4px solid var(--c-accent); margin: 1em 0; padding: 4px 16px; color: var(--c-text-2); }
.prose iframe, .map-embed iframe { width: 100%; aspect-ratio: 16/10; border: 0; border-radius: var(--radius); }
.map-embed { margin: 1em 0; }
.editor { min-width: 0; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid var(--c-border-strong); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--c-surface-2); position: sticky; top: 0; z-index: 2; align-items: center; }
.editor-toolbar button { font: inherit; font-size: 0.8125rem; padding: 5px 9px; border: 1px solid var(--c-border); background: var(--c-surface); border-radius: 4px; cursor: pointer; color: var(--c-text); min-height: 30px; }
.editor-toolbar button:hover { background: var(--c-surface-3); }
.editor-toolbar button.is-active { background: var(--c-primary); color: var(--c-primary-ink); border-color: var(--c-primary); }
.editor-sep { width: 1px; align-self: stretch; background: var(--c-border-strong); margin: 0 4px; }
.editor-status { font-size: 0.8125rem; padding: 4px 8px; color: var(--c-muted); }
.editor-status-ok { color: var(--c-ok); }
.editor-status-error { color: var(--c-error); }
.editor-preview-toggle { margin-left: auto; }
.editor-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.editor-surface { border: 1px solid var(--c-border-strong); border-radius: 0 0 var(--radius) var(--radius); padding: 18px 20px; min-height: 380px; background: var(--c-surface); }
.editor-surface .ProseMirror { outline: none; min-height: 340px; }
.editor-surface .ProseMirror p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--c-muted); float: left; pointer-events: none; height: 0; }
.editor-preview-mobile .editor-surface { max-width: 390px; margin: 0 auto; }
.rules-table { margin-bottom: 20px; }

/* ---------- Aikataulu ---------- */
.schedule-editor { min-width: 0; }
.schedule-day { margin-bottom: 24px; }
.schedule-grid { display: grid; gap: 1px; background: var(--c-border); border: 1px solid var(--c-border); overflow: auto; font-size: 0.8125rem; border-radius: var(--radius); }
.schedule-grid .cell { background: var(--c-surface); padding: 3px 6px; min-height: 30px; min-width: 0; }
.schedule-grid .head { background: var(--c-surface-2); font-weight: 600; position: sticky; top: 0; z-index: 1; }
.schedule-grid .time { background: var(--c-surface-2); color: var(--c-muted); position: sticky; left: 0; white-space: nowrap; }
.schedule-grid .match { border-left: 4px solid var(--c-primary); border-radius: 3px; cursor: grab; overflow: hidden; }
.schedule-grid .match.locked { border-left-color: var(--c-muted); cursor: not-allowed; opacity: 0.85; }
.schedule-grid .match.hard { outline: 2px solid var(--c-error); outline-offset: -2px; }
.schedule-grid .match.soft { outline: 2px solid var(--c-warn); outline-offset: -2px; }
.schedule-grid .match.dragging { opacity: 0.4; }
.schedule-grid .cell.drop-ok { background: var(--c-ok-bg); }
.schedule-grid .cell.drop-bad { background: var(--c-error-bg); }
.match-row { display: grid; grid-template-columns: 3.5rem 1fr auto 1fr; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--c-border); }
.match-row:last-child { border-bottom: 0; }
.match-row .time { color: var(--c-muted); white-space: nowrap; }
.match-row .score { font-weight: 700; font-size: 1.125rem; text-align: center; min-width: 3.5rem; }
.match-row .home { text-align: right; }
.match-row .side { min-width: 0; overflow-wrap: anywhere; }
.match-row .live { color: var(--c-live); font-weight: 600; }
.match-row.finished .score { color: var(--c-text); }
.match-row .meta { grid-column: 1 / -1; font-size: 0.8125rem; }
.day-heading { margin-top: 28px; padding-bottom: 6px; border-bottom: 2px solid var(--c-border); }
.field-heading { margin-top: 16px; font-size: 0.9375rem; color: var(--c-muted); }
.live-list { display: grid; gap: 8px; }
.teams-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.team-name { font-weight: 600; }

/* ---------- Kirjausnäkymä (mobiili) ---------- */
.scorer { max-width: 520px; margin: 0 auto; padding: 8px 0 40px; }
.scorer .scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; text-align: center; padding: 16px; background: var(--c-surface); border-radius: var(--radius-lg); border: 1px solid var(--c-border); }
.scorer .scoreboard .big, .big-score { font-size: 3rem; font-weight: 800; line-height: 1; }
.scorer .scoreboard .name { font-weight: 600; overflow-wrap: anywhere; }
.scorer .clock { font-size: 2rem; font-weight: 700; text-align: center; margin: 8px 0; }
.scorer .goal-btn { font-size: 1.25rem; padding: 18px; width: 100%; min-height: 64px; }
.scorer .event-list { list-style: none; padding: 0; margin: 12px 0; }
.scorer .event-list li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--c-border); }
.scorer .event-list li.corrected { text-decoration: line-through; color: var(--c-muted); }
.scorer .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.scorer .controls .btn { min-height: 48px; }
.offline-banner { background: var(--c-warn-bg); color: var(--c-warn); padding: 8px 12px; text-align: center; border-radius: var(--radius); margin-bottom: 8px; font-weight: 600; }

/* ---------- Areenan näyttö (koko ruutu, luettava 10 metristä) ---------- */
/* Mitat yksiköstä --u = 1 % 16:9-ruudun korkeudesta (1080p: 10,8 px), joten näkymä skaalautuu näytön mukaan.
   Näyttötilassa värit ovat kiinteitä (design.md, periaate 7); tumma on oletus, vaalea valittavissa näytön asetuksista.
   Näkymien HTML tulee tiedostosta src/lib/display/render.ts. */
body.variant-display { background: #0e0e0e; color: #f4f5f7; overflow: hidden; }
body.variant-display .content { max-width: none; padding: 0; margin: 0; }
.screen {
  --u: min(1vh, 0.5625vw);
  --s-bg: #0e0e0e; --s-head: #000000; --s-surface: #17191d; --s-surface-2: #22252b; --s-line: #2e3238;
  --s-text: #f4f5f7; --s-muted: #a9b0bb; --s-accent: #efe012; --s-accent-ink: #0e0e0e; --s-score: #efe012;
  --s-live: #ff4d4d; --s-glass: rgba(12, 14, 17, 0.74); --s-pitch: #1d5a38; --s-pitch-line: rgba(255, 255, 255, 0.42);
  --s-canvas: #121417;
  /* Kenttäkartan tokenit näytön teeman mukaan (alueet, palvelut, tekstit). */
  --c-surface: #1d2025; --c-surface-2: var(--s-canvas); --c-surface-3: #262a31; --c-text: var(--s-text);
  --c-text-2: #d0d5dc; --c-muted: var(--s-muted); --c-border-strong: #434951; --c-accent: var(--s-accent);
  --c-primary-soft: #2a2810;
  position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--s-bg); color: var(--s-text); font-size: calc(var(--u) * 2.8); line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.screen.theme-light {
  --s-bg: #eef0f3; --s-head: #0e0e0e; --s-surface: #ffffff; --s-surface-2: #f3f4f6; --s-line: #d9dde3;
  --s-text: #121417; --s-muted: #535b67; --s-score: #121417; --s-live: #d61f1f; --s-glass: rgba(255, 255, 255, 0.9);
  --s-pitch: #3f8f5f; --s-pitch-line: rgba(255, 255, 255, 0.7); --s-canvas: #e4e7eb;
  --c-surface: #ffffff; --c-surface-3: #d9dde3; --c-text-2: #2b313b; --c-border-strong: #a9b0bb; --c-primary-soft: #fbf7c8;
}
body.variant-display:has(.screen.theme-light) { background: #eef0f3; }
.screen.is-cursor-hidden, .screen.is-cursor-hidden * { cursor: none; }

/* Kehys: tunnus ja turnaus, näkymän nimi, kello; edistymispalkki; tiedoterivi. */
.screen-head {
  flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center;
  gap: calc(var(--u) * 3); height: calc(var(--u) * 8); padding: 0 calc(var(--u) * 2.6);
  background: var(--s-head); color: #ffffff;
}
.screen-brand { display: flex; align-items: center; gap: calc(var(--u) * 2); min-width: 0; }
.screen-brand .wordmark { height: calc(var(--u) * 3.2); width: auto; flex: 0 0 auto; color: #efe012; }
.screen-tournament { font-size: calc(var(--u) * 3); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-title { display: flex; align-items: baseline; gap: calc(var(--u) * 1.4); font-size: calc(var(--u) * 3); font-weight: 600; white-space: nowrap; }
.screen-page { font-size: calc(var(--u) * 2.2); color: #a9b0bb; font-weight: 500; }
.screen-clock { font-size: calc(var(--u) * 4.4); font-weight: 800; letter-spacing: -0.01em; min-width: 4.2ch; text-align: right; }
.screen-progress { flex: 0 0 auto; height: calc(var(--u) * 0.5); background: color-mix(in srgb, var(--s-head) 80%, var(--s-line)); }
.screen-progress span { display: block; height: 100%; width: 0; background: var(--s-accent); }
.screen-stage { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.screen-stage > * { animation: screen-in 0.45s ease-out; }
.screen-stage[data-refresh] > * { animation: none; }
@keyframes screen-in { from { opacity: 0; transform: translateY(calc(var(--u) * 0.8)); } to { opacity: 1; transform: none; } }
.screen-ticker {
  flex: 0 0 auto; height: calc(var(--u) * 6); display: flex; align-items: center; overflow: hidden;
  background: var(--s-accent); color: var(--s-accent-ink); font-size: calc(var(--u) * 3); font-weight: 650; white-space: nowrap;
}
.screen-ticker[hidden] { display: none; }
.screen-ticker span { display: inline-block; padding-left: 100%; animation: ticker var(--ticker-s, 30s) linear infinite; }
@keyframes ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
.screen-identify {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(0, 0, 0, 0.95);
  color: #efe012; font-size: calc(var(--u) * 12); font-weight: 800; text-align: center; padding: calc(var(--u) * 4);
}
.screen-identify[hidden] { display: none; }
.screen-offline { position: absolute; right: calc(var(--u) * 2); bottom: calc(var(--u) * 2); z-index: 4; width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); border-radius: 50%; background: var(--s-live); animation: pulse 1.4s infinite; }
.screen-ticker:not([hidden]) ~ .screen-offline { bottom: calc(var(--u) * 8); }

/* Yhteiset ottelun osat: pistetaulu (joukkueet allekkain, maalit oikealla), paidan väri, kello. */
.kit { display: inline-block; width: 0.62em; height: 0.62em; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 2px color-mix(in srgb, var(--s-text, #000) 25%, transparent); }
.kit-none { background: transparent; box-shadow: inset 0 0 0 2px var(--s-line, #ccc); }
.sb { display: grid; gap: calc(var(--u) * 0.6); }
.sb-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: calc(var(--u) * 1.2); }
.sb-name { font-size: 1.12em; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-score { font-size: 2.1em; font-weight: 800; line-height: 1; color: var(--s-score); min-width: 1.2ch; text-align: right; }
.sb.is-decided .sb-row:not(.is-winner) .sb-name { color: var(--s-muted); font-weight: 550; }
.sb-foot { display: flex; justify-content: space-between; align-items: baseline; gap: calc(var(--u) * 1.4); margin-top: calc(var(--u) * 0.4); font-size: 0.82em; }
.sb-clock { font-weight: 700; white-space: nowrap; }
.sb-clock.live { color: var(--s-score); }
.sb-clock.live::before { content: ""; display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: var(--s-live); margin-right: 0.45em; vertical-align: 0.06em; animation: pulse 1.4s infinite; }
.sb-clock.finished { color: var(--s-muted); }
.sb-meta { color: var(--s-muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-empty { height: 100%; display: grid; place-items: center; color: var(--s-muted); font-size: calc(var(--u) * 3.6); text-align: center; padding: calc(var(--u) * 4); }

/* Kentät sarakkeina. */
.sc-fields { height: 100%; display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: calc(var(--u) * 1.6); padding: calc(var(--u) * 1.8) calc(var(--u) * 2); }
.sf { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--s-surface); border-radius: calc(var(--u) * 1.2); overflow: hidden; }
.sf-name { margin: 0; padding: calc(var(--u) * 1.2) calc(var(--u) * 2); font-size: calc(var(--u) * 3.6); font-weight: 800; letter-spacing: -0.01em; background: var(--s-surface-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf.is-live .sf-name { background: var(--s-accent); color: var(--s-accent-ink); }
.sf-now { padding: calc(var(--u) * 2) calc(var(--u) * 2) calc(var(--u) * 2.2); border-bottom: 1px solid var(--s-line); font-size: calc(var(--u) * 3); }
.sf-idle { color: var(--s-muted); font-size: calc(var(--u) * 2.8); }
.sf-next { padding: calc(var(--u) * 1.4) calc(var(--u) * 2); min-height: 0; overflow: hidden; }
.sf-next h3 { margin: 0 0 calc(var(--u) * 0.6); font-size: calc(var(--u) * 2.2); font-weight: 600; color: var(--s-muted); }
.sf-next ol, .sm-next ol { list-style: none; margin: 0; padding: 0; }
.sf-next li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: calc(var(--u) * 1.6); padding: calc(var(--u) * 1) 0; border-top: 1px solid var(--s-line); font-size: calc(var(--u) * 2.6); }
.sf-next li:first-child { border-top: 0; }
.sf-next time { font-weight: 800; color: var(--s-score); grid-row: span 2; font-size: 1.08em; }
.nx-teams { display: grid; min-width: 0; font-weight: 600; }
.nx-teams span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-upcoming .sf-when { color: var(--s-muted); font-size: 0.8em; font-weight: 600; }
.sf-upcoming .sf-when time { color: var(--s-score); font-weight: 800; font-size: 1.25em; margin-left: 0.2em; }
.sf-upcoming .sb-foot { justify-content: flex-start; }
.sf-upcoming .sb-meta { text-align: left; }
.sf-next small { color: var(--s-muted); font-size: 0.78em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Kenttäkartta: kartta mahtuu näyttämöön mittasuhteet säilyttäen, kentillä ottelukortit (HTML kartan päällä). */
.sc-map { height: 100%; display: grid; place-items: center; padding: calc(var(--u) * 1.6) calc(var(--u) * 2); container-type: size; }
.sm-map { position: relative; width: min(100cqw, calc(100cqh * var(--ar, 1.5))); aspect-ratio: var(--ar, 1.5); }
.sm-map .fmap-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.screen .fmap-canvas { fill: var(--s-canvas); }
.screen .fmap-field .fmap-pitch { fill: var(--s-pitch); stroke: var(--s-pitch-line); stroke-width: 3; }
.screen .fmap-field .fmap-pitch-line { stroke: var(--s-pitch-line); stroke-width: 2; }
.screen .fmap-field.is-current .fmap-pitch { stroke: var(--s-accent); stroke-width: 6; }
.mc { position: absolute; container-type: size; display: flex; }
.mc-in {
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4cqmin;
  padding: 5cqmin 6cqmin; border-radius: 4cqmin; background: var(--s-glass); color: var(--s-text);
  backdrop-filter: blur(2px);
  font-size: clamp(9px, 10cqmin, calc(var(--u) * 3.4)); overflow: hidden;
  box-shadow: 0 calc(var(--u) * 0.4) calc(var(--u) * 1.6) rgba(0, 0, 0, 0.35);
}
.mc.is-live .mc-in { box-shadow: 0 0 0 max(2px, 1.2cqmin) var(--s-accent), 0 calc(var(--u) * 0.4) calc(var(--u) * 1.6) rgba(0, 0, 0, 0.35); }
.mc.is-out .mc-in { background: transparent; box-shadow: none; align-items: center; }
.mc-name { font-weight: 800; font-size: 1.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc.is-live .mc-name::after { content: ""; display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.4em; border-radius: 50%; background: var(--s-live); vertical-align: 0.1em; animation: pulse 1.4s infinite; }
.mc .sb-name { font-size: 1em; }
.mc .sb-score { font-size: 1.5em; }
.mc .sb-foot { font-size: 0.78em; }
.mc .sb-meta { display: none; }
.mc-next, .mc-upcoming { color: var(--s-muted); font-size: 0.82em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-next time, .mc-upcoming time { color: var(--s-score); font-weight: 800; }
.mc-teams { display: grid; gap: 1.5cqmin; font-weight: 650; }
.mc-teams span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-quiet { color: var(--s-muted); font-size: 0.85em; }
/* "Olet tässä": nasta osoittaa kohdan, nimilappu nastan yläpuolella. Myös hallinnan merkkieditorissa. */
.mk { position: absolute; z-index: 2; width: 0; height: 0; pointer-events: none; }
.mk[hidden] { display: none; }
.mk-pin { position: absolute; left: 0; top: 0; width: 1.3em; height: 1.3em; margin: -0.65em 0 0 -0.65em; border-radius: 50%; background: #efe012; box-shadow: 0 0 0 0.22em #0e0e0e, 0 0 0 0.44em #efe012; }
.mk-pin::after { content: ""; position: absolute; inset: -0.9em; border-radius: 50%; border: 0.2em solid #efe012; animation: mk-ring 1.8s ease-out infinite; }
@keyframes mk-ring { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.mk-label { position: absolute; left: 0; bottom: 1.3em; transform: translateX(-50%); padding: 0.2em 0.6em; border-radius: 0.4em; background: #efe012; color: #0e0e0e; font-weight: 800; white-space: nowrap; box-shadow: 0 0.15em 0.5em rgba(0, 0, 0, 0.35); }
.screen .mk { font-size: calc(var(--u) * 2.8); }

/* Aikataulu: alkamisajat riveinä, kentät sarakkeina. */
.sc-schedule { height: 100%; padding: calc(var(--u) * 1.8) calc(var(--u) * 2); overflow: hidden; }
.ss { width: 100%; border-collapse: separate; border-spacing: calc(var(--u) * 0.8); table-layout: fixed; margin: calc(var(--u) * -0.8); width: calc(100% + var(--u) * 1.6); }
.ss th { font-size: calc(var(--u) * 3); font-weight: 800; text-align: left; padding: calc(var(--u) * 1) calc(var(--u) * 1.6); background: var(--s-surface-2); border-radius: calc(var(--u) * 0.8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss .ss-time { width: calc(var(--u) * 15); background: transparent; text-align: right; padding: 0 calc(var(--u) * 0.6) 0 0; overflow: visible; }
.ss tbody .ss-time time { font-size: calc(var(--u) * 3.8); font-weight: 800; color: var(--s-score); }
.ss tbody tr.is-live .ss-time time::before { content: ""; display: inline-block; width: 0.4em; height: 0.4em; margin-right: 0.35em; border-radius: 50%; background: var(--s-live); vertical-align: 0.15em; animation: pulse 1.4s infinite; }
.ss td { vertical-align: top; padding: calc(var(--u) * 1.1) calc(var(--u) * 1.6); background: var(--s-surface); border-radius: calc(var(--u) * 0.8); font-size: calc(var(--u) * 2.6); }
.ss td.is-live { box-shadow: inset calc(var(--u) * 0.6) 0 0 var(--s-accent); }
.ss td.ss-none { background: transparent; }
.ss-teams { display: grid; gap: calc(var(--u) * 0.2); font-weight: 650; }
.ss-teams span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-meta { display: flex; gap: calc(var(--u) * 1); align-items: baseline; margin-top: calc(var(--u) * 0.4); color: var(--s-muted); font-size: 0.8em; white-space: nowrap; overflow: hidden; }
.ss-meta small { font-size: 1em; overflow: hidden; text-overflow: ellipsis; }
.ss-score { color: var(--s-score); font-weight: 800; font-size: 1.15em; }

/* Tulokset: kaksi saraketta, uusin ensin (sarake kerrallaan). */
.sc-results { height: 100%; padding: calc(var(--u) * 1.8) calc(var(--u) * 2); overflow: hidden; }
.sr { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 4), auto); gap: calc(var(--u) * 1.4) calc(var(--u) * 2); }
.sr-item { display: grid; gap: calc(var(--u) * 0.4); padding: calc(var(--u) * 1.2) calc(var(--u) * 2); background: var(--s-surface); border-radius: calc(var(--u) * 1); font-size: calc(var(--u) * 2.8); }
.sr-meta { color: var(--s-muted); font-size: 0.75em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr .sb-score { font-size: 1.5em; }
.sr .sb-score { color: var(--s-text); }
.sr-item.is-decided .sb-row.is-winner .sb-score { color: var(--s-score); }
.sr-item.is-decided .sb-row:not(.is-winner) .sb-name, .sr-item.is-decided .sb-row:not(.is-winner) .sb-score { color: var(--s-muted); font-weight: 550; }

/* Odotus ja pariliitos. */
.sc-idle, .pair { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--u) * 2); text-align: center; padding: calc(var(--u) * 4); }
.sc-idle .idle-mark, .pair .wordmark { height: calc(var(--u) * 7); width: auto; color: #efe012; }
.screen.theme-light .sc-idle .idle-mark { color: #0e0e0e; }
.sc-idle h2 { margin: calc(var(--u) * 2) 0 0; font-size: calc(var(--u) * 5); }
.sc-idle p { margin: 0; font-size: calc(var(--u) * 3); }
.sc-idle .muted, .pair-steps, .pair-expiry { color: var(--s-muted); }
.pair h1 { margin: calc(var(--u) * 2) 0 0; font-size: calc(var(--u) * 4.4); }
.pair-code { margin: calc(var(--u) * 1) 0; font-family: var(--font-mono); font-size: calc(var(--u) * 16); font-weight: 800; letter-spacing: 0.12em; color: #efe012; line-height: 1; }
.pair-steps { margin: 0; padding: 0; list-style-position: inside; font-size: calc(var(--u) * 3.2); line-height: 1.5; }
.pair-expiry { margin: calc(var(--u) * 2) 0 0; font-size: calc(var(--u) * 2.4); }

/* ---------- Hallinta: näytöt ---------- */
.screens-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem); gap: 20px; align-items: start; }
.screens-main, .screens-aside { min-width: 0; }
.screens-aside { display: grid; gap: 16px; }
.screens-aside > .card, .screens-main > .card:last-child { margin-bottom: 0; }
.screen-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.scene-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.scene-chips li { padding: 2px 8px; border-radius: 999px; background: var(--c-surface-2); font-size: 0.8125rem; white-space: nowrap; }
.scene-chips li.is-pinned { background: var(--c-primary-soft); box-shadow: inset 0 0 0 1.5px var(--c-accent); font-weight: 600; }
.pin-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.pin-form select { max-width: 100%; min-width: 13rem; }
.other-screen { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0 !important; border-bottom: 1px solid var(--c-border); }
.other-screen:last-child { border-bottom: 0; }
.copy-line code { display: block; padding: 10px 12px; background: var(--c-surface-2); border-radius: var(--radius); overflow-wrap: anywhere; user-select: all; }
.screen-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(20rem, 30rem); gap: 20px; align-items: start; }
.se-main, .se-aside { min-width: 0; }
.se-aside { display: grid; gap: 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.se-aside > .card, .se-main > .card:last-of-type { margin-bottom: 0; }
.se-scenes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.se-scene { border: 1px solid var(--c-border); border-radius: var(--radius-lg); background: var(--c-surface); padding: 10px 14px 4px; }
.se-scene.is-removed { opacity: 0.55; border-style: dashed; }
.se-scene.is-removed .se-scene-body { display: none; }
.se-scene-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.se-handle { width: 14px; height: 20px; flex: 0 0 auto; cursor: grab; background: radial-gradient(circle, var(--c-muted) 1.4px, transparent 1.6px) 0 0 / 7px 6px; opacity: 0.8; }
.se-index { color: var(--c-muted); font-variant-numeric: tabular-nums; }
.se-kind { font-size: 1rem; }
.se-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.se-remove { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; color: var(--c-text-2); margin-left: 6px; cursor: pointer; }
.se-scene-body .form-row { margin-bottom: 0; }
.se-scene-body .field { flex: 0 1 11rem; }
.se-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.se-add-label { color: var(--c-text-2); font-size: 0.875rem; margin-right: 4px; }
.se-marker { margin: 4px 0 8px; }
.se-marker-stage { position: relative; max-width: 30rem; border-radius: var(--radius); overflow: hidden; cursor: crosshair; font-size: 0.9375rem; touch-action: none; }
.se-marker-stage[hidden] { display: none; }
.se-marker-stage .mk { pointer-events: auto; cursor: grab; }
.se-marker-fields .field { flex: 1 1 9rem; }
.se-marker-fields .btn-link { align-self: center; }
.se-save { position: sticky; bottom: 0; z-index: 2; padding: 12px 0; background: var(--c-bg); border-top: 1px solid var(--c-border); display: flex; align-items: center; gap: 14px; }
.check-grid { border: 0; padding: 0; margin: 14px 0 0; }
.check-grid legend { font-weight: 600; padding: 0; margin-bottom: 2px; }
.check-grid .field-check { display: inline-flex; margin: 0 18px 6px 0; }
.se-preview { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius); background: #0e0e0e; }
.se-preview iframe { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 0; transform-origin: 0 0; pointer-events: none; }
.se-preview.is-scaled iframe { width: 1920px; height: 1080px; }
.control-actions { margin-top: 12px; }
@media (max-width: 1280px) {
  .screen-editor { grid-template-columns: minmax(0, 1fr); }
  .se-aside { position: static; max-height: none; overflow: visible; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
}
@media (max-width: 1100px) {
  .screens-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Muut ---------- */
.tournament-card { display: flex; flex-direction: column; gap: 6px; }
.tournament-card h3 { margin: 0; }
.tournament-card .dates { color: var(--c-muted); }
.checklist { list-style: none; padding: 0; margin: 8px 0; }
.checklist li { padding: 4px 0 4px 26px; position: relative; }
.checklist li::before { content: "○"; position: absolute; left: 4px; color: var(--c-muted); }
.checklist li.done::before { content: "●"; color: var(--c-ok); }
.checklist li.missing::before { content: "!"; color: var(--c-error); font-weight: 700; }
.transition { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--c-border); border-radius: var(--radius-lg); margin-bottom: 10px; background: var(--c-surface); }
.line-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; border: 0; padding: 0; margin: 0 0 8px; }
.line-row .field { flex: 1 1 160px; margin-bottom: 0; }
.mail-frame { width: 100%; min-height: 360px; border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff; }
.mail-text { white-space: pre-wrap; font-family: inherit; max-width: var(--measure); }
.mail-attachments { display: flex; gap: 8px; flex-wrap: wrap; }
.diploma-preview { max-width: 100%; border: 1px solid var(--c-border); border-radius: var(--radius); background: #fff; }
.register-form .card { margin-bottom: 18px; }
.register-form .repeat-item { margin-bottom: 12px; }

/* ---------- Tulostus ---------- */
@media print {
  .topbar, .sidebar, .footer, .actions, .subnav, .tabs, .btn, form, .theme-toggle { display: none !important; }
  .content { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; color: #000; }
}

/* ---------- Responsiivisuus ---------- */
@media (max-width: 960px) {
  .shell-admin { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; border-right: 0; border-bottom: 1px solid var(--c-border); padding: 0; position: static; max-height: none; min-height: 0; overflow: visible; }
  .sidebar nav ul { display: flex; flex-wrap: nowrap; gap: 0; padding: 0 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .sidebar nav ul::-webkit-scrollbar { display: none; }
  .sidebar li { flex: 0 0 auto; }
  .sidebar li a { padding: 10px 10px; border-left: 0; border-bottom: 3px solid transparent; font-size: 0.875rem; white-space: nowrap; }
  .nav-two-line { display: inline; line-height: inherit; }
  .nav-two-line .nav-sub { padding-left: 0; }
  .sidebar li a[aria-current="page"] { border-bottom-color: var(--c-brand); background: none; }
  .sidebar:has(.tournament-nav) > nav:first-child:not(.tournament-nav) a[aria-current="page"] { border-bottom-color: transparent; }
  .tournament-nav { margin-top: 0; padding-top: 0; border-top: 1px solid var(--c-border); }
  .tournament-nav:first-child { border-top: 0; }
  .tournament-nav h2 { padding: 8px 16px 0; font-size: 0.75rem; }
  .shell-admin .content { padding: 20px 16px 48px; }
}
@media (max-width: 640px) {
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .brand { min-width: 112px; gap: 10px; }
  .topbar .brand-context { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; font-size: 0.8125rem; line-height: 1.2; padding-left: 10px; }
  .brand .wordmark { height: 16px; }
  .topnav { gap: 0; font-size: 0.875rem; }
  .topnav > a, .topnav button.link { padding: 6px 8px; }
  .user-menu { padding-left: 6px; }
  .user-menu > summary { padding: 3px 4px; gap: 4px; }
  .user-menu .who { display: none; }
  .user-menu .user-initials { display: inline-flex; }
  h1 { font-size: 1.375rem; }
  .card-body { padding: 14px 16px; }
  .card-header { padding: 10px 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .match-row { grid-template-columns: 3rem 1fr auto 1fr; font-size: 0.875rem; gap: 6px; }
  .definition { grid-template-columns: 1fr; gap: 2px 0; }
  .definition dd { margin-bottom: 8px; }
  .form-actions .btn { width: 100%; }
  .page-header-row { align-items: flex-start; }
}

/* Hallinta: perusnäkymät */
/* Perussääntö `input:not(...)×4` on spesifimpi kuin tyyppikohtaiset leveydet; sama spesifisyys myöhemmin voittaa. */
.field input[type="number"]:not([type="text"]):not([type="search"]) { max-width: 12rem; }
.field input[type="date"]:not([type="text"]):not([type="search"]),
.field input[type="time"]:not([type="text"]):not([type="search"]) { max-width: 14rem; }
.field input[type="datetime-local"]:not([type="text"]):not([type="search"]) { max-width: 18rem; }
.form-row .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) { max-width: 100%; }
.form-narrow { max-width: 32rem; }
.form-narrow .form-row .field { flex: 1 1 140px; }
ul.links { list-style: none; padding: 0; margin: 0; }
.checklist li.done { color: var(--c-text-2); }
.checklist li .fix { margin-left: 8px; font-size: 0.875rem; white-space: nowrap; }
.next-step .card-body > p:first-child { font-size: 1rem; }
.transition-secondary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--c-border); }
.transition-secondary .muted { margin-right: 4px; }
.order-cell { white-space: nowrap; }
.order-cell .btn { padding: 2px 7px; min-height: 26px; font-size: 0.8125rem; line-height: 1; }
.order-cell .num { display: inline-block; min-width: 1.5rem; }
.audit-table td.detail { min-width: 16rem; max-width: 30rem; }
.table td.actions-cell { white-space: nowrap; }
.table td.actions-cell .actions { flex-wrap: nowrap; }
.audit-table td.detail code { white-space: pre-wrap; word-break: break-word; }
.audit-table td.target small { display: block; font-size: 0.75rem; }
.audit-table td.nowrap code { white-space: nowrap; }
.audit-table td.target { min-width: 9rem; }
.audit-target-type { display: block; font-size: 0.75rem; color: var(--c-muted); }
.audit-target-name { font-weight: 500; overflow-wrap: anywhere; }
.audit-detail { display: grid; gap: 3px; margin: 0; }
.audit-detail > div { display: flex; flex-wrap: wrap; gap: 0 6px; }
.audit-detail dt { color: var(--c-muted); font-weight: 500; }
.audit-detail dt::after { content: ":"; }
.audit-detail dd { margin: 0; overflow-wrap: anywhere; }
.official-row { padding: 12px 0; border-top: 1px solid var(--c-border); }
.official-row:first-of-type { border-top: 0; padding-top: 0; }
.official-row h3 { margin-bottom: 8px; }
.official-row .pill-list .field-check { margin-bottom: 0; }
.official-row .form-actions { margin-top: 10px; }
.definition-actions { margin-top: 8px; }
@media (max-width: 640px) {
  .page-header .actions .badge { align-self: center; }
  .transition-secondary form, .transition-secondary .btn { width: 100%; }
}

/* Julkiset sivut */
.brand-center { display: flex; justify-content: center; margin: 4px 0 20px; }
.tournament-list { list-style: none; padding: 0; margin: 0; }
.tournament-list > li { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--c-border); }
.tournament-list > li:first-child { border-top: 0; padding-top: 0; }
.tournament-list > li:last-child { padding-bottom: 0; }
.tournament-list .tournament-card { flex: 1 1 320px; gap: 4px; }
.tournament-list .tournament-card h3 { font-size: 1.0625rem; }
.tournament-list .tournament-card .status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.tournament-list .tournament-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px; }
/* QR-käynnin vaihtoehdot (`/?qr`): korostettu rivi ulottuu tekstin ohi, joten erotinviivat jäävät pois sen ympäriltä. */
.tournament-list > li.is-highlight { background: var(--c-primary-soft); box-shadow: inset 4px 0 0 var(--c-brand); border-radius: var(--radius); margin: 0 -12px; padding: 12px 12px 12px 16px; }
.tournament-list > li.is-highlight, .tournament-list > li.is-highlight + li { border-top-color: transparent; }
.tournament-list > li.is-highlight + li.is-highlight { margin-top: 8px; }
.fixture { display: grid; grid-template-columns: 7rem minmax(0, 1fr) auto minmax(0, 1fr); gap: 4px 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.fixture:last-child { border-bottom: 0; }
/* Peliryhmän tauko tai siirtymä kahden ottelun välissä: matalampi ja hillitympi kuin ottelurivi. */
.fixture-gap { padding: 4px 0; font-size: 0.8125rem; line-height: 1.4; color: var(--c-muted); border-bottom: 1px solid var(--c-border); }
.fixture-gap a { font-weight: 500; }
.fixture .fixture-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: 0.8125rem; color: var(--c-muted); }
/* Pitkä kentän nimi: lyhenne työpöydän kapeassa aikasarakkeessa, koko nimi puhelimen leveällä rivillä (FieldLink). */
.fixture .field-name-full { display: none; }
@media (max-width: 640px) {
  .fixture .field-name-full { display: inline; }
  .fixture .field-name-short { display: none; }
}
.fixture .fixture-meta .time { color: var(--c-text); font-weight: 600; font-size: 0.9375rem; white-space: nowrap; }
.fixture .team { min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.fixture .team.home { text-align: right; }
.fixture .team a { color: var(--c-text); font-weight: 500; }
.fixture .team .placeholder { color: var(--c-muted); }
.fixture .fixture-score { text-align: center; min-width: 4rem; display: flex; flex-direction: column; align-items: center; gap: 0; }
.fixture .fixture-score .score { font-weight: 700; font-size: 1.25rem; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fixture[data-state="scheduled"] .fixture-score .score { color: var(--c-muted); font-weight: 500; }
.fixture .fixture-score .status { font-size: 0.75rem; color: var(--c-muted); white-space: nowrap; }
.fixture .fixture-score .status.live { color: var(--c-live); font-weight: 700; }
.fixture .badge-live { font-size: 0.6875rem; padding: 1px 7px; }
.fixture .team .logo-sm { width: 20px; height: 20px; margin: 0 6px 0 0; }
.fixture .team.home .logo-sm { margin: 0 0 0 6px; }
.card-body > .day-heading:first-child, .card-body > .fixture-group:first-child > .day-heading { margin-top: 0; }
.day-heading { font-size: 0.9375rem; }
.fixture-group + .fixture-group .day-heading { margin-top: 24px; }
.standings-table td.team-cell a { font-weight: 500; }
.standings-table td.pts { font-weight: 700; }
.rules-table .table th, .rules-table .table td { white-space: nowrap; }
.rules-table .table td.ranking { white-space: normal; min-width: 16rem; }
.rules-table .table td.ranking ol { margin: 0; padding-left: 1.1rem; }
.form-narrow { max-width: 44rem; }
.form-narrow input:not([type="checkbox"]):not([type="radio"]), .form-narrow select, .form-narrow textarea { max-width: 100%; }
.register-form .repeat-item { padding-right: 16px; }
.register-form .repeat-item .repeat-remove { top: -4px; }
.register-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 16px; padding: 0; list-style: none; }
.register-facts li { display: flex; gap: 6px; align-items: baseline; }
.register-facts .label { color: var(--c-muted); font-size: 0.8125rem; }
.auth-card { max-width: 30rem; margin: 0 auto; }
.auth-card .field input { max-width: 100%; }
.auth-card .form-actions .btn { flex: 1 1 auto; }
.login-code input { font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.centered { text-align: center; }
.centered p { margin-left: auto; margin-right: auto; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--c-border); }
.todo-list li:first-child { border-top: 0; padding-top: 0; }
.todo-list li::before { content: "○"; color: var(--c-muted); flex: 0 0 auto; }
.todo-list li.done::before { content: "●"; color: var(--c-ok); }
.todo-list li.done { color: var(--c-muted); }
.todo-list li .todo-text { flex: 1 1 auto; }
.todo-list li a { white-space: nowrap; }
.prose-policy h3 { margin-top: 1.2em; font-size: 0.9375rem; }
.prose-policy h3:first-child { margin-top: 0; }
.error-page .emblem-pair { margin-bottom: 12px; }
.error-page .error-code { font-size: 0.8125rem; font-weight: 600; color: var(--c-muted); letter-spacing: 0.04em; margin: 0 auto 4px; }
.error-page h1 { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.015em; margin-bottom: 20px; }
.page-header .actions .btn { white-space: nowrap; }
.filters .filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.filters select { min-width: 12rem; }
.filters .field-check { flex: 0 1 auto; max-width: none; flex-wrap: wrap; row-gap: 2px; align-self: flex-end; }
.filters .field-check label { white-space: nowrap; }
.filters .field-check .help { padding-left: 26px; }
.player-table td.num { width: 3.5rem; }
.public-tabs { margin-bottom: 8px; }
.public-tabs + .public-tabs { margin-bottom: 18px; }
@media (max-width: 640px) {
  .fixture { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "meta meta" "home score" "away score"; gap: 2px 12px; padding: 10px 0; }
  .fixture .fixture-meta { grid-area: meta; flex-direction: row; flex-wrap: wrap; gap: 0 8px; align-items: baseline; margin-bottom: 2px; }
  .fixture .team.home { grid-area: home; text-align: left; }
  .fixture .team.away { grid-area: away; }
  .fixture .team.home .logo-sm { margin: 0 6px 0 0; }
  .fixture .fixture-score { grid-area: score; align-self: center; align-items: flex-end; min-width: 0; }
  .tournament-list .tournament-actions { width: 100%; }
  .tournament-list .tournament-actions .btn { flex: 1 1 0; }
  .register-facts { flex-direction: column; gap: 4px; }
  .filters .field, .filters select { max-width: 100%; width: 100%; }
}

/* Hallinta: ilmoittautumiset, laskutus, posti, diplomit */
.stats-3 { max-width: 720px; }
.grid-2 > .grid-span { grid-column: 1 / -1; }
.grid > div > .card:last-child { margin-bottom: 0; }
.table tr.row-alert td { background: var(--c-warn-bg); }
.table td.contact-cell { min-width: 14rem; overflow-wrap: break-word; }
.table .pill-list { gap: 4px; }
.table .pill-list li { white-space: normal; border-radius: 6px; line-height: 1.35; padding: 3px 8px; }
.table .pill-list li.nowrap { white-space: nowrap; }
.table .pill-list li.muted { text-decoration: line-through; }
.people-list { list-style: none; padding: 0; margin: 0; }
.people-list li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.people-list li:last-child { border-bottom: 0; }
.people-list li > span { min-width: 0; overflow-wrap: anywhere; }
.plain-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { padding: 2px 0; }
.squad-danger { margin: 4px 0 8px; }
form.plain fieldset .form-row .field { flex-basis: 200px; }
/* Lasku: tila ja avoin summa ensin */
.invoice-stats .stat-value .badge { font-size: 0.9375rem; padding: 4px 12px; }
.lines-table tr.total-row th, .lines-table tr.total-row td { border-top: 2px solid var(--c-border-strong); border-bottom: 0; background: var(--c-surface); }
.lines-table tr.total-row th { text-align: right; color: var(--c-text); font-size: 0.9375rem; }
.invoice-edit textarea { max-width: 32rem; }
.invoice-edit .line-row { flex-direction: column; gap: 0; border: 1px solid var(--c-border); border-radius: var(--radius); padding: 10px 12px 0; margin-bottom: 10px; }
.invoice-edit .line-row legend { font-size: 0.8125rem; color: var(--c-muted); font-weight: 600; }
.invoice-edit .line-row .form-row { width: 100%; }
.invoice-edit .line-row .form-row .field { margin-bottom: 10px; }
.invoice-edit .line-desc { flex: 3 1 240px; }
.invoice-edit .line-qty { flex: 0 1 7rem; }
.invoice-edit .line-unit { flex: 0 1 10rem; }
.invoice-edit .line-qty input, .invoice-edit .line-unit input { max-width: 100%; }
/* Posti */
.mail-list td.mail-subject { min-width: 16rem; }
.mail-list td.mail-counterpart { max-width: 22rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-message.mail-inbound { border-left: 4px solid var(--c-primary); }
.mail-message .definition-compact { gap: 4px 16px; margin-bottom: 12px; font-size: 0.875rem; }
.mail-frame-text { min-height: 200px; }
.mail-form textarea { max-width: 40rem; }
.mail-thread-forms .card-body p.muted { margin-bottom: 12px; }
/* Diplomit */
.diploma-preview-wrap { border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.diploma-preview-wrap svg { display: block; width: 100%; height: auto; }
.diploma-editor input[type="color"] { min-width: 56px; }
.diploma-merged { border-top: 1px solid var(--c-border); padding-top: 14px; }
.diploma-merged h3 { margin-bottom: 4px; }
@media (max-width: 640px) {
  .mail-list thead { display: none; }
  .mail-list tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
  .mail-list td { display: block; border: 0; padding: 2px 0; }
  .mail-list td.mail-counterpart { max-width: 100%; color: var(--c-muted); font-size: 0.875rem; }
  .mail-list td.date { color: var(--c-muted); font-size: 0.875rem; }
  .mail-list tbody tr:hover td { background: transparent; }
  .invoice-stats .stat { padding: 10px 12px; }
  .people-list li { flex-direction: column; align-items: flex-start; gap: 4px; }
  .table .pill-list li { white-space: normal; }
}
.standings-table td:first-child { min-width: 0; width: 2.25rem; }
.standings-table td.team-cell { white-space: nowrap; min-width: 12rem; }
.rules-table .table td.ranking { min-width: 24rem; }
.rules-table .table th[scope="row"] { color: var(--c-text); font-size: inherit; }
.rules-table .table tbody tr:last-child td { border-bottom: 1px solid var(--c-border); }
.fixture-group > h2.day-heading, h2.day-heading { font-size: 1.0625rem; margin: 24px 0 12px; }
.auth-card-wide { max-width: 40rem; }
.todo-list li.optional .todo-text { color: var(--c-text-2); }
.form-inline .field { flex: 1 1 200px; }
.form-inline .btn { margin-bottom: 0; }
.error-page .card-actions { justify-content: center; }
.page-header h1, .error-page h1 { overflow-wrap: anywhere; }
.field-check .error { flex-basis: 100%; }
/* Ottelumuodon valinta (tasoryhmä): valintakortit; valitun muodon lisäkenttä näkyy. */
fieldset.format-options { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 8px; }
fieldset.format-options > legend { padding: 0; margin-bottom: 6px; font-size: 0.875rem; }
.format-option { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 10px 12px; background: var(--c-surface); }
.format-option:has(> .field-check input:checked) { border-color: var(--c-border-strong); background: var(--c-primary-soft); box-shadow: inset 3px 0 0 var(--c-brand); }
.format-option > .field-check { margin-bottom: 0; }
.format-detail { margin: 10px 0 0 26px; }
.format-detail .field { max-width: 240px; margin-bottom: 6px; }
.format-detail .match-summary { margin: 0; font-variant-numeric: tabular-nums; }
.format-option:not(:has(> .field-check input:checked)) > .format-detail { display: none; }
.portal-squads td:first-child { white-space: nowrap; }
.portal-squads td:first-child { white-space: normal; }
.register-form .field-check, .form-narrow .field-check { flex-wrap: wrap; }
.register-form .field-check label, .form-narrow .field-check label { flex: 1 1 0; }
@media (max-width: 640px) {
  body.variant-public .page-header h1, .error-page h1 { font-size: 1.375rem; }
}

/* Hallinta: aikataulu, toimisto, laitteet, näytöt, sisältö */
/* Vaiheet: linkki perii värin, valmis vaihe himmeä, aktiivinen korostettu. */
.steps .step a { color: var(--c-text-2); }
.steps .step a:hover { text-decoration: none; color: var(--c-text); }
.steps .step.is-active { border-color: var(--c-primary); background: var(--c-primary-soft); }
.steps .step.is-active a { color: var(--c-text); font-weight: 600; }
.steps .step.done:not(.is-active)::before { content: "✓"; }
.page-header .actions .badge { align-self: center; }
/* Tuomiokortti: väri kertoo tilan, otsikko lukee ensin. */
.verdict .verdict-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.verdict .verdict-title { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.01em; }
.table td.desc { min-width: 16rem; }
.table td.wide { min-width: 14rem; }
.verdict .actions { margin-top: 12px; }
.verdict-ok { border-color: var(--c-ok); }
.verdict-error { border-color: var(--c-error); }
.verdict-warn { border-color: var(--c-warn); }
.verdict-info { border-color: var(--c-border-strong); }
/* Ottelut rikkomus- ja erolistoissa: yksi ottelu per rivi, tunnus vain varalla. */
.match-keys { list-style: none; padding: 0; margin: 0; }
.match-keys li { padding: 1px 0; }
.match-keys code { font-size: 0.75rem; overflow-wrap: anywhere; }
.violation-list { list-style: none; padding: 0; margin: 0; }
.violation-list > li { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.violation-list > li:last-child { border-bottom: 0; }
.violation-list .badge { margin-right: 6px; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: 2px 0; }
.form-inline .btn-link { align-self: center; }
.pairing-edit .field { flex: 1 1 160px; }
.pairing-edit select { max-width: 16rem; }
.table td.actions-cell .pairing-edit { text-align: left; }
/* Aikatauluedittori: ruudukko luettavaksi, suljetut ja poissuljetut ruudut merkitty, selite. */
.schedule-grid-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; }
.schedule-grid { font-size: 0.8125rem; }
.schedule-grid .cell { padding: 4px 8px; min-height: 0; }
.schedule-grid .head { font-weight: 600; color: var(--c-text); padding: 8px; }
.schedule-grid .time { color: var(--c-muted); font-variant-numeric: tabular-nums; padding-top: 6px; }
.schedule-grid .cell.closed { background: var(--c-surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--c-border) 6px 7px); }
.schedule-grid .cell.blackout { background: var(--c-warn-bg); background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c-warn) 45%, transparent) 6px 7px); }
.schedule-grid .match { background: var(--c-primary-soft); border: 1px solid color-mix(in srgb, var(--c-primary) 35%, transparent); border-left: 4px solid var(--c-primary); border-radius: 4px; padding: 4px 8px; display: flex; flex-direction: column; justify-content: center; gap: 1px; line-height: 1.25; color: var(--c-text); }
.schedule-grid .match .match-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-grid .match .match-meta { color: var(--c-text-2); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schedule-grid .match.locked { background: var(--c-surface-2); border-left-color: var(--c-muted); border-color: var(--c-border-strong); opacity: 1; }
.schedule-grid .match.locked .match-title::before { content: "🔒 "; font-size: 0.75rem; }
.schedule-grid .match.hard { outline: 2px solid var(--c-error); outline-offset: -2px; background: var(--c-error-bg); border-left-color: var(--c-error); }
.schedule-grid .match.soft { outline: 2px solid var(--c-warn); outline-offset: -2px; background: var(--c-warn-bg); border-left-color: var(--c-warn); }
.schedule-grid .match:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.schedule-grid .match[draggable="true"]:hover { box-shadow: var(--shadow-1); }
.editor-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 0 0 12px; font-size: 0.8125rem; color: var(--c-text-2); }
.editor-legend li { display: inline-flex; align-items: center; gap: 8px; }
.editor-legend .swatch { display: inline-block; width: 22px; height: 16px; border-radius: 3px; border: 1px solid var(--c-border-strong); background: var(--c-surface); }
.editor-legend .swatch.match { background: var(--c-primary-soft); border-color: color-mix(in srgb, var(--c-primary) 35%, transparent); border-left: 3px solid var(--c-primary); }
.editor-legend .swatch.locked { background: var(--c-surface-2); border-left-color: var(--c-muted); }
.editor-legend .swatch.hard { background: var(--c-error-bg); border-left-color: var(--c-error); outline: 2px solid var(--c-error); outline-offset: -2px; }
.editor-legend .swatch.soft { background: var(--c-warn-bg); border-left-color: var(--c-warn); outline: 2px solid var(--c-warn); outline-offset: -2px; }
.editor-legend .swatch.closed { background: var(--c-surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 4px, var(--c-border-strong) 4px 5px); }
.editor-legend .swatch.blackout { background: var(--c-warn-bg); background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--c-warn) 45%, transparent) 4px 5px); }
#editor-status:empty { display: none; }
/* Turnaustoimisto: käynnissä olevat ensin, rivit skannattaviksi. */
.live-list { gap: 0; list-style: none; padding: 0; margin: 0; }
.live-row { border-bottom: 1px solid var(--c-border); }
.live-row:last-child { border-bottom: 0; }
.live-link { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "field teams score" "field teams clock"; gap: 2px 14px; align-items: center; padding: 10px 0; color: inherit; }
.live-link:hover { text-decoration: none; background: var(--c-surface-2); }
.live-field { grid-area: field; font-weight: 600; color: var(--c-text-2); white-space: nowrap; }
.live-teams { grid-area: teams; font-weight: 600; }
/* Peliaika omalla rivillään tuloksen alla. */
.live-clock { grid-area: clock; justify-self: center; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.live-score { grid-area: score; justify-self: center; font-weight: 800; font-size: 1.75rem; line-height: 1; }
.card-warn { border-color: var(--c-warn); }
.alert-group h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.score-line { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 8px 0 12px; }
.score-line .score-side { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.score-line .score-side:last-child { text-align: right; }
.score-line .big-score { font-size: 2.75rem; }
.table tr.corrected td { color: var(--c-muted); text-decoration: line-through; }
.table tr.corrected td .badge { text-decoration: none; }
/* Kirjaus: yhdellä kädellä puhelimessa. */
.scorer { padding: 0 0 48px; }
.scorer-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 0 10px; }
.scorer-top .btn-link { padding-left: 0; }
.scorer-meta { font-size: 0.875rem; }
.scorer .scoreboard { gap: 8px; padding: 14px 12px; }
.scorer .scoreboard .side { min-width: 0; }
.scorer .scoreboard .name { font-size: 0.9375rem; line-height: 1.25; }
.scorer .scoreboard .big { font-size: 3.5rem; margin-top: 4px; }
.scorer .scoreboard .middle { min-width: 5.5rem; }
.scorer .scoreboard .clock { font-size: 1.75rem; margin: 0; font-variant-numeric: tabular-nums; }
.scorer .scoreboard .period { color: var(--c-muted); font-size: 0.8125rem; margin-top: 2px; }
.scorer-status { text-align: center; font-size: 0.875rem; margin: 8px 0 4px; min-height: 1.4em; }
.scorer-status.error { color: var(--c-error); font-weight: 600; }
.scorer .controls { gap: 10px; }
.scorer .controls .wide { grid-column: 1 / -1; }
.scorer .controls .btn { min-height: 52px; white-space: normal; line-height: 1.2; }
.scorer .controls .goal-btn { min-height: 76px; font-size: 1.375rem; }
.scorer .controls .undo-btn { border-style: dashed; }
.scorer .controls .final-btn { margin-top: 6px; }
.scorer .controls .more-btn { min-height: 40px; }
.scorer .controls .more-btn.is-open { color: var(--c-text-2); }
.scorer .controls .card-yellow { border-color: var(--c-warn); color: var(--c-warn); }
.scorer .controls .scorer-note { text-align: center; margin: 4px 0; }
.scorer-picker { margin: 12px 0; padding: 12px; border: 1px solid var(--c-primary); border-radius: var(--radius-lg); background: var(--c-surface); }
.scorer-picker h3 { margin-bottom: 8px; }
.scorer-events-title { font-size: 0.9375rem; color: var(--c-muted); margin: 20px 0 4px; }
.scorer .event-list li.muted { justify-content: center; border-bottom: 0; }
/* Laitteet ja näytöt */
.enrollment-code { font-size: 2.75rem; letter-spacing: 0.3em; padding: 14px 22px 14px 26px; }
.assignment-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 3px 0; }
/* Kentät: käyttöaikaparit yhdellä rivillä. */
.time-range { display: inline-flex; align-items: center; gap: 6px; }
.time-range input[type="time"] { width: 7.5rem; min-width: 7.5rem; }
/* Asetuslomake: kortit kapeina, jotta rivit eivät veny koko leveydelle. */
.form-narrow-cards .card { max-width: 52rem; }
.form-narrow-cards .form-row .field { flex: 1 1 200px; max-width: 20rem; }
@media (max-width: 640px) {
  .steps { gap: 6px; }
  .steps .step { font-size: 0.8125rem; padding: 4px 10px 4px 4px; }
  .live-link { grid-template-columns: 1fr auto; grid-template-areas: "field score" "teams clock"; }
  .score-line .big-score { font-size: 2.25rem; }
  .scorer .scoreboard .big { font-size: 3rem; }
  .scorer .scoreboard .clock { font-size: 1.5rem; }
  .schedule-grid-wrap { margin: 0 -16px; padding: 0 16px 4px; }
  .enrollment-code { font-size: 2rem; letter-spacing: 0.22em; padding: 12px 16px 12px 20px; }
}

/* Aikataulutus: yleiskuva */
/* Tasoryhmien paletti (8 väriä): vaalealla kylläiset, tummalla vaaleammat; lohkon tausta sekoitetaan pintaan. */
:root {
  --div-1: #2f5fd6;
  --div-2: #1f8a4c;
  --div-3: #d9740a;
  --div-4: #7b4bc9;
  --div-5: #0f8f96;
  --div-6: #c93a8a;
  --div-7: #8a6a12;
  --div-8: #5b6b7f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --div-1: #7fa3ff;
    --div-2: #62cf8f;
    --div-3: #ffb060;
    --div-4: #b993ff;
    --div-5: #5fd2d8;
    --div-6: #ff8fcc;
    --div-7: #d9b84a;
    --div-8: #a7b6c8;
  }
}
:root[data-theme="dark"] {
  --div-1: #7fa3ff;
  --div-2: #62cf8f;
  --div-3: #ffb060;
  --div-4: #b993ff;
  --div-5: #5fd2d8;
  --div-6: #ff8fcc;
  --div-7: #d9b84a;
  --div-8: #a7b6c8;
}
.div-c1 { --div: var(--div-1); }
.div-c2 { --div: var(--div-2); }
.div-c3 { --div: var(--div-3); }
.div-c4 { --div: var(--div-4); }
.div-c5 { --div: var(--div-5); }
.div-c6 { --div: var(--div-6); }
.div-c7 { --div: var(--div-7); }
.div-c8 { --div: var(--div-8); }
.swatch { display: inline-block; width: 16px; height: 14px; border-radius: 3px; box-sizing: border-box; vertical-align: -2px; background: color-mix(in srgb, var(--div, var(--c-muted)) 20%, var(--c-surface)); border: 1px solid color-mix(in srgb, var(--div, var(--c-muted)) 45%, transparent); border-left: 4px solid var(--div, var(--c-muted)); }
.swatch.mark-locked { background: var(--c-surface-2); border-color: var(--c-border-strong); border-left-color: var(--c-muted); }
.swatch.mark-hard { outline: 2px solid var(--c-error); outline-offset: -2px; border-left-color: var(--c-error); background: var(--c-error-bg); }
.swatch.mark-soft { outline: 2px solid var(--c-warn); outline-offset: -2px; border-left-color: var(--c-warn); background: var(--c-warn-bg); }
.swatch.mark-blackout { border-left-width: 1px; border-color: var(--c-border-strong); background: var(--c-warn-bg); background-image: repeating-linear-gradient(135deg, transparent 0 4px, color-mix(in srgb, var(--c-warn) 45%, transparent) 4px 5px); }
.swatch.mark-closed { border-left-width: 1px; border-color: var(--c-border-strong); background: var(--c-surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 4px, var(--c-border-strong) 4px 5px); }
.board-legend { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 12px; font-size: 0.8125rem; color: var(--c-text-2); }
.board-legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.board-legend-list li { display: inline-flex; align-items: center; gap: 6px; }
.board-legend-list li .swatch.mark-locked::after { content: "🔒"; font-size: 8px; display: block; line-height: 12px; text-align: center; }
/* Lauta: sarakkeet kentät, rivit ruudut; otsikot ja aikasarake pysyvät paikoillaan vieritettäessä. */
.board-wrap { min-width: 0; }
.board-day { margin-bottom: 20px; }
.board-day:last-child { margin-bottom: 0; }
.board-day-title { font-size: 0.9375rem; margin: 0 0 8px; color: var(--c-text-2); }
.board-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; }
.board { display: grid; position: relative; width: max-content; min-width: 100%; box-sizing: border-box; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); font-size: 0.8125rem; }
.board-corner, .board-head { position: sticky; top: 0; z-index: 3; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
.board-corner { left: 0; z-index: 4; border-top-left-radius: var(--radius); }
.board-head { padding: 8px 10px; font-weight: 600; color: var(--c-text); border-left: 1px solid var(--c-border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.board-time { position: sticky; left: 0; z-index: 2; background: var(--c-surface-2); color: var(--c-muted); font-variant-numeric: tabular-nums; font-size: 0.75rem; padding: 2px 6px 0 0; text-align: right; border-top: 1px solid var(--c-border); }
.board-time.hour { color: var(--c-text-2); font-weight: 600; }
.board-cell { border-left: 1px solid var(--c-border); border-top: 1px solid transparent; min-width: 0; }
.board-cell.half { border-top-color: color-mix(in srgb, var(--c-border) 60%, transparent); }
.board-cell.hour { border-top-color: var(--c-border-strong); }
.board-cell.closed { background: var(--c-surface-2); background-image: repeating-linear-gradient(135deg, transparent 0 6px, var(--c-border) 6px 7px); }
.board-cell.blackout { background: var(--c-warn-bg); background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c-warn) 45%, transparent) 6px 7px); }
.board-cell-note { display: block; font-size: 0.6875rem; color: var(--c-warn); padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.board-match { z-index: 1; margin: 1px 3px; border-radius: 4px; padding: 3px 6px; background: color-mix(in srgb, var(--div, var(--c-primary)) 16%, var(--c-surface)); border: 1px solid color-mix(in srgb, var(--div, var(--c-primary)) 45%, transparent); border-left: 4px solid var(--div, var(--c-primary)); display: flex; flex-direction: column; justify-content: flex-start; gap: 1px; line-height: 1.2; overflow: hidden; color: var(--c-text); container-type: size; min-width: 0; }
.board-match .bm-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.8125rem; }
.board-match .bm-meta { display: flex; gap: 8px; color: var(--c-text-2); font-size: 0.6875rem; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.board-match .bm-code { font-weight: 600; margin-left: auto; letter-spacing: 0.02em; }
@container (max-height: 34px) {
  .bm-meta { display: none; }
  .bm-title { font-size: 0.75rem; }
}
.board-match.locked { background: var(--c-surface-2); border-left-color: var(--c-muted); border-color: var(--c-border-strong); }
.board-match.locked .bm-title::before { content: "🔒 "; font-size: 0.6875rem; }
.board-match.hard { outline: 2px solid var(--c-error); outline-offset: -1px; }
.board-match.soft { outline: 2px solid var(--c-warn); outline-offset: -1px; }
.board-match[draggable="true"] { cursor: grab; }
.board-match[draggable="true"]:hover { box-shadow: var(--shadow-1); filter: brightness(1.02); }
.board-match:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.board-match.dragging { opacity: 0.4; }
.board-cell.drop-ok { background: var(--c-ok-bg); background-image: none; }
.board-cell.drop-bad { background: var(--c-error-bg); background-image: none; }
.drag-hint { position: fixed; z-index: 50; pointer-events: none; background: var(--c-primary); color: var(--c-primary-ink); padding: 4px 10px; border-radius: 4px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow-2); }
.drag-hint.bad { background: var(--c-error-bg); color: var(--c-error); border: 1px solid var(--c-error); }
.drag-hint[hidden] { display: none; }
/* Editori: tyhjän ruudun napsautus lisää ottelun, ottelun napsautus avaa muokkauksen. */
.board-wrap[data-editable="1"] .board-cell[data-droppable="1"] { cursor: pointer; position: relative; }
.board-wrap[data-editable="1"] .board-cell[data-droppable="1"]:hover { background: color-mix(in srgb, var(--c-link) 9%, transparent); }
.board-wrap[data-editable="1"] .board-cell[data-droppable="1"]:hover::after { content: "+"; position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-weight: 700; font-size: 0.875rem; line-height: 1; color: var(--c-link); pointer-events: none; }
.board-wrap[data-editable="1"] .board-match { cursor: pointer; }
/* Päällekkäiset ottelut samalla kentällä rinnakkain (kaistat), jotta kumpikin näkyy ja on napsautettavissa. */
.board-match.in-lane { justify-self: start; width: calc((100% - 6px) / var(--lanes) - 2px); margin-left: calc(3px + (100% - 6px) / var(--lanes) * var(--lane)); margin-right: 0; }
.board-match.double { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c-error) 16%, transparent) 6px 9px); }
.bm-flag { display: inline-block; margin-right: 4px; padding: 0 4px; border-radius: 3px; background: var(--c-error); color: var(--c-surface); font-size: 0.6875rem; font-weight: 700; line-height: 1.35; letter-spacing: 0.02em; vertical-align: 1px; }
.board-legend .bm-flag { margin-right: 0; }
.board-match.just-changed { animation: just-changed 1.6s ease-out; }
@keyframes just-changed {
  0%, 30% { box-shadow: 0 0 0 3px var(--c-brand), var(--shadow-2); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .board-match.just-changed { animation: none; box-shadow: 0 0 0 3px var(--c-brand); }
}

/* Ottelulomake (lisää / muokkaa) */
dialog.match-dialog { max-width: min(680px, calc(100vw - 24px)); }
.modal-footer { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--c-border); background: var(--c-surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-footer-spacer { flex: 1 1 auto; }
.match-dialog .modal-footer { position: sticky; bottom: 0; z-index: 2; }
.md-head { min-width: 0; }
.md-sub { margin: 2px 0 0; color: var(--c-text-2); font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.match-dialog .modal-body { max-height: none; overflow: visible; padding-bottom: 12px; }
.md-when { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.md-when .field { margin-bottom: 12px; }
.md-when .field[hidden] { display: none; }
.md-when select { max-width: 100%; }
.md-issues { margin: 0 0 12px; }
.md-issues h3 { font-size: 0.8125rem; margin: 0 0 6px; color: var(--c-text-2); }
.md-issues ul, .md-warnings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.md-warnings:empty { display: none; }
.md-warnings { margin-top: 12px; }
.md-warning { padding: 7px 10px 7px 30px; border-radius: var(--radius); font-size: 0.8125rem; line-height: 1.35; position: relative; border: 1px solid transparent; }
.md-warning::before { position: absolute; left: 10px; top: 7px; font-weight: 700; }
.md-warning-error { background: var(--c-error-bg); color: var(--c-error); border-color: color-mix(in srgb, var(--c-error) 30%, transparent); }
.md-warning-error::before { content: "!"; }
.md-warning-warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: color-mix(in srgb, var(--c-warn) 30%, transparent); }
.md-warning-warn::before { content: "i"; font-style: italic; font-family: Georgia, serif; }
.md-sides { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: stretch; margin: 0 0 12px; padding: 0; border: 0; min-width: 0; }
.md-side { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; text-align: left; font: inherit; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); padding: 8px 12px; cursor: pointer; }
.md-side:hover { border-color: var(--c-text-2); }
.md-side[aria-pressed="true"] { border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary); background: var(--c-primary-soft); }
.md-side:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.md-side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-width: 0; }
.md-side-label { font-size: 0.75rem; font-weight: 600; color: var(--c-text-2); }
.md-side-level { display: inline-flex; align-items: center; gap: 5px; min-width: 0; font-size: 0.75rem; font-weight: 600; color: var(--c-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-side-level:empty { display: none; }
.md-side-level .swatch { width: 12px; height: 11px; flex: 0 0 auto; }
.md-side-team { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-side.is-empty .md-side-team { color: var(--c-muted); font-weight: 500; }
.md-side-team.is-placeholder { font-style: italic; font-weight: 500; }
.md-side-status { font-size: 0.75rem; min-height: 1em; }
.md-side-status[data-level="free"], .md-team[data-level="free"] .md-team-status { color: var(--c-ok); }
.md-side-status[data-level="tight"], .md-team[data-level="tight"] .md-team-status { color: var(--c-warn); }
.md-side-status[data-level="busy"], .md-team[data-level="busy"] .md-team-status { color: var(--c-error); }
.md-swap { align-self: center; font: inherit; font-size: 1.125rem; line-height: 1; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text-2); cursor: pointer; }
.md-swap:hover { background: var(--c-surface-2); color: var(--c-text); }
.md-side:disabled, .md-swap:disabled { cursor: default; opacity: 0.7; }
.md-search-row { display: flex; align-items: center; gap: 12px; }
.md-search-row input[type="search"] { flex: 1 1 auto; max-width: none; }
.md-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; white-space: nowrap; cursor: pointer; }
.md-toggle[hidden] { display: none; }
.md-toggle input { width: 16px; height: 16px; margin: 0; }
.md-other-levels { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; margin: 6px 0 0; font-size: 0.8125rem; color: var(--c-text-2); }
.md-other-levels[hidden] { display: none; }
.md-other-levels .btn-link { padding: 2px 4px; }
.md-pick-help { margin: 6px 0 8px; color: var(--c-muted); font-size: 0.8125rem; }
.md-list { max-height: min(40vh, 360px); overflow: auto; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); overscroll-behavior: contain; }
.md-group[hidden], .md-teams li[hidden] { display: none; }
.md-group-title { position: sticky; top: 0; z-index: 1; margin: 0; padding: 6px 12px; font-size: 0.8125rem; font-weight: 600; color: var(--c-text-2); background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: 8px; }
.md-teams { list-style: none; margin: 0; padding: 0; }
.md-teams li + li { border-top: 1px solid var(--c-border); }
.md-team { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "meta status"; align-items: center; gap: 1px 12px; width: 100%; padding: 7px 12px; font: inherit; text-align: left; color: var(--c-text); background: transparent; border: 0; cursor: pointer; }
.md-team:hover:not(:disabled) { background: var(--c-surface-2); }
.md-team:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.md-team[aria-pressed="true"] { background: var(--c-primary-soft); box-shadow: inset 4px 0 0 var(--c-primary); }
.md-team:disabled { cursor: default; color: var(--c-muted); }
.md-team-name { grid-area: name; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-team-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--c-muted); }
.md-team-status { grid-area: status; font-size: 0.8125rem; font-weight: 600; text-align: right; white-space: nowrap; }
.md-team[data-level="busy"] .md-team-name { color: var(--c-text-2); }
.md-team[data-level="selected-other"] .md-team-status { color: var(--c-muted); font-weight: 500; }
.md-chip { padding: 0 6px; border-radius: 999px; font-weight: 600; line-height: 1.5; }
.md-chip-warn { background: var(--c-warn-bg); color: var(--c-warn); }
.md-chip-error { background: var(--c-error-bg); color: var(--c-error); }
.md-nomatch { margin: 0; padding: 12px; }
@media (max-width: 640px) {
  .match-dialog .modal-header, .match-dialog .modal-body, .modal-footer { padding-left: 14px; padding-right: 14px; }
  .md-search-row { flex-wrap: wrap; gap: 6px 12px; }
  .md-team { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "status" "meta"; }
  .md-team-status { text-align: left; white-space: normal; }
  .md-list { max-height: 42vh; }
}
/* Yleiskuva: tila, tunnusluvut, tasapaino, peliryhmätaulukko */
.overview-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.overview-status-link { margin-left: auto; font-weight: 600; white-space: nowrap; }
.overview-kpis .stat-value { font-variant-numeric: tabular-nums; }
.balance-table td:first-child { min-width: 0; }
.squad-table .group-row th { background: var(--c-surface-2); color: var(--c-text); font-size: 0.875rem; padding: 6px 12px; text-align: left; position: static; }
.squad-table td.squad-cell { min-width: 11rem; font-weight: 500; }
.squad-table td.matches-cell { white-space: nowrap; min-width: 7rem; text-align: left; }
.bar { display: inline-block; width: 64px; height: 10px; background: var(--c-surface-2); border-radius: 3px; vertical-align: middle; margin-right: 8px; overflow: hidden; border: 1px solid var(--c-border); }
.bar-fill { display: block; height: 100%; background: var(--div, var(--c-primary)); border-radius: 2px; }
.bar-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.squad-table td.rhythm-cell { min-width: 220px; width: 28%; }
.rhythm-days { display: flex; flex-direction: column; gap: 4px; }
.rhythm-row { display: flex; align-items: center; gap: 8px; }
.rhythm-day { font-size: 0.75rem; color: var(--c-muted); width: 1.75rem; flex: 0 0 auto; }
.rhythm { display: flex; height: 18px; width: 100%; min-width: 180px; background: var(--c-surface-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--c-border); box-sizing: border-box; }
.rs { display: flex; align-items: center; justify-content: center; min-width: 0; flex-basis: 0; font-size: 0.6875rem; overflow: hidden; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rs-match { background: var(--div, var(--c-primary)); }
.rs-match + .rs-match { border-left: 1px solid var(--c-surface); }
.rs-break { background: var(--c-surface); color: var(--c-text-2); }
.rs-break.long { background: var(--c-warn-bg); color: var(--c-warn); font-weight: 600; }
.rs-idle { background: transparent; }
.flag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.rhythm-priority { display: block; }
.version-tabs { margin: -4px 0 18px; }
.btn[hidden] { display: none; }
.pdf-links { gap: 8px; }
@media (max-width: 640px) {
  .board-scroll { margin: 0 -16px; padding: 0 16px 4px; }
  .squad-table td.rhythm-cell { min-width: 160px; }
  .overview-status-link { margin-left: 0; }
  .board-legend { gap: 6px 16px; }
}

/* Otteluparien eheysvirheet */
.issue-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.issue-list li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.table tr.row-issue td { background: var(--c-error-bg); }
.table tr.row-issue:hover td { background: color-mix(in srgb, var(--c-error-bg) 80%, var(--c-surface)); }

/* ---------------------------------------------------------------------------------------- Kenttäkartta */
/* SVG-kartta (src/lib/fields/map-svg.ts): värit tokeneista luokkien kautta, skaalautuu leveyteen. */
.fmap { margin: 0 auto; }
.fmap-svg { display: block; width: 100%; height: auto; font-family: var(--font); }
/* Koordinaatisto on metrejä: viivat piirretään näyttöpikseleinä, jotta ne eivät skaalaudu kartan koon mukaan.
   Säännöt on sidottu svg:n omaan luokkaan, koska editori piirtää svg:n ilman figure-kuorta. */
.fmap-svg rect, .fmap-svg line, .fmap-svg circle { vector-effect: non-scaling-stroke; }
.fmap-scale line { stroke: var(--c-muted); stroke-width: 1.5; }
.fmap-scale text { fill: var(--c-muted); font-weight: 600; }
.fmap-thumb { max-width: 380px; margin: 0 auto; }
.fmap-canvas { fill: var(--c-surface-2); }
.fmap-label { fill: var(--c-text); }
.fmap-area .fmap-box { fill: var(--c-surface-3); stroke: var(--c-border-strong); stroke-width: 2; }
.fmap-area .fmap-label { fill: var(--c-text-2); font-weight: 600; }
.fmap-service .fmap-box { fill: var(--c-surface); stroke: var(--c-border-strong); stroke-width: 2; }
.fmap-service .fmap-label { fill: var(--c-text); font-weight: 600; }
.fmap-text .fmap-label { fill: var(--c-muted); font-weight: 600; }
.fmap-field .fmap-pitch { fill: var(--c-surface); stroke: var(--c-text-2); stroke-width: 4; }
.fmap-field .fmap-pitch-line { fill: none; stroke: var(--c-border-strong); stroke-width: 3; }
.fmap-field .fmap-label-bg { fill: var(--c-surface); opacity: 0.92; }
.fmap-field .fmap-label { font-weight: 700; }
a.fmap-field { cursor: pointer; }
a.fmap-field:hover .fmap-pitch, a.fmap-field:hover .fmap-label-bg { fill: var(--c-primary-soft); }
a.fmap-field:focus { outline: none; }
a.fmap-field:focus-visible .fmap-pitch { stroke: var(--c-focus); stroke-width: 7; }
.fmap-field.is-current .fmap-pitch, .fmap-field.is-current .fmap-label-bg { fill: var(--c-primary-soft); }
.fmap-field.is-current .fmap-pitch { stroke: var(--c-accent); stroke-width: 7; }
.fmap-field.is-empty .fmap-pitch { stroke: var(--c-border-strong); stroke-dasharray: 14 10; }
.fmap-field.is-empty .fmap-label { fill: var(--c-muted); }
.field-list { list-style: none; margin: 0; padding: 0; }
.field-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.field-list li:last-child { border-bottom: 0; }
.field-list a { font-weight: 600; }
.field-list li.is-highlight { background: var(--c-primary-soft); margin: 0 -20px; padding: 10px 20px; }

/* Editori: kangas, kahvat, työkalupalkki ja sivupaneeli. */
/* Järjestys DOM:ssa: kangas, paneeli, nimilomake. Leveällä paneeli on oikealla koko korkeudelta, kapealla
   paneeli seuraa heti kangasta, jotta valitun kohteen tiedot ovat käden ulottuvilla. */
.fmap-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto auto; gap: 0 20px; align-items: start; }
.fmap-canvas-col { grid-column: 1; grid-row: 1; min-width: 0; }
.fmap-editor-layout > form { grid-column: 1; grid-row: 2; min-width: 0; }
.fmap-panel { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: calc(var(--topbar-h) + 12px); }
@media (max-width: 1100px) {
  .fmap-editor-layout { grid-template-columns: 1fr; grid-template-rows: none; }
  .fmap-canvas-col, .fmap-editor-layout > form, .fmap-panel { grid-column: auto; grid-row: auto; }
  .fmap-panel { position: static; }
}
.fmap-stage { max-width: 900px; margin: 0 auto 12px; }
.fmap-svg-editor { touch-action: none; user-select: none; -webkit-user-select: none; border-radius: var(--radius-lg); }
.fmap-svg-editor:focus { outline: none; }
.fmap-svg-editor:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.fmap-svg-editor .fmap-item { cursor: move; outline: none; }
.fmap-svg-editor .fmap-item:focus-visible .fmap-pitch, .fmap-svg-editor .fmap-item:focus-visible .fmap-box { stroke: var(--c-focus); }
.fmap-svg-editor .fmap-item.is-selected .fmap-pitch, .fmap-svg-editor .fmap-item.is-selected .fmap-box { stroke: var(--c-info); }
.fmap-outline { fill: none; stroke: var(--c-info); stroke-width: 2; stroke-dasharray: 8 6; pointer-events: none; }
.fmap-outline-group { stroke-width: 1.5; stroke-dasharray: none; }
.fmap-marquee { fill: var(--c-info); fill-opacity: 0.12; stroke: var(--c-info); stroke-width: 1.5; stroke-dasharray: 6 4; pointer-events: none; }
.fmap-svg-editor .fmap-canvas { cursor: crosshair; }
.fmap-handle { fill: var(--c-surface); stroke: var(--c-info); stroke-width: 2; }
.fmap-handle[data-handle="nw"], .fmap-handle[data-handle="se"] { cursor: nwse-resize; }
.fmap-handle[data-handle="ne"], .fmap-handle[data-handle="sw"] { cursor: nesw-resize; }
.fmap-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.fmap-toolbar-label { font-size: 0.8125rem; color: var(--c-muted); margin-right: 4px; }
.fmap-toolbar-sep { width: 1px; height: 22px; background: var(--c-border); margin: 0 6px; }
.fmap-toolbar-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--c-text-2); margin-left: 4px; }
.fmap-guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 12px 28px; margin: 4px 0 0; font-size: 0.8125rem; line-height: 1.5; color: var(--c-text-2); }
.fmap-guide > div { min-width: 0; }
.fmap-guide dt { font-weight: 600; color: var(--c-text); margin-bottom: 2px; }
.fmap-guide dd { margin: 0; }
.fmap-guide kbd { font: inherit; font-size: 0.75rem; font-weight: 600; color: var(--c-text); background: var(--c-surface); border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.fmap-dirty { font-size: 0.8125rem; align-self: center; }
.fmap-dirty::before { content: "●"; color: var(--c-warn); margin-right: 6px; }
.fmap-panel .card { margin-bottom: 16px; }
.fmap-panel [hidden], .fmap-panel .field[hidden] { display: none; }
/* Nimilapun muokkaus suoraan kartalla (kaksoisnapautus). */
.fmap-stage { position: relative; }
.fmap-inline { position: absolute; z-index: 2; box-sizing: border-box; text-align: center; font-weight: 700; font-family: var(--font); background: var(--c-surface); color: var(--c-text); border: 2px solid var(--c-info); border-radius: 6px; padding: 2px 6px; box-shadow: var(--shadow-2); outline: none; min-width: 6rem; }
.fmap-kind { margin: 0 0 10px; }
.fmap-nums { gap: 8px; flex-wrap: nowrap; }
.fmap-nums .field { flex: 1 1 0; min-width: 0; }
.fmap-nums .field label { font-size: 0.75rem; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fmap-nums input { width: 100%; }
/* Sijainti ja koko omina ryhminään. */
.fmap-group { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 8px 10px 2px; margin: 0 0 12px; min-width: 0; }
.fmap-group legend { font-size: 0.8125rem; font-weight: 600; color: var(--c-text-2); padding: 0 4px; }
.fmap-group .fmap-nums .field { margin-bottom: 8px; }
.fmap-group-help { margin: -2px 0 8px; font-size: 0.75rem; color: var(--c-muted); }
.fmap-scale-field { margin-bottom: 8px; }
.fmap-scale-field label { font-size: 0.75rem; color: var(--c-muted); }
.fmap-scale-row { display: flex; align-items: stretch; gap: 8px; }
.fmap-scale-row input { flex: 0 1 8rem; min-width: 0; }
.fmap-scale-row .btn { flex: none; }
.fmap-note { color: var(--c-text-2); }
.fmap-note:empty { margin: 0; }
.fmap-missing { color: var(--c-warn); background: var(--c-warn-bg); border-radius: var(--radius); padding: 8px 10px; font-size: 0.8125rem; margin: 0 0 10px; }
.fmap-missing[hidden] { display: none; }
.fmap-fieldlist { list-style: none; margin: 0; padding: 0; }
.fmap-fieldlist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--c-border); font-size: 0.875rem; }
.fmap-fieldlist li:last-child { border-bottom: 0; }

/* ---------- Hallinta: yksittäinen ilmoittautuminen ---------- */
/* Pääpalsta (peliryhmät, yhteystiedot) ja kapea sivupalsta (laskut, toimihenkilöt, tapahtumat, peruminen). */
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem); gap: 20px; align-items: start; }
.entry-main, .entry-aside { min-width: 0; }
.entry-main > .card:last-child { margin-bottom: 0; }
.entry-aside { display: grid; gap: 16px; }
.entry-aside > .card { margin-bottom: 0; }
/* Peliryhmätaulukko tarvitsee ~46 rem; kapeammalla sivupalsta siirtyy pääpalstan alle. */
@media (max-width: 1380px) {
  .entry-layout { grid-template-columns: minmax(0, 1fr); }
  .entry-aside { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
  .entry-aside > .card-danger { grid-column: 1 / -1; }
}
.entry-status { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.card-danger { border-color: color-mix(in srgb, var(--c-error) 35%, var(--c-border)); }
.card-danger .card-body > p { font-size: 0.875rem; }
.pre-line { white-space: pre-line; }

/* Peliryhmät: muokattava taulukko, yksi tallennus. */
.squad-table td { vertical-align: middle; }
.squad-table th, .squad-table td { padding-left: 8px; padding-right: 8px; }
.squad-table th:last-child, .squad-table td:last-child { padding-right: 4px; }
.squad-table td.sq-name { width: 40%; min-width: 12rem; }
.squad-table td.sq-division { width: 12rem; min-width: 9rem; }
.squad-table td.sq-kits, .squad-table td.sq-logo { white-space: nowrap; }
.squad-table td.sq-players { width: 4.5rem; }
.squad-table td.sq-actions { width: 1%; }
.squad-table .error { display: block; margin-top: 4px; font-size: 0.8125rem; }
.squad-table .logo-sm { margin: 0; }
.kits { display: inline-flex; gap: 10px; align-items: center; }
.kit { display: inline-flex; gap: 2px; }
.kit .kit-swatch { margin: 0; width: 14px; height: 14px; }
/* Muuttunut kenttä, uusi rivi ja peruttava rivi erottuvat ennen tallennusta. Valitsimen pitää voittaa yleinen
   input:not(…)-sääntö. */
.squad-table tbody tr td.is-changed { background: var(--c-primary-soft); }
.squad-editor .squad-table td.is-changed :is(input[name], select[name]) { border-color: var(--c-warn); }
.squad-table tbody tr.is-new td { background: var(--c-ok-bg); }
.squad-table tbody tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--c-ok); }
.squad-table tbody tr.is-withdrawing td { background: var(--c-error-bg); }
.squad-table tbody tr.is-withdrawing td:first-child { box-shadow: inset 3px 0 0 var(--c-error); }
.squad-editor .squad-table tr.is-withdrawing :is(input[name], select[name]) { text-decoration: line-through; color: var(--c-muted); opacity: 0.8; }
.squad-table tr.is-withdrawn td { color: var(--c-muted); }
.squad-table tr.is-withdrawn td.sq-name { text-decoration: line-through; }
.squad-table .squad-group th { padding-top: 18px; font-size: 0.8125rem; color: var(--c-muted); background: transparent; }
.squad-table tbody tr.squad-group:hover th { background: transparent; }
.squad-table .sq-new-note .badge { white-space: normal; }
/* Perumisvalinta on valintaruutu, joka näyttää napilta (toimii ilman JS:ää). */
.squad-withdraw { position: relative; color: var(--c-error); background: transparent; border-color: transparent; }
.squad-withdraw:hover { background: var(--c-error-bg); }
.squad-withdraw input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.squad-withdraw:has(input:focus-visible) { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.squad-withdraw .when-on { display: none; }
.squad-withdraw:has(input:checked) { color: var(--c-text); background: var(--c-surface); border-color: var(--c-border-strong); }
.squad-withdraw:has(input:checked) .when-on { display: inline; }
.squad-withdraw:has(input:checked) .when-off { display: none; }
/* Pelaajat peliryhmän alla (vain erikseen pyydettäessä). */
.squad-table tr:has(+ tr.squad-players) td { border-bottom: 0; }
.squad-table tbody tr.squad-players td, .squad-table tbody tr.squad-players:hover td { background: transparent; padding-top: 0; }
.player-list { list-style: none; margin: 0; padding: 8px 12px; columns: 13rem auto; column-gap: 24px; font-size: 0.875rem; background: var(--c-surface-2); border-radius: var(--radius); }
.player-list li { display: flex; gap: 8px; padding: 2px 0; break-inside: avoid; }
.player-list .player-no { min-width: 2.5ch; text-align: right; color: var(--c-muted); font-variant-numeric: tabular-nums; }
/* Tallennuspalkki pysyy näkyvissä pitkänkin taulukon alla. */
.squad-editor-bar { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px -20px -18px; padding: 12px 20px; background: var(--c-surface); border-top: 1px solid var(--c-border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.squad-editor-bar .squad-add { order: -1; }
.squad-editor-status { flex: 1 1 14rem; margin: 0; font-size: 0.875rem; color: var(--c-muted); max-width: none; }
.squad-editor.is-dirty .squad-editor-bar { box-shadow: 0 -8px 20px -12px rgba(0, 0, 0, 0.35); }
.squad-editor.is-dirty .squad-editor-status { color: var(--c-text); font-weight: 600; }
.squad-editor.is-dirty .squad-editor-status::before { content: "●"; color: var(--c-warn); margin-right: 6px; }
.squad-editor[aria-busy="true"] { opacity: 0.7; }
.squad-editor > .flash { margin-bottom: 12px; }

/* Laitteet: muokattava taulukko, monivalinta ja ottelunvalitsin (client/lib/device-editor.ts). */
#device-editor:not(.is-enhanced) .js-only { display: none; }
.device-table td { vertical-align: top; }
.device-table th, .device-table td { padding-left: 8px; padding-right: 8px; }
/* Valinta- ja toimintosarake kutistuvat sisältöönsä; ylimääräinen leveys jaetaan muille sarakkeille. */
.device-table .dv-select { width: 30px; padding-left: 6px; padding-right: 0; }
.device-table .dv-select input { width: 18px; height: 18px; margin: 9px 0 0; cursor: pointer; }
.device-table th.dv-select input { margin: 0; }
.device-table td.dv-name { min-width: 12rem; }
.device-table td.dv-person { min-width: 9.5rem; }
/* Kenttäsirut mahtuvat yhdelle riville kuuteen kenttään asti (--chips asetetaan sivulla). */
.device-table td.dv-fields { min-width: calc(var(--chips, 3) * 3.5rem); }
.device-table td.dv-matches { min-width: 12rem; }
.device-table .dv-actions { width: 0; white-space: nowrap; }
.device-table .dv-actions .actions { flex-direction: column; align-items: stretch; gap: 4px; }
.device-table .dv-actions .squad-withdraw { justify-content: center; }
.device-table .dv-name input[type="text"], .device-table td select { width: 100%; max-width: none; }
.device-table .error { display: block; margin-top: 4px; font-size: 0.8125rem; }
.device-table td.dv-fields .chip-list, .device-table td.dv-matches .chip-list { padding-top: 5px; }
.device-table .dv-pick { margin: 4px 0 0 -10px; }
.device-table .dv-revoke { color: var(--c-error); }
.device-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; margin-top: 7px; font-size: 0.8125rem; color: var(--c-muted); }
.device-meta .badge { margin-right: 2px; }
.dv-hint { display: block; margin-top: 7px; font-size: 0.8125rem; color: var(--c-muted); }
.dv-hint:empty { display: none; }
.device-table tbody tr td.is-changed { background: var(--c-primary-soft); }
.device-table td.is-changed :is(input[type="text"], select) { border-color: var(--c-warn); }
.device-table tbody tr.is-selected td { background: color-mix(in srgb, var(--c-info-bg) 70%, var(--c-surface)); }
.device-table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--c-info); }
.device-table tbody tr.is-new td { background: var(--c-ok-bg); }
.device-table tbody tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--c-ok); }
.device-table tbody tr.is-removing td { background: var(--c-error-bg); }
.device-table tbody tr.is-removing td:first-child { box-shadow: inset 3px 0 0 var(--c-error); }
.device-table tr.is-removing .dv-name input[type="text"] { text-decoration: line-through; color: var(--c-muted); }
.device-table tr.is-revoked .dv-name input[type="text"] { color: var(--c-muted); }
/* Sirut: kentät ja ottelut valintaruutuina (toimivat ilman JS:ää), joukkovalinnan kolmitilaiset napit. */
.chip-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 3px 11px; border: 1px solid var(--c-border-strong); border-radius: 999px; background: var(--c-surface); color: var(--c-text-2); font: inherit; font-size: 0.8125rem; font-weight: 600; line-height: 1.3; white-space: nowrap; font-variant-numeric: tabular-nums; cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--c-text-2); color: var(--c-text); }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip:has(input:focus-visible), .chip:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.chip:has(input:checked), .chip[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-ink); }
.chip:has(input:checked)::before, .chip[aria-pressed="true"]::before { content: "✓"; font-size: 0.75rem; }
.chip[aria-pressed="mixed"] { background: var(--c-primary-soft); border: 1px dashed var(--c-text-2); color: var(--c-text); }
.chip[aria-pressed="mixed"]::before { content: "–"; font-weight: 700; }
/* Ottelusiru näkyy vain valittuna; valinnan poisto merkitsee sen suljettavaksi tallennuksessa. */
.chip-match:has(input:checked) { background: var(--c-surface-2); border-color: var(--c-border-strong); color: var(--c-text); }
.chip-match:has(input:checked)::before { content: none; }
.chip-match::after { content: "×"; margin-left: 1px; font-size: 1rem; line-height: 1; color: var(--c-muted); }
.chip-match:hover::after { color: var(--c-error); }
.chip.is-added { box-shadow: 0 0 0 2px var(--c-ok); }
.chip.is-removed { border-style: dashed; border-color: var(--c-error); background: transparent; color: var(--c-muted); text-decoration: line-through; }
.chip-match.is-removed::after { content: "↶"; text-decoration: none; color: var(--c-text-2); }
/* Joukkomuokkaus: näkyy taulukon yläpuolella ja pysyy näkyvissä vieritettäessä. */
.device-bulk { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; min-height: 50px; margin: 0 0 8px; padding: 8px 12px; border: 1px dashed var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); }
.device-bulk.has-selection { border: 0; background: var(--c-info-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-info) 40%, transparent), 0 6px 14px -12px rgba(0, 0, 0, 0.45); }
.device-bulk-hint { margin: 0; font-size: 0.875rem; color: var(--c-muted); max-width: none; }
.device-bulk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; width: 100%; }
.device-bulk-tools[hidden], .device-bulk-hint[hidden] { display: none; }
.device-bulk-count { font-size: 0.875rem; min-width: 5.5rem; }
.device-bulk-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.device-bulk-label { float: left; padding: 0; margin-right: 2px; font-size: 0.8125rem; font-weight: 600; color: var(--c-text-2); }
.device-bulk .chip:not([aria-pressed="true"]):not([aria-pressed="mixed"]) { background: var(--c-surface); }
/* Ottelunvalitsin */
dialog.device-picker { max-width: min(780px, calc(100vw - 24px)); }
.dp-tools { display: grid; gap: 10px; padding: 14px 20px 12px; border-bottom: 1px solid var(--c-border); }
.dp-tools input[type="search"] { width: 100%; max-width: none; }
.dp-tools .dp-help { margin: 0; font-size: 0.8125rem; color: var(--c-muted); }
.dp-body { max-height: min(56vh, 560px); padding-top: 8px; }
.dp-day { font-size: 0.875rem; margin: 14px 8px 4px; color: var(--c-text-2); }
.dp-day:first-child { margin-top: 4px; }
.dp-day[hidden], .dp-list[hidden] { display: none; }
.dp-list { list-style: none; margin: 0; padding: 0; }
.dp-list li[hidden] { display: none; }
.dp-list label { display: grid; grid-template-columns: auto 3rem 2.75rem 3.5rem minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius); cursor: pointer; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.dp-list label:hover { background: var(--c-surface-2); }
.dp-list li:has(input:checked) label, .dp-list li:has(input:indeterminate) label { background: var(--c-primary-soft); }
.dp-list input { width: 18px; height: 18px; margin: 0; }
.dp-time { font-weight: 600; }
.dp-field { color: var(--c-text-2); }
.dp-code { font-weight: 700; }
.dp-teams { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-note { display: inline-flex; gap: 8px; justify-self: end; white-space: nowrap; }
.dp-note small[hidden] { display: none; }
.dp-covered { color: var(--c-ok); font-weight: 600; }
.dp-mixed { color: var(--c-warn); font-weight: 600; }
.dp-count { font-size: 0.875rem; }
/* Rekisteröintikoodit (näytetään vain luonnin tai uusinnan jälkeen). */
.code-card[hidden] { display: none; }
.code-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.code-list li { display: grid; grid-template-columns: minmax(8rem, 18rem) auto minmax(0, 1fr); align-items: center; gap: 4px 24px; padding: 8px 0; border-top: 1px solid var(--c-border); }
.code-list li:first-child { border-top: 0; padding-top: 0; }
.code-device { font-weight: 700; font-size: 1.0625rem; overflow-wrap: anywhere; }
.code-list .enrollment-code { justify-self: start; font-size: 2rem; letter-spacing: 0.14em; padding: 6px 16px 6px 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.code-expires { font-size: 0.8125rem; }
.quick-open-match { font-size: 1rem; margin-bottom: 10px; }
.quick-open-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 16px; }
.quick-open-form .field { flex: 1 1 16rem; max-width: 26rem; margin-bottom: 0; }
.quick-open-form .form-actions { margin: 0 0 2px; }
@media (max-width: 760px) {
  .device-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .device-table, .device-table tbody { display: block; }
  .device-table tr { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "select name" ". person" ". fields" ". matches" ". actions"; gap: 10px 10px; padding: 14px 0; border-bottom: 1px solid var(--c-border); }
  #device-editor:not(.is-enhanced) .device-table tr { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "person" "fields" "matches" "actions"; }
  .device-table tbody tr:last-child { border-bottom: 0; }
  .device-table td, .device-table td:is(.dv-name, .dv-person, .dv-fields, .dv-matches, .dv-actions, .dv-select) { display: block; padding: 0; border: 0; width: auto; min-width: 0; }
  .device-table td.dv-select { grid-area: select; }
  .device-table td.dv-name { grid-area: name; }
  .device-table td.dv-person { grid-area: person; }
  .device-table td.dv-fields { grid-area: fields; }
  .device-table td.dv-matches { grid-area: matches; }
  .device-table td.dv-actions { grid-area: actions; justify-self: start; }
  .device-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--c-muted); font-size: 0.8125rem; font-weight: 600; }
  .device-table tbody tr td, .device-table tbody tr td.is-changed, .device-table tbody tr td:first-child { background: transparent; box-shadow: none; }
  .device-table tbody tr.is-new, .device-table tbody tr.is-removing, .device-table tbody tr.is-selected { padding-left: 10px; padding-right: 10px; }
  .device-table tbody tr.is-new { background: var(--c-ok-bg); box-shadow: inset 3px 0 0 var(--c-ok); }
  .device-table tbody tr.is-removing { background: var(--c-error-bg); box-shadow: inset 3px 0 0 var(--c-error); }
  .device-table tbody tr.is-selected { background: color-mix(in srgb, var(--c-info-bg) 70%, var(--c-surface)); box-shadow: inset 3px 0 0 var(--c-info); }
  .device-table td.is-changed :is(input[type="text"], select) { background: var(--c-primary-soft); }
  .device-table .dv-pick { margin-left: -10px; }
  .device-bulk { margin-left: -4px; margin-right: -4px; }
  .dp-tools { padding: 12px 14px; }
  .dp-list label { grid-template-columns: auto 2.75rem 2.25rem minmax(0, 1fr) auto; gap: 2px 10px; }
  .dp-list .dp-teams { grid-column: 2 / -1; grid-row: 2; white-space: normal; font-size: 0.875rem; }
  .dp-list .dp-note { grid-column: 2 / -1; grid-row: 3; justify-self: start; }
  .dp-list .dp-note:not(:has(small:not([hidden]))) { display: none; }
  .code-list li { grid-template-columns: minmax(0, 1fr); }
  .code-list .enrollment-code { font-size: 1.75rem; }
}

/* Järjestettävä lista (client/lib/sortable.ts): rivit päällekkäin, veto kahvasta tai rivistä, nuolinapit varalla. */
.sortable-list { list-style: none; margin: 0; padding: 0; position: relative; display: flex; flex-direction: column; gap: 6px; max-width: 32rem; counter-reset: sortable; }
.sortable-item {
  counter-increment: sortable; position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 6px 6px 4px;
  background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--radius); cursor: grab; user-select: none;
}
.sortable-item::before { content: counter(sortable); min-width: 2ch; text-align: right; font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--c-muted); }
.sortable-handle { order: -1; display: inline-flex; align-items: center; justify-content: center; align-self: stretch; width: 24px; margin: -6px -6px -6px 0; color: var(--c-muted); touch-action: none; }
.sortable-handle svg { fill: currentColor; }
.sortable-item:hover .sortable-handle { color: var(--c-text); }
.sortable-label { flex: 1 1 auto; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.sortable-moves { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.sortable-moves .btn { width: 32px; padding: 0; cursor: pointer; }
.sortable-list.is-sorting, .sortable-list.is-sorting * { cursor: grabbing; }
.sortable-item.is-dragging { z-index: 2; background: var(--c-primary-soft); border-color: var(--c-text); box-shadow: var(--shadow-2); }
.sortable-status { margin: 10px 0 0; font-size: 0.875rem; font-weight: 600; }
.sortable-status::before { content: "●"; color: var(--c-warn); margin-right: 6px; }

/* Yhteys- ja laskutustiedot: lukunäkymä ↔ lomake samassa kortissa. */
[data-editable]:not(.is-editing) .edit-view { display: none; }
[data-editable].is-editing .read-view, [data-editable].is-editing [data-edit-toggle] { display: none; }
.detail-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 4px 32px; }
.detail-groups h3 { font-size: 0.9375rem; margin: 0 0 8px; }
.detail-groups .definition { grid-template-columns: minmax(6.5rem, max-content) 1fr; margin-bottom: 12px; }
.detail-notes { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--c-border); }
.edit-view .detail-groups fieldset { margin-bottom: 14px; }
.edit-view .detail-groups .field input { max-width: 100%; }
.edit-view textarea { max-width: 100%; }
.field-label { font-weight: 600; font-size: 0.875rem; }
.field-static { overflow-wrap: anywhere; }

/* Sivupalstan tiiviit listat. */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { padding: 8px 0; border-bottom: 1px solid var(--c-border); min-width: 0; }
.mini-list li:first-child { padding-top: 0; }
.mini-list li:last-child { padding-bottom: 0; border-bottom: 0; }
.mini-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mini-amount { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.mini-sub { display: block; font-size: 0.8125rem; overflow-wrap: anywhere; }
.entry-aside .definition { grid-template-columns: minmax(7rem, max-content) 1fr; gap: 6px 16px; margin: 0; font-size: 0.875rem; }

/* Pienellä näytöllä peliryhmärivit pinotaan korteiksi. */
@media (max-width: 760px) {
  .squad-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .squad-table, .squad-table tbody { display: block; }
  .squad-table tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "name name name" "division division division" "kits logo players" "actions actions actions"; align-items: center; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--c-border); }
  .squad-table tbody tr:last-child { border-bottom: 0; }
  .squad-table td, .squad-table th, .squad-table td:is(.sq-name, .sq-division, .sq-players, .sq-actions) { display: block; padding: 0; border: 0; min-width: 0; width: auto; }
  .squad-table td.sq-name { grid-area: name; }
  .squad-table td.sq-division { grid-area: division; }
  .squad-table td.sq-kits { grid-area: kits; }
  .squad-table td.sq-logo { grid-area: logo; }
  .squad-table td.sq-players { grid-area: players; }
  .squad-table td.sq-new-note { grid-row: 3; grid-column: 1 / -1; }
  .squad-table td.sq-actions { grid-area: actions; justify-self: end; }
  .squad-table th[scope="rowgroup"] { grid-column: 1 / -1; }
  .squad-table td[data-label]::before { content: attr(data-label) " "; color: var(--c-muted); font-size: 0.8125rem; margin-right: 4px; }
  .squad-table td.sq-players { text-align: left; }
  .squad-table tbody tr.is-new td, .squad-table tbody tr.is-withdrawing td, .squad-table tbody tr td.is-changed { background: transparent; }
  .squad-table tbody tr.is-new, .squad-table tbody tr.is-withdrawing { padding-left: 10px; }
  .squad-table tbody tr.is-new { background: var(--c-ok-bg); box-shadow: inset 3px 0 0 var(--c-ok); }
  .squad-table tbody tr.is-withdrawing { background: var(--c-error-bg); box-shadow: inset 3px 0 0 var(--c-error); }
  .squad-table tbody tr td:first-child { box-shadow: none; }
  .squad-table tr.squad-players { display: block; padding-top: 0; }
  .squad-table tr:has(+ tr.squad-players) { border-bottom: 0; }
  .squad-editor-bar { margin: 12px -16px -14px; padding: 12px 16px; }
  .squad-editor-bar .btn-primary, .squad-editor-bar .btn-secondary:not(.squad-add) { flex: 1 1 100%; }
}

/* Taustatallennuksen ilmoitus. */
.toast { position: fixed; top: 16px; left: 50%; z-index: 60; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; max-width: min(36rem, calc(100vw - 32px)); padding: 11px 16px; border-radius: var(--radius); border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-2); font-weight: 500; cursor: default; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-ok { background: var(--c-ok-bg); color: var(--c-ok); border-color: color-mix(in srgb, var(--c-ok) 35%, transparent); }
.toast-error { background: var(--c-error-bg); color: var(--c-error); border-color: color-mix(in srgb, var(--c-error) 35%, transparent); }
.toast-info { background: var(--c-info-bg); color: var(--c-info); border-color: color-mix(in srgb, var(--c-info) 35%, transparent); }

/* Viestit (src/routes/admin/messages.tsx, client/lib/messages-page.ts): keskustelulista + keskustelu. */
.msg-identity { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius); background: var(--c-surface-2); }
.msg-identity .btn { border: 0; }
.msg-identity .btn.is-active { background: var(--c-surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.msg-layout { display: grid; grid-template-columns: minmax(17rem, 23rem) minmax(0, 1fr); height: max(32rem, calc(100vh - 13.5rem)); padding: 0; overflow: hidden; }
.msg-list { border-right: 1px solid var(--c-border); overflow-y: auto; min-height: 0; }
.msg-list ul { list-style: none; margin: 0; padding: 6px 0; }
.msg-list-empty { padding: 28px 22px; }
.msg-list-empty p { margin: 0 0 4px; }
.msg-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 16px 10px 13px; border-left: 3px solid transparent; color: var(--c-text); text-decoration: none; }
.msg-item:hover { background: var(--c-surface-2); text-decoration: none; }
.msg-item.is-active { background: var(--c-primary-soft); border-left-color: var(--c-brand); }
.msg-item-main { display: grid; gap: 2px; min-width: 0; }
.msg-item-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg-item-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.msg-item-time { flex: 0 0 auto; font-size: 0.75rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.msg-item-preview { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; color: var(--c-muted); }
.msg-item.has-unread .msg-item-title { font-weight: 700; }
.msg-item.has-unread .msg-item-preview { color: var(--c-text); }
.msg-unread { min-width: 1.5rem; height: 1.5rem; padding: 0 6px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; background: var(--c-text); color: var(--c-surface); font-variant-numeric: tabular-nums; }
.msg-item.has-critical .msg-unread { background: var(--c-error); color: #fff; }
.msg-flag-inline { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; background: var(--c-error-bg); color: var(--c-error); vertical-align: 1px; }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 0.875rem; font-weight: 700; background: var(--c-surface-3); color: var(--c-text-2); letter-spacing: 0.02em; }
.msg-avatar-office { background: var(--c-brand); color: var(--c-brand-ink); }
.msg-avatar-head { background: var(--c-black); color: var(--c-brand); }
.msg-avatar-group { background: var(--c-info-bg); color: var(--c-info); }
.msg-avatar-device { background: transparent; border: 1.5px dashed var(--c-border-strong); color: var(--c-muted); }
.msg-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.msg-pane-empty { align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.msg-thread-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--c-border); }
.msg-thread-title { min-width: 0; }
.msg-thread-title h2 { margin: 0; font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-thread-title p { margin: 1px 0 0; font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: none; }
.msg-thread-title .is-online { color: var(--c-ok); }
.msg-presence::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--c-border-strong); vertical-align: 1px; }
.msg-presence.is-online::before { background: var(--c-ok); }
.msg-back { display: none; }
.msg-thread { flex: 1 1 auto; overflow-y: auto; list-style: none; margin: 0; padding: 16px 20px 8px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.msg-day { align-self: center; margin: 10px 0 4px; }
.msg-day span { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--c-surface-2); color: var(--c-muted); font-size: 0.75rem; font-weight: 600; }
.msg-more { align-self: center; font-size: 0.875rem; margin-bottom: 6px; }
.msg-bubble { align-self: flex-start; max-width: min(36rem, 78%); padding: 8px 12px 6px; border-radius: 14px 14px 14px 4px; background: var(--c-surface-2); position: relative; }
.msg-bubble.is-own { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: color-mix(in srgb, var(--c-brand) 30%, var(--c-surface)); }
.msg-bubble.is-critical { box-shadow: inset 3px 0 0 var(--c-error); background: var(--c-error-bg); }
.msg-bubble.is-own.is-critical { box-shadow: inset -3px 0 0 var(--c-error); }
.msg-sender { display: block; font-size: 0.75rem; font-weight: 700; color: var(--c-text-2); margin-bottom: 1px; }
.msg-flag { display: inline-block; margin-bottom: 3px; padding: 0 7px; border-radius: 999px; background: var(--c-error); color: #fff; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.02em; }
.msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-width: none; }
/* Kellonaika ja omien viestien rastit kuplan oikeassa alakulmassa viimeisen rivin perässä (Telegramin tapaan):
   tekstin loppuun varataan näkymätön tila, jonka päälle aika sijoitetaan; jos tila ei mahdu riville, se siirtyy uudelle
   riville ja aika sen mukana. */
.msg-bubble { position: relative; }
.msg-body::after { content: ""; display: inline-block; width: 2.6rem; height: 1px; }
.msg-bubble.is-own .msg-body::after { width: 3.9rem; }
.msg-meta { position: absolute; right: 12px; bottom: 6px; display: flex; align-items: center; gap: 3px; }
.msg-time { font-size: 0.6875rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.msg-ticks { display: inline-flex; color: var(--c-muted); line-height: 0; }
.msg-ticks svg { width: 17px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.msg-ticks.is-delivered, .msg-ticks.is-read { color: var(--c-link); }
.msg-item-top .msg-ticks { align-self: center; margin-right: -4px; }
.msg-compose { padding: 12px 16px 14px; border-top: 1px solid var(--c-border); background: var(--c-surface); }
.msg-compose-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.msg-compose textarea { width: 100%; max-width: none; min-height: 44px; resize: none; line-height: 1.4; }
.msg-compose-actions { display: flex; align-items: center; gap: 8px; }
.msg-compose .error { display: block; margin: 0 0 8px; }
.msg-urgency { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 1px solid var(--c-border-strong); border-radius: 999px; font-size: 0.875rem; font-weight: 600; color: var(--c-text-2); cursor: pointer; user-select: none; white-space: nowrap; }
.msg-urgency input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.msg-urgency::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; font-size: 0.75rem; font-weight: 800; }
.msg-urgency:has(input:focus-visible) { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.msg-urgency:has(input:checked) { background: var(--c-error); border-color: var(--c-error); color: #fff; }
.msg-compose.is-critical textarea, form.is-critical .msg-compose textarea { border-color: var(--c-error); }
.msg-compose.is-critical .msg-send, form.is-critical .msg-send { background: var(--c-error); border-color: var(--c-error); color: #fff; }
.msg-send { min-height: 40px; white-space: nowrap; }
/* Uusi viesti: vastaanottajat ryhmittäin. */
.msg-pane-new { overflow-y: auto; }
.msg-new { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.msg-recipients { margin: 0; padding: 14px 20px 4px; border: 0; min-width: 0; }
.msg-recipients legend { float: left; padding: 0; font-weight: 700; margin-bottom: 8px; }
.msg-recipients-tools { clear: both; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 8px; }
.msg-recipients-tools input[type="search"] { flex: 1 1 16rem; max-width: 26rem; }
.msg-recipient-group { margin-bottom: 12px; }
.msg-recipient-group[hidden] { display: none; }
.msg-recipient-group-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.msg-recipient-group-head[hidden] { display: none; }
.msg-recipient-group-head h3 { margin: 0; font-size: 0.8125rem; color: var(--c-muted); }
.msg-recipient-group ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 4px 12px; }
.msg-recipient-group li[hidden] { display: none; }
.msg-recipient { display: grid; grid-template-columns: auto auto minmax(0, 1fr); grid-template-areas: "box dot name" ". . detail"; align-items: center; column-gap: 8px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; }
.msg-recipient:hover { background: var(--c-surface-2); }
.msg-recipient:has(input:checked) { background: var(--c-primary-soft); }
.msg-recipient input { grid-area: box; width: 18px; height: 18px; margin: 0; }
.msg-recipient .msg-dot { grid-area: dot; }
.msg-recipient-name { grid-area: name; font-weight: 500; overflow-wrap: anywhere; }
.msg-recipient small { grid-area: detail; overflow-wrap: anywhere; }
.msg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--c-border-strong); }
.msg-dot.is-online { background: var(--c-ok); border-color: var(--c-ok); }
.msg-recipient-hint { margin: 0 20px 8px; }
.msg-recipient-hint.is-group { color: var(--c-info); font-weight: 600; }
.msg-new > .msg-compose { margin-top: auto; position: sticky; bottom: 0; }
/* Hallinnan valikon lukemattomat ja ilmoitukset muilla sivuilla. */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 1.35rem; height: 1.35rem; margin-left: 8px; padding: 0 5px; border-radius: 999px; background: var(--c-error); color: #fff; font-size: 0.6875rem; font-weight: 700; vertical-align: 1px; font-variant-numeric: tabular-nums; }
.nav-badge[hidden] { display: none; }
/* Saapumiset: joukkue saapumatta avausottelun lähestyessä. Vilkkuu (1 Hz), kunnes joukkue on merkitty saapuneeksi. */
.nav-alert { animation: nav-alert 1s ease-in-out infinite alternate; }
@keyframes nav-alert { from { opacity: 1; } to { opacity: 0.3; } }
.rt-toasts { position: fixed; top: 68px; right: 16px; z-index: 70; display: flex; flex-direction: column; gap: 10px; width: min(24rem, calc(100vw - 32px)); pointer-events: none; }
.rt-toast { position: relative; pointer-events: auto; padding: 12px 40px 12px 14px; border-radius: var(--radius-lg); border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-2); animation: rt-in 0.2s ease-out; }
.rt-toast strong { display: block; margin-bottom: 2px; }
.rt-toast p { margin: 0 0 8px; font-size: 0.875rem; color: var(--c-text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rt-toast.is-critical { border: 2px solid var(--c-error); background: var(--c-error-bg); }
.rt-toast.is-critical strong { color: var(--c-error); }
.rt-toast-close { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--c-muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.rt-toast-close:hover { background: var(--c-surface-2); color: var(--c-text); }
@keyframes rt-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .rt-toast { animation: none; } }
@media (max-width: 760px) {
  .msg-layout { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - 12rem); min-height: 26rem; }
  .msg-layout.has-open .msg-list { display: none; }
  .msg-layout:not(.has-open) .msg-pane { display: none; }
  .msg-list { border-right: 0; }
  .msg-back { display: inline-flex; flex: 0 0 auto; font-size: 0.875rem; }
  .msg-thread-head { padding: 10px 14px; gap: 10px; }
  .msg-thread-head .msg-avatar { display: none; }
  .msg-thread { padding: 12px 12px 6px; }
  .msg-bubble { max-width: 88%; }
  .msg-compose { padding: 10px 12px 12px; }
  .msg-compose-row { grid-template-columns: minmax(0, 1fr); }
  .msg-compose-actions { justify-content: space-between; }
  .msg-recipients { padding: 12px 14px 4px; }
  .msg-recipient-hint { margin: 0 14px 8px; }
  .rt-toasts { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
}

/* ---------- Hallinta: henkilöt (uusi henkilö, henkilön sivu) ---------- */
/* Pääpalsta (roolit) ja kapea sivupalsta (perustiedot, tallennus); kapeammalla sivupalsta siirtyy alle. */
.person-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 21rem); gap: 20px; align-items: start; }
.person-main, .person-aside { min-width: 0; }
.person-aside { display: grid; gap: 16px; position: sticky; top: 16px; }
.person-main > .card:last-child, .person-aside > .card { margin-bottom: 0; }
/* Kapeassa sivupalstassa nimike arvon yläpuolella, jotta sähköposti ja aikaleima eivät katkea. */
.person-aside .definition { grid-template-columns: minmax(0, 1fr); gap: 0; margin: 0; font-size: 0.9375rem; }
.person-aside .definition dt { font-size: 0.8125rem; }
.person-aside .definition dd { margin-bottom: 10px; }
.person-aside .definition dd:last-child { margin-bottom: 0; }
.person-aside .form-actions { margin-top: 14px; }
.field-note { margin: -6px 0 14px; padding: 8px 10px; border-radius: var(--radius); background: var(--c-error-bg); color: var(--c-text); font-size: 0.875rem; }
@media (max-width: 1100px) {
  .person-layout { grid-template-columns: minmax(0, 1fr); }
  .person-aside { position: static; }
}
/* Roolien valinta: kohde (seura, joukkue, turnaus) vasemmalla, roolit ja lisäoikeudet valintanappeina. */
.role-section + .role-section { margin-top: 20px; }
.role-section > h3 { margin: 0 0 2px; font-size: 0.9375rem; }
.role-section > .empty { margin: 6px 0 0; }
.role-row { display: grid; grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr); gap: 6px 16px; margin: 0; padding: 10px 0; border: 0; border-top: 1px solid var(--c-border); border-radius: 0; }
.role-section > h3 + .role-row { border-top: 0; }
/* Kelluva legend on tavallinen ruudukon solu (ei kehyksen otsikko). */
.role-row > legend { float: left; padding: 0; font-size: 0.9375rem; }
.role-row-name { font-weight: 600; padding-top: 4px; overflow-wrap: anywhere; }
.role-row-name small { display: block; font-weight: 400; font-size: 0.8125rem; color: var(--c-muted); }
.role-row .help { display: block; margin-top: 6px; }
.check-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.check-pills-sub { margin-top: 8px; }
.check-pills-label { font-size: 0.8125rem; color: var(--c-muted); margin-right: 2px; }
.check-pills-sub .check-pill { font-size: 0.8125rem; padding: 3px 10px 3px 8px; }
.check-pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px 4px 9px; border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-surface); font-size: 0.875rem; font-weight: 500; line-height: 1.35; cursor: pointer; }
.check-pill input { width: 15px; height: 15px; margin: 0; flex: 0 0 auto; }
.check-pill:hover { border-color: var(--c-border-strong); }
.check-pill:has(input:checked) { background: var(--c-primary-soft); border-color: var(--c-border-strong); }
.check-pill.is-main { font-weight: 600; }
/* Voimassa oleva rooli: harmaa, erottuu uusista (keltaisista) valinnoista. */
.check-pill.is-held, .check-pill.is-held:has(input:checked) { cursor: default; background: var(--c-surface-2); border-color: var(--c-border); color: var(--c-text-2); }
@media (max-width: 640px) {
  .role-row { grid-template-columns: minmax(0, 1fr); }
  .role-row-name { padding-top: 0; }
  .check-pills-label { flex-basis: 100%; }
}

/* ---------- Hallinta: pelinohjaajien ja tuomarien vuorot ---------- */
/* Henkilöiden värit vuorotaulussa (sirut, valittu henkilö); punainen on varattu päällekkäisyyksille. */
:root {
  --o-1: #2563eb; --o-2: #16a34a; --o-3: #ea580c; --o-4: #9333ea; --o-5: #0891b2; --o-6: #db2777;
  --o-7: #a16207; --o-8: #4f46e5; --o-9: #65a30d; --o-10: #0d9488; --o-11: #c026d3; --o-12: #475569;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --o-1: #7aa7ff; --o-2: #5fd38d; --o-3: #ffa366; --o-4: #c39bff; --o-5: #57d1e6; --o-6: #ff8cc6;
    --o-7: #e0b85a; --o-8: #a5a8ff; --o-9: #a9dc5a; --o-10: #4fd6c8; --o-11: #ef8cf5; --o-12: #a8b6c8;
  }
}
:root[data-theme="dark"] {
  --o-1: #7aa7ff; --o-2: #5fd38d; --o-3: #ffa366; --o-4: #c39bff; --o-5: #57d1e6; --o-6: #ff8cc6;
  --o-7: #e0b85a; --o-8: #a5a8ff; --o-9: #a9dc5a; --o-10: #4fd6c8; --o-11: #ef8cf5; --o-12: #a8b6c8;
}
.o-c1 { --o: var(--o-1); } .o-c2 { --o: var(--o-2); } .o-c3 { --o: var(--o-3); } .o-c4 { --o: var(--o-4); }
.o-c5 { --o: var(--o-5); } .o-c6 { --o: var(--o-6); } .o-c7 { --o: var(--o-7); } .o-c8 { --o: var(--o-8); }
.o-c9 { --o: var(--o-9); } .o-c10 { --o: var(--o-10); } .o-c11 { --o: var(--o-11); } .o-c12 { --o: var(--o-12); }
.sb-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--o, var(--c-muted)); flex: 0 0 auto; vertical-align: 0; }

.sb-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, 20rem); gap: 20px; align-items: start; }
.sb-main, .sb-aside { min-width: 0; }
.sb-aside { display: grid; gap: 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sb-aside > .card { margin-bottom: 0; }
.sb-stats { margin-bottom: 12px; }
.sb-legend { margin: 0 0 14px; font-size: 0.8125rem; color: var(--c-text-2); }
.sb-layout:not(.is-enhanced) .sb-legend-js { display: none; }
.sb-legend-mark { display: inline-block; width: 16px; height: 12px; border-radius: 3px; background: var(--c-surface); border: 1px solid var(--c-border-strong); position: relative; }
.sb-legend-mark.is-conflict { outline: 2px solid var(--c-error); outline-offset: -1px; }
.sb-legend-mark.is-changed::after { content: ""; position: absolute; top: -3px; right: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--c-link); box-shadow: 0 0 0 2px var(--c-surface); }

.sb-day { margin-bottom: 22px; }
.sb-day-title { font-size: 0.9375rem; margin: 0 0 8px; color: var(--c-text-2); }
.sb-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; }
.sb-grid { display: grid; width: 100%; box-sizing: border-box; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); font-size: 0.8125rem; }
.sb-corner, .sb-field { background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
.sb-corner { border-top-left-radius: var(--radius); }
.sb-field { padding: 7px 10px; font-weight: 600; border-left: 1px solid var(--c-border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sb-time { padding: 7px 6px 0 0; text-align: right; color: var(--c-text-2); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 0.75rem; border-top: 1px solid var(--c-border); background: var(--c-surface-2); }
.sb-cell { border-left: 1px solid var(--c-border); border-top: 1px solid var(--c-border); padding: 3px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.sb-match { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 4px 6px 5px; border-radius: 4px; color: var(--c-text); text-decoration: none; background: color-mix(in srgb, var(--div, var(--c-primary)) 7%, var(--c-surface)); border: 1px solid color-mix(in srgb, var(--div, var(--c-primary)) 30%, var(--c-border)); border-left: 4px solid var(--div, var(--c-primary)); min-width: 0; line-height: 1.25; touch-action: manipulation; }
.sb-match:hover { text-decoration: none; border-color: color-mix(in srgb, var(--div, var(--c-primary)) 60%, var(--c-border)); box-shadow: var(--shadow-1); }
.sb-match:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.sb-mhead { display: flex; gap: 8px; align-items: baseline; color: var(--c-text-2); font-size: 0.6875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-mcode { margin-left: auto; font-weight: 700; letter-spacing: 0.02em; }
.sb-mteams { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-chips { display: flex; flex-wrap: wrap; gap: 3px; min-height: 20px; }
.sb-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 0 7px 0 5px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--c-text); background: color-mix(in srgb, var(--o, var(--c-muted)) 15%, var(--c-surface)); border: 1px solid color-mix(in srgb, var(--o, var(--c-muted)) 55%, transparent); }
.sb-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--o, var(--c-muted)); flex: 0 0 auto; }
.sb-chip.is-conflict { border: 2px solid var(--c-error); background: var(--c-error-bg); line-height: 16px; }
.sb-chip.is-former { border-style: dashed; color: var(--c-muted); }
.sb-chip-missing { color: var(--c-warn); background: var(--c-warn-bg); border: 1px dashed color-mix(in srgb, var(--c-warn) 70%, transparent); font-weight: 600; padding: 0 7px; }
.sb-chip-missing::before { display: none; }
.sb-match.is-conflict { outline: 2px solid var(--c-error); outline-offset: -1px; }
.sb-match.is-closed { opacity: 0.62; }
.sb-match.is-cancelled .sb-mteams { text-decoration: line-through; }
.sb-match.is-changed::after { content: ""; position: absolute; top: -4px; right: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--c-link); box-shadow: 0 0 0 2px var(--c-surface); }
/* Valittu henkilö: hänen ottelunsa korostuvat hänen värillään, samaan aikaan muualla olevat ovat varattuja. */
.sb-layout.has-active .sb-grid { user-select: none; -webkit-user-select: none; }
.sb-layout.has-active .sb-match { cursor: pointer; touch-action: none; }
.sb-layout.has-active .sb-match.is-mine { background: color-mix(in srgb, var(--sb-active, var(--c-link)) 22%, var(--c-surface)); box-shadow: inset 0 0 0 2px var(--sb-active, var(--c-link)); }
.sb-layout.has-active .sb-match.is-busy { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c-muted) 22%, transparent) 6px 8px); }
.sb-layout.has-active .sb-match.is-busy .sb-mteams { color: var(--c-muted); }
.sb-layout.has-active .sb-match.is-closed:not(.is-mine) { opacity: 0.45; }
/* Lukutila (pelinohjaaja/tuomari): ottelut eivät ole linkkejä; katsojan omat ottelut korostuvat hänen värillään. */
.sb-layout.is-readonly .sb-match:hover { border-color: color-mix(in srgb, var(--div, var(--c-primary)) 30%, var(--c-border)); box-shadow: none; }
.sb-layout.is-readonly .sb-match.is-own { background: color-mix(in srgb, var(--sb-me, var(--c-link)) 22%, var(--c-surface)); box-shadow: inset 0 0 0 2px var(--sb-me, var(--c-link)); }
.sb-layout.is-readonly .sb-main > .help { margin: 0 0 12px; }
.sb-legend-mark.is-own { background: color-mix(in srgb, var(--sb-me, var(--c-link)) 22%, var(--c-surface)); border: 2px solid var(--sb-me, var(--c-link)); }

.sb-help { margin: 0 0 10px; }
.sb-roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sb-person { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "dot name key" ". stats stats" ". warn warn"; align-items: center; gap: 0 8px; width: 100%; padding: 7px 10px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text); font: inherit; text-align: left; cursor: pointer; }
.sb-person:hover { border-color: var(--c-border-strong); background: var(--c-surface-2); }
.sb-person:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.sb-person[aria-pressed="true"] { border: 2px solid var(--o); padding: 6px 9px; background: color-mix(in srgb, var(--o) 14%, var(--c-surface)); }
.sb-person .sb-swatch { grid-area: dot; width: 12px; height: 12px; }
.sb-person.is-static { cursor: default; }
.sb-person.is-static:hover { border-color: var(--c-border); background: var(--c-surface); }
.sb-person.is-me, .sb-person.is-me:hover { border: 2px solid var(--o); padding: 6px 9px; background: color-mix(in srgb, var(--o) 14%, var(--c-surface)); }
.sb-pmain { grid-area: name; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; }
.sb-pname { font-weight: 600; font-size: 0.875rem; overflow-wrap: anywhere; }
.sb-pstats { grid-area: stats; font-size: 0.75rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.sb-pwarn { grid-area: warn; font-size: 0.75rem; color: var(--c-error); font-weight: 600; }
.sb-pwarn[hidden] { display: none; }
.sb-key { grid-area: key; font: 600 0.6875rem/1 var(--font-mono); color: var(--c-muted); border: 1px solid var(--c-border); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--c-surface-2); }
.sb-layout:not(.is-enhanced) .sb-key { display: none; }
.sb-settings .field { margin-bottom: 10px; }
.sb-savebar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-top: 4px; padding: 12px 0; background: var(--c-bg); border-top: 1px solid var(--c-border); }
.sb-layout:not(.is-enhanced) .sb-savebar { display: none; }
/* Tallennuksen tila: tallennettu, tallennetaan, ei yhteyttä (muutokset odottavat) tai virhe. */
.sb-sync { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--c-ok); white-space: nowrap; }
.sb-sync-mark { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.sb-sync[data-state="saving"] { color: var(--c-text-2); }
.sb-sync[data-state="saving"] .sb-sync-mark { animation: pulse 1s infinite; }
.sb-sync[data-state="offline"] { color: var(--c-warn); }
.sb-sync[data-state="failed"] { color: var(--c-error); }
.sb-savebar:has(.sb-sync[data-state="offline"], .sb-sync[data-state="failed"]) { border-top: 2px solid var(--c-warn); }
.sb-status { flex: 1 1 16rem; min-width: 0; font-size: 0.875rem; color: var(--c-text-2); }
/* Muut taulun muokkaajat: pallo henkilön valitseman sivellinvärin mukaan. */
.sb-presence { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8125rem; color: var(--c-text-2); min-width: 0; }
.sb-presence[hidden] { display: none; }
.sb-avatars { display: inline-flex; flex: 0 0 auto; }
.sb-avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 0.6875rem; font-weight: 700; color: var(--c-text); background: color-mix(in srgb, var(--o, var(--c-link)) 18%, var(--c-surface)); border: 2px solid var(--o, var(--c-link)); box-shadow: 0 0 0 2px var(--c-bg); }
.sb-avatar + .sb-avatar { margin-left: -6px; }
.sb-presence-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-save-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
/* Toisen muokkaajan muutos korostuu hetken. */
.sb-match.is-remote { animation: sb-remote 2.4s ease-out; }
@keyframes sb-remote { 0%, 35% { box-shadow: 0 0 0 3px var(--c-link); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .sb-match.is-remote { box-shadow: 0 0 0 3px var(--c-link); } }
dialog.sb-dialog { max-width: min(560px, calc(100vw - 24px)); }
.sb-picker-sub { margin: 2px 0 0; font-size: 0.875rem; }
.sb-picker-foot { flex-wrap: wrap; gap: 4px 12px; }
.sb-picker-foot .help { margin: 0; }
.sb-picker-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.sb-pick { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--radius); cursor: pointer; }
.sb-pick:hover { background: var(--c-surface-2); }
.sb-pick:has(input:checked) { border-color: var(--o); background: color-mix(in srgb, var(--o) 12%, var(--c-surface)); }
.sb-pick input { width: 18px; height: 18px; margin: 0; }
.sb-pick-name { font-weight: 600; overflow-wrap: anywhere; }
.sb-pick-note { font-size: 0.8125rem; color: var(--c-muted); text-align: right; }
.sb-pick.is-busy .sb-pick-note { color: var(--c-warn); font-weight: 600; grid-column: 3 / -1; text-align: left; }
.sb-fill-persons { columns: 2 12rem; margin-top: 4px; }
.sb-fill-persons .field-check { display: flex; break-inside: avoid; margin: 0 0 6px; }
.sb-dialog .field-check { flex-wrap: wrap; }
.sb-dialog .field-check label { flex: 1 1 0; min-width: 0; }
.sb-dialog .field-check .help { padding-left: 26px; }
@media (max-width: 1100px) {
  .sb-layout { grid-template-columns: minmax(0, 1fr); }
  .sb-aside { position: static; order: -1; max-height: none; overflow: visible; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
  .sb-roster { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
  /* Lukutilassa henkilöt ovat vain selite: taulu ensin. */
  .sb-layout.is-readonly .sb-aside { order: 0; }
}
@media (max-width: 640px) {
  .sb-status[data-idle] { display: none; }
  .sb-pick { grid-template-columns: auto auto minmax(0, 1fr); }
  .sb-pick-note { grid-column: 3; text-align: left; }
}

/* Tilanne: kentät nyt ja seuraavaksi, huomioitavat ja henkilöt. */
.os-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem); gap: 20px; align-items: start; }
.os-main, .os-aside { min-width: 0; }
.os-main > .card:last-child, .os-aside > .card { margin-bottom: 0; }
.os-aside { position: sticky; top: 16px; }
/* Kentät tasapainoisina riveinä: sarakemäärä tulee palvelimelta (balancedColumns), leveys säiliökyselyistä (~16rem/kortti). */
.os-fields { container: os-fields / inline-size; }
.os-fields-grid { display: grid; grid-template-columns: repeat(var(--os-c1, 1), minmax(0, 1fr)); gap: 12px; }
@container os-fields (min-width: 33rem) { .os-fields-grid { grid-template-columns: repeat(var(--os-c2, 2), minmax(0, 1fr)); } }
@container os-fields (min-width: 50rem) { .os-fields-grid { grid-template-columns: repeat(var(--os-c3, 3), minmax(0, 1fr)); } }
@container os-fields (min-width: 66rem) { .os-fields-grid { grid-template-columns: repeat(var(--os-c4, 4), minmax(0, 1fr)); } }
@container os-fields (min-width: 83rem) { .os-fields-grid { grid-template-columns: repeat(var(--os-c5, 5), minmax(0, 1fr)); } }
.os-field { border: 1px solid var(--c-border); border-radius: var(--radius-lg); padding: 10px 12px; background: var(--c-surface); min-width: 0; }
.os-field-name { margin: 0 0 6px; font-size: 0.9375rem; }
.os-slot { padding: 6px 0; border-top: 1px solid var(--c-border); }
.os-slot-label { display: block; font-size: 0.75rem; color: var(--c-muted); margin-bottom: 2px; }
.os-idle { margin: 0; font-size: 0.875rem; }
.os-match-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.os-time { font-variant-numeric: tabular-nums; }
.os-teams { font-weight: 600; margin: 2px 0 4px; overflow-wrap: anywhere; }
/* Henkilötaulukon Nyt/Sitten-ottelut: paikka ja aika, joukkueet toisella rivillä. */
.os-refs { display: flex; flex-direction: column; gap: 6px; }
.os-ref { display: flex; flex-direction: column; }
.os-ref-teams { font-size: 0.875rem; color: var(--c-muted); overflow-wrap: break-word; }
.os-officials { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.os-fix { font-size: 0.8125rem; margin-left: 4px; }
.os-officials .os-fix:first-of-type { margin-left: auto; }
.sb-chip.os-chip-online::after, .sb-chip.os-chip-offline::after { content: ""; width: 6px; height: 6px; border-radius: 50%; margin-left: 2px; }
.sb-chip.os-chip-online::after { background: var(--c-ok); }
.sb-chip.os-chip-offline::after { background: var(--c-warn); }
.os-alerts { list-style: none; margin: 0; padding: 0; }
.os-alert { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0 8px 10px; border-bottom: 1px solid var(--c-border); border-left: 3px solid var(--c-border-strong); font-size: 0.875rem; }
.os-alert:last-child { border-bottom: 0; }
.os-alert a { white-space: nowrap; }
.os-alert-error { border-left-color: var(--c-error); }
.os-alert-warn { border-left-color: var(--c-warn); }
.os-link { white-space: nowrap; }
.os-contact { display: block; font-size: 0.8125rem; margin-top: 2px; overflow-wrap: anywhere; }
.os-battery-low { color: var(--c-error); }
@media (max-width: 1100px) {
  .os-layout { grid-template-columns: minmax(0, 1fr); }
  .os-aside { position: static; order: -1; }
}

/* Saapumiset: haku ja tilavalitsin, joukkueet seuroittain (src/routes/admin/checkin.tsx). */
.checkin [hidden] { display: none !important; }
.checkin-toolbar { display: grid; grid-template-columns: minmax(0, 34rem) auto; justify-content: start; align-items: center; gap: 5px 24px; margin-bottom: 18px; }
.checkin-search { display: contents; }
.checkin-search > label { grid-column: 1; grid-row: 1; }
.checkin-search-row { grid-column: 1; grid-row: 2; display: flex; gap: 8px; }
.checkin-search-row input { flex: 1 1 auto; min-width: 0; }
.checkin-search > .help { grid-column: 1 / -1; grid-row: 3; margin: 0; }
.checkin-toolbar .segmented { grid-column: 2; grid-row: 2; }
.segmented { display: inline-flex; border: 1px solid var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); }
.segmented-item { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 6px 14px; border-left: 1px solid var(--c-border-strong); color: var(--c-text-2); font-weight: 600; white-space: nowrap; }
.segmented-item:first-child { border-left: 0; border-radius: calc(var(--radius) - 1px) 0 0 calc(var(--radius) - 1px); }
.segmented-item:last-child { border-radius: 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0; }
.segmented-item:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.segmented-item:focus-visible { outline-offset: -4px; }
.segmented-item[aria-current="true"] { background: var(--c-primary); color: var(--c-primary-ink); }
.segmented-item[aria-current="true"]:focus-visible { outline-color: var(--c-primary-ink); }
.segmented-count { min-width: 24px; padding: 2px 7px; border-radius: 999px; background: var(--c-surface-2); color: var(--c-text-2); font-size: 0.8125rem; text-align: center; font-variant-numeric: tabular-nums; }
.segmented-item[aria-current="true"] .segmented-count { background: color-mix(in srgb, var(--c-primary-ink) 20%, transparent); color: var(--c-primary-ink); }
.checkin-table tbody tr.checkin-team > * { vertical-align: middle; }
.checkin-table tbody tr:last-child > th { border-bottom: 0; }
.checkin-table tbody th[scope="row"] { color: var(--c-text); font-size: 0.9375rem; font-weight: 600; white-space: normal; overflow-wrap: break-word; background: transparent; }
.checkin-table tbody tr:hover th[scope="row"] { background: var(--c-surface-2); }
.checkin-table tr.row-alert th[scope="row"] { background: var(--c-warn-bg); }
.checkin-table .ck-division { width: 9rem; white-space: nowrap; }
.checkin-table .ck-first { width: 9rem; }
.checkin-table .ck-countdown { width: 10rem; }
.countdown { color: var(--c-text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.countdown-soon { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--c-error-bg); color: var(--c-error); font-weight: 700; }
.countdown-late { color: var(--c-error); font-weight: 700; }
.checkin-table .ck-arrival { width: 18rem; }
.checkin-table .ck-award { width: 10rem; }
.ck-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.ck-cell .btn-link { padding-left: 4px; padding-right: 4px; }
.checkin-club-row th { padding: 8px 12px; background: var(--c-surface-2); color: var(--c-text); font-size: 0.875rem; font-weight: 500; white-space: normal; position: static; }
.checkin-club + .checkin-club .checkin-club-row th { border-top: 12px solid var(--c-surface); }
.checkin-club-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; min-height: 30px; }
.checkin-club-name { font-size: 1rem; font-weight: 700; color: var(--c-text); }
.checkin-club-progress { font-variant-numeric: tabular-nums; color: var(--c-text-2); }
.checkin-club-invoice { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.checkin-team { scroll-margin-top: 96px; }
.checkin-team:target > * { background: var(--c-primary-soft); }
/* Toisen käyttäjän muutos (reaaliaikainen synkronointi) korostuu hetken. */
@keyframes ck-synced { from { background-color: var(--c-info-bg); } to { background-color: transparent; } }
.checkin-table tr.checkin-team.is-synced, .checkin-table tr.checkin-team.is-synced > * { animation: ck-synced 2.5s ease-out; }
/* Omat vuoroni: uusi tai muuttunut ottelu (vuoroja jaettiin toisaalla) korostuu hetken. */
[data-my-shifts] tr.is-synced > * { animation: ck-synced 2.5s ease-out; }
@media (max-width: 760px) {
  .checkin-toolbar { grid-template-columns: minmax(0, 1fr); }
  .checkin-toolbar .segmented { grid-column: 1; grid-row: 4; margin-top: 10px; }
  .segmented { display: flex; }
  .segmented-item { flex: 1 1 0; min-width: 0; padding: 6px 8px; }
  .checkin-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .checkin-table, .checkin-table tbody, .checkin-table tr.checkin-club-row, .checkin-table .checkin-club-row th { display: block; }
  .checkin-table tr.checkin-team { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name division" "first countdown" "arrival arrival"; align-items: center; gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--c-border); }
  .checkin-table tbody tr.checkin-team:last-child { border-bottom: 0; }
  .checkin-table tr.checkin-team > * { display: block; width: auto; min-width: 0; padding: 0; border: 0; background: transparent; }
  .checkin-table tr.checkin-team.row-alert, .checkin-table tr.checkin-team:target { background: var(--c-warn-bg); }
  .checkin-table tr.checkin-team:target { background: var(--c-primary-soft); }
  .checkin-table tbody tr.checkin-team:hover > * { background: transparent; }
  .checkin-table .ck-name { grid-area: name; }
  .checkin-table .ck-division { grid-area: division; justify-self: end; }
  .checkin-table .ck-first { grid-area: first; }
  .checkin-table .ck-countdown { grid-area: countdown; justify-self: end; }
  .checkin-table .ck-countdown:empty { display: none; }
  .checkin-table .ck-arrival { grid-area: arrival; }
  .checkin-table .ck-award { grid-row: 4; grid-column: 1; justify-self: start; }
  .checkin-table .ck-award + .ck-award { grid-column: 2; justify-self: end; }
  .checkin-table .ck-award.is-empty { display: none; }
  .checkin-table .ck-award.is-done[data-label]::before { content: attr(data-label) " "; color: var(--c-muted); font-size: 0.8125rem; margin-right: 4px; }
  .checkin-table .ck-first[data-label]::before { content: attr(data-label) " "; color: var(--c-muted); font-size: 0.8125rem; margin-right: 4px; }
}
@media (max-width: 480px) {
  .segmented-item { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 0.875rem; }
}

/*
 * Ilmoittautumiset: sama haku, tilavalitsin ja seuran otsikkorivi kuin saapumisissa (checkin-toolbar, checkin-club-*),
 * joukkuerivillä tasoryhmä, peliasut, logo ja pelaajat (src/routes/admin/entries.tsx).
 */
.entries-list [hidden] { display: none !important; }
.entries-table tbody tr.en-team > * { vertical-align: middle; }
.entries-table tbody tr:last-child > th { border-bottom: 0; }
.entries-table tbody th[scope="row"] { color: var(--c-text); font-size: 0.9375rem; font-weight: 600; white-space: normal; overflow-wrap: break-word; background: transparent; }
.entries-table tbody tr:hover th[scope="row"] { background: var(--c-surface-2); }
.entries-table .en-name .badge { margin-left: 8px; vertical-align: 1px; }
.entries-table tr.is-withdrawn .en-name-text { color: var(--c-muted); text-decoration: line-through; font-weight: 500; }
.entries-table tr.is-withdrawn > td { color: var(--c-muted); }
.entries-table .en-division { width: 11rem; white-space: nowrap; }
.entries-table .en-kits { width: 9rem; }
.entries-table .en-logo { width: 5rem; }
.entries-table .en-logo .logo-sm { margin: 0; }
.entries-table .en-players { width: 6rem; }
.en-club-state { white-space: nowrap; }
.en-club-meta { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 16px; margin-left: auto; }
.en-contact { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; color: var(--c-text-2); }
.en-contact a { overflow-wrap: anywhere; }
.en-team { scroll-margin-top: 96px; }
.en-team:target > * { background: var(--c-primary-soft); }
.en-club { scroll-margin-top: 96px; }
.en-club-title { display: inline-flex; align-items: center; gap: 2px; }
/* Pikamuokkauksen kynäkuvake: paikka on varattu aina (ei hyppyä), näkyy solun päällä ja kohdistettaessa. */
.en-edit { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin: -4px 0 -4px 4px; border-radius: 6px; color: var(--c-text-2); vertical-align: middle; opacity: 0; transition: opacity 0.12s; }
.en-edit:hover { background: var(--c-surface); color: var(--c-text); box-shadow: inset 0 0 0 1px var(--c-border-strong); }
.en-edit:focus-visible, .en-name:hover .en-edit, .en-division:hover .en-edit, .en-club-title:hover .en-edit { opacity: 1; }
.checkin-club-row .en-edit:hover { background: var(--c-surface); }
@media (hover: none) { .en-edit { opacity: 0.7; } }
.en-saved > * { animation: en-saved 2.5s ease-out; }
@keyframes en-saved { from { background-color: var(--c-primary-soft); } to { background-color: transparent; } }
.checkin-club-row.en-saved th { animation-name: en-saved-club; }
@keyframes en-saved-club { from { background-color: var(--c-primary-soft); } to { background-color: var(--c-surface-2); } }
dialog.en-dialog { max-width: min(460px, calc(100vw - 32px)); }
.en-dialog .modal-body { padding-bottom: 6px; }
.en-dialog-subject { margin: 0 0 12px; color: var(--c-text-2); }
.en-division-options { display: grid; gap: 6px; margin: 0 0 12px; padding: 0; border: 0; }
.en-division-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--c-border-strong); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.en-division-option:hover { background: var(--c-surface-2); }
.en-division-option-name { flex: 1 1 auto; }
.en-division-option-current { display: none; color: var(--c-text-2); font-size: 0.8125rem; font-weight: 500; }
.en-division-option.is-current { cursor: default; background: var(--c-primary-soft); border-color: var(--c-border-strong); }
.en-division-option.is-current .en-division-option-current { display: inline; }
.en-dialog [hidden] { display: none !important; }
.en-move-question { margin: 0 0 12px; font-weight: 600; }
.en-move-path { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; }
.en-move-division { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--c-border-strong); border-radius: var(--radius); font-weight: 600; }
.en-move-arrow { color: var(--c-text-2); font-size: 1.25rem; }
.en-move-warning { margin: 0 0 12px; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--c-warn) 35%, transparent); border-left-width: 4px; border-radius: var(--radius); background: var(--c-warn-bg); color: var(--c-text); }
.en-move-warning-title { margin: 0 0 6px; font-weight: 700; color: var(--c-warn); }
.en-move-warning ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 6px; }
@media (max-width: 760px) {
  .en-club-meta { margin-left: 0; flex-basis: 100%; }
  .entries-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .entries-table, .entries-table tbody, .entries-table tr.checkin-club-row, .entries-table .checkin-club-row th { display: block; }
  .entries-table tr.en-team { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name division" "kits players"; align-items: center; gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--c-border); }
  .entries-table tr.en-team.has-logo { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "logo name division" "logo kits players"; }
  .entries-table tbody tr.en-team:last-child { border-bottom: 0; }
  .entries-table tr.en-team > * { display: block; width: auto; min-width: 0; padding: 0; border: 0; background: transparent; }
  .entries-table tr.en-team > td[colspan] { grid-column: 1 / -1; }
  .entries-table tr.en-team:target { background: var(--c-primary-soft); }
  .entries-table tbody tr.en-team:hover > * { background: transparent; }
  .entries-table .en-logo { grid-area: logo; }
  .entries-table .en-logo.is-empty { display: none; }
  .entries-table .en-name { grid-area: name; }
  .entries-table .en-division { grid-area: division; justify-self: end; }
  .entries-table .en-kits { grid-area: kits; }
  .entries-table .en-players { grid-area: players; justify-self: end; }
  .entries-table .en-division { display: flex; align-items: center; gap: 4px; }
  .entries-table .en-kits[data-label]::before, .entries-table .en-players[data-label]::before { content: attr(data-label) " "; color: var(--c-muted); font-size: 0.8125rem; font-weight: 400; margin-right: 4px; }
}
/* Viisi tilaa ei mahdu puhelimen levyiseen valitsimeen tasajaolla: kohdat saavat tekstinsä levyn ja rivi vierii. */
@media (max-width: 480px) {
  .entries-list .segmented { overflow-x: auto; scrollbar-width: none; }
  .entries-list .segmented-item { flex: 1 0 auto; padding: 6px 4px; font-size: 0.8125rem; }
}

/* Turnauksen asetukset: laskutuksesta riippuvat kentät ja otsikot vaihtuvat valinnan mukaan (ilman JavaScriptia). */
form:has(input[name="billingEnabled"]:not(:checked)) [data-requires="billing"],
form:has(input[name="billingEnabled"]:checked) [data-requires-not="billing"] { display: none; }
.form-row > [data-requires] { flex: 1 1 220px; min-width: 0; }
/* Piilotetun kentän rivikaveri pysyy puolen rivin levyisenä. */
form:has(input[name="billingEnabled"]:not(:checked)) .form-row:has(> [data-requires="billing"]) > .field { flex: 0 1 calc(50% - 8px); }

/* Pelinohjaajat → Henkilöt: Otteluita-otsikon alla aikataulutetut ja ohjatut (kaksi otsikkoriviä, ei kiinnitystä). */
.people-table thead th { position: static; }
.people-table thead th.th-group { text-align: center; padding-bottom: 2px; border-bottom-color: transparent; }
.people-table thead tr + tr th { padding-top: 2px; }
/* Toiminnot allekkain: sarake ei vie tilaa uudelta Ohjattu-sarakkeelta (taulukko mahtuu kortin levyyn). */
.people-table td.actions-cell > form { display: block; }
.people-table td.actions-cell > form + form { margin-top: 6px; }
.people-table td.actions-cell .btn { width: 100%; }

/* Pelinohjaajat → Palkkiot (client/lib/fee-editor.ts). */
.flash-warn { background: var(--c-warn-bg); color: var(--c-warn); border-color: color-mix(in srgb, var(--c-warn) 30%, transparent); font-weight: 500; }
.fee-fill[hidden], .fee-copy[hidden] { display: none; }
.fee-fill { display: flex; align-items: center; gap: 8px; }
.fee-input { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
/* Valitsimen pitää voittaa yleinen input:not(…)-sääntö (leveys 100 %). */
.fee-table .fee-input input[type="text"][name] { width: 7.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.fee-fill .fee-input input[type="text"][data-fee-fill] { width: 5.5rem; min-height: 32px; padding-top: 4px; padding-bottom: 4px; text-align: right; }
.fee-unit { color: var(--c-muted); }
.fee-table td { vertical-align: middle; }
.fee-table td.num, .fee-table tfoot td { font-variant-numeric: tabular-nums; }
.fee-table td.fee-cell { width: 1%; }
.fee-table td.fee-cell .error { display: block; margin-top: 4px; font-size: 0.8125rem; white-space: normal; text-align: right; }
.fee-table tbody tr td.is-changed { background: var(--c-primary-soft); }
.fee-table td.is-changed .fee-input input[type="text"][name] { border-color: var(--c-warn); }
.entry-layout + .fee-sheet { margin-top: 20px; }
.fee-table tbody tr.is-former td:first-child { color: var(--c-muted); }
.fee-table tfoot th, .fee-table tfoot td { border-bottom: 0; border-top: 2px solid var(--c-border); color: var(--c-text); font-weight: 700; font-size: 0.9375rem; }
.fee-table tfoot th { text-align: right; }
.fee-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
.fee-stats .stat { padding: 10px 12px; }
.fee-stats .stat-value { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.entry-aside .flash { margin: 12px 0 0; font-size: 0.875rem; }
.fee-sheet-table { font-size: 0.875rem; }
.fee-sheet-table th, .fee-sheet-table td { padding: 7px 10px; }
.fee-sheet-table td { font-variant-numeric: tabular-nums; }
/* Tyhjät sarakkeet ovat kopioinnissa mukana, mutta sivulla vain kapea rako. */
.fee-sheet-table :is(th, td).fee-gap { width: 0; min-width: 0; padding: 0 2px; }
/* Puhelimella palkkiorivit pinotaan: nimi, luvut ja palkkiokenttä summineen näkyvät ilman vaakavieritystä. */
@media (max-width: 760px) {
  .fee-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fee-table, .fee-table tbody, .fee-table tfoot { display: block; }
  .fee-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name name" "scheduled refereed" "fee total"; align-items: center; gap: 6px 16px; padding: 12px 0; border-bottom: 1px solid var(--c-border); }
  .fee-table tbody tr:last-child { border-bottom: 0; }
  .fee-table td, .fee-table th { display: block; padding: 0; border: 0; min-width: 0; width: auto; }
  .fee-table td.fe-name { grid-area: name; }
  .fee-table td.fe-scheduled { grid-area: scheduled; text-align: left; }
  .fee-table td.fe-refereed { grid-area: refereed; }
  .fee-table td.fee-cell { grid-area: fee; text-align: left; }
  .fee-table td.fee-cell .fee-input { justify-content: flex-start; }
  .fee-table td.fee-cell .error { text-align: left; }
  .fee-table td.fe-total { grid-area: total; font-weight: 600; }
  .fee-table td[data-label]::before { content: attr(data-label) " "; color: var(--c-muted); font-size: 0.8125rem; margin-right: 4px; }
  .fee-table tbody tr:hover td, .fee-table tbody tr td.is-changed { background: transparent; }
  .fee-table tbody tr:has(td.is-changed) { background: var(--c-primary-soft); box-shadow: inset 3px 0 0 var(--c-warn); padding-left: 10px; }
  .fee-table tfoot tr { grid-template-areas: "label sum"; border-top: 2px solid var(--c-border); border-bottom: 0; }
  .fee-table tfoot th, .fee-table tfoot td { border-top: 0; }
}

/* Pelinohjaajat → Henkilöt: yhteystietojen kynä nimen vieressä ja henkilö ilman sähköpostia (client/lib/official-contact.ts). */
.oc-name:hover .en-edit, .oc-name:focus-within .en-edit { opacity: 1; }
.oc-no-email { font-style: italic; }
dialog.oc-dialog .field input:not([type="checkbox"]) { max-width: none; }
dialog.oc-dialog .modal-body > .flash { margin-bottom: 14px; }
/* Ohjeteksti valintaruudun alle (field-check ei muuten rivity), tasattuna otsikon kanssa. */
.field-check[data-contact-notify] { flex-wrap: wrap; row-gap: 2px; }
.field-check[data-contact-notify] .help { padding-left: 26px; }
.field-check[data-contact-notify][hidden] { display: none; }
