/* The neutral look (sign-in problems, the portal, anything before a game is chosen) and the page
   skeleton every game shares. A game's own theme.css is loaded on top once a campaign is open and
   restyles these same classes through the variables and a few overrides. */
:root {
  --bg: #f4f4f1; --panel: #ffffff; --ink: #1b1d22; --muted: #4d525c; --line: #d9d9d2; --line-strong: #8b8f99;
  --accent: #3442b8; --accent-ink: #ffffff; --accent-soft: #e6e8f7; --danger: #a80d26; --danger-ink: #ffffff;
  --good: #1e7a33; --warn-bg: #fff4d6; --warn-ink: #5c4300;
  --nav-bg: #ffffff; --nav-ink: #1b1d22; --nav-active-bg: #e6e8f7; --nav-active-ink: #222c85;
  --head-bg: #ffffff; --head-ink: #1b1d22;
  --font: Inter, system-ui, -apple-system, sans-serif; --font-display: 'Space Grotesk', Inter, system-ui, sans-serif; --font-label: Inter, system-ui, sans-serif;
  --radius: 10px; --border: 1px solid var(--line); --shadow: none; --control-border: 1px solid var(--line-strong);
  --tap: 44px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.45 var(--font); min-height: 100dvh; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 8px 12px; background: var(--panel); border: var(--control-border); border-radius: calc(var(--radius) - 2px); }
textarea { resize: vertical; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.boot { padding: 48px 24px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---- small pieces ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px; background: var(--panel); color: var(--ink); border: var(--control-border); border-radius: calc(var(--radius) - 2px); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; text-decoration: underline; padding: 0 8px; }
.btn.small { padding: 0 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--nav-active-ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.solid { background: var(--ink); color: var(--panel); }
.chip.bad { background: var(--danger); color: var(--danger-ink); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.title { font: 700 32px/1.1 var(--font-display); letter-spacing: -0.5px; }
.subtitle { font: 600 20px/1.2 var(--font-display); }
.label { font: 600 13px/1.2 var(--font-label); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 200px; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.cols > .main { flex: 999 1 480px; min-width: 0; }
.cols > .side { flex: 1 1 300px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font: 600 13px/1.2 var(--font-label); }
.field-hint { font-size: 13px; color: var(--muted); }
.panel { background: var(--panel); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: var(--border); }
.panel-head h2, .panel-head h3 { font: 600 18px/1.2 var(--font-display); }
.notice { display: flex; gap: 10px; padding: 12px; border-radius: calc(var(--radius) - 2px); background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; }
.empty { padding: 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; padding: 8px 12px; font: 600 13px/1.2 var(--font-label); }
.table td { padding: 8px 12px; border-top: var(--border); vertical-align: middle; }
.table td.actions { text-align: right; white-space: nowrap; }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--ink); color: var(--panel); font: 600 13px/1 var(--font-label); }
.live::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #5fd97a; }
.live.stale::before { background: #f29e2e; }
.bar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--good); }
.bar.mid > span { background: #c98a00; }
.bar.low > span { background: var(--danger); }

/* ---- fold-out menu ---- */
.menu { position: relative; }
.menu > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: var(--tap); padding: 0 14px; background: var(--panel); border: var(--control-border); border-radius: calc(var(--radius) - 2px); font-weight: 600; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] .menu-caret { transform: rotate(180deg); }
.menu-items { position: absolute; right: 0; z-index: 20; min-width: 230px; margin-top: 4px; display: flex; flex-direction: column; background: var(--panel); border: var(--control-border); border-radius: calc(var(--radius) - 2px); box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; }
.menu-item { display: flex; align-items: center; min-height: var(--tap); padding: 0 14px; background: none; border: 0; border-top: var(--border); text-align: left; font-weight: 600; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu-item:first-child { border-top: 0; }
.menu-item.danger { background: var(--ink); color: var(--panel); }

/* ---- dialogs and pick-lists ---- */
dialog.dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; background: var(--panel); color: var(--ink); border: var(--control-border); border-radius: var(--radius); box-shadow: 0 16px 48px rgba(0,0,0,.3); }
dialog.dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog.dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 10px 18px; background: var(--panel); border-bottom: var(--border); }
.dialog-head h2 { font: 700 20px/1.2 var(--font-display); }
.dialog-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 52dvh; overflow-y: auto; padding: 2px; }
.pick-group { position: sticky; top: 0; padding: 6px 4px; background: var(--panel); font: 600 13px/1.2 var(--font-label); color: var(--muted); }
.pick-item { display: flex; flex-direction: column; gap: 2px; min-height: var(--tap); padding: 8px 12px; background: var(--panel); border: var(--border); border-radius: calc(var(--radius) - 2px); text-align: left; cursor: pointer; }
.pick-item:hover { border-color: var(--accent); }
.pick-name { font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.pick-meta { font-size: 13px; font-weight: 500; color: var(--muted); }
.pick-text { font-size: 14px; color: var(--muted); }
#toasts { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { padding: 12px 16px; background: var(--ink); color: var(--panel); border-radius: var(--radius); font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--danger); color: var(--danger-ink); }

/* ---- page skeleton ---- */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 24px; background: var(--head-bg); color: var(--head-ink); border-bottom: var(--border); }
.topbar .brand { font: 700 22px/1 var(--font-display); color: inherit; text-decoration: none; }
.topbar .game-name { font: 600 14px/1.2 var(--font-label); }
.topbar a.plain { color: inherit; font-weight: 600; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 6px; }
.shell { display: flex; min-height: calc(100dvh - 64px); }
.sidenav { flex: 0 0 210px; display: flex; flex-direction: column; gap: 6px; padding: 20px 14px; background: var(--nav-bg); border-right: var(--border); }
.sidenav a { display: flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: calc(var(--radius) - 2px); color: var(--nav-ink); text-decoration: none; font-weight: 600; }
.sidenav a.sub { margin-left: 14px; font-size: 15px; }
.sidenav a[aria-current=page] { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.sidenav .nav-heading { margin: 14px 12px 2px; font: 600 12px/1.2 var(--font-label); color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.page { flex: 1 1 0; min-width: 0; padding: 26px 30px 48px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 36px 24px 60px; display: flex; flex-direction: column; gap: 28px; }

/* cards used by the core pages */
.campaign-card { display: flex; background: var(--panel); border: var(--border); border-radius: var(--radius); overflow: hidden; color: var(--ink); text-decoration: none; }
.campaign-card .swatch { flex: 0 0 120px; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center; font: 700 18px/1.05 var(--font-display); }
.campaign-card .body { flex: 1; min-width: 0; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.game-option { display: flex; align-items: center; gap: 12px; padding: 14px; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.game-option:has(input:checked) { border-color: var(--accent); }
.member-card { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 16px; }
.member-card .who { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.member-card .name { font: 700 22px/1.1 var(--font-display); }
.facts { display: flex; flex-wrap: wrap; gap: 14px; }
.fact { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
.fact b { font: 700 22px/1 var(--font-display); }
.fact span { font: 600 12px/1.3 var(--font-label); color: var(--muted); text-transform: uppercase; }
.health { flex: 1 1 160px; min-width: 140px; display: flex; flex-direction: column; gap: 4px; }
.health .row { justify-content: space-between; font: 600 13px/1.2 var(--font-label); }
.day-divider { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.day-divider h2 { font: 700 18px/1.2 var(--font-display); white-space: nowrap; }
.day-divider::after { content: ''; flex: 1; height: 2px; background: var(--line-strong); }
.note .panel-head { font-weight: 600; font-size: 15px; }
.note p { white-space: pre-wrap; overflow-wrap: anywhere; }
.memorial-card .panel-head { flex-direction: column; align-items: flex-start; gap: 2px; }
.memorial-card .epitaph { font-style: italic; font-size: 17px; }
.memorial-card dl { margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.memorial-card dt { display: inline; font-weight: 600; }
.memorial-card dd { display: inline; margin: 0; }
.deceased { opacity: .85; border-style: dashed; }
.deceased .name { text-decoration: line-through; }

/* ---- phone: the side menu becomes a bar along the bottom ---- */
@media (max-width: 820px) {
  .topbar { padding: 10px 14px; }
  .topbar .game-name { display: none; }
  .shell { flex-direction: column; min-height: 0; }
  .sidenav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex: none; flex-direction: row; gap: 0; padding: 0 0 env(safe-area-inset-bottom); border-right: 0; border-top: var(--border); overflow-x: auto; }
  .sidenav a, .sidenav a.sub { flex: 1 0 auto; justify-content: center; min-height: 58px; margin: 0; padding: 0 14px; border-radius: 0; font-size: 14px; }
  .sidenav .nav-heading { display: none; }
  .page { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); gap: 16px; }
  .wrap { padding: 20px 14px 60px; gap: 20px; }
  .title { font-size: 26px; }
  .campaign-card .swatch { flex-basis: 84px; font-size: 14px; }
  .menu-items { position: static; box-shadow: none; }
  .table th, .table td { padding: 8px; }
}
