/* Light is the default. data-theme="dark" on <html> switches to dark (set in Settings). */
:root {
  --bg: #f1f4fa; --top: #ffffff; --panel: #ffffff; --panel2: #e5ebf6; --line: #c9d3e6;
  --text: #17203a; --dim: #55627f;
  --accent: #ffc21a; --on-accent: #1b1500; --accent-text: #9a5600;
  --blue: #2570d8; --on-blue: #ffffff; --green: #1a9a55; --red: #d6403f;
  --right-bg: #d3f3e0; --wrong-bg: #fbdcdc;
  --warn-bg: #fff0c2; --warn-text: #6b4e00; --danger-bg: #fbdcdc; --danger-text: #9b1c1c;
  --shadow: 0 0.12rem 0.35rem #1a2a4a26;
  --radius: 1rem;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1320; --top: #0a0f1a; --panel: #1a2236; --panel2: #232d47; --line: #34415f;
  --text: #f5f8ff; --dim: #a9b6d3;
  --accent: #ffd23f; --on-accent: #1b1500; --accent-text: #ffd23f;
  --blue: #4da3ff; --on-blue: #02172e; --green: #3ddc84; --red: #ff6464;
  --right-bg: #14633a; --wrong-bg: #5b2430;
  --warn-bg: #4a3b10; --warn-text: #ffe08a; --danger-bg: #5b2430; --danger-text: #ffb3b3;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Everything is sized in rem; rem follows the screen so it looks the same on any monitor. */
html { font-size: min(2.2vh, 1.4vw); font-size: min(2.2dvh, 1.4vw); }
body {
  overscroll-behavior: none; -webkit-touch-callout: none;
  margin: 0; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: default; }
input { user-select: text; -webkit-user-select: text; }

/* ---------- top bar ---------- */
#top { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem 1.6rem; background: var(--top); border-bottom: 2px solid var(--line); flex: none; }
#nav { display: flex; gap: 1rem; }
#nav button { background: var(--panel2); border-radius: var(--radius); padding: 0.7rem 1.2rem; font-size: 1.5rem; font-weight: 700; min-height: 4rem; }
#nav button.active, #gear.active { background: var(--accent); color: var(--on-accent); }
#nav .ico { margin-right: 0.3rem; }
#clock { text-align: right; line-height: 1.05; }
#clock-time { font-size: 3.6rem; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
#clock-date { font-size: 1.5rem; color: var(--dim); white-space: nowrap; }

main#view { flex: 1; min-height: 0; padding: 1.2rem 1.6rem calc(1.8rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
#top { padding-left: calc(1.6rem + env(safe-area-inset-left)); padding-right: calc(1.6rem + env(safe-area-inset-right)); }

/* ---------- shared ---------- */
.btn { background: var(--panel2); border-radius: var(--radius); padding: 0.6rem 1.4rem; font-size: 1.5rem; font-weight: 700; min-height: 3.6rem; }
.btn:active { filter: brightness(1.3); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--danger-bg); color: var(--danger-text); }
.btn.round { width: 3.6rem; padding: 0; font-size: 2.2rem; line-height: 1; }
.btn.xl { font-size: 2.2rem; padding: 1rem 2.4rem; min-height: 5.5rem; }
.btn.back { background: var(--panel); }
.big-icon { font-size: 4rem; line-height: 1; }
.empty { margin: auto; text-align: center; font-size: 2.4rem; color: var(--dim); display: flex; flex-direction: column; gap: 1rem; align-items: center; }
.none-big { font-size: 1.8rem; color: var(--dim); padding: 1rem; }
.source-tag.warn { background: var(--warn-bg); color: var(--warn-text); border-radius: 0.6rem; padding: 0.35rem 0.9rem; font-size: 1.1rem; font-weight: 600; margin-left: auto; }
.error-box { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 1.2rem; align-items: center; font-size: 1.8rem; }
.spin { animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1rem; flex: none; }
.page-title { font-size: 2.4rem; margin: 0; }
@media (min-width: 821px) { .page-title { white-space: nowrap; } .bar .record { white-space: nowrap; } .bar .source-tag { white-space: nowrap; flex: none; } }
.scroll { overflow-y: auto; min-height: 0; flex: 1; padding-right: 0.4rem; }
.scroll::-webkit-scrollbar { width: 1rem; }
.scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 1rem; }

/* ---------- tiles / grids ---------- */
.grid { display: grid; gap: 1rem; }
.league-grid { grid-template-columns: repeat(var(--cols, 2), 1fr); flex: 1; min-height: 0; margin-top: 0.5rem; }
.team-grid { grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.game-grid { grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); }
.tile { box-shadow: var(--shadow); background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; text-align: center; padding: 1rem; border: 2px solid transparent; }
.tile:active { border-color: var(--accent); background: var(--panel2); }
.league-tile .big-icon { font-size: 7rem; }
.league-tile .tile-title { font-size: 3.4rem; font-weight: 800; }
.tile-sub { font-size: 1.4rem; color: var(--dim); }
.team-tile { min-height: 11rem; }
.team-name { font-size: 1.35rem; font-weight: 700; line-height: 1.15; }
.game-tile { min-height: 8rem; }
.game-tile .tile-title { font-size: 2rem; font-weight: 800; }
.logo, .badge { flex: none; }
.logo.md, .badge.md { width: 4rem; height: 4rem; }
.logo.lg, .badge.lg { width: 5.5rem; height: 5.5rem; }
.logo.xl, .badge.xl { width: 8rem; height: 8rem; }
.logo { object-fit: contain; }
.badge { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; text-shadow: 0 1px 3px #0008; }
.badge.md { font-size: 1.4rem; } .badge.lg { font-size: 1.9rem; } .badge.xl { font-size: 2.6rem; }

/* ---------- sports team page ---------- */
.sports, .ask { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.record { font-size: 1.6rem; color: var(--dim); font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; flex: 1; min-height: 0; }
.two-col section { display: flex; flex-direction: column; min-height: 0; }
.two-col h2 { margin: 0 0 0.6rem; font-size: 2rem; color: var(--accent-text); }
.game { box-shadow: var(--shadow); display: flex; align-items: center; gap: 1rem; background: var(--panel); border-radius: var(--radius); padding: 0.8rem 1.1rem; margin-bottom: 0.7rem; }
.wl { width: 3.6rem; text-align: center; font-size: 2rem; font-weight: 800; flex: none; }
.game.win { background: color-mix(in srgb, var(--green) 10%, var(--panel)); } .game.loss { background: color-mix(in srgb, var(--red) 8%, var(--panel)); }
.win .wl { color: var(--green); } .loss .wl { color: var(--red); } .wl.soon { font-size: 1.1rem; color: var(--dim); }
.g-main { flex: 1; min-width: 0; }
.g-vs { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.g-date { font-size: 1.2rem; color: var(--dim); }
.g-score { font-size: 2.2rem; font-weight: 800; }
.g-score.time { font-size: 1.5rem; color: var(--blue); }

/* ---------- ask ---------- */
.quiz-stage { flex: 1; display: flex; min-height: 0; }
.quiz { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1.2rem; }
.quiz-head { display: flex; align-items: center; justify-content: space-between; }
.dots { display: flex; gap: 0.8rem; }
.dot { width: 2rem; height: 2rem; border-radius: 50%; background: var(--panel2); } .dot.now { background: var(--accent); } .dot.done { background: var(--green); }
.quiz-cat { font-size: 2.2rem; font-weight: 700; color: var(--accent-text); }
.quiz-q { box-shadow: var(--shadow); flex: none; font-size: 3.8rem; font-weight: 800; text-align: center; line-height: 1.15; padding: 1rem 2rem; background: var(--panel); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; min-height: 10rem; }
.answers { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; gap: 1.2rem; flex: 1; min-height: 0; }
.answer { color: var(--text); box-shadow: var(--shadow); background: var(--panel2); border-radius: var(--radius); font-size: 2.8rem; font-weight: 800; padding: 1rem; border: 3px solid var(--line); }
.answer:active:not(:disabled) { border-color: var(--accent); }
.answer.right { background: var(--right-bg); border-color: var(--green); }
.answer.wrong { background: var(--wrong-bg); border-color: var(--red); opacity: 0.45; animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-0.6rem); } 75% { transform: translateX(0.6rem); } }
.read-btn { font-size: 1.6rem; padding: 0.7rem 1.4rem; background: var(--accent); color: #1a1a1a; font-weight: 800; }
.quiz-pics { flex: none; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.3rem; font-size: 2.4rem; line-height: 1; min-height: 3rem; }
.quiz-pics .pic.b { filter: hue-rotate(80deg); }
.quiz-pics .pic.gone { opacity: 0.25; filter: grayscale(1); }
.quiz-pics .pic-op { font-size: 2.6rem; font-weight: 800; margin: 0 0.5rem; color: var(--dim); }
.quiz-msg { flex: none; text-align: center; font-size: 2.2rem; font-weight: 700; min-height: 2.8rem; margin: -0.6rem 0; }
.reveal { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.reveal-congrats { font-size: 2.2rem; color: var(--accent-text); font-weight: 700; }
.reveal-big { font-size: 5.2rem; font-weight: 900; line-height: 1.05; }
.reveal.win .reveal-big { color: var(--green); }
.reveal-score { font-size: 4.2rem; font-weight: 800; color: var(--accent-text); }
.reveal-small { font-size: 2rem; color: var(--dim); }
.reveal-actions { display: flex; gap: 1.5rem; margin-top: 1rem; }
.reveal .source-tag { margin: 0; }

/* ---------- calendar ---------- */
.cal { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.cal-bar { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 0.9rem; flex: none; }
.cal-nav { display: flex; gap: 0.6rem; }
.cal-title { font-size: 2.6rem; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: flex; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.seg button { background: transparent; padding: 0.6rem 1.3rem; font-size: 1.5rem; font-weight: 700; min-height: 3.6rem; }
.seg button.on { background: var(--blue); color: var(--on-blue); }
/* An entry: tinted card, with the person's colour and character as a disc (not a coloured edge). */
.ev { display: flex; flex-direction: column; gap: 0.25rem; width: 100%; text-align: left; flex: none; color: var(--text); background: color-mix(in srgb, var(--c) 17%, var(--panel)); border-radius: 0.7rem; padding: 0.45rem 0.6rem 0.5rem; margin-bottom: 0.45rem; }
.ev-top { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.45rem; min-height: 1.8rem; }
.ev-av { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--c); display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; line-height: 1; box-shadow: 0 0 0 0.12rem var(--panel); }
.ev-av.lg { width: 3.8rem; height: 3.8rem; font-size: 2.1rem; }
.ev-time { font-size: 1.15rem; font-weight: 700; color: var(--dim); white-space: nowrap; }
.ev-title { font-size: 1.3rem; font-weight: 700; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.ev.compact { flex-direction: row; align-items: center; gap: 0.4rem; padding: 0.2rem 0.4rem; margin-bottom: 0.25rem; border-radius: 0.55rem; }
.ev.compact .ev-av { width: 1.5rem; height: 1.5rem; font-size: 0.9rem; }
.ev.compact .ev-title { display: block; flex: 1; min-width: 0; font-size: 1.15rem; white-space: nowrap; text-overflow: ellipsis; }
.more { display: block; width: 100%; text-align: center; background: var(--panel2); color: var(--text); border-radius: 0.6rem; font-size: 1.15rem; font-weight: 800; padding: 0.25rem; min-height: 2.3rem; flex: none; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto repeat(6, 1fr); gap: 0.35rem; flex: 1; min-height: 0; }
.dow { text-align: center; font-size: 1.3rem; font-weight: 700; color: var(--dim); text-transform: uppercase; }
.cell { display: flex; flex-direction: column; box-shadow: var(--shadow); background: var(--panel); border-radius: 0.6rem; padding: 0.3rem 0.4rem; overflow: hidden; min-height: 0; border: 2px solid transparent; }
.cell.other { opacity: 0.4; }
.cell.today, .col.today { border-color: var(--accent); }
.cell-head { display: flex; align-items: center; gap: 0.3rem; flex: none; min-width: 0; }
.cell .num { font-size: 1.4rem; font-weight: 800; margin-bottom: 0.1rem; flex: none; }
.cell.today .num { color: var(--accent-text); }
.cell-ev { flex: 1; min-height: 0; overflow: hidden; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.6rem; flex: 1; min-height: 0; }
.col { box-shadow: var(--shadow); background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 3px solid transparent; }
.col-head { background: var(--panel2); display: flex; flex-direction: column; align-items: center; padding: 0.5rem 0; flex: none; }
.col.today .col-head { background: var(--accent); color: var(--on-accent); }
.col-head .dow { color: inherit; font-size: 1.3rem; }
.col-head .dnum { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.col-body { padding: 0.5rem; overflow: hidden; flex: 1; min-height: 0; }
.none { text-align: center; color: var(--dim); font-size: 2rem; opacity: 0.5; }
.day { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 22rem; gap: 1.2rem; }
.day-list { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 0.8rem; }
.day-row { display: flex; align-items: center; gap: 1.4rem; flex: none; text-align: left; color: var(--text); background: color-mix(in srgb, var(--c) 17%, var(--panel)); border-radius: var(--radius); padding: 0.9rem 1.4rem; }
.day-title { font-size: 2.4rem; font-weight: 800; line-height: 1.1; }
.day-meta { font-size: 1.5rem; font-weight: 600; color: var(--dim); margin-top: 0.2rem; }
.day-side { display: flex; flex-direction: column; gap: 0.7rem; background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); padding: 1.1rem; overflow-y: auto; min-height: 0; }
.side-label { font-size: 1.15rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin-top: 0.3rem; }
.legend-row { display: flex; align-items: center; gap: 0.8rem; font-size: 1.5rem; font-weight: 700; }
.legend-row .ev-av { width: 2.4rem; height: 2.4rem; font-size: 1.4rem; }

/* ---------- event form ---------- */
.modal-back { position: fixed; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal { box-shadow: 0 1rem 3rem #0006; background: var(--panel); border-radius: 1.4rem; padding: 1.8rem 2.2rem; width: 52rem; max-width: 94vw; max-height: min(94vh, calc(var(--vvh, 100vh) * 0.94)); overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; font-size: 1.4rem; }
.modal h2 { margin: 0; font-size: 2.2rem; }
.modal label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--dim); font-weight: 600; flex: 1; }
.modal label.check-row { flex: none; width: fit-content; flex-direction: row; align-items: center; gap: 0.8rem; color: var(--text); font-size: 1.6rem; font-weight: 700; cursor: pointer; }
.modal input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 2.4rem; height: 2.4rem; border: 3px solid var(--line); border-radius: 0.5rem; background: var(--bg); display: inline-grid; place-content: center; cursor: pointer; }
.modal input[type=checkbox]:checked { background: var(--blue); border-color: var(--blue); }
.modal input[type=checkbox]:checked::after { content: ''; width: 0.6rem; height: 1.2rem; border: solid var(--on-blue); border-width: 0 0.28rem 0.28rem 0; transform: translateY(-0.12rem) rotate(45deg); }
.modal input[type=checkbox]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.modal input[type=text], .modal textarea, .pick-btn, .recipe-form input, .recipe-form textarea, .modal select { font: inherit; font-size: 1.6rem; padding: 0.6rem 0.8rem; border-radius: 0.6rem; border: 2px solid var(--line); background: var(--bg); color: var(--text); min-height: 3.2rem; }
.modal .row { display: flex; gap: 1rem; }
.who { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.chip { background: var(--panel2); border: 3px solid var(--c); border-radius: 2rem; padding: 0.4rem 1.2rem; font-size: 1.4rem; font-weight: 700; min-height: 3rem; }
.chip.on { background: var(--c); color: #0a0f1a; }
.form-error { color: var(--red); font-weight: 700; min-height: 1.4rem; }
.modal-actions { display: flex; gap: 0.8rem; align-items: center; position: sticky; bottom: -1.8rem; background: var(--panel); padding: 0.8rem 0 0.2rem; margin-top: auto; }
.spacer { flex: 1; }

/* ---------- gear / header ---------- */
#clock-wrap { display: flex; align-items: center; gap: 1.2rem; }
#gear { background: var(--panel2); border-radius: var(--radius); width: 4rem; height: 4rem; display: grid; place-items: center; padding: 0; flex: none; }
#gear svg { width: 2.3rem; height: 2.3rem; display: block; }

/* ---------- dinner ---------- */
.dinner { display: flex; align-items: flex-start; gap: 0.45rem; width: 100%; text-align: left; background: color-mix(in srgb, #ffa63d 22%, var(--panel)); border: 2px dashed color-mix(in srgb, #ffa63d 60%, var(--line)); border-radius: 0.6rem; padding: 0.4rem 0.6rem; font-size: 1.25rem; font-weight: 700; line-height: 1.15; color: var(--text); }
.dinner:not(.set) { background: transparent; color: var(--dim); font-weight: 600; }
.dinner-ico { flex: none; }
.dish { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; }
.dinner.compact { font-size: 1rem; padding: 0.05rem 0.35rem; margin: 0; border-width: 1px; flex: 1; min-width: 0; width: auto; align-items: center; gap: 0.25rem; }
.dinner.compact .dish { -webkit-line-clamp: 1; }
.col-foot { padding: 0.5rem; border-top: 2px solid var(--line); flex: none; min-height: 5.4rem; display: flex; }
.col-foot .dinner { flex: 1; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 0.1rem; padding: 0.3rem 0.25rem; font-size: 1.15rem; }
.col-foot .dinner .dish { flex: none; max-width: 100%; }
.day-side .dinner { font-size: 2rem; padding: 0.8rem 1rem; }

/* ---------- repeat / selects ---------- */
.modal select { appearance: auto; }
.modal .hint, .hint { color: var(--dim); font-size: 1.2rem; font-weight: 600; margin: 0 0 0.4rem; }

/* ---------- food ---------- */
.food { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.food .bar { margin-bottom: 0.4rem; }
.food h2 { margin: 0; font-size: 2rem; white-space: nowrap; color: var(--accent-text); }
.food .bar .btn { font-size: 1.3rem; white-space: nowrap; }
.item { display: flex; align-items: stretch; gap: 0.5rem; margin-bottom: 0.6rem; }
.item-main { flex: 1; display: flex; align-items: center; gap: 1rem; background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); padding: 0.7rem 1.1rem; text-align: left; font-size: 1.8rem; font-weight: 700; min-height: 4.2rem; color: var(--text); }
.item-main.static { cursor: default; }
.check { width: 2.2rem; height: 2.2rem; border: 3px solid var(--line); border-radius: 0.5rem; display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem; color: #fff; flex: none; }
.item.done .check { background: var(--green); border-color: var(--green); }
/* The tick is drawn, not typed, so it looks the same on every device. */
.check { position: relative; }
.item.done .check::after, .item.inc .check::after { content: ''; position: absolute; left: 50%; top: 46%; width: 0.6rem; height: 1.2rem; border: solid #fff; border-width: 0 0.3rem 0.3rem 0; transform: translate(-50%, -55%) rotate(45deg); }
.item.done .item-text { text-decoration: line-through; color: var(--dim); }
.x { width: 4.2rem; background: var(--panel2); border-radius: var(--radius); font-size: 1.5rem; color: var(--dim); flex: none; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.6rem; }
.quick { background: var(--panel2); border: 3px solid transparent; border-radius: var(--radius); padding: 0.7rem 0.4rem; font-size: 1.4rem; font-weight: 700; min-height: 4.4rem; color: var(--text); }
.quick:active { border-color: var(--accent); }
.quick.added { background: var(--right-bg); border-color: var(--green); }

/* ---------- settings ---------- */
.settings { max-width: 70rem; width: 100%; margin: 0 auto; }
.set { background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); padding: 1.1rem 1.5rem; margin-bottom: 1rem; }
.set h2 { margin: 0 0 0.2rem; font-size: 1.9rem; }
.set .hint { font-size: 1.4rem; margin: 0 0 0.7rem; }
.seg.big { display: inline-flex; background: var(--panel2); }
.seg.big button { font-size: 1.8rem; padding: 0.6rem 1.8rem; min-height: 4rem; min-width: 4.4rem; }
.saved { color: var(--green); font-weight: 700; font-size: 1.5rem; }
.examples { margin-top: 0.8rem; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.ex-label { color: var(--dim); font-weight: 600; font-size: 1.2rem; }
.ex { background: var(--panel2); border-radius: 0.6rem; padding: 0.2rem 0.8rem; font-size: 1.4rem; font-weight: 700; }
.urls .url { font-size: 2rem; font-weight: 800; color: var(--blue); user-select: text; -webkit-user-select: text; }
.quiz-head .btn { margin: 0 auto; }

/* ---------- tablet (iPad) in landscape: the screen is squarer, so tighten the top bar ---------- */
@media (min-width: 821px) and (max-width: 1180px) {
  #top { padding: 0.6rem 1.2rem; }
  #nav { gap: 0.6rem; }
  #nav button { padding: 0.5rem 0.9rem; font-size: 1.35rem; min-height: 3.6rem; }
  #clock-time { font-size: 3rem; } #clock-date { font-size: 1.25rem; }
  #gear { width: 3.6rem; height: 3.6rem; }
  .cal-title { font-size: 2.1rem; }
}

/* ---------- phone layout ---------- */
@media (max-width: 820px) {
  html { font-size: 14px; }
  body { height: 100dvh; }
  #top { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 0.8rem; }
  #nav { gap: 0.4rem; order: 2; width: 100%; }
  #nav button { flex: 1; padding: 0.4rem 0.2rem; min-height: 3.4rem; font-size: 1.1rem; }
  #nav .ico { margin: 0; display: block; font-size: 1.4rem; }
  #nav .lbl { font-size: 1rem; }
  #clock-wrap { width: 100%; justify-content: space-between; order: 1; }
  #clock { display: flex; align-items: baseline; gap: 0.8rem; text-align: left; }
  #clock-time { font-size: 2.2rem; white-space: nowrap; } #clock-date { font-size: 1.1rem; white-space: nowrap; }
  #gear { width: 3rem; height: 3rem; } #gear svg { width: 1.8rem; height: 1.8rem; }
  main#view { padding: 0.6rem; overflow-y: auto; }
  .cal-bar { flex-wrap: wrap; gap: 0.5rem; }
  .cal-title { font-size: 1.7rem; order: -1; flex: 1 0 100%; }
  .col-foot .dinner { flex-direction: row; gap: 0.45rem; padding: 0.4rem 0.6rem; }
  .cal-nav { flex: none; }
  .seg { order: 3; width: 100%; } .seg button { flex: 1; min-height: 3rem; font-size: 1.2rem; padding: 0.3rem; }
  .btn { font-size: 1.2rem; min-height: 3rem; padding: 0.4rem 0.9rem; }
  .btn.round { width: 3rem; }
  .icon-grid { grid-template-columns: repeat(8, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); overflow-y: auto; }
  .bracket { min-width: 70rem; }
  .modal.wide { width: 96vw; }
  .gd-line { font-size: 1.2rem; }
  .recipe-cols { grid-template-columns: 1fr; overflow-y: auto; }
  .recipe-cols section { min-height: 20rem; }
  .week { grid-template-columns: 1fr; grid-auto-rows: min-content; overflow-y: auto; gap: 0.5rem; }
  .col { flex-direction: row; flex-wrap: wrap; min-height: 4.5rem; }
  .col-head { flex-direction: row; gap: 0.4rem; padding: 0.4rem 0.8rem; width: 100%; justify-content: flex-start; }
  .col-head .dnum { font-size: 1.6rem; }
  .col-body { width: 100%; overflow: visible; padding: 0.3rem 0.5rem; }
  .col-body .none { display: none; }
  .col-foot { width: 100%; border-top: 0; padding: 0 0.5rem 0.5rem; }
  .ev { font-size: 1.2rem; }
  .month { gap: 0.2rem; }
  .ev.compact .ev-time { display: none; }
  .cell { padding: 0.15rem; } .cell .num { font-size: 1.1rem; }
  .ev.compact { font-size: 0.8rem; padding: 0.05rem 0.2rem; }
  .day { grid-template-columns: 1fr; overflow-y: auto; }
  .day-list { overflow: visible; }
  .day-row { padding: 0.7rem 1rem; } .day-title { font-size: 1.8rem; }
  .two-col { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .food h2 { white-space: normal; font-size: 1.6rem; }
  .food .bar { flex-wrap: wrap; gap: 0.5rem; }
  .food .two-col section { min-height: 22rem; }
  .modal { padding: 1.1rem; width: 96vw; }
  .modal-actions { bottom: -1.1rem; }
  .modal .row { flex-direction: column; }
  .page-title { font-size: 1.7rem; }
  .league-tile .big-icon { font-size: 4rem; } .league-tile .tile-title { font-size: 2rem; }
  .team-grid { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
  .league-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .quiz-q { font-size: 2.2rem; } .answer { font-size: 1.8rem; }
  .reveal-big { font-size: 3rem; } .reveal-score { font-size: 2.6rem; }
}

/* ---------- tap pickers (date / time) ---------- */
.pick-btn { text-align: left; cursor: pointer; width: 100%; }
.pick-btn.empty { color: var(--dim); }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.dp-title { font-size: 2rem; font-weight: 800; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.35rem; }
.dp-day { height: 3.6rem; border-radius: 0.6rem; background: var(--panel2); font-size: 1.5rem; font-weight: 700; color: var(--text); border: 3px solid transparent; }
.dp-day.other { opacity: 0.35; } .dp-day.today { border-color: var(--accent); }
.dp-day.sel { background: var(--blue); color: var(--on-blue); }
.tp-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.tp-preview { font-size: 3rem; font-weight: 800; }
.tp-top .seg.big { margin: 0; }
.tp-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.4rem; }
.tp-btn { height: 3.2rem; border-radius: 0.6rem; background: var(--panel2); font-size: 1.6rem; font-weight: 700; color: var(--text); }
.tp-btn.sel { background: var(--blue); color: var(--on-blue); }
.modal .seg.big { align-self: flex-start; }

/* ---------- recipes ---------- */
.recipes { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.recipe-grid { grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); }
.recipe-tile { min-height: 9rem; }
.recipe-tile .tile-title { font-size: 1.8rem; font-weight: 800; }
.recipe-actions { display: flex; flex-direction: column; gap: 1rem; align-items: stretch; }
.recipe-msg { font-size: 1.5rem; font-weight: 700; min-height: 2rem; }
.item.inc .check { background: var(--green); border-color: var(--green); }
.item.skip .item-text { text-decoration: line-through; color: var(--dim); }
.recipe-form label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--dim); font-weight: 600; margin-bottom: 1rem; font-size: 1.4rem; }
.recipe-form input, .recipe-form textarea, .modal textarea { font: inherit; font-size: 1.6rem; padding: 0.6rem 0.8rem; border-radius: 0.6rem; border: 2px solid var(--line); background: var(--bg); color: var(--text); width: 100%; user-select: text; -webkit-user-select: text; }
.recipe-form .row { display: flex; gap: 1rem; }
.recipe-form .row input { flex: 1; }
textarea { resize: none; min-height: 7rem; }

/* ---------- on-screen keyboard ---------- */
.osk { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--panel2); border-top: 2px solid var(--line); padding: 0.3rem 0.8rem 0.7rem; box-shadow: 0 -0.4rem 1.2rem #0004; user-select: none; }
.osk[hidden] { display: none; }
.osk-row { display: flex; gap: 0.4rem; margin-top: 0.4rem; justify-content: center; }
.osk-key { flex: 1 1 0; max-width: 8rem; height: 3.6rem; border-radius: 0.6rem; background: var(--panel); box-shadow: var(--shadow); font-size: 1.7rem; font-weight: 700; color: var(--text); padding: 0; }
.osk-key.special { background: var(--panel2); border: 2px solid var(--line); }
.osk-key.on { background: var(--accent); color: var(--on-accent); }
.osk-key.wide { flex: 2 1 0; max-width: none; font-size: 1.3rem; }
.osk-key.space { flex: 7 1 0; max-width: none; }
.osk-key.done { background: var(--accent); color: var(--on-accent); }
.osk-key:active { background: var(--blue); color: var(--on-blue); }
html.kb-open .modal-back { padding-bottom: var(--kb-h, 0px); }
html.kb-open .modal { max-height: calc(100vh - var(--kb-h, 0px) - 1.5rem); }
html.kb-open main#view { padding-bottom: calc(var(--kb-h, 0px) + 1rem); }
html.kb-open .recipes .scroll, html.kb-open .food .scroll { padding-bottom: 1rem; }

/* ---------- people, characters, trivia ---------- */
.avatar { --c: #8a97b8; flex: none; border-radius: 50%; background: color-mix(in srgb, var(--c) 35%, var(--panel)); border: 0.25rem solid var(--c); display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.avatar.md { width: 4rem; height: 4rem; font-size: 2.2rem; }
.avatar.xl { width: 9rem; height: 9rem; font-size: 5rem; }
.person-chip { font-size: 1.6rem; min-height: 3.6rem; }
.person-top { display: flex; align-items: center; gap: 1.5rem; }
.person-top label { flex: 1; }
.preview-name { font-weight: 800; font-size: 1.3rem; text-align: center; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-preview { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; flex: none; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.swatch { width: 3.4rem; height: 3.4rem; border-radius: 50%; background: var(--c); border: 0.3rem solid transparent; box-shadow: var(--shadow); }
.swatch.on { border-color: var(--text); }
.swatch.on { display: inline-grid; place-items: center; }
.swatch.on::after { content: ''; width: 0.7rem; height: 1.4rem; border: solid #fff; border-width: 0 0.3rem 0.3rem 0; transform: translateY(-0.15rem) rotate(45deg); filter: drop-shadow(0 0 2px #0008); }
.icon-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 0.4rem; }
.icon-pick { height: 3.6rem; border-radius: 0.6rem; background: var(--panel2); font-size: 2rem; border: 3px solid transparent; padding: 0; }
.icon-pick.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 25%, var(--panel)); }
.modal .seg.big button { font-size: 1.4rem; padding: 0.4rem 1.1rem; min-height: 3.2rem; min-width: 3.2rem; }
.reset-row { margin-top: 0.8rem; }
.player-grid { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
.player-tile .tile-title { font-size: 2.2rem; font-weight: 800; }
.player-tile { min-height: 14rem; border-color: color-mix(in srgb, var(--c) 50%, transparent); }
.cat-grid { grid-template-columns: repeat(3, 1fr); flex: 1; min-height: 0; }
.cat-tile .big-icon { font-size: 4.5rem; } .cat-tile .tile-title { font-size: 2.2rem; font-weight: 800; }
.dot.miss { background: #ff9f1c; }

/* ---------- playoff bracket ---------- */
.b-wrap { flex: 1; min-height: 0; overflow: auto; }
.bracket { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 0.5rem; height: 100%; }
.b-col { display: flex; flex-direction: column; min-height: 0; }
.b-head { display: flex; align-items: center; justify-content: center; text-align: center; font-size: 1.05rem; line-height: 1.1; font-weight: 800; color: var(--accent-text); min-height: 2.6rem; padding-bottom: 0.3rem; }
.b-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 0.5rem; min-height: 0; }
.b-col.final .b-body { justify-content: center; align-items: stretch; }
.b-card { min-width: 0; background: var(--panel); box-shadow: var(--shadow); border-radius: 0.8rem; border: 3px solid var(--line); padding: 0.25rem 0.4rem; display: flex; flex-direction: column; gap: 0.15rem; text-align: left; color: var(--text); }
.b-card.live { border-color: var(--accent); }
.b-card.final { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.b-card.upcoming { border-style: dashed; }
.b-card:active { background: var(--panel2); }
.b-row { display: flex; align-items: center; gap: 0.25rem; font-size: 1.05rem; font-weight: 700; min-height: 2.2rem; min-width: 0; }
.b-row.win { color: var(--green); } .b-row.win .b-name::after { content: ' ✓'; }
.b-row.lose { color: var(--dim); font-weight: 600; }
.b-row.tbd { color: var(--dim); font-weight: 600; }
.b-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: clip; }
.b-seed { font-size: 0.95rem; color: var(--dim); font-weight: 600; flex: none; }
.b-score { flex: none; min-width: 1.6rem; text-align: right; font-size: 1.25rem; font-weight: 800; }
.b-dot { width: 1.3rem; height: 1.3rem; border-radius: 50%; flex: none; }
.b-dot.tbd { background: var(--line); }
.b-logo { width: 1.5rem; height: 1.5rem; object-fit: contain; flex: none; }
.b-champ { text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--green); margin-bottom: 0.6rem; }
.b-legend { display: flex; gap: 1.6rem; justify-content: center; padding-top: 0.5rem; font-size: 1.15rem; color: var(--dim); font-weight: 600; flex: none; }
.b-legend .live { color: var(--accent-text); }
.sd-side { display: flex; align-items: center; gap: 1rem; font-size: 2rem; font-weight: 800; padding: 0.6rem 1rem; background: var(--panel2); border-radius: var(--radius); }
.sd-side .b-dot, .sd-side .b-logo { width: 3rem; height: 3rem; }
.sd-side.win { background: var(--right-bg); }
.sd-side.lose { opacity: 0.6; }
.sd-name { flex: 1; } .sd-score { font-size: 2.6rem; }
.sd-text { font-size: 1.8rem; font-weight: 700; text-align: center; }

/* ---------- game details, favourites ---------- */
.modal.wide { width: 70rem; }
button.game { width: 100%; text-align: left; border: 0; color: var(--text); font: inherit; cursor: pointer; }
.g-more { font-size: 2.2rem; color: var(--dim); flex: none; }
.hint-inline { font-size: 1.1rem; color: var(--dim); font-weight: 600; margin-left: 0.5rem; }
.gd-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.gd-top h2 { margin: 0; } .gd-status { font-size: 1.5rem; font-weight: 700; color: var(--dim); }
.gd-team { display: flex; align-items: center; gap: 1rem; background: var(--panel2); border-radius: var(--radius); padding: 0.5rem 1.2rem; }
.gd-team.win { background: var(--right-bg); } .gd-team.lose { opacity: 0.75; }
.gd-name { flex: 1; font-size: 2rem; font-weight: 800; } .gd-score { font-size: 3rem; font-weight: 900; }
.gd-line { display: grid; grid-template-columns: 5rem repeat(var(--cols), 1fr) 4rem; gap: 0.2rem 0.4rem; font-size: 1.5rem; font-weight: 700; text-align: center; align-items: center; }
.gd-h { color: var(--dim); font-size: 1.2rem; } .gd-abbr { text-align: left; } .gd-total { font-weight: 900; }
.gd-sub { margin: 0.2rem 0 0; font-size: 1.7rem; color: var(--accent-text); }
.gd-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0.8rem; }
.gd-cat { background: var(--panel2); border-radius: var(--radius); padding: 0.6rem 0.9rem; }
.gd-cat-title { font-size: 1.3rem; font-weight: 800; color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem; }
.gd-player { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.gd-rank { font-size: 1.5rem; width: 2rem; flex: none; }
.gd-pname { font-size: 1.4rem; font-weight: 800; } .gd-team-abbr { font-size: 1rem; font-weight: 700; color: var(--dim); }
.gd-pdetail { font-size: 1.15rem; color: var(--dim); font-weight: 600; }
.sd-games { display: flex; flex-direction: column; gap: 0.4rem; }
.sd-game { display: flex; align-items: center; gap: 1rem; background: var(--panel2); border-radius: 0.8rem; padding: 0.5rem 1rem; font-size: 1.5rem; font-weight: 700; color: var(--text); text-align: left; min-height: 3.4rem; }
.sd-gn { width: 8rem; white-space: nowrap; color: var(--dim); } .sd-gs { flex: 1; } .sd-more { color: var(--blue); font-size: 1.2rem; }
.team-tile { position: relative; }
.team-tile.fav { border-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.fav-star { position: absolute; top: 0.3rem; right: 0.5rem; font-size: 1.5rem; }
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 0.4rem; margin-top: 0.7rem; }
.fav-chip { background: var(--panel2); border-radius: 0.6rem; padding: 0.4rem 0.6rem; font-size: 1.2rem; font-weight: 700; color: var(--text); text-align: left; min-height: 3rem; border: 3px solid transparent; }
.fav-chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--panel)); }
.fav-chip.on::before { content: '⭐ '; }
.set-gap { margin-top: 0.8rem; }

/* ---------- recipe reading view ---------- */
.recipe-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin: -0.3rem 0 0.9rem; flex: none; }
.recipe-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 1.4rem; font-size: 1.5rem; font-weight: 700; color: var(--dim); }
.recipe-tools .recipe-msg { flex: 1; text-align: right; font-size: 1.2rem; min-width: 8rem; }
.recipe-cols { display: grid; grid-template-columns: 4fr 6fr; gap: 1.6rem; flex: 1; min-height: 0; }
.recipe-cols section { display: flex; flex-direction: column; min-height: 0; }
.recipe-cols h2 { margin: 0 0 0.6rem; font-size: 2rem; color: var(--accent-text); }
.recipe-actions { display: flex; flex-direction: column; gap: 0.8rem; margin: 1rem 0 0.4rem; }
.step { display: flex; align-items: flex-start; gap: 1rem; width: 100%; text-align: left; background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); padding: 0.8rem 1.1rem; margin-bottom: 0.7rem; font-size: 1.7rem; font-weight: 600; line-height: 1.3; color: var(--text); }
.step-n { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.step.done { opacity: 0.5; }
.step.done .step-n { background: var(--green); color: #fff; }
.step.done .step-text { text-decoration: line-through; }
.recipe-form .row label { flex: 1; }

/* ---------- sign-in screen (online version) ---------- */
body.locked #nav, body.locked #gear { visibility: hidden; }
.login-wrap { margin: auto; width: 100%; display: flex; justify-content: center; }
.login-card { background: var(--panel); box-shadow: var(--shadow); border-radius: 1.4rem; padding: 2.2rem 2.6rem; width: 44rem; max-width: 94vw; display: flex; flex-direction: column; align-items: center; gap: 1rem; text-align: center; }
.login-card h1 { margin: 0; font-size: 2.8rem; }
.login-card .hint { font-size: 1.4rem; margin: 0; }
.login-card input { width: 100%; font: inherit; font-size: 2rem; padding: 0.8rem 1rem; text-align: center; border-radius: 0.8rem; border: 3px solid var(--line); background: var(--bg); color: var(--text); user-select: text; -webkit-user-select: text; }
.login-card input:focus { border-color: var(--blue); outline: none; }
.login-error { color: var(--red); font-weight: 700; font-size: 1.4rem; min-height: 1.8rem; }

/* ---------- toast (short message, optional Undo) ---------- */
.toast { position: fixed; left: 50%; bottom: calc(1.4rem + var(--kb-h, 0px)); transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 1.2rem; background: var(--text); color: var(--bg); padding: 0.8rem 1.4rem; border-radius: 1rem; font-size: 1.5rem; font-weight: 700; box-shadow: 0 0.5rem 1.6rem #0005; max-width: 92vw; animation: toast-in 0.28s cubic-bezier(0.16, 1, 0.3, 1); }
.toast-btn { background: var(--accent); color: var(--on-accent); border-radius: 0.7rem; padding: 0.4rem 1.1rem; font-size: 1.5rem; font-weight: 800; min-height: 3rem; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 1rem); } }

/* ---------- gear: hold 2 seconds to open Settings ---------- */
#gear { position: relative; -webkit-touch-callout: none; user-select: none; touch-action: none; overflow: hidden; }
#gear.holding { background-image: linear-gradient(var(--accent), var(--accent)); background-repeat: no-repeat; background-position: bottom; background-size: 100% 0%; animation: gear-fill var(--hold-ms, 2s) linear forwards; }
@keyframes gear-fill { to { background-size: 100% 100%; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- looks: Settings > Style. Each look swaps colors, fonts and corners. Light and dark both covered. ---------- */
/* Paper: a warm kitchen calendar. Serif headings, cream paper, terracotta. */
:root[data-look="paper"] {
  --bg: #f6efe0; --top: #fbf6ea; --panel: #fffaf0; --panel2: #eadfc8; --line: #d9c9a8;
  --text: #2a2016; --dim: #6a5a44;
  --accent: #c4521c; --on-accent: #ffffff; --accent-text: #a8461a;
  --blue: #2a7f7a; --on-blue: #ffffff; --green: #2f7d4a; --red: #b83a2e;
  --right-bg: #d9edd3; --wrong-bg: #f6d8cf;
  --warn-bg: #f7e4b0; --warn-text: #5e4400; --danger-bg: #f6d8cf; --danger-text: #8a2a1c;
  --shadow: 0 0.1rem 0.25rem #5a431f26;
  --radius: 0.7rem;
  --display: ui-serif, "New York", Georgia, "Times New Roman", serif;
}
:root[data-look="paper"][data-theme="dark"] {
  --bg: #1d1710; --top: #17120c; --panel: #2a2118; --panel2: #382d20; --line: #4f4130;
  --text: #f7eedd; --dim: #cbb995;
  --accent: #f08a4b; --on-accent: #231507; --accent-text: #f4a46f;
  --blue: #5cc2bb; --on-blue: #06201e; --green: #7fd69a; --red: #ff8a7a;
  --right-bg: #24502f; --wrong-bg: #5a2a22;
  --warn-bg: #4d3b12; --warn-text: #ffe0a0; --danger-bg: #5a2a22; --danger-text: #ffc0b3;
  --shadow: none;
}
/* Chalk: a classroom board. Dark green, chalk white, rounded handwriting. */
:root[data-look="chalk"][data-theme="dark"] {
  --bg: #1e3b2f; --top: #173026; --panel: #27493b; --panel2: #33594a; --line: #5d8272;
  --text: #f6f3e7; --dim: #cfdccf;
  --accent: #f8d95c; --on-accent: #1c2a10; --accent-text: #f8d95c;
  --blue: #8fd3f4; --on-blue: #0b2330; --green: #8ee6a8; --red: #ff9a8f;
  --right-bg: #2f6b47; --wrong-bg: #6b3a36;
  --warn-bg: #5b4d1c; --warn-text: #ffeaa0; --danger-bg: #6b3a36; --danger-text: #ffd0ca;
  --shadow: none;
  --radius: 1.1rem;
  --display: "Chalkboard SE", "Marker Felt", "Bradley Hand", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color-scheme: dark;
}
/* Chalk, light: a classroom whiteboard. Off-white, green marker, yellow highlighter. */
:root[data-look="chalk"][data-theme="light"] {
  --bg: #f4f6f0; --top: #ffffff; --panel: #ffffff; --panel2: #e3ebdf; --line: #a9bfae;
  --text: #17352a; --dim: #4b6657;
  --accent: #f5c518; --on-accent: #1c2a10; --accent-text: #2f6b4a;
  --blue: #1f6f8f; --on-blue: #ffffff; --green: #23794a; --red: #b83a2e;
  --right-bg: #d4eedd; --wrong-bg: #f7d9d4;
  --warn-bg: #fbeaa6; --warn-text: #5a4300; --danger-bg: #f7d9d4; --danger-text: #8a2a1c;
  --shadow: 0 0.1rem 0.25rem #17352a22;
  color-scheme: light;
}
:root[data-look="chalk"] { --radius: 1.1rem; --display: "Chalkboard SE", "Marker Felt", "Bradley Hand", ui-rounded, "SF Pro Rounded", system-ui, sans-serif; }
:root[data-look="chalk"] body { font-family: var(--display); }
:root[data-look="chalk"] .modal, :root[data-look="chalk"] .cell, :root[data-look="chalk"] .col, :root[data-look="chalk"] .tile, :root[data-look="chalk"] .b-card { border: 2px dashed var(--line); }
:root[data-look="chalk"] #top { border-bottom: 3px dashed var(--line); }
:root[data-look="paper"] #clock-time, :root[data-look="paper"] .page-title, :root[data-look="paper"] .modal h2,
:root[data-look="paper"] .col-head, :root[data-look="paper"] .cal-title, :root[data-look="paper"] .quiz-q, :root[data-look="paper"] .dnum { font-family: var(--display); font-weight: 700; }
:root[data-look="paper"] #nav button { border-radius: 0.5rem; }
:root[data-look="paper"] #nav button.active { box-shadow: 0 0.2rem 0 var(--accent-text); }

.cal-link { display: flex; flex-direction: column; gap: 0.8rem; align-items: flex-start; }
.cal-link .url { word-break: break-all; user-select: text; -webkit-user-select: text; font-size: 1.35rem; font-weight: 700; color: var(--blue); }
.cal-link .seg-row { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.cal-link .steps { margin: 0; padding-left: 1.8rem; font-size: 1.3rem; font-weight: 600; line-height: 1.5; }

/* ---------- polish: the parts the browser draws by default ---------- */
::selection { background: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--text); }
input, textarea, select { caret-color: var(--accent-text); accent-color: var(--blue); }
/* Keyboard focus (phones/PCs with a keyboard) gets a clear ring; touch taps do not. */
button:focus-visible, a:focus-visible, select:focus-visible, .pick-btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.modal input[type=text]:focus, .modal textarea:focus, .modal select:focus { border-color: var(--blue); }
/* A pressed button answers right away, even on a slow iPad. */
button:active:not(:disabled) { filter: brightness(0.94); }
button:disabled { opacity: 0.55; }
.answer:disabled.right, .answer:disabled.wrong { opacity: 1; }
.answer:disabled.wrong { opacity: 0.45; }
/* Numbers line up and do not jump as they change. */
#clock-time, .ev-time, .b-score, .b-seed, .g-score, .tp-preview, .gd-total, .dnum, .num, .record { font-variant-numeric: tabular-nums; }
/* Headings break evenly instead of leaving one lonely word. */
h1, h2, .page-title, .quiz-q, .tile-title, .ev-title, .empty { text-wrap: balance; }
.modal::-webkit-scrollbar { width: 0.9rem; }
.modal::-webkit-scrollbar-thumb { background: var(--line); border-radius: 1rem; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  #gear.holding { animation-duration: var(--hold-ms, 2s) !important; } /* the hold bar is progress, not decoration */
}

/* ---------- second polish round ---------- */
/* Month cells too small for names: little faces show who is busy, "+N" opens the day. */
.cell-ev.faces { display: flex; flex-wrap: wrap; gap: 0.2rem; align-content: flex-start; }
.cell-ev.faces .ev { width: auto; padding: 0; background: none; margin: 0; flex: none; }
.cell-ev.faces .ev-title { display: none; }
.cell-ev.faces .more { width: auto; min-height: 1.5rem; padding: 0 0.5rem; font-size: 1rem; margin: 0; border-radius: 0.75rem; }
/* Events earlier today that are already over fade back. */
.ev.past { opacity: 0.55; }
.dinner.compact { font-size: 1.1rem; }
/* On dark looks the person colors need a stronger tint or they turn muddy. */
:root[data-theme="dark"] .ev { background: color-mix(in srgb, var(--c) 28%, var(--panel)); }
@media (max-width: 820px) {
  .modal.wide { width: 96vw; }
  .recipe-cols { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .quiz { min-width: 0; }
  .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer { min-width: 0; overflow-wrap: anywhere; padding: 0.5rem; }
  .quiz-head { flex-wrap: wrap; gap: 0.5rem; }
  .quiz-head .dots { flex-wrap: wrap; }
  .dot { width: 1.1rem; height: 1.1rem; }
  #gear { flex: none; }
  .bar { flex-wrap: wrap; gap: 0.5rem; }
  #clock { flex: 1; min-width: 0; }
  #clock-date { white-space: normal !important; line-height: 1.1; min-width: 0; }
}

/* ---------- new/edit event: two columns, Save on top ---------- */
.modal.event-form { width: min(94vw, 80rem); }
.ef-head { display: flex; align-items: center; gap: 0.8rem; }
.ef-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 2.2rem; align-items: start; }
.ef-col { display: flex; flex-direction: column; gap: 0.9rem; min-width: 0; }
.event-form .row { gap: 0.8rem; }
@media (max-width: 820px) { .ef-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 821px) and (max-height: 820px) {
  .modal.event-form { padding: 1.1rem 1.8rem; gap: 0.7rem; }
  .event-form .chip { font-size: 1.25rem; min-height: 2.6rem; padding: 0.25rem 1rem; }
  .event-form .ef-col { gap: 0.5rem; }
  .event-form h2 { font-size: 1.8rem; }
  .event-form label { font-size: 1.15rem; gap: 0.15rem; }
  .event-form input[type=text], .event-form .pick-btn, .event-form select { min-height: 2.8rem; padding: 0.3rem 0.7rem; font-size: 1.45rem; }
  .event-form .btn { min-height: 3rem; padding: 0.3rem 1.1rem; }
}
@media (min-width: 821px) {
  .event-form .quick-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 0.3rem; -webkit-overflow-scrolling: touch; }
  .event-form .quick-row .chip { flex: none; white-space: nowrap; }
  .event-form .row > label:first-child { flex: 1.6; }
}

/* ---------- screen rest (black screen, faint clock, tap to wake) ---------- */
#sleep { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation; }
#sleep[hidden] { display: none; }
.sleep-time { color: #2e2e2e; font-size: 7rem; font-weight: 800; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none; }
.voice-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem; }
.voice-pick select { max-width: 100%; }

/* ---------- calendar swipe: the calendar itself does not scroll the page ---------- */
.cal .week, .cal .month { touch-action: none; }
.cal .day { touch-action: pan-y; }
@media (max-width: 820px) { .cal .week { touch-action: pan-y; } }
.slide-next { animation: slide-next 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.slide-prev { animation: slide-prev 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slide-next { from { transform: translateX(4rem); opacity: 0.2; } }
@keyframes slide-prev { from { transform: translateX(-4rem); opacity: 0.2; } }
/* iPad: stop the whole page from bouncing when a finger drags. */
html { overflow: hidden; overscroll-behavior: none; height: 100%; }
body { position: fixed; top: 0; left: 0; right: 0; }

/* ---------- sports: "what do you want to know?" ---------- */
.hub-ask { margin: 0.4rem 0 1rem; font-size: 2.2rem; }
.team-hub { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; flex: 1; min-height: 0; padding-bottom: 0.4rem; }
.hub-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.7rem; text-align: center; background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); border: 3px solid var(--line); padding: 1.2rem; color: var(--text); }
.hub-tile.win { background: var(--right-bg); border-color: var(--green); }
.hub-tile.loss { background: var(--wrong-bg); border-color: var(--red); }
.hub-title { font-size: 2.2rem; font-weight: 800; }
.hub-big { font-size: 3rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hub-sub { font-size: 1.6rem; font-weight: 600; color: var(--dim); }
.big-game { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; text-align: center; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); border: 3px solid var(--line); padding: 1.5rem; }
.big-game.win { background: var(--right-bg); border-color: var(--green); }
.big-game.loss { background: var(--wrong-bg); border-color: var(--red); }
.big-word { font-size: 3.2rem; font-weight: 800; }
.big-score { font-size: 9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.big-score.time { font-size: 7rem; }
.big-vs { font-size: 2.4rem; font-weight: 700; color: var(--dim); }
@media (max-width: 820px) { .team-hub { grid-template-columns: minmax(0, 1fr); } .hub-tile { padding: 0.8rem; } .hub-big { font-size: 2.6rem; } .big-score { font-size: 5.5rem; } .big-score.time { font-size: 4.5rem; } .big-word { font-size: 2.2rem; } .big-vs { font-size: 1.6rem; } }

/* several people on one event: little faces that overlap */
.ev-avs { display: inline-flex; align-items: center; flex: none; }
.ev-avs .ev-av + .ev-av { margin-left: -0.55rem; }
.ev-avs .ev-av.lg + .ev-av.lg { margin-left: -1.1rem; }
.ev-avs-n { margin-left: 0.3rem; font-size: 1rem; font-weight: 800; color: var(--dim); }
.ev-avs.lg .ev-avs-n { font-size: 1.4rem; }
.chip[aria-pressed] { position: relative; }

/* ---------- live games ---------- */
.live-btn { font-size: 1.6rem; background: var(--danger-bg); color: var(--danger-text); font-weight: 800; }
.live-body { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.8rem; }
.live-body h2 { margin: 0.4rem 0 0; font-size: 2rem; color: var(--accent-text); }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(26rem, 1fr)); gap: 1rem; }
.live-card { display: flex; flex-direction: column; gap: 0.5rem; text-align: left; background: var(--panel); border: 3px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); color: var(--text); }
.live-card.on { border-color: var(--red); }
.live-lg { font-size: 1.3rem; font-weight: 800; color: var(--dim); }
.live-team { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.9rem; font-weight: 700; }
.live-team b { font-size: 2.6rem; font-variant-numeric: tabular-nums; }
.live-status { font-size: 1.5rem; font-weight: 700; color: var(--dim); }
.live-status.on { color: var(--red); }
/* Top-of-page buttons stay on one line; a long title gives way first. */
@media (min-width: 821px) { .bar .btn { white-space: nowrap; flex: none; } .bar .page-title { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; } }

/* ---------- other people's calendars (Settings) ---------- */
.ext-cal { display: flex; flex-direction: column; gap: 0.9rem; align-items: stretch; }
.ext-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--panel2); border-radius: var(--radius); padding: 0.8rem 1.1rem; }
.ext-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.ext-main b { font-size: 1.7rem; }
.ext-status { font-size: 1.3rem; font-weight: 600; color: var(--green); }
.ext-status.bad { color: var(--red); }
.ext-add { display: grid; grid-template-columns: 1fr 2fr 1fr auto; gap: 0.8rem; align-items: end; }
.ext-add label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 1.2rem; font-weight: 600; color: var(--dim); min-width: 0; }
.ext-add input, .ext-add select { font: inherit; font-size: 1.5rem; padding: 0.5rem 0.7rem; border-radius: 0.6rem; border: 2px solid var(--line); background: var(--bg); color: var(--text); min-height: 3.2rem; min-width: 0; user-select: text; -webkit-user-select: text; }
@media (max-width: 820px) { .ext-add { grid-template-columns: minmax(0, 1fr); } .ext-row { flex-direction: column; align-items: stretch; } }
