/* BoardGameStats — designed for one phone passed round a dim table.
   Palette: felt green base, chalk cream text, brass for the thing you tap. */
:root {
  --felt: #17302A;
  --felt-2: #223F37;
  --felt-3: #2E5148;
  --chalk: #F1E9D6;
  --chalk-dim: #B9B3A4;
  --brass: #E0A64B;
  --brass-ink: #2B1D07;
  --loss: #C4553A;
  --focus: #FFD27A;
  --tabbar-h: 64px;
  --r: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--felt); color: var(--chalk); }
body {
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  /* Tapping a word otherwise triggers Chrome's "Touch to Search" bar. This is
     a tap-driven app, so only real fields need selectable text. */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
main#view { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); min-height: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brass); text-decoration: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

h1 { font-size: 1.75rem; margin: 0 0 .5rem; letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; font-weight: 700; color: var(--chalk); }
small, .small { font-size: .8rem; color: var(--chalk-dim); display: block; }
.muted { color: var(--chalk-dim); }
.error { color: #FFB39F; }
.pad { padding: 1.1rem 1.1rem 0; max-width: 640px; margin: 0 auto; }
.pad:last-child { padding-bottom: 1.5rem; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.spread { justify-content: space-between; }
.link { display: inline-block; margin: .5rem 0; }

/* Hero / setup */
.hero { padding-top: 3rem; }
.hero h1 { font-size: 2.6rem; }
.hero h1 span { color: var(--brass); }
.lede { font-size: 1.1rem; color: var(--chalk-dim); max-width: 28ch; }
.setup { padding-left: 1.4rem; margin-top: 2rem; }
.setup li { margin: .8rem 0; font-size: 1.05rem; }
.setup li.done { color: var(--chalk-dim); text-decoration: line-through; }
.setup li.done a { color: var(--chalk-dim); }

/* Buttons */
.primary, .ghost, .btn, .danger {
  border: 0; border-radius: var(--r); padding: .75rem 1.1rem; font-weight: 700;
  background: var(--felt-3); color: var(--chalk);
}
.primary { background: var(--brass); color: var(--brass-ink); }
.primary:disabled { opacity: .35; cursor: default; }
.ghost, .btn { background: transparent; border: 1.5px solid var(--felt-3); }
.ghost.small { padding: .4rem .7rem; font-size: .85rem; }
.ghost.danger, .danger.ghost { color: #FFB39F; border-color: transparent; }
.big { width: 100%; padding: 1rem; font-size: 1.1rem; margin-top: 1.2rem; }
.huge {
  width: 100%; padding: 1.5rem; font-size: 1.6rem; letter-spacing: -.01em; border-radius: 22px;
  box-shadow: 0 8px 0 #9C6E27, 0 12px 24px rgba(0,0,0,.35);
  transition: transform .08s, box-shadow .08s;
}
.huge:active { transform: translateY(5px); box-shadow: 0 3px 0 #9C6E27, 0 6px 12px rgba(0,0,0,.35); }

/* Fields */
.field { display: block; margin: .9rem 0 0; font-size: .85rem; color: var(--chalk-dim); }
.field input, .field select, input[type=search] {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem; border-radius: 10px;
  border: 1.5px solid var(--felt-3); background: var(--felt-2); color: var(--chalk); font-size: 1rem;
}
.field input[type=file] { padding: .5rem; }
.fieldlabel { margin: 1.1rem 0 .4rem; font-size: .85rem; color: var(--chalk-dim); }
.toggle { display: flex; align-items: center; gap: .6rem; margin: 1rem 0 0; }
.toggle input { width: 1.25rem; height: 1.25rem; accent-color: var(--brass); }

/* Avatars & box art */
.avatar {
  --c: var(--brass); display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover;
  background: var(--c); color: #fff; font-weight: 800; flex: none; border: 2px solid var(--c);
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.avatar.sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar.md { width: 44px; height: 44px; font-size: .95rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 2rem; border-width: 4px; }
.boxart { border-radius: 8px; object-fit: cover; flex: none; background: var(--felt-3); display: grid; place-items: center; font-weight: 800; color: var(--chalk-dim); }
.boxart.sm { width: 44px; height: 44px; font-size: .8rem; }
.boxart.md { width: 64px; height: 64px; }
.gamepreview { display: flex; gap: .8rem; align-items: center; margin-top: .8rem; }
.gamepreview b { display: block; }

/* Cover grid (game picking) */
.covergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .6rem; }
.cover { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .5rem .3rem; border-radius: 14px; border: 2px solid transparent; background: var(--felt-2); text-align: center; }
.cover .boxart { width: 84px; height: 84px; border-radius: 10px; }
.cover span { font-weight: 700; font-size: .85rem; line-height: 1.15; }
.cover small { font-size: .7rem; }
.cover.on { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 18%, var(--felt-2)); }

/* Turn breakdown */
.turnsummary { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
.turnsummary li { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: 12px; background: var(--felt-2); }
.turnlog { margin-top: .8rem; }
.turnlog summary { cursor: pointer; color: var(--brass); font-weight: 600; padding: .3rem 0; }
.turnlog ol { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
.turnlog li { --w: 0%; display: flex; gap: .5rem; align-items: center; padding: .3rem .4rem; }
.turnlog .rnd { width: 2.2rem; font-size: .75rem; color: var(--chalk-dim); font-variant-numeric: tabular-nums; }
.turnlog li .grow { position: relative; padding-bottom: .45rem; font-size: .9rem; }
.turnlog li .grow i { position: absolute; left: 0; bottom: 0; height: 4px; width: var(--w); background: var(--c); border-radius: 2px; }
.turnlog b { font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }

/* Player chips (seat picking) */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  --c: var(--brass); display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .8rem .35rem .35rem;
  border-radius: 999px; border: 2px solid var(--felt-3); background: var(--felt-2); position: relative;
}
.chip.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, var(--felt-2)); }
.chip .seat { min-width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--chalk); color: var(--felt);
  font-size: .75rem; display: grid; place-items: center; }
.chip:not(.on) .seat { visibility: hidden; }

.locpick { display: flex; gap: .5rem; align-items: stretch; }
.locpick select { flex: 1; padding: .7rem .8rem; border-radius: 10px; border: 1.5px solid var(--felt-3); background: var(--felt-2); color: var(--chalk); font-size: 1rem; }
.locpick .iconbtn { font-size: 1.3rem; padding: 0 1rem; }
.locicon { font-size: 1.3rem; width: 44px; text-align: center; flex: none; }

/* Live play */
.live { padding: .8rem 1.1rem 1.5rem; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; min-height: calc(100vh - var(--tabbar-h)); }
.livehead { display: flex; gap: .7rem; align-items: center; }
.livehead b { display: block; }
.gameclock { text-align: center; }
.gameclock span { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.paused .gameclock span, .paused .turnclock { color: var(--chalk-dim); }
.paused .gameclock::after { content: 'paused'; display: block; color: var(--brass); font-size: .8rem; }
.turncard {
  --c: var(--brass); display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; align-items: center;
  padding: 1.2rem; border-radius: 22px; background: var(--felt-2);
  border: 3px solid var(--c); box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 25%, transparent);
}
.turncard .avatar { grid-row: 1 / 3; }
.turnwho b { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.turnclock { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: .01em; }
.turncard.flip { animation: flip .35s ease-out; }
@keyframes flip { 0% { transform: scale(.97); opacity: .6; } 100% { transform: none; opacity: 1; } }
.seats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.seats li { display: flex; gap: .6rem; align-items: center; padding: .4rem .6rem; border-radius: 10px; }
.seats li.active { background: var(--felt-2); }
.seats li small { text-align: right; }
.seats.plain { flex-direction: row; flex-wrap: wrap; }

/* Who's next picker (variable turn order) */
.whopicker { background: var(--felt-2); border-radius: 18px; padding: .8rem 1rem 1rem; border: 2px solid var(--brass); }
.whopicker .fieldlabel { margin: 0 0 .6rem; color: var(--chalk); font-weight: 700; font-size: 1rem; }
.whogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.who { --c: var(--brass); display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .7rem .3rem; border-radius: 14px; border: 2px solid transparent; background: var(--felt); font-weight: 700; font-size: .9rem; }
.who.on { border-color: var(--c); }
.picking .turncard, .picking #next { opacity: .35; pointer-events: none; }
.iconbtn { padding: .6rem .8rem; font-size: 1.1rem; line-height: 1; }
.fsexit { display: none; }

/* Full-screen clock mode */
.fsname, .fsrow { display: none; }
body.fs .tabbar, body.fs .livehead, body.fs .seats:not(.plain), body.fs .row:not(.fsrow), body.fs #abandon, body.fs #finish { display: none; }
/* The browser's "swipe to exit full screen" banner lands along the bottom, so
   these sit at the top instead of underneath it. */
body.fs .fsrow {
  display: flex; justify-content: center; gap: .6rem; order: -1;
  flex: 0 0 auto; margin: 0; padding-top: env(safe-area-inset-top);
}
body.fs .fsrow #fsexit { opacity: .6; }
body.fs .fsname { display: block; text-align: center; color: var(--chalk-dim); font-weight: 700; margin: 0; }
/* No turn timer: the game clock is the whole show */
body.fs .noturns .gameclock span { font-size: 6rem; line-height: 1; }
body.fs .noturns .seats.plain { display: flex; justify-content: center; gap: 1rem; }
body.fs .noturns .seats.plain li { flex-direction: column; font-size: .85rem; }
body.fs .noturns .seats.plain .avatar { width: 56px; height: 56px; font-size: 1.1rem; }
body.fs .noturns .fsrow .primary { padding: 1rem 2rem; font-size: 1.1rem; }
body.fs main#view { padding-bottom: 0; }
body.fs .live { min-height: 100vh; justify-content: center; padding: 1rem 1.2rem calc(3.5rem + env(safe-area-inset-bottom)); gap: 1.6rem; }
body.fs .gameclock span { font-size: 3.2rem; }
body.fs .turncard { grid-template-columns: 1fr; text-align: center; justify-items: center; padding: 1.6rem 1.2rem; }
body.fs .turncard .avatar { grid-row: auto; width: 120px; height: 120px; font-size: 2.6rem; }
body.fs .turnwho b { font-size: 2rem; }
body.fs .turnclock { font-size: 5.5rem; }
body.fs .huge { padding: 2.2rem; font-size: 2.2rem; }
body.fs .whopicker { position: fixed; inset: auto 1rem 1rem 1rem; z-index: 5; }
@media (orientation: landscape) {
  body.fs .live { flex-direction: row; flex-wrap: wrap; align-items: center; }
  body.fs .gameclock { flex: 1 1 100%; }
  body.fs .turncard { flex: 1 1 45%; }
  body.fs .huge { flex: 1 1 45%; width: auto; }
}

/* Finish */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }
.segmented button { border: 2px solid var(--felt-3); background: var(--felt-2); border-radius: 12px; padding: .8rem; font-weight: 700; }
.segmented button.on { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 20%, var(--felt-2)); }
.segmented button[data-o=coop_loss].on { border-color: var(--loss); background: color-mix(in srgb, var(--loss) 20%, var(--felt-2)); }
.scorelist { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.scorelist li { --c: var(--brass); display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: 12px; background: var(--felt-2); }
.scorelist input { width: 5.5rem; padding: .55rem; border-radius: 8px; border: 1.5px solid var(--felt-3); background: var(--felt); text-align: right; }
.winbtn { width: 40px; height: 40px; border-radius: 50%; border: 2px dashed var(--felt-3); background: transparent; font-size: 1.1rem; filter: grayscale(1); opacity: .5; }
.winbtn.on { border-style: solid; border-color: var(--brass); background: color-mix(in srgb, var(--brass) 25%, transparent); filter: none; opacity: 1; }
.scorelist:not(.pickwinners) .winbtn { visibility: hidden; }
.scorelist.readonly .trophy { width: 1.6rem; text-align: center; }
.scorelist.readonly b { min-width: 2.5rem; text-align: right; font-size: 1.1rem; }
.result { font-weight: 700; font-size: .85rem; color: var(--brass); white-space: nowrap; }
.result.coop_loss { color: #FFB39F; }
.result.big { font-size: 1.3rem; margin: .6rem 0 0; }
.notes { background: var(--felt-2); padding: .8rem; border-radius: 12px; }

/* Lists */
.playlist, .gamelist, .peoplelist, .gamestats { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
.playlist a, .gamelist li, .peoplelist li, .gamestats li { display: flex; gap: .8rem; align-items: center; padding: .6rem; border-radius: 12px; background: var(--felt-2); color: var(--chalk); }
.playlist b, .gamelist b, .peoplelist b, .gamestats b { display: block; }
.gamestats li { align-items: flex-start; }
.gamestats small { margin-top: .15rem; }

/* Compact games list */
.gamelist.compact { gap: .25rem; }
.gamelist.compact li { padding: .3rem .4rem .3rem .3rem; }
.gamelist.compact .boxart.sm { width: 36px; height: 36px; border-radius: 6px; }
.gamelist.compact b { font-size: .9rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gamelist.compact small { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gamelist.compact .plays { font-weight: 800; font-size: 1.05rem; color: var(--brass); min-width: 1.8rem; text-align: right; font-variant-numeric: tabular-nums; }
.gamelist.compact .ghost.small { padding: .3rem .5rem; font-size: .75rem; }

.clk { width: .8em; height: .8em; vertical-align: -.08em; margin: 0 .15em 0 .05em; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* Files on a game */
.filelist { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
.filelist li { display: flex; align-items: center; gap: .4rem; background: var(--felt-2); border-radius: 10px; padding: .2rem .4rem .2rem .6rem; }
.filelist li a { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; color: var(--chalk); padding: .45rem 0; }
.filelist .ficon { flex: none; }

/* Game page */
.rowlink { display: flex; gap: .8rem; align-items: center; flex: 1; min-width: 0; color: var(--chalk); }
.gamelist li { padding-right: .6rem; }
.bars.counts li { grid-template-columns: 2.6rem 1fr auto; }
.bars .cnt { grid-row: 1 / 3; font-weight: 800; font-size: 1.1rem; color: var(--brass); }
.gamepreview h1 a { color: var(--chalk); }
a.btn { display: inline-block; }

/* Stats */
.bignums { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-top: .6rem; }
.bignums div { background: var(--felt-2); border-radius: 12px; padding: .8rem; }
.bignums b { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.bars { list-style: none; padding: 0; margin: .5rem 0 0; display: flex; flex-direction: column; gap: .5rem; }
.bars li { --w: 0%; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; gap: .1rem .7rem; align-items: center; }
.bars .avatar { grid-row: 1 / 3; }
.bars span { position: relative; padding-bottom: .5rem; font-weight: 600; }
.bars span i { position: absolute; left: 0; bottom: 0; height: 6px; width: var(--w); background: var(--c); border-radius: 3px; }
.bars b { font-variant-numeric: tabular-nums; }
.bars small { grid-column: 2 / 4; }
.h2hwrap { overflow-x: auto; }
.h2h { border-collapse: collapse; margin-top: .5rem; }
.h2h th, .h2h td { padding: .4rem .5rem; text-align: center; }
.h2h th:first-child { text-align: left; font-weight: 600; }
.h2h td { background: var(--felt-2); border-radius: 6px; min-width: 3rem; }
.h2h td.self { background: transparent; }
.h2h td small { display: inline; color: var(--chalk-dim); }

/* Sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: flex-end; z-index: 20; }
.sheet.open { display: flex; }
.sheet-panel { background: var(--felt-2); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 22px 22px 0 0; padding: 1.2rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-panel h2 { margin-top: 0; }
.sheet-panel .row.spread { margin-top: 1.2rem; }
.results { margin-top: .6rem; display: flex; flex-direction: column; gap: .3rem; }
/* Fixed-height results so the sheet doesn't jump as results come and go; scrolls inside. */
.results.fixed { height: 42vh; overflow-y: auto; align-content: start; transition: opacity .15s; }
.results.busy { opacity: .45; }
.sheet-panel:has(.results.fixed) { height: 88vh; display: flex; flex-direction: column; }
.sheet-panel:has(.results.fixed) .results.fixed { flex: 1; height: auto; }
.hit { text-align: left; border: 0; background: var(--felt); border-radius: 10px; padding: .6rem .8rem; display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.photopick { display: flex; gap: .9rem; align-items: flex-end; }
.photobtn { width: 84px; height: 84px; border-radius: 50%; border: 2px dashed var(--felt-3); display: grid; place-items: center; font-size: .75rem; color: var(--chalk-dim); overflow: hidden; flex: none; cursor: pointer; text-align: center; }
.photobtn img { width: 100%; height: 100%; object-fit: cover; }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; background: var(--c); }
.swatches button.on { border-color: var(--chalk); }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: flex; background: #102420; border-top: 1px solid var(--felt-3); z-index: 10;
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--chalk-dim); font-size: .7rem; position: relative; }
.tabbar a.active { color: var(--brass); }
.tabbar svg { width: 24px; height: 24px; fill: currentColor; }
.tabbar .dot { position: absolute; top: 8px; right: calc(50% - 14px); width: 8px; height: 8px; border-radius: 50%; background: var(--brass); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px); transform: translate(-50%, 20px); background: var(--chalk); color: var(--felt); padding: .6rem 1rem; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: var(--loss); color: #fff; }

@media (min-width: 720px) {
  .bignums { grid-template-columns: repeat(4, 1fr); }
  .segmented { grid-template-columns: repeat(4, 1fr); }
}

/* Rulebook viewer — full screen: the tab bar goes, and one slim bar floats
   over the pages so nothing is lost to chrome. Tap a page to dismiss it. */
body.reading .tabbar { display: none; }
body.reading main#view { padding-bottom: 0; }
.pdfview { position: relative; height: 100vh; overflow: hidden; }
@supports (height: 100dvh) { .pdfview { height: 100dvh; } }
.pdfbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: .35rem;
  padding: calc(.45rem + env(safe-area-inset-top)) .6rem .45rem;
  background: color-mix(in srgb, var(--felt-2) 92%, transparent);
  border-bottom: 1px solid var(--felt-3);
  transition: transform .18s ease, opacity .18s ease;
}
@supports not (background: color-mix(in srgb, red 50%, transparent)) { .pdfbar { background: var(--felt-2); } }
.pdfview.barsoff .pdfbar { transform: translateY(-102%); opacity: 0; pointer-events: none; }
.pdfbar .btn { flex: none; font-size: 1.2rem; line-height: 1; padding: .25rem .55rem; }
.pdfbar .ttl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; font-weight: 600; }
.pdfbar button { flex: none; padding: .25rem .5rem; }
.pgind { font-variant-numeric: tabular-nums; color: var(--chalk-dim); font-size: .8rem; flex: none; }
.pdfpages {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: calc(3rem + env(safe-area-inset-top)) 0 calc(1rem + env(safe-area-inset-bottom));
  background: var(--felt);
}
.pdfpg { flex: none; background: #fff; border-radius: 3px; overflow: hidden; box-shadow: 0 2px 8px #0006; }
.pdfpg canvas { display: block; }
/* Contents + search drawer, pulled out over the pages */
/* An author `display` beats the UA's [hidden] rule, so hidden must be spelled
   out here or setting .hidden changes nothing on screen. */
.pdfdrawer { position: absolute; inset: 0; z-index: 8; background: #0008; display: none; }
.pdfdrawer:not([hidden]) { display: flex; }
.drawerpanel {
  width: min(78%, 330px); background: var(--felt-2); display: flex; flex-direction: column;
  padding: calc(.6rem + env(safe-area-inset-top)) .6rem calc(.6rem + env(safe-area-inset-bottom));
  gap: .5rem; box-shadow: 2px 0 14px #0007; animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(-100%); } to { transform: none; } }
/* Search is its own panel, not part of the contents drawer. As above, an
   author display must spell out [hidden] or it can never be closed. */
.pdfsearch { position: absolute; top: 0; left: 0; right: 0; z-index: 9; display: none; flex-direction: column; }
.pdfsearch:not([hidden]) { display: flex; }
.searchhead {
  display: flex; align-items: center; gap: .5rem; flex: none;
  padding: .5rem .6rem; background: var(--felt-2); border-bottom: 1px solid var(--felt-3);
}
.searchhead input { flex: 1; min-width: 0; }
.searchhead button { flex: none; }
/* Only as tall as the results need, and never more than half the screen. */
.pdfsearch .drawerlist {
  flex: 0 1 auto; max-height: 45vh; padding: .25rem;
  background: var(--felt-2); border-radius: 0 0 12px 12px; box-shadow: 0 10px 20px #0007;
}
.pdfsearch .drawerlist:empty { display: none; }
.ditem mark { background: var(--brass); color: var(--brass-ink); border-radius: 3px; padding: 0 .1em; }

.drawerhead { display: flex; align-items: center; gap: .4rem; }
.drawerhead b { font-size: .95rem; }
.drawerhead button { flex: none; font-size: 1rem; padding: .2rem .5rem; }
.drawerpanel input[type=search] { width: 100%; }
.drawerlist { overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: .15rem; }
.ditem {
  text-align: left; border: 0; background: none; color: var(--chalk); font: inherit; font-size: .85rem;
  padding: .5rem .4rem .5rem calc(.4rem + var(--d, 0) * .8rem); border-radius: 8px; cursor: pointer;
}
.ditem:active { background: var(--felt-3); }
.ditem { display: flex; align-items: baseline; gap: .5rem; }
.ditem .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ditem i { flex: none; font-style: normal; font-size: .75rem; color: var(--chalk-dim); font-variant-numeric: tabular-nums; }
.ditem.hit { display: flex; gap: .4rem; align-items: baseline; }
.ditem.hit b { color: var(--brass); flex: none; font-variant-numeric: tabular-nums; }
.ditem.hit span { color: var(--chalk-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pdferr { color: var(--loss); font: 500 .85rem/1.4 system-ui, sans-serif; text-align: center; padding: 1.2rem .8rem; margin: 0; }
.pdferr small { color: #666; display: block; margin-top: .3rem; word-break: break-word; }
.ownermap { display: flex; flex-direction: column; gap: .2rem; max-height: 50vh; overflow-y: auto; }
.ownermap .field span { display: flex; align-items: baseline; gap: .4rem; }
.ownermap .field i { font-style: normal; font-size: .75rem; }

/* Games list: search, filters, and multi-select for bulk removal */
#gq { width: 100%; margin: .6rem 0 .4rem; }
.filters { display: flex; gap: .4rem; align-items: center; margin-bottom: .4rem; }
/* These sit outside .field, so they missed the dark form styling and rendered
   as white system boxes. appearance:none is what stops iOS re-skinning them. */
.filters select {
  flex: 1; min-width: 0; font-size: .85rem;
  padding: .5rem 1.7rem .5rem .6rem; border-radius: 10px;
  border: 1.5px solid var(--felt-3); color: var(--chalk);
  -webkit-appearance: none; appearance: none;
  background-color: var(--felt-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5l5-5' fill='none' stroke='%23B9B3A4' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .55rem center; background-size: .7rem;
}
/* The open list is drawn by the OS; this is all we can reach of it. */
.filters select option { background: var(--felt-2); color: var(--chalk); }
.filters button { flex: none; }
.gamelist li.chosen { outline: 2px solid var(--brass); }
.tick {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--chalk-dim);
  margin-left: .2rem; display: grid; place-items: center;
}
li.chosen .tick { background: var(--brass); border-color: var(--brass); }
li.chosen .tick::after { content: '✓'; color: var(--brass-ink); font-size: .8rem; font-weight: 800; }
.picking .rowlink { pointer-events: none; }
.selbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem;
  background: var(--felt-2); border-top: 1px solid var(--felt-3); z-index: 15;
}
.selbar[hidden] { display: none; }
/* Scoped: bare .danger is used elsewhere as `danger ghost`, which must keep
   its existing look. */
.selbar .danger { background: var(--loss); color: #fff; padding: .5rem .9rem; }
.selbar .danger:disabled { opacity: .4; }
.selbar .ghost { padding: .5rem .9rem; }

/* New-play wizard */
.wizhead { display: flex; align-items: center; gap: .5rem; margin: 0 0 .8rem; }
.wizhead .btn { flex: none; font-size: 1.2rem; line-height: 1; padding: .25rem .55rem; }
.wizhead b { font-size: 1.15rem; }
.wizard .big { margin-top: 1.1rem; }
.wizard .gamelist li.chosen { outline: 2px solid var(--brass); }

/* Stats: activity chart, records, shelf coverage */
/* Scoped to .seg: bare .chip is the player picker, which keeps its own colour. */
.chips.seg { display: flex; gap: .4rem; margin: .6rem 0 .2rem; flex-wrap: wrap; }
.seg .chip { border: 1px solid var(--felt-3); background: var(--felt-2); color: var(--chalk-dim); border-radius: 999px; padding: .3rem .7rem; font-size: .8rem; }
.seg .chip.on { background: var(--brass); color: var(--brass-ink); border-color: var(--brass); font-weight: 600; }
.chart { margin-top: .5rem; }
/* One series, so one hue; the baseline is the only axis and stays recessive. */
.cbars { display: flex; align-items: flex-end; gap: 2px; height: 110px; border-bottom: 1px solid var(--felt-3); }
.cbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.cbar i { display: block; width: 100%; background: var(--brass); border-radius: 4px 4px 0 0; }
.cbar.zero i { background: var(--felt-3); }
.cbar .cnum { font-size: .62rem; color: var(--chalk); font-variant-numeric: tabular-nums; line-height: 1; height: .8rem; }
.clabels { display: flex; gap: 2px; margin-top: .25rem; }
.clabels span { flex: 1; text-align: center; font-size: .62rem; color: var(--chalk-dim); }
.records { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .3rem; }
.records li { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-radius: 10px; background: var(--felt-2); }
.records li b { display: block; font-size: .9rem; }
.records .recval { flex: none; color: var(--brass); font-variant-numeric: tabular-nums; }
.shelfbar { height: 8px; border-radius: 999px; background: var(--felt-2); overflow: hidden; margin: .5rem 0; }
.shelfbar i { display: block; height: 100%; background: var(--brass); border-radius: 999px; }
.minibars { list-style: none; padding: 0; margin: .4rem 0 0; display: flex; flex-direction: column; gap: .25rem; }
.minibars li { display: flex; align-items: center; gap: .5rem; }
.minibars .mlabel { flex: none; width: 4.6rem; font-size: .8rem; color: var(--chalk-dim); }
.minibars i { flex: 1; height: 12px; border-radius: 4px; background: var(--felt-2); position: relative; }
.minibars i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--brass); border-radius: 4px; }
.minibars b { flex: none; min-width: 1.6rem; text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.minibars.wide .mlabel { width: 6.6rem; }
.minibars b { color: var(--chalk); }
.advanced { margin: .6rem 0 0; }
.advanced summary { font-size: .85rem; color: var(--chalk-dim); cursor: pointer; padding: .3rem 0; }
.joincode { font-size: 2rem; font-weight: 800; letter-spacing: .22em; text-align: center; color: var(--brass); margin: .6rem 0 .2rem; font-variant-numeric: tabular-nums; }

/* Settings: each section enclosed, so the page reads as blocks rather than a
   single run of headings. */
.card { background: var(--felt-2); border-radius: 16px; padding: .9rem 1rem 1.1rem; margin: .8rem 0 0; }
.card > h2:first-child { margin: 0 0 .2rem; font-size: 1.05rem; }
.card.admin { border: 1px solid var(--brass); }
.card .fieldlabel { margin: 1.1rem 0 .5rem; padding-top: .8rem; border-top: 1px solid var(--felt-3); color: var(--chalk); font-weight: 700; }
.card .fieldlabel:first-of-type { border-top: 0; padding-top: 0; margin-top: .8rem; }
.buildstamp { text-align: center; margin-top: 1.2rem; opacity: .6; }
.idbox { width: 100%; margin-top: .3rem; }
/* Shared game notes */
.notes h3 { font-size: .95rem; margin: 1rem 0 .3rem; color: var(--brass); }
.notes h3:first-child { margin-top: .2rem; }
.notes p { margin: .4rem 0; font-size: .88rem; line-height: 1.45; }
.notes ul { margin: .3rem 0; padding-left: 1.1rem; }
.notes li { font-size: .88rem; line-height: 1.45; margin: .25rem 0; }
