/* Quorum, a merchants' council: parchment, ink and two seals. One fixed palette, the same in
   light and dark OS modes. Mobile first: the council is a two-column grid, so ten seats fit a
   390px phone without a single horizontal scroll. */
:root {
  --bg: #f4efe4;
  --surface: #fffdf7;
  --surface2: #eae0cd;
  --line: rgba(58, 46, 30, .14);
  --ink: #33291d;
  --muted: #7b6d58;
  --accent: #2f6f63;            /* you, and anything you may tap */
  --accent-dark: #255c52;
  --sound: #2e7d5b;
  --sound-soft: #dff0e5;
  --rotten: #b06a34;
  --rotten-soft: #f6e3ce;
  --cabal: #7b4a6b;
  --cabal-soft: #f0e3ee;
  --wood: #5d4a32;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #c08a3e;
  --tut-accent-ink: #33291d;
  --tut-bubble: #fffdf5;
  --tut-ink: #33291d;
  --tut-muted: #7b6d58;
  --tut-dim: rgba(40, 32, 20, .55);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; touch-action: manipulation; min-height: 100vh; overflow-x: hidden; }
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 20px; height: 20px; display: inline-block; vertical-align: -4px; flex: none; }

.app { position: relative; max-width: 760px; margin: 0 auto; padding: 0 12px 16px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

/* ---------- top bar + menu ---------- */
.topbar { display: flex; align-items: center; gap: 4px; height: 50px; }
.back, .iconbtn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 22px; background: none; border: 0; cursor: pointer; padding: 0; }
.back:hover, .iconbtn:hover, .iconbtn[aria-expanded="true"] { color: var(--ink); background: var(--surface2); }
.brand { flex: 1; text-align: center; font: 700 21px/1 Georgia, "Times New Roman", serif; letter-spacing: .12em; text-transform: uppercase; color: var(--wood); }
.menu { position: absolute; right: 12px; top: 46px; z-index: 45; min-width: 200px; padding: 6px; background: var(--surface); border-radius: 14px; box-shadow: 0 14px 36px rgba(58, 46, 30, .25); display: flex; flex-direction: column; animation: pop .14s ease-out; }
.menu button { min-height: 46px; text-align: left; padding: 0 14px; border: 0; background: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.menu button:hover, .menu button:focus-visible { background: var(--surface2); }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 0; background: var(--surface2); color: var(--ink); cursor: pointer; font-weight: 650; transition: background .15s, transform .1s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover:not(:disabled) { background: #ddd1ba; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn.quiet { background: transparent; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 14px; }
.btn.wide { flex: 1 1 140px; }
.btn.yes { background: var(--sound); color: #fff; }
.btn.yes:hover:not(:disabled) { background: #26684b; }
.btn.no { background: var(--rotten); color: #fff; }
.btn.no:hover:not(:disabled) { background: #96592a; }

/* ---------- status ---------- */
.status { min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 4px 4px; font-size: 15px; color: var(--muted); text-align: center; }
.status.mine { color: var(--ink); font-weight: 650; }
.status .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- the board: two tracks and the council ---------- */
.board { background: var(--surface); border-radius: 18px; padding: 10px 8px 8px; box-shadow: 0 2px 10px rgba(58, 46, 30, .08); }
.tracks { display: flex; flex-direction: column; gap: 7px; align-items: center; }
.trk { display: flex; align-items: center; gap: 6px; }
.trk .lbl { width: 54px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: right; line-height: 1.1; }
.slots { display: flex; gap: 4px; }
.slot { width: 34px; height: 40px; border-radius: 7px; border: 2px dashed var(--line); display: grid; place-items: center; background: var(--bg); color: var(--muted); }
.slot svg { width: 20px; height: 20px; }
.slot.on { border-style: solid; }
.trk.sound .slot.on { background: var(--sound-soft); border-color: var(--sound); }
.trk.rotten .slot.on { background: var(--rotten-soft); border-color: var(--rotten); }
.slot.fresh { animation: stamp .45s ease-out; }
@keyframes stamp { from { transform: scale(1.45); opacity: .2; } to { transform: none; opacity: 1; } }
.slot.win { box-shadow: inset 0 0 0 2px currentColor; }
.trk.sound .slot.win { color: var(--sound); }
.trk.rotten .slot.win { color: var(--rotten); }
.deckline { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 2px; }
.deckline b { color: var(--ink); }
.warnline { font-size: 12px; font-weight: 700; color: var(--rotten); text-align: center; margin-top: 2px; }

.council { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.seat { position: relative; min-height: 56px; border: 0; border-radius: 12px; background: var(--bg); padding: 6px 8px; text-align: left; cursor: default; display: flex; flex-direction: column; gap: 3px; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .18s, opacity .18s, background .18s; }
.seat .nm { font-size: 13.5px; font-weight: 700; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.seat .nm i { width: 8px; height: 8px; border-radius: 50%; background: var(--pc, var(--muted)); flex: none; }
.seat .marks { display: flex; flex-wrap: wrap; gap: 3px; min-height: 18px; align-items: center; }
.seat.me { background: var(--surface); box-shadow: inset 0 0 0 2px rgba(47, 111, 99, .35); }
.seat.out { opacity: .5; }
.seat.pick { cursor: pointer; box-shadow: inset 0 0 0 2px var(--accent); background: var(--surface); }
.seat.pick:hover { background: #eef5f3; }
.seat.chosen { box-shadow: inset 0 0 0 3px var(--accent), 0 3px 10px rgba(47, 111, 99, .3); background: #e7f1ee; }
.seat.tappable { cursor: pointer; }
.seat.open { opacity: .75; }
.seat.away .nm { font-style: italic; opacity: .75; }
.chip { font-size: 10.5px; font-weight: 800; letter-spacing: .03em; padding: 1px 6px; border-radius: 8px; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.chip.speaker { background: var(--wood); color: #fff; }
.chip.chair { background: var(--ink); color: #fff; }
.chip.nominee { background: var(--surface2); color: var(--ink); }
.chip.yes { background: var(--sound-soft); color: var(--sound); }
.chip.no { background: var(--rotten-soft); color: var(--rotten); }
.chip.cast { background: var(--surface2); color: var(--muted); }
.chip.cabal { background: var(--cabal-soft); color: var(--cabal); }
.chip.out { background: #e2dccf; color: var(--muted); }
.chip.you { background: rgba(47, 111, 99, .14); color: var(--accent); }

/* ---------- you ---------- */
.you { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.youbar { background: var(--surface); border-radius: 14px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; box-shadow: 0 1px 4px rgba(58, 46, 30, .08); }
.youbar .role { font-weight: 800; }
.youbar .role.loyal { color: var(--sound); }
.youbar .role.cabal, .youbar .role.quiet { color: var(--cabal); }
.youbar .with { font-size: 13px; color: var(--muted); }
.act { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; min-height: 48px; }
.act .hint { font-size: 13.5px; color: var(--muted); text-align: center; flex: 1 1 100%; }
.act .tally { font-size: 14px; text-align: center; flex: 1 1 100%; }
.act .tally b { font-size: 17px; }

/* decrees: the cards only the seat that drew them may see */
.decrees { display: flex; gap: 8px; justify-content: center; flex: 1 1 100%; flex-wrap: wrap; }
.decree { width: min(100px, 27vw); border: 0; border-radius: 12px; padding: 10px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); transition: transform .15s, box-shadow .18s; }
.decree svg { width: 34px; height: 34px; }
.decree .t { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.decree.sound { background: var(--sound-soft); box-shadow: inset 0 0 0 2px rgba(46, 125, 91, .35); }
.decree.sound .t { color: var(--sound); }
.decree.rotten { background: var(--rotten-soft); box-shadow: inset 0 0 0 2px rgba(176, 106, 52, .35); }
.decree.rotten .t { color: var(--rotten); }
.decree.pickable:hover { transform: translateY(-2px); }
.decree.chosen { box-shadow: inset 0 0 0 3px var(--accent), 0 4px 12px rgba(47, 111, 99, .25); transform: translateY(-2px); }
.decree.flat { cursor: default; }
.decree .n { font-size: 11px; color: var(--muted); font-weight: 700; }
.bigdecree { flex: 1 1 100%; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 17px; }
.bigdecree svg { width: 30px; height: 30px; }
.bigdecree.sound { color: var(--sound); }
.bigdecree.rotten { color: var(--rotten); }
.answer { flex: 1 1 100%; text-align: center; font-size: 16px; font-weight: 700; }
.answer .loyal { color: var(--sound); }
.answer .cabal { color: var(--cabal); }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(40, 32, 20, .38); }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .18s ease-out; box-shadow: 0 -10px 40px rgba(58, 46, 30, .2); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { font: 700 19px/1.2 Georgia, serif; margin-bottom: 8px; color: var(--wood); }
.sheet p { margin: 6px 0; }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { flex: 1 1 0; }
.sheet .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 12px 0 5px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; font-size: 13px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.log li:first-child, .log li.mine { color: var(--ink); }
.roster { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.roster li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 2px; border-bottom: 1px solid var(--line); }
.roster .s { color: var(--muted); font-size: 13px; }
.roster .s.loyal { color: var(--sound); font-weight: 700; }
.roster .s.cabal { color: var(--cabal); font-weight: 700; }

/* ---------- modals ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(40, 32, 20, .42); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(58, 46, 30, .3); }
.over-modal { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.modal-head h2 { font: 700 21px/1.2 Georgia, serif; color: var(--wood); }
.modal-body { padding: 0 18px 14px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; }
.modal-foot .btn { flex: 1 1 110px; }
.rules h3 { font-size: 15px; margin: 16px 0 4px; color: var(--wood); font-family: Georgia, serif; }
.rules p, .rules li { font-size: 14px; }
.rules ol, .rules ul { padding-left: 20px; margin: 4px 0; }
.rules li { margin: 4px 0; }
.result-banner { font: 800 25px/1.2 Georgia, serif; margin: 0 0 10px; }
.result-banner.win { color: var(--sound); }
.result-banner.loss { color: var(--rotten); }

/* ---------- online (a table with friends: tables.js) ---------- */
.game { position: relative; }
.net-note { position: absolute; left: 50%; top: 34px; transform: translateX(-50%); z-index: 6; width: max-content; max-width: min(88vw, 360px);
  padding: 4px 12px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 12.5px; font-weight: 700; line-height: 1.3; text-align: center;
  white-space: normal; box-shadow: 0 4px 14px rgba(58, 46, 30, .3); pointer-events: none; animation: pop .25s ease-out; }
.menu #menu-online, .menu #menu-leave { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
/* the kit's end bar (Play again / Leave) makes room while a bottom sheet is open */
.sheet-wrap:not([hidden]) ~ .bp-tables-endbar { display: none !important; }

@media (min-width: 560px) {
  .council { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slot { width: 40px; height: 46px; }
}
@media (min-width: 760px) {
  .council { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .slot { width: 30px; height: 36px; }
  .trk .lbl { width: 46px; font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
