@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/baloo2-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/baloo2-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  --bg: #f4f4f2;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #63636b;
  --line: #e3e3df;
  --chip: #f1f1ee;
  --head: #26272b;
  --head-text: #f4f4f2;
  --orange: #ff8c00;
  --on-orange: #1b1c1f;
  --green: #0a8a0a;
  --green-text: #0a7a0a;
  --yellow: #e6a800;
  --meter-empty: #dcdcd7;
  --warn-bg: #fff1dc;
  --warn-text: #7a4300;
  --error: #b42318;
  --fun: "Baloo 2", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141518;
    --card: #1e2024;
    --text: #ececef;
    --muted: #a0a0a8;
    --line: #33363c;
    --chip: #2a2c31;
    --green-text: #5ccf5c;
    --yellow: #ffc61a;
    --meter-empty: #3a3d43;
    --warn-bg: #3a2a12;
    --warn-text: #ffc680;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--green-text); }
[hidden] { display: none !important; }
button { font-family: var(--fun); font-weight: 700; }

/* ---- app header */
.titlebar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  padding: calc(6px + env(safe-area-inset-top)) 6px 6px 12px;
  background: var(--head); color: var(--head-text);
}
.logo { flex: none; width: 38px; height: 38px; margin-right: 4px; }
.titlebar h1 { flex: 1; min-width: 0; margin: 0; font: 800 22px/1.1 var(--fun); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  min-width: 42px; min-height: 44px; padding: 0;
  background: none; border: 0; border-radius: 10px; color: inherit; cursor: pointer;
}
.icon-btn:active { background: rgb(127 127 127 / 18%); }

.status {
  margin: 8px 16px 0; padding: 6px 12px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-text); font-size: 13px;
}
.toasts, .toasts[popover] {
  position: fixed; inset: auto auto calc(16px + env(safe-area-inset-bottom)) 50%; z-index: 20;
  margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: inherit;
  transform: translateX(-50%); width: min(92vw, 420px);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: 14px; font: 600 15px/1.35 system-ui, sans-serif;
  background: var(--green); color: #fff; box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
}
.toast::before { content: "✓"; font-weight: 800; }
.toast.error { background: var(--orange); color: var(--on-orange); }
.toast.error::before { content: "!"; }
.toast.note { background: #1f6feb; color: #fff; }
.toast.note::before {
  content: "i"; flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px;
  border: 2px solid #fff; border-radius: 50%; font: 800 12px/1 Georgia, serif;
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .2s ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
}

/* ---- search, today, filters */
.controls { padding: 12px 16px 0; }
.searchrow { display: flex; gap: 6px; align-items: stretch; }
.searchrow input[type="search"] {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text);
}
.searchrow .btn { min-height: 44px; padding: 6px 12px; font-size: 15px; white-space: nowrap; }
.quick-btn[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: var(--on-orange); }
.searchrow .star-btn { padding: 0; width: 44px; display: inline-grid; place-items: center; color: var(--muted); }
.star-btn[aria-pressed="true"] { color: var(--on-orange); }
#filters-btn[aria-expanded="true"] { border-color: var(--green); }
.count-badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 5px;
  border-radius: 999px; background: var(--green); color: #fff; font-size: 12px;
}
.filter-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.active-filters { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chip.active {
  cursor: pointer; padding: 1px 8px; font: 600 12.5px/1.6 system-ui, sans-serif;
  border-color: var(--green); white-space: nowrap;
}
.chip.active span { color: var(--muted); margin-left: 1px; }
.filter-panel { margin-top: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.filters label { display: flex; flex-direction: column; min-width: 0; font-size: 12px; color: var(--muted); }
.filters select {
  margin-top: 2px; padding: 8px; font-size: 15px; min-height: 40px; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
.toggle { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--green); }

/* ---- cards (stat-strip layout) */
main { padding: 0 16px 24px; }
.count[hidden] { display: none; }
.count { flex: none; margin: 0 0 0 auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
main { padding-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row1 { display: flex; gap: 12px; padding: 12px 8px 0 12px; }
.thumb { flex: none; width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--chip); }
.head-text { min-width: 0; flex: 1; }
.card-top { display: flex; align-items: flex-start; gap: 2px; }
.name {
  flex: 1; min-width: 0; font: 700 19px/1.15 var(--fun);
  color: var(--text); text-decoration: none; padding-top: 2px;
}
.name::after { content: "\00a0↗"; color: var(--muted); font: 400 13px var(--fun); }
.actions { flex: none; display: flex; margin: -6px 0 0; color: var(--muted); }
.actions .icon-btn { min-width: 36px; min-height: 36px; }
.desc { margin: 3px 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.35; }

.strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; border-top: 1px solid var(--line); }
.strip > div { padding: 8px 4px 7px; text-align: center; border-left: 1px solid var(--line); min-width: 0; }
.strip > div:first-child { border-left: 0; }
.strip b { display: block; font: 800 20px/1.1 var(--fun); font-variant-numeric: tabular-nums; }
.strip small { display: block; color: var(--muted); font-size: 11.5px; }
.strip .best { color: var(--green-text); }
.strip .best.here { text-decoration: underline; text-underline-offset: 3px; }
.mrow { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 22px; }
.wnum { font: 700 14px/1 var(--fun); font-variant-numeric: tabular-nums; }
.meter { display: flex; gap: 2px; }
.meter i { position: relative; width: 9px; height: 8px; border-radius: 3px; background: var(--meter-empty); overflow: hidden; }
.meter i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--f, 0%); background: var(--green); }
.pending { padding: 10px 12px; }

.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: var(--chip); border-top: 1px solid var(--line); }
/* Every chip and button in the bar shares one height. */
.foot .chip, .foot .faces { height: 30px; }
.foot .chip { padding: 0 10px; font-size: 13px; }
.chip.plain { background: var(--card); border-color: var(--line); color: var(--muted); font-weight: 600; }
.foot .icon-chip { width: 36px; padding: 0; justify-content: center; cursor: pointer; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}
.foot .where { color: var(--muted); font-size: 13px; opacity: .85; }
.foot .where b { font-weight: 700; }

.interest-group { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.foot .chip.interest { cursor: pointer; width: 36px; padding: 0; justify-content: center; }
.chip.interest .star { width: 17px; height: 17px; }
.chip.interest .star { color: var(--muted); }
.chip.interest[aria-pressed="true"] { border-color: var(--yellow); }
.chip.interest[aria-pressed="true"] .star { color: var(--yellow); }
.chip.fans-count { margin-left: auto; gap: 4px; }
.chip.fans-count .star { color: var(--yellow); }
.faces { display: inline-flex; padding: 0; border: 0; background: none; cursor: pointer; }
.faces .av + .av { margin-left: -7px; }
.av {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover;
  font: 700 11px/1 var(--fun); color: #fff; background: var(--green); border: 2px solid var(--card);
}
/* Ten avatar colours, all readable with white initials (orange keeps its dark text). */
.av.c0 { background: var(--orange); color: var(--on-orange); }
.av.c1 { background: #0a8a0a; }
.av.c2 { background: #1f6feb; }
.av.c3 { background: #8250df; }
.av.c4 { background: #d6336c; }
.av.c5 { background: #0f7f80; }
.av.c6 { background: #b42318; }
.av.c7 { background: #7a4b1e; }
.av.c8 { background: #3b4cc0; }
.av.c9 { background: #5c6b10; }
.av.more { background: var(--muted); }
.av.sm { width: 30px; height: 30px; }
.av.md { width: 52px; height: 52px; font-size: 18px; border-width: 0; }
.av.head { width: 32px; height: 32px; font-size: 13px; border: 2px solid var(--head-text); }
.tag { font-size: 12px; color: var(--warn-text); background: var(--warn-bg); padding: 1px 8px; border-radius: 999px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

/* ---- buttons */
.btn {
  min-height: 44px; padding: 8px 16px; font-size: 17px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text);
}
.btn.primary { background: var(--orange); color: var(--on-orange); border-color: var(--orange); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.danger-icon { color: var(--error); margin-right: auto; }
.reset-btn { color: var(--error); border-color: var(--error); }
.icon-label { display: inline-flex; align-items: center; gap: 6px; }
.sheet-foot.row { justify-content: flex-end; align-items: center; }
.sheet-foot.row .btn { flex: none; }
/* Remove (admins) sits in the card's top-right corner; floating it means only the
   first line of the name wraps around it. */
.chip.corner-btn { float: right; height: 30px; width: 36px; padding: 0; justify-content: center; margin: -4px -2px -6px 8px; color: var(--error); cursor: pointer; }
.corner-btn svg { width: 17px; height: 17px; }
.data-table .user-cell { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.data-table .user-actions { text-align: right; white-space: nowrap; width: 1%; }
.data-table .user-actions .btn, .data-table .user-actions .icon-btn { vertical-align: middle; }
.users-table .role { color: var(--muted); font-size: 12px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 16px 24px; opacity: .6; }
.footer a { color: inherit; text-decoration: none; }
.tiny-star { margin: 0 4px; vertical-align: 0; color: var(--orange); }

/* ---- dialogs (settings, editor) */
dialog.sheet {
  width: min(92vw, 420px); padding: 0; overflow-y: auto; overscroll-behavior: contain;
  max-height: 85vh; max-height: calc(100dvh - 32px);
  border: 0; border-radius: 16px; background: var(--card); color: var(--text);
  box-shadow: 0 10px 40px rgb(0 0 0 / 40%);
}
dialog::backdrop { background: rgb(0 0 0 / 55%); }
.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 6px 6px 16px; background: var(--head); color: var(--head-text);
}
.sheet-head h2 { margin: 0; font: 800 21px/1.2 var(--fun); }
.me-name { color: var(--orange); }
.sheet-section { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--chip); }
.sheet-section p { margin: 0 0 8px; font-size: 14px; }
.sheet-body { padding: 4px 16px 12px; }
.sheet-foot {
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted); text-align: center;
}
.sheet-foot.row { display: flex; gap: 8px; justify-content: flex-end; }
dialog h3 { margin: 14px 0 6px; font: 700 16px/1.2 var(--fun); }
dialog label { display: block; margin-bottom: 10px; font-size: 14px; }
dialog input:not([type="checkbox"]) {
  display: block; width: 100%; margin-top: 4px; padding: 10px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
dialog fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; }
dialog .check { display: inline-flex; gap: 4px; margin: 0 10px 0 0; align-items: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.ok { color: var(--green-text); font-weight: 700; }
.profile { display: flex; gap: 12px; align-items: center; }
.avatar-pick { position: relative; margin: 0 !important; cursor: pointer; flex: none; }
.avatar-edit {
  position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  padding: 0 6px; border-radius: 999px; background: var(--head); color: var(--head-text); font-size: 11px;
}
.profile-main { flex: 1; min-width: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { flex: 1; min-width: 0; margin: 0 !important; }
.inline-form .btn { flex: none; }
.stack-form { display: grid; gap: 8px; }
.stack-form input { margin: 0 !important; }
.profile-links { display: flex; gap: 14px; margin-top: 6px; }
.linkish { padding: 0; border: 0; background: none; color: var(--muted); font: 13px system-ui, sans-serif; text-decoration: underline; cursor: pointer; }
.tabs { display: flex; gap: 4px; margin: 0 0 12px; border-bottom: 2px solid var(--line); }
.tab {
  flex: 1; padding: 8px 6px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px;
  background: none; color: var(--muted); font-size: 15px; cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--orange); }
.sheet-body .tabs { margin-top: 12px; }
.data-table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 14px; border-radius: 10px; overflow: hidden; }
.data-table thead th { text-align: left; padding: 7px 10px; background: var(--head); color: var(--head-text); font: 700 14px/1.2 var(--fun); }
.data-table tbody th { text-align: left; font-weight: 400; color: var(--muted); padding: 6px 10px; width: 45%; }
.data-table td { padding: 6px 10px; }
.data-table tbody tr:nth-child(odd) { background: var(--chip); }
/* Add game sits at the top so the phone keyboard never pushes its header off screen. */
#editor { margin: 12px auto auto; }
.add-body { padding-top: 12px; }
.add-body label { display: block; margin-bottom: 6px; }
.add-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.add-hint.error { color: var(--error); }
.suggestions { list-style: none; margin: 8px 0 0; padding: 0; border-radius: 10px; overflow-y: auto; max-height: 40vh; max-height: 40dvh; }
.suggestions:empty { display: none; }
.suggestions li + li { border-top: 1px solid var(--line); }
.suggest {
  display: flex; width: 100%; align-items: baseline; gap: 10px; padding: 11px 12px;
  border: 0; background: var(--chip); color: var(--text); font: 600 15px/1.3 system-ui, sans-serif; text-align: left; cursor: pointer;
}
.suggest:active { background: var(--line); }
.s-name { flex: 1; min-width: 0; }
.s-meta { flex: none; color: var(--muted); font-size: 13px; font-weight: 400; }
.share-body { padding-top: 12px; }
.share-what select {
  display: block; width: 100%; margin-top: 4px; padding: 10px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text);
}
.share-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 8px 10px 10px; }
.share-fields legend { padding: 0 4px; font-size: 13px; color: var(--muted); }
.share-fields .check { margin: 0; font-size: 14px; }
.share-label { margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.share-preview {
  margin: 0; max-height: 34vh; overflow: auto; padding: 10px; border-radius: 10px;
  background: var(--head); color: var(--head-text); font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.admin-login { margin-top: 12px; font-size: 14px; }
.admin-login summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.people { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.person { display: flex; align-items: center; gap: 8px; }
.person .pname { flex: 1; min-width: 0; font-size: 15px; }
.person .role { color: var(--muted); font-size: 12px; }
.add-person { display: flex; gap: 8px; }
.add-person input { margin: 0 !important; }
.add-person .btn { white-space: nowrap; }
.invite-body { text-align: center; }
.qr { width: min(240px, 70vw); margin: 4px auto 10px; padding: 8px; background: #fff; border-radius: 12px; }
.qr svg { display: block; width: 100%; height: auto; }
.code-label { margin: 0; color: var(--muted); font-size: 12px; }
.code { margin: 0 0 12px; font: 800 28px/1.2 var(--fun); letter-spacing: .08em; }
.hint { color: var(--muted); font-size: 13px; text-align: left; }
.bad { color: var(--error); font-weight: 700; }
.error { color: var(--error); font-size: 14px; }

/* ---- print / Save as PDF: a plain group plan, one column, large type */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; padding: 0; font: 12pt/1.4 Georgia, "Times New Roman", serif; }
  body > *:not(#print-view) { display: none !important; }
  #print-view { display: block !important; }
  .pv-title { margin: 0; font: 700 20pt/1.2 var(--fun); }
  .pv-sub { margin: 2pt 0 12pt; font-size: 10pt; color: #444; }
  .pv-game { padding: 6pt 0; border-bottom: 0.5pt solid #999; break-inside: avoid; }
  .pv-name { font-weight: 700; font-size: 13pt; }
  .pv-votes { float: right; font-size: 11pt; }
  .pv-line { font-size: 11pt; }
  .pv-desc { font-size: 10.5pt; font-style: italic; color: #333; }
  .pv-who { font-size: 10.5pt; }
  .pv-empty { font-style: italic; }
}
