/* Fonts are self-hosted (SIL Open Font License), no external requests. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f3f2f8;
  --surface: #ffffff;
  --surface-2: #e9e7f3;
  --text: #1e1b3a;
  --text-muted: #4f4b6e;
  --border: #d8d5e8;
  --brand: #6440f0;
  --accent: #6440f0;
  --accent-btn: #5a35e8;
  --accent-text: #ffffff;
  --link: #5a35e8;
  --play: #17a862;
  --play-soft: #e2f6ec;
  --low: #e09400;
  --stop: #c9353b;
  --stop-text: #b42328;
  --stop-soft: #fde8e9;
  --cell-off: #dddaea;
  --ok: #0b6e34;
  --ok-bg: #e2f6ec;
  --danger: #b42328;
  --danger-bg: #fde8e9;
  --danger-solid: #c9353b;
  --warn: #7a4d00;
  --warn-bg: #fff3d6;
  --series-1: #6440f0;
  --series-2: #0f9f8f;
  --series-3: #e08a00;
  --series-4: #d6408a;
  --series-5: #2f86d6;
  --series-6: #6f9a1a;
  --avatar-text: #ffffff;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17152b;
    --surface: #211e3a;
    --surface-2: #2c2849;
    --text: #f2f0ff;
    --text-muted: #c5c1e0;
    --border: #3a3560;
    --accent: #8d75ff;
    --accent-btn: #6a4cf6;
    --link: #b6a8ff;
    --play: #2fd187;
    --play-soft: #173a2c;
    --low: #f2a60c;
    --stop: #e5484d;
    --stop-text: #ff9a9d;
    --stop-soft: #3f1d2b;
    --cell-off: #343058;
    --avatar-text: #17152b;
    --ok: #7be3a9;
    --ok-bg: #173a2c;
    --danger: #ff9a9d;
    --danger-bg: #3f1d2b;
    --warn: #ffd27a;
    --warn-bg: #3a2a08;
    --series-1: #8d75ff;
    --series-2: #2dd4bf;
    --series-3: #fbbf24;
    --series-4: #f472b6;
    --series-5: #60a5fa;
    --series-6: #a3e635;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 2rem; font-weight: 750; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 0.2em; }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.05em 0.35em; border-radius: 5px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.9rem; }

/* --- frame --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: 1480px;
  margin: 0 auto;
  padding: 1rem 24px 0;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.03em; }
.brand img { width: 36px; height: 36px; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 0 1.5rem; flex: 1; }
.topbar nav a { position: relative; padding: 0.5rem 0; color: var(--text-muted); text-decoration: none; font-weight: 700; white-space: nowrap; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a[aria-current="page"] { color: var(--text); }
.topbar nav a[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px; background: var(--brand); }
.tabs svg { display: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs circle[r="1.6"] { fill: currentColor; stroke: none; }
.tab-short { display: none; }
.logout { margin: 0; }

main { max-width: 1480px; margin: 0 auto; padding: 1.75rem 24px 4rem; }
body > footer { text-align: center; color: var(--text-muted); font-size: 0.85rem; padding: 0 0 2rem; }

.page-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
main > h1 { margin-bottom: 1.25rem; }
main > h1 + .muted { margin: -0.5rem 0 1.5rem; max-width: 70ch; }

.banner { padding: 0.8rem 1.1rem; border-radius: 12px; margin-bottom: 1.25rem; font-weight: 700; }
.banner strong { font-weight: 700; }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner.err { background: var(--danger-bg); color: var(--danger); }
.banner.warn { background: var(--warn-bg); color: var(--warn); font-weight: 400; }

.new-link { display: grid; gap: 0.6rem; padding: 1rem 1.1rem; border-radius: 14px; background: var(--ok-bg); }
.link-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.link-field { flex: 1 1 18rem; font-family: ui-monospace, monospace; font-size: 0.9rem; }
.access-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1.5rem 2rem; }
.access-groups > div { display: grid; gap: 0.75rem; align-content: start; }
.install-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding: 0.8rem 1.1rem; border-radius: 14px; margin-bottom: 1.25rem; background: var(--surface-2); color: var(--text); }
.install-hint p { flex: 1 1 16rem; }
.page-kind .install-hint { margin-bottom: 0.75rem; text-align: left; }

/* Generic panel used by the settings pages. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.5rem; margin-bottom: 1.25rem; }
.card > h2 { margin-bottom: 0.5rem; }
.card > .muted { margin-bottom: 1rem; max-width: 75ch; }
.grid { display: grid; gap: 1.25rem; margin-bottom: 1.25rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid > .card { margin-bottom: 0; }

/* --- controls --- */

button, a.button {
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}
button:hover, a.button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: var(--accent-text); }
button.danger { background: transparent; border-color: var(--stop); color: var(--stop-text); }
button.danger:hover { background: var(--stop-soft); }
button.danger.strong { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
button.link { background: none; border: none; padding: 0; color: var(--link); font-weight: 700; text-decoration: underline; text-underline-offset: 0.2em; }
.danger-text { color: var(--danger) !important; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.92rem; font-weight: 700; color: var(--text-muted); }
label.check { flex-direction: row; align-items: center; gap: 0.45rem; color: var(--text); }

.inline-form { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: flex-end; }
.filters { margin-bottom: 1.25rem; }

/* --- dashboard: players --- */

.holiday { margin-bottom: 1.25rem; padding: 0.75rem 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); align-items: center; }
.holiday-label { font-weight: 700; color: var(--text-muted); }
.free-until { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr)); gap: 1.5rem; margin-bottom: 2.5rem; }

.player {
  --state: var(--play);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem 1.75rem 1.5rem;
  overflow: hidden;
}
.player.is-paused { --state: var(--stop); }
.player::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--state); }

.player-head { display: flex; align-items: center; gap: 1rem; }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--player); color: var(--avatar-text);
  font-family: var(--font-display); font-weight: 800; font-size: 1.6rem;
}
.player-head h2 { font-size: 1.9rem; font-weight: 800; }
.playing { display: flex; align-items: center; gap: 0.45rem; margin-left: auto; font-weight: 700; color: var(--play); }
.status { font-weight: 700; color: var(--state); }
.player.is-paused .status { color: var(--stop-text); }
.status .reason { color: var(--text-muted); font-weight: 400; margin-left: 0.5rem; }

.timer { display: flex; align-items: baseline; gap: 0.85rem; flex-wrap: wrap; }
.time { font-family: var(--font-display); font-weight: 800; font-size: clamp(3rem, 6vw, 4.5rem); line-height: 1; letter-spacing: -0.04em; }
.player.is-paused .time { color: var(--stop-text); }
.time-caption { color: var(--text-muted); font-weight: 700; }

.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 1.5rem 2rem; }
.meter-block { display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.meter-block h3 { font-size: 1.05rem; color: var(--text-muted); }
.meter-block .time { font-size: clamp(2.4rem, 4vw, 3.4rem); }
.meter-block.is-paused .time { color: var(--stop-text); }
.meter-block .time-caption { margin-top: -0.35rem; }
.meter-block .reason { color: var(--text-muted); font-size: 0.92rem; }
.meter-block .budget { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.meter-block.is-paused .time-caption { font-weight: 400; }

/* The energy bar: one segment per 15 minutes of today's budget. */
.energy { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.cell { height: 22px; border-radius: 6px; background: var(--cell-off); }
.cell.left { background: var(--play); }
.cell.low { background: var(--low); }
.cell.paused { background: repeating-linear-gradient(-45deg, var(--stop) 0 5px, transparent 5px 10px); box-shadow: inset 0 0 0 2px var(--stop); }

.budget { display: flex; gap: 2.5rem; flex-wrap: wrap; margin: 0; }
.budget div { display: flex; flex-direction: column; }
.budget dt { color: var(--text-muted); font-size: 0.92rem; }
.budget dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.week-bar { height: 8px; border-radius: 8px; background: var(--cell-off); overflow: hidden; margin-top: -0.5rem; }
.week-bar span { display: block; height: 100%; background: var(--player); border-radius: inherit; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin: 0; padding: 0; }
.chips a { text-decoration: none; color: inherit; }
.chips a:hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.chip { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.85rem 0.4rem 0.7rem; border-radius: 999px; background: var(--surface-2); }
.chip-name { font-weight: 700; }
.chip-state { color: var(--text-muted); font-size: 0.92rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); opacity: 0.5; flex: none; }
.active .dot, .dot.active { background: var(--play); opacity: 1; box-shadow: 0 0 0 3px var(--play-soft); }

.overrides { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.overrides li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0.9rem; border-radius: 12px; border: 1.5px dashed var(--border); }
.overrides form { margin: 0; }

.controls { display: flex; flex-wrap: wrap; gap: 1.25rem 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.control-group h3 { color: var(--text-muted); margin-bottom: 0.5rem; }
.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.buttons form { margin: 0; }
.kidlink { font-weight: 700; align-self: flex-start; }

.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr)); gap: 1.5rem 3rem; }
.tool { padding-top: 1.25rem; border-top: 2px solid var(--border); }
.tool h2 { font-size: 1.2rem; margin-bottom: 0.35rem; }
.tool .muted { margin-bottom: 1rem; }

.empty { max-width: 65ch; padding: 2rem 0; }
.empty h2 { margin-bottom: 0.5rem; }

/* --- settings pages --- */

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.lead { max-width: 75ch; color: var(--text-muted); margin: -0.75rem 0 1.75rem; }

.profile-rules { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 1.75rem; margin-bottom: 1.5rem; }
.profile-rules.is-new { background: transparent; border: 2px dashed var(--border); }
.profile-rules-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem; }
.profile-rules-head h2 { width: 100%; }
.name-field { flex: 0 1 340px; }
.name-field input { font-family: var(--font-display); font-size: 1.4rem; font-weight: 750; }

.rulesets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(560px, 100%), 1fr)); gap: 2.25rem 3.5rem; }
.ruleset-optional { align-self: start; border: 2px dashed var(--border); border-radius: 18px; padding: 1.1rem 1.25rem; }
.ruleset-optional summary { cursor: pointer; display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.ruleset-optional .summary-title { font-family: var(--font-display); font-size: 1.45rem; font-weight: 800; }
.ruleset-optional[open] .ruleset { margin-top: 1rem; }
.ruleset-optional[open] .ruleset legend { display: none; }
.ruleset { border: 0; padding: 0; margin: 0; min-width: 0; }
.ruleset legend { padding: 0; font-family: var(--font-display); font-size: 1.45rem; font-weight: 800; }
.ruleset > .muted { margin: 0.2rem 0 1.1rem; }

.limits { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; margin-bottom: 1.4rem; }
.unit-input { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 10px; background: var(--bg); }
.unit-input:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.unit-input input { border: 0; background: transparent; width: 8rem; outline: none; }
.unit-input span { padding: 0 0.75rem 0 0.25rem; color: var(--text-muted); font-weight: 700; }

.week { display: grid; gap: 0.45rem; }
.day-row { display: grid; grid-template-columns: 2.4rem minmax(9rem, 15rem) 1fr; gap: 0.75rem; align-items: center; }
.day { font-family: var(--font-display); font-size: 1rem; font-weight: 800; color: var(--text); }
.win { font-variant-numeric: tabular-nums; }
.win.invalid { border-color: var(--stop); }
.track {
  position: relative;
  height: 28px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent calc(25% - 1px), var(--border) calc(25% - 1px) 25%, transparent 25% calc(50% - 1px), var(--border) calc(50% - 1px) 50%, transparent 50% calc(75% - 1px), var(--border) calc(75% - 1px) 75%, transparent 75%),
    var(--cell-off);
}
.slot { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; background: var(--play); }
.axis-labels { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); }
.copy-weekdays { margin-top: 0.9rem; }
.plan-days { display: grid; gap: 0.45rem; }
.plan-days .copy-weekdays, .plan-days > .muted { justify-self: start; }
.plan-row { display: grid; grid-template-columns: 2.4rem 5.2rem 5.2rem 7rem 1fr; gap: 0.6rem; align-items: center; }
.plan-head span { font-size: 0.85rem; font-weight: 700; color: var(--text-muted); }
.plan-row input { font-variant-numeric: tabular-nums; }
.plan-row input.invalid { border-color: var(--stop); }
.kid-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
@media (max-width: 700px) {
  .plan-row { grid-template-columns: 2.4rem 1fr 1fr 1fr; }
  .plan-row .track, .plan-head .axis-labels { display: none; }
}

.profile-rules-foot { display: flex; align-items: center; gap: 1.5rem; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 1rem; }
.avatar.small { width: 40px; height: 40px; border-radius: 12px; font-size: 1.15rem; }
.type-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--surface-2); color: var(--accent); }
.tile-name { width: 100%; border-color: transparent; background: transparent; padding: 0.15rem 0.35rem; margin-left: -0.35rem; font-family: var(--font-display); font-size: 1.2rem; font-weight: 750; }
.tile-name:hover { border-color: var(--border); }

.card.console { display: flex; flex-direction: column; gap: 1.1rem; margin: 0; }
.console-form { display: flex; flex-direction: column; gap: 1rem; }
.console-head { display: flex; align-items: center; gap: 0.85rem; }
.console-title { min-width: 0; flex: 1; }
.console-fields { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: flex-end; }
.console-fields label { flex: 1 1 12rem; }
.console-today { margin: 0; }
.console-sync { margin: 0; padding: 0.6rem 0.9rem; border-radius: 12px; background: var(--surface-2); font-size: 0.95rem; }
.console-sync.is-ok { background: var(--ok-bg); color: var(--ok); }
.console-sync.is-error { background: var(--warn-bg); color: var(--warn); }
.plan-line { color: var(--text-muted); }
.kid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 1.25rem; }
.kid-card { display: flex; flex-direction: column; gap: 1rem; margin: 0; }
.kid-card.is-new { background: transparent; border: 2px dashed var(--border); }
.kid-card-form { display: grid; gap: 0.9rem; }
.tile-note { color: var(--warn); font-size: 0.9rem; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-label { font-size: 0.92rem; font-weight: 700; color: var(--text-muted); }

.switch { flex-direction: row; align-items: center; gap: 0.65rem; color: var(--text); font-weight: 700; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--cell-off); transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent-btn); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }

.settings { max-width: 860px; }
.settings + .settings { margin-top: 2.5rem; }
.settings .card { display: flex; flex-direction: column; gap: 1.1rem; }
.settings .card > .muted { margin: -0.5rem 0 0; }
.switch.big { align-items: flex-start; font-weight: 400; }
.switch.big .switch-track { margin-top: 0.2rem; }
.form-actions { margin-top: 1rem; }

.crumb { display: inline-block; margin-bottom: 1rem; font-weight: 700; }
.nintendo-account { display: flex; flex-direction: column; gap: 1rem; }
.nintendo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.nintendo-device { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.nintendo-device-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.nintendo-device-head h3 { font-size: 1.15rem; }
.nintendo-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.nintendo-players li { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; padding: 0.5rem 0.75rem; border-radius: 14px; background: var(--surface-2); }
.nintendo-players img { border-radius: 50%; }
.player-name { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.steps { padding-left: 1.2rem; display: grid; gap: 0.5rem; max-width: 75ch; }
.connect-form { display: grid; gap: 0.85rem; max-width: 640px; margin-top: 1rem; }
.nintendo-line { color: var(--text-muted); font-size: 0.95rem; }
.nintendo-line strong { color: var(--text); }

.notify-events { display: grid; gap: 0.8rem; }
.recipient { display: grid; gap: 0.9rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.recipient-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.channel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.channel-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.5rem 0.75rem; border-radius: 14px; background: var(--surface-2); }
.games { display: flex; flex-direction: column; gap: 1rem; }
.games h2 .muted { font-size: 1rem; font-weight: 600; margin-left: 0.4rem; }
.game-top { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; max-width: 760px; }
.game-top > li { display: flex; align-items: center; gap: 0.85rem; }
.game-top img, .game-cover { width: 48px; height: 48px; border-radius: 10px; flex: none; object-fit: cover; }
.game-cover { display: grid; place-items: center; background: var(--surface-2); color: var(--text-muted); font-weight: 800; }
.game-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.game-line { display: flex; justify-content: space-between; gap: 1rem; }
.game-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-bar { height: 8px; border-radius: 8px; background: var(--cell-off); overflow: hidden; }
.game-bar span { display: block; height: 100%; border-radius: 8px; background: var(--series-1); }
.game-details summary { cursor: pointer; font-weight: 700; color: var(--link); }
.game-stats { max-width: 900px; gap: 1.1rem; }
.game-stats img, .game-stats .game-cover { width: 64px; height: 64px; border-radius: 12px; }
.game-facts { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.92rem; }
.game-kid { color: var(--text-muted); }
.game-kid strong { color: var(--text); }
.game-shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.6rem; }
.game-shelf li { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; border-radius: 12px; background: var(--surface-2); }
.game-shelf img, .game-cover.small { width: 40px; height: 40px; border-radius: 8px; flex: none; object-fit: cover; }
.game-days { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.9rem; max-width: 760px; }
.game-days > li { display: flex; flex-direction: column; gap: 0.4rem; }
.game-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.game-chips li { padding: 0.3rem 0.7rem; border-radius: 999px; background: var(--surface-2); font-size: 0.9rem; }

.manual { margin-top: 1.5rem; }
.manual summary { cursor: pointer; font-weight: 700; color: var(--link); }
.manual > .muted { margin: 0.75rem 0 1rem; }

/* --- history --- */

.chart { position: relative; height: 280px; }
.chart.tall { height: 340px; }
.heatmap { display: grid; gap: 4px; overflow-x: auto; }
.hm-row { display: grid; grid-template-columns: 2.4rem repeat(24, minmax(16px, 1fr)); gap: 4px; }
.hm-head span { font-size: 0.8rem; color: var(--text-muted); }
.hm-day { font-family: var(--font-display); font-weight: 800; align-self: center; }
.hm-cell { aspect-ratio: 1; border-radius: 4px; background: var(--cell-off); position: relative; overflow: hidden; }
.hm-cell::after { content: ""; position: absolute; inset: 0; background: var(--accent); opacity: var(--a); }

/* --- log --- */

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 8rem 6.5rem 1fr; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.events time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tag { font-weight: 700; color: var(--text-muted); }
.ev-block .tag, .ev-error .tag { color: var(--danger); }
.ev-unblock .tag { color: var(--ok); }
.ev-parent .tag { color: var(--link); }
.ev-dryrun .tag { color: var(--warn); }
.ev-online .tag { color: var(--play); }
.ev-offline .tag, .ev-roam .tag { color: var(--text-muted); }

.filter-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.filter-tabs a { padding: 0.4rem 0.9rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 700; text-decoration: none; }
.filter-tabs a[aria-current="page"] { background: var(--accent-btn); color: var(--accent-text); }

/* --- login --- */

.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login h1 { margin: 0.75rem 0 0; }
.login form { display: flex; flex-direction: column; gap: 1rem; text-align: left; margin-top: 1.5rem; }

/* --- kid view --- */

/* The kid view doubles as an installable app (PWA), always in the dark palette. */
.page-kind {
  --bg: #17152b; --surface: #211e3a; --surface-2: #2c2849; --text: #f2f0ff; --text-muted: #c5c1e0;
  --border: #3a3560; --play: #2fd187; --low: #f2a60c; --stop: #e5484d; --stop-text: #ff9a9d; --cell-off: #343058;
  color-scheme: dark;
  min-height: 100dvh;
}
.page-kind main {
  max-width: 640px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
}
.kid-app { flex: 1; display: flex; flex-direction: column; }
.kid { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem; }
.kid-head { display: flex; align-items: center; gap: 0.75rem; align-self: stretch; }
.kid-head h1 { font-size: 1.6rem; }
.kid-main { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; padding: 2rem 0; }
.kid-label { font-size: 1.35rem; color: var(--text-muted); font-weight: 700; }
.kid-big { font-family: var(--font-display); font-size: clamp(4.5rem, 24vw, 9rem); font-weight: 800; letter-spacing: -0.05em; line-height: 1; }
.kid.is-allowed .kid-big { color: var(--play); }
.kid.is-paused .kid-big { color: var(--stop-text); }
.kid-energy { width: 100%; max-width: 520px; margin: 2rem 0 0.75rem; }
.kid-energy .cell { height: 36px; border-radius: 9px; }
.kid-small { color: var(--text-muted); }
.kid-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.kid-facts li { padding: 0.6rem 1.1rem; border-radius: 999px; background: var(--surface-2); font-weight: 700; }
.kid-facts .is-paused { color: var(--stop-text); }
.kid-preview { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; margin-bottom: 1rem; padding: 0.7rem 1rem; border-radius: 14px; background: var(--surface-2); color: var(--text); font-weight: 700; text-decoration: none; }
.kid-preview span { color: var(--text-muted); font-weight: 400; font-size: 0.9rem; }
.kid-statslink { margin-top: 1.25rem; padding: 0.85rem 1.6rem; border-radius: 999px; background: var(--brand); color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; }
.kid-statslink::after { content: " \2192"; }
.kid-statslink:focus-visible, .kid-back:focus-visible { outline: 3px solid var(--play); outline-offset: 3px; }
.kid-subhead { margin-bottom: 1.25rem; }
.kid-subhead h1 { font-size: 1.45rem; }
.kid-back { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); color: var(--text); font-size: 1.4rem; font-weight: 700; text-decoration: none; }

/* Statistics below the fold: tabs, numbers, a bar chart and the games. */
.kid-stats { display: flex; flex-direction: column; gap: 1.25rem; padding: 1.4rem 1.2rem; border-radius: 24px; background: var(--surface); }
.kid-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 999px; background: var(--bg); }
.kid-tabs a { padding: 0.55rem 0.25rem; border-radius: 999px; text-align: center; color: var(--text-muted); font-weight: 700; text-decoration: none; white-space: nowrap; }
.kid-tabs a[aria-current="page"] { background: var(--brand); color: #fff; }
.kid-tabs a:focus-visible { outline: 3px solid var(--play); outline-offset: 2px; }
.kid-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); gap: 0.75rem; margin: 0; }
.kid-numbers div { display: flex; flex-direction: column-reverse; gap: 0.15rem; }
.kid-numbers dt { color: var(--text-muted); font-size: 0.9rem; font-weight: 700; }
.kid-numbers dd { margin: 0; font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.kid-chart { position: relative; height: 170px; margin-top: 0.75rem; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; align-items: end; padding-bottom: 1.4rem; }
.kid-chart.is-dense { gap: 2px; }
.kid-bar { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.kid-col { flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.kid-col span { width: 100%; max-width: 56px; border-radius: 6px 6px 2px 2px; background: var(--brand); }
.kid-chart.is-dense .kid-col span { border-radius: 3px 3px 1px 1px; }
.kid-bar.is-current .kid-col span { background: var(--play); }
.kid-bar.is-over .kid-col span { background: var(--low); }
.kid-bar small { position: absolute; bottom: -1.4rem; left: 50%; transform: translateX(-50%); font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.kid-bar.is-current small { color: var(--text); font-weight: 700; }
.kid-limit { position: absolute; left: 0; right: 0; height: 0; bottom: calc(1.4rem + (100% - 1.4rem) * var(--p) / 100); border-top: 2px dashed var(--text-muted); z-index: 1; pointer-events: none; }
.kid-limit em { position: absolute; right: 0; bottom: 2px; font-style: normal; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); background: var(--surface); padding: 0 0.3rem; border-radius: 4px; }
.kid-games { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.kid-games > li { display: flex; align-items: center; gap: 0.85rem; text-align: left; }
.kid-games img, .kid-games .game-cover { width: 56px; height: 56px; border-radius: 12px; flex: none; object-fit: cover; }
.kid-games .game-bar span { background: var(--play); }
.kid-empty { color: var(--text-muted); }
.kid-stamp { text-align: center; color: var(--text-muted); font-size: 0.85rem; min-height: 1.3em; margin-top: 0.75rem; }
.is-offline .kid-stamp { color: var(--low); }

/* Phones: the menu becomes a tab bar at the bottom, like an app. */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .topbar { gap: 1rem; padding: max(0.75rem, env(safe-area-inset-top)) 16px 0; }
  .topbar nav {
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 0;
    padding: 0.35rem 4px max(0.35rem, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .topbar nav a { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.3rem 0; font-size: 0.72rem; }
  .topbar nav a[aria-current="page"] { color: var(--accent); }
  .topbar nav a[aria-current="page"]::after { display: none; }
  .tabs svg { display: block; }
  .tab-wide, .tab-long { display: none !important; }
  .tab-short { display: inline; }
  .logout { margin-left: auto; }
  body > footer { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  main { padding: 1.25rem 16px 3rem; }
  .player { padding: 1.4rem 1.1rem 1.2rem; border-radius: 20px; }
  .profile-rules { padding: 1.25rem 1rem; }
  .day-row { grid-template-columns: 2.4rem 1fr; }
  .day-row .track { grid-column: 2; }
  .day-row.axis { display: none; }
  .events li { grid-template-columns: 1fr; gap: 0.1rem; }
}

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