/* Clue: palette from the Board & Card Games hub so it reads as a sibling. */
:root {
  --bg: #0f1117;
  --bg-soft: #161923;
  --card: #1a1e2b;
  --card-hover: #212636;
  --line: #2a3042;
  --text: #e8eaf0;
  --muted: #969db4;
  --accent: #6ea8fe;
  --warm: #f0b354;
  --good: #6ee7a8;
  --bad: #f08c8c;
  --radius: 12px;
  --tabh: 58px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden; overflow-x: clip; touch-action: manipulation;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ shell */
.app { height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; min-height: 0; position: relative; }
.tab { position: absolute; inset: 0; display: none; flex-direction: column; padding: 8px 10px 6px; overflow: hidden; }
.tab.active { display: flex; }
.tab.scroll { overflow-y: auto; }
nav.tabs {
  height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--bg-soft); border-top: 1px solid var(--line); flex: none;
}
nav.tabs button {
  flex: 1; background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button.on { color: var(--accent); }
nav.tabs .brand { display: none; }

@media (min-width: 900px) {
  .app { flex-direction: row-reverse; }
  nav.tabs { flex-direction: column; width: 190px; height: 100dvh; border-top: 0; border-right: 1px solid var(--line); padding: 18px 10px; justify-content: flex-start; gap: 4px; }
  nav.tabs button { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; border-radius: 10px; font-size: 15px; }
  nav.tabs button.on { background: rgba(110,168,254,.12); }
  nav.tabs .brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 18px; font-weight: 800; font-size: 20px; letter-spacing: .02em; }
  nav.tabs .brand img { width: 30px; height: 30px; border-radius: 7px; }
  .tab { padding: 14px 18px; }
}

/* ---------------------------------------------------------------- basics */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 14px; min-height: 44px; cursor: pointer; font-weight: 650;
  transition: background .12s, border-color .12s, transform .08s, opacity .2s;
}
/* hover only where there is a real mouse: on a phone a tap leaves :hover stuck, which greyed out the blue/gold buttons */
@media (hover: hover) {
  .btn:not(.primary):not(.warm):not(.danger):hover:not(:disabled) { background: var(--card-hover); border-color: #3a4258; }
  .btn.primary:hover:not(:disabled), .btn.warm:hover:not(:disabled), .btn.danger:hover:not(:disabled) { filter: brightness(1.08); }
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d1424; }
.btn.warm { background: var(--warm); border-color: var(--warm); color: #231703; }
.btn.danger { background: rgba(240,140,140,.14); border-color: var(--bad); color: #ffc9c9; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 13.5px; border-radius: 8px; }
.btn.hinted { outline: 2px solid var(--warm); outline-offset: 2px; }
.q { display: inline-flex; width: 19px; height: 19px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted);
  font-size: 12px; font-weight: 700; align-items: center; justify-content: center; cursor: pointer; background: var(--bg-soft); vertical-align: 2px; margin-left: 4px; padding: 0; flex: none; }
.label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 7px 4px; min-height: 42px;
  cursor: pointer; font-size: 14px; font-weight: 650; line-height: 1.2; transition: background .12s, border-color .12s; }
.seg button small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 1px; }
.seg button.on { background: rgba(110,168,254,.14); border-color: var(--accent); color: var(--accent); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #2b3246; border-radius: 15px; transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
input[type=text], select { background: var(--bg-soft); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 16px; width: 100%; }
select { -webkit-appearance: none; appearance: none; padding-right: 30px; color-scheme: dark;
  background: var(--bg-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238e97ad' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat right 11px center / 12px 8px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.panel h2 { margin: 0 0 8px; font-size: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------------------------------------- setup */
.setup-wrap { max-width: 540px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 6px; }
/* centre the setup column in the leftover height (auto margins never cut the top when it overflows) */
.setup-wrap > :first-child { margin-top: auto; }
.setup-wrap > :last-child { margin-bottom: auto; }
.hero { text-align: center; padding: 4px 0 2px; }
.hero svg { width: 220px; max-width: 70%; height: auto; }
.hero h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: .04em; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }
.who { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.who button { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 6px 2px 5px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 650; color: var(--muted); transition: border-color .15s, background .15s; }
.who button svg { width: 30px; height: 30px; }
.who button.on { border-color: var(--accent); background: rgba(110,168,254,.12); color: var(--text); }
.who button.off { opacity: .35; }
.record { display: flex; gap: 14px; justify-content: center; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------- game layout: a real table seen from your seat
   (css/table.css is the shared table kit, copied unchanged; .tbl-surface.tbl-wood-dark is the wooden table top) */
.game { display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 0;
  margin: -8px -10px -6px; padding: 8px 10px 6px; --back: #7a1f2b; --ink: rgba(243, 234, 214, .28); }
.players { display: flex; gap: 4px; flex: none; align-items: flex-end; min-height: 40px; }

/* a seat: the cards they hold (backs in a small fan) above a name plate in their colour */
.pl { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 650;
  position: relative; transition: opacity .3s; padding: 0 1px; }
.pl .plate { display: flex; align-items: center; gap: 5px; max-width: 100%; min-height: 22px; padding: 1px 7px 1px 4px; border-radius: 5px;
  color: #f6efdc; background: linear-gradient(#3b2a1a, #24180d); border: 1px solid #7a5a2e;
  box-shadow: inset 0 1px 0 rgba(255,220,150,.22), 0 2px 4px rgba(0,0,0,.45); transition: border-color .2s, box-shadow .2s; }
.pl i { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 -2px 2px rgba(0,0,0,.35), inset 0 1px 1px rgba(255,255,255,.5), 0 1px 1px rgba(0,0,0,.5); }
.pl .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pl .backs { position: relative; height: 22px; width: calc(14px + (var(--n) - 1) * 6px); flex: none; margin-bottom: -9px; }
/* the cards are held behind the name plate, so the seats take less height from the board */
.pl .plate { position: relative; z-index: 1; }
.pl .backs i { position: absolute; left: calc(50% - 7px); bottom: 0; width: 14px; height: 21px; border-radius: 2px;
  transform-origin: 50% 110%; transform: translateX(calc(var(--k) * 6px)) rotate(calc(var(--k) * 8deg));
  background-color: var(--back);
  background-image: repeating-linear-gradient(45deg, var(--ink) 0 1px, transparent 1px 3px), repeating-linear-gradient(-45deg, var(--ink) 0 1px, transparent 1px 3px);
  box-shadow: inset 0 0 0 1.5px #f3ead6, 0 1px 2px rgba(0,0,0,.5); }
.pl.turn .plate { border-color: #f0c35a; box-shadow: 0 0 0 2px rgba(240,195,90,.45), 0 2px 4px rgba(0,0,0,.45); animation: turnglow 1.8s ease-in-out infinite; }
@keyframes turnglow { 50% { box-shadow: 0 0 0 2px rgba(240,195,90,.55), 0 0 14px rgba(240,195,90,.55); } }
.pl.asking .plate { border-color: var(--warm); }
.pl.out { opacity: .45; }
.pl.out .nm { text-decoration: line-through; }
.pl .say { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px); background: #f6efdc; color: #2b1d12; font-size: 11.5px; font-weight: 750; padding: 2px 7px; border-radius: 7px; white-space: nowrap; z-index: 5; animation: pop .25s ease-out; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,.45); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 0) scale(.9); } }
.pl.away { cursor: pointer; }
.pl.away .plate { border-style: dashed; }

/* the detective notepad, lying on the table (opens the notes on a phone) */
.notepad-btn { flex: none; align-self: stretch; min-width: 52px; min-height: 40px; border: 0; padding: 0 6px; cursor: pointer; border-radius: 3px;
  color: #2b2418; font: 700 12px/1 Georgia, "Times New Roman", serif; transform: rotate(3deg);
  background: repeating-linear-gradient(#f4ecd8 0 7px, #b9c7dc 7px 8px), #f4ecd8; background-position: 0 4px;
  box-shadow: inset 0 3px 0 #9a2b2b, 1px 2px 4px rgba(0,0,0,.5); }
.notepad-btn span { background: #f4ecd8; padding: 1px 2px; }

/* the board: printed cardboard lying on the table, with a thick edge and a soft shadow */
.boardwrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.boardwrap svg.board { height: 100%; width: 100%; max-width: 100%; display: block; touch-action: none; }
/* back to the whole board (shown only while zoomed in) */
.zoomout { position: absolute; bottom: 2px; left: 2px; width: 40px; height: 40px; opacity: .9; border-radius: 50%; border: 1.5px solid #c9a85a; padding: 0; cursor: pointer;
  background: rgba(20,15,10,.82); color: #f3ead6; display: flex; align-items: center; justify-content: center; z-index: 3; box-shadow: 0 2px 6px rgba(0,0,0,.5); }
.zoomout svg { width: 22px; height: 22px; }
.board .sq { transition: fill .2s; }
.board .reach { fill: rgba(64,128,255,.72); stroke: #fff; stroke-opacity: .8; stroke-width: .06; cursor: pointer; animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { fill: rgba(64,128,255,.95); } }
.board .room-hit { fill: transparent; cursor: default; }
.board .room-hit.can { fill: rgba(240,179,84,.38); cursor: pointer; animation: glow2 1.4s ease-in-out infinite; }
@keyframes glow2 { 50% { fill: rgba(240,179,84,.6); } }
.board .tok { transition: transform .32s cubic-bezier(.3,.7,.3,1); }
.board .wep { transition: transform .5s cubic-bezier(.3,.7,.3,1); }
.board text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; pointer-events: none; }
.board text[font-family] { font-family: Georgia, "Times New Roman", serif; }
/* the room odds are pencilled on the floor: a dark halo keeps them readable on every floor */
.board .roomodds { paint-order: stroke; stroke: #1a130d; stroke-width: .16; stroke-linejoin: round; }

/* your turn: what to do + the buttons, on the table edge in front of you */
.bar { flex: none; padding: 2px 0 0; display: flex; flex-direction: column; gap: 5px; border-radius: 12px; transition: box-shadow .25s; }
.bar .msg { font-size: 15px; font-weight: 700; min-height: 26px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; row-gap: 0; color: #f6efdc; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.bar .msg .sub { color: #d8cdb4; font-weight: 500; font-size: 13px; }
.bar.mine .msg { color: #fff; }
.bar .acts { display: flex; gap: 6px; min-height: 44px; }
/* buttons never wrap onto a second row, so the board never changes size between turns */
.bar .acts .btn { flex: 1; min-width: 0; height: 44px; font-size: 13.5px; line-height: 1.1; padding: 4px 6px; box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.bar:not(.mine) .acts .btn:not(.primary):not(.warm):not(.danger) { background: rgba(22,25,35,.85); }
.dice { display: inline-flex; gap: 6px; }
.die { width: 28px; height: 28px; border-radius: 22%; display: inline-block; position: relative; animation: tumble .45s ease-out;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.9), transparent 45%), #f6f2e8;
  box-shadow: inset -2px -3px 3px rgba(0,0,0,.22), inset 2px 2px 2px rgba(255,255,255,.8), 2px 4px 5px rgba(0,0,0,.5); }
.die b { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #1c1c22; box-shadow: inset 0 1px 1px rgba(0,0,0,.6); }
/* the Roll button carries the ivory die you pick up */
#bRoll { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.rolldie { display: inline-flex; transform: rotate(-12deg); }
.rolldie .die { width: 22px; height: 22px; animation: none; }
.rolldie .die b { width: 4px; height: 4px; margin: .5px; }
@keyframes tumble { from { transform: translate(-14px, -10px) rotate(-260deg) scale(.7); } 70% { transform: rotate(12deg); } }

/* your seat: your name plate and your hand, held as a fan of real cards at the bottom edge */
.bar .msgrow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar .msgrow .msg { flex: 1; min-width: 0; }
#meSeat { flex: none; }
#meSeat .pl .plate { padding-right: 7px; }
.myseat { flex: none; display: flex; justify-content: center; }
/* on short phones the hand gives way to the board (58 px cards on a tall phone, 44 px on a 320 x 568) */
.hand { flex: 1; min-width: 0; max-width: 520px; --card-w: clamp(44px, calc(8dvh - 2px), 58px); --ratio: 57 / 89; }
@media (min-width: 900px) { .hand { --card-w: 78px; max-width: 640px; } .game .side .log { max-height: 17% !important; } }

/* the pick grid for suggestions / accusations */
.picker { display: flex; flex-direction: column; gap: 5px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.chips.rooms { grid-template-columns: repeat(3, 1fr); }
.chip { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font-size: 13px; font-weight: 650; cursor: pointer; display: flex; align-items: center; gap: 5px; min-height: 40px; text-align: left; position: relative; overflow: hidden; transition: border-color .12s, background .12s; }
.chip .pc { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 700; }
.chip.on { border-color: var(--accent); background: rgba(110,168,254,.15); }
.chip.no { opacity: .45; }
.chip.best::after { content: "★"; position: absolute; top: 0; right: 3px; font-size: 9px; color: var(--warm); }
.chip i.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* cards: real 57 x 89 cards with rounded corners, a paper sheen, and the shared printed back behind */
.cardf { width: 50px; aspect-ratio: 57 / 89; height: auto; flex: none; border-radius: 6px; position: relative; cursor: default;
  box-shadow: 0 1px 1px rgba(0,0,0,.3), 0 3px 7px rgba(0,0,0,.35); transition: transform .2s, box-shadow .2s; }
.cardf svg { width: 100%; height: 100%; display: block; border-radius: inherit; }
.cardf::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,.3), transparent 38%, transparent 70%, rgba(0,0,0,.07)); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
/* the back is shown only while a card is still turning over (no reliance on backface-visibility, which WebKit drops in flat layers) */
.clue-back { position: absolute; inset: 0; border-radius: inherit; opacity: 0; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='17' cy='17' r='10' fill='%237a1f2b' stroke='%23f3ead6' stroke-width='3'/%3E%3Cpath d='m24.5 24.5 9 9' stroke='%23f3ead6' stroke-width='4.5' stroke-linecap='round'/%3E%3Ctext x='17' y='22' text-anchor='middle' font-size='14' font-weight='700' font-family='Georgia,serif' fill='%23f3ead6'%3E%3F%3C/text%3E%3C/svg%3E") center / 52% no-repeat,
    repeating-linear-gradient(45deg, rgba(243,234,214,.22) 0 1px, transparent 1px 5px), repeating-linear-gradient(-45deg, rgba(243,234,214,.22) 0 1px, transparent 1px 5px), #7a1f2b;
  box-shadow: inset 0 0 0 3px #f3ead6, inset 0 0 0 4px rgba(0,0,0,.25); }
/* in the held fan the kit positions each card; tbl-card brings the real shape, our face is the SVG */
.hand .cardf.tbl-card { width: var(--card-w); border: 0; background: none; border-radius: calc(var(--card-w) * .08); cursor: default; }
.hand .cardf.tbl-card::after { box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.cardf.pick { cursor: pointer; animation: bob 1.3s ease-in-out infinite; outline: 2px solid var(--warm); outline-offset: 2px; }
.cardf.lg { width: 92px; border-radius: 8px; }
@keyframes bob { 50% { transform: translateY(-4px); } }
.deal-in { animation: dealin .45s cubic-bezier(.3,.7,.3,1) both; }
@keyframes dealin { from { transform: translateY(-40px) rotate(-8deg); opacity: 0; } }
/* a card turned face up with a 3-D turn (shown to you, or the case file opened) */
.turnup { animation: turnup .7s cubic-bezier(.3,.7,.3,1) both; }
.turnup .clue-back { animation: backshow .7s cubic-bezier(.3,.7,.3,1) both; animation-delay: inherit; }
@keyframes backshow { 0%, 76% { opacity: 1; } 77%, 100% { opacity: 0; } }
@keyframes turnup { from { transform: perspective(700px) translateY(-24px) rotateY(180deg); } 55% { transform: perspective(700px) translateY(-8px) rotateY(180deg); } to { transform: perspective(700px) rotateY(0deg); } }

/* notes grid (play + notepad) */
.notes { overflow: auto; min-height: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-soft); }
.notes table { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.notes th, .notes td { padding: 3px 4px; text-align: center; border-bottom: 1px solid #222838; white-space: nowrap; }
.notes th { position: sticky; top: 0; background: var(--card); font-size: 11px; color: var(--muted); font-weight: 700; z-index: 1; }
.notes td.nm { text-align: left; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.notes tr.cat td { background: #1c2130; color: var(--muted); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; text-align: left; }
.notes td.env { font-weight: 800; }
.notes td .y { color: var(--good); font-weight: 800; }
.notes td .x { color: #5d6478; }
.notes tr.solved td.nm { color: var(--warm); }
.notes .mine td.nm::after { content: " ●"; color: var(--accent); font-size: 9px; }

/* in a game the notes are your detective sheet: cream paper, blue rules, pencil marks */
.game .side { color: #2b2418; background: #f4ecd8; border-radius: 3px; padding: 10px 10px 8px;
  background-image: linear-gradient(90deg, transparent 30px, rgba(196,74,74,.35) 30px 31px, transparent 31px);
  box-shadow: inset 0 4px 0 #9a2b2b, 0 2px 3px rgba(0,0,0,.4), 0 10px 22px rgba(0,0,0,.4); }
.game .side .label { color: #6b5a3e; font-family: Georgia, "Times New Roman", serif; }
.game .side .q { background: #efe5cc; border-color: #c9b88f; color: #6b5a3e; }
.game .side .btn.ghost { color: #2b2418; border-color: #c9b88f; }
.game .side .envline, .game .side .envline .muted { color: #4a3f2c; }
.game .side .notes { background: transparent; border: 0; border-radius: 0; }
.game .side .notes th { background: #f4ecd8; color: #6b5a3e; border-bottom: 1.5px solid #8aa0c4; }
.game .side .notes td { color: #2b2418; border-bottom: 1px solid #b9c7dc; }
.game .side .notes tr.cat td { background: transparent; color: #9a2b2b; font-family: Georgia, "Times New Roman", serif; }
.game .side .notes td.nm { font-family: Georgia, "Times New Roman", serif; font-weight: 700; }
.game .side .notes tr.solved td.nm { color: #b0701a; }
.game .side .notes .mine td.nm::after { color: #2f5fb0; }
.game .side .notes td .x { color: #8b8270; }
.game .side .notes td .y { color: #217a46; }
/* odds are coloured for a dark screen: darken them so they read like ink on the paper */
.game .side .notes td[style], .game .side .envline b { filter: brightness(.58) saturate(1.6); }
/* the pale suspect colours (white, mustard) as darker ink for the column heads */
.game .side .notes th[style*="#f2f2ee"] { color: #8a8574 !important; }
.game .side .notes th[style*="#e8c24a"] { color: #a8841a !important; }
.game .side .notes td[style="color:#c9cede"] { color: #4a3f2c !important; filter: none; }
.game .side .log { color: #5a4c34; }
.game .side .log div { border-bottom: 1px solid #b9c7dc; }
.game .side .log b { color: #2b2418; }

.sidepanel { display: none; }
.log { font-size: 12.5px; color: var(--muted); overflow-y: auto; min-height: 0; }
.log div { padding: 2px 0; border-bottom: 1px solid #1f2433; }
.log b { color: var(--text); font-weight: 650; }

@media (min-width: 900px) {
  /* laptop: the others across the top and the board as tall as the screen allows on the left;
     your detective sheet, your turn and your hand down the right */
  .game { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 10px 18px; margin: -14px -18px; padding: 12px 18px; }
  .game .players { grid-column: 1; grid-row: 1; justify-content: space-around; min-height: 46px; }
  .game .boardwrap { grid-column: 1; grid-row: 2 / 5; }
  .game .myseat { grid-column: 2; grid-row: 4; }
  .game .side { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 8px; min-height: 0; transform: rotate(.6deg); }
  .game .bar { grid-column: 2; grid-row: 3; align-self: end; padding: 8px; background: rgba(12,10,8,.35); }
  .pl { flex: 0 1 150px; font-size: 13.5px; }
  .pl .backs { height: 30px; width: calc(20px + (var(--n) - 1) * 9px); }
  .pl .backs i { width: 20px; height: 30px; left: calc(50% - 10px); transform: translateX(calc(var(--k) * 9px)) rotate(calc(var(--k) * 7deg)); }
  .pl .plate { padding: 2px 9px 2px 5px; }
  .chip { font-size: 13px; }
  .notes table { font-size: 13px; }
  .notes th, .notes td { padding: 4px 5px; }
  .game .side .notes th, .game .side .notes td { padding: 4px 3px; }
  .game .side .notes td.nm { font-size: 12.5px; }
  .setup-wrap { max-width: 580px; }
}
@media (max-width: 899px) and (min-aspect-ratio: 4/3) {
  /* phone on its side: the tabs become a slim rail on the left so the board gets the full height */
  .app { flex-direction: row-reverse; }
  nav.tabs { flex-direction: column; width: calc(60px + env(safe-area-inset-left)); height: 100dvh; padding: 6px 0 6px env(safe-area-inset-left); border-top: 0; border-right: 1px solid var(--line); }
  nav.tabs button { font-size: 10px; }
  .tab { padding-right: max(10px, env(safe-area-inset-right)); }
  .game { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto minmax(0, 1fr); column-gap: 12px; row-gap: 8px; }
  .game .boardwrap { grid-column: 1; grid-row: 1 / 6; aspect-ratio: 25.6 / 26.7; height: 100%; }
  .game .players { grid-column: 2; grid-row: 1; flex-wrap: wrap; justify-content: center; row-gap: 4px; }
  .game .players .pl { flex: 0 1 30%; }
  .game .bar { grid-column: 2; grid-row: 3; }
  .game .bar .acts { flex-wrap: wrap; }
  .game .bar .acts .btn { flex: 1 1 40%; }
  .game .myseat { grid-column: 2; grid-row: 4; }
  .hand { --card-w: 46px; }
}
@media (max-width: 899px) {
  .game .side { display: none; }
  .game.notesopen .side { display: flex; position: absolute; inset: 4px 6px; z-index: 20; flex-direction: column; gap: 8px; animation: slideup .25s ease-out; }
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
/* a 320 px phone with 6 players: every column of the sheet still fits across */
@media (max-width: 360px) {
  .game .side { padding-left: 6px; padding-right: 6px; }
  .game .side .notes table { font-size: 11px; }
  .game .side .notes th, .game .side .notes td { padding: 3px 1px; }
  .game .side .notes td.nm { font-size: 11.5px; max-width: 78px; }
}

/* ------------------------------------------------------------- overlay / sheets */
#overlay { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; background: rgba(5,7,12,.6); z-index: 50; }
#overlay.on { display: flex; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 16px 16px 0 0; width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.3,.7,.3,1); }
@media (min-width: 900px) { #overlay { align-items: center; } .sheet { border-radius: 16px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 8px; font-size: 17px; }
/* a tall sheet scrolls, but its buttons stay on screen */
.sheet > .row:last-child { position: sticky; bottom: calc(-14px - env(safe-area-inset-bottom)); background: var(--card); padding: 8px 0 calc(14px + env(safe-area-inset-bottom)); margin-bottom: calc(-14px - env(safe-area-inset-bottom)); z-index: 2; }
.sheet .cardf.lg { width: 104px; border-radius: 8px; }
@media (min-width: 900px) { .sheet .cardf.lg { width: 124px; border-radius: 10px; } }
.sheet p { margin: 6px 0; color: #c9cede; font-size: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 16px); transform: translateX(-50%); background: var(--text); color: #11141c; padding: 8px 14px; border-radius: 10px; font-weight: 650; font-size: 14px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }

/* ------------------------------------------------------------- notepad tab */
.np { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.np .top { display: flex; gap: 6px; flex: none; }
.np .top .btn { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
#tnames .btn { min-width: 58px; min-height: 42px; flex: none; }
.chip > svg, .chip > .dot, .chip > .pc { flex: none; }
.chip > span:not(.pc) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) {
  .np { display: grid; grid-template-columns: minmax(0, 1fr) 400px; grid-template-rows: auto minmax(0, 1fr); }
  .np .top { grid-column: 1 / 3; }
  .np .notes { grid-row: 2; }
  .np .npside { grid-row: 2; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
}
@media (max-width: 899px) { .np .npside { display: flex; flex-direction: column; gap: 8px; flex: none; max-height: 46%; overflow-y: auto; } .np .npside > .panel { flex: none; } }
.chip > span:not(.pc) { white-space: nowrap; }

/* ------------------------------------------------------------- learn / settings */
.page { max-width: 760px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.page h2 { margin: 4px 0 0; font-size: 18px; }
.page p, .page li { color: #c9cede; font-size: 14.5px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.setrow .lbl { font-weight: 650; }
.setrow .lbl small { display: block; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.stat { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.meter { height: 8px; border-radius: 4px; background: #232a3c; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; }
.chart svg { width: 100%; height: auto; display: block; }
@media (min-width: 900px) { #notesBtn, #closeNotes { display: none; } }
@media (max-width: 520px) { .setrow { flex-wrap: wrap; } .setrow .seg { flex: 1 1 100%; } }
@media (max-width: 520px) {
  /* sheet chips: drop the small weapon/room drawings so whole names fit */
  #overlay .chip > svg, #troom .chip > svg { display: none; }
  #overlay .chip, #troom .chip { gap: 3px; padding: 4px 5px; }
}

/* Sound & effects (js/fx.js): its rows take this page's own row, switch and segment look */
.fx-set .fx-row { padding: 8px 0; border-top: 0; border-bottom: 1px solid var(--line); min-height: 46px; gap: 10px; }
.fx-set .fx-row:last-child { border-bottom: 0; }
.fx-set .fx-lab { font-weight: 650; }
.fx-set .switch { width: 50px; height: 30px; }
.fx-set .switch input { width: 0; height: 0; }
.fx-set .switch span { background: #2b3246; border-radius: 15px; }
.fx-set .switch span::after { width: 24px; height: 24px; }
.fx-set .switch input:checked + span { background: var(--accent); }
.fx-set .switch input:checked + span::after { transform: translateX(20px); }
.fx-set .seg { background: none; border: 0; padding: 0; gap: 6px; }
.fx-set .seg button { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; min-height: 36px; padding: 6px 14px; color: var(--text); font-size: 14px; }
.fx-set .seg button[aria-pressed="true"] { background: rgba(110,168,254,.14); border-color: var(--accent); color: var(--accent); }
.fx-set .fx-test { min-height: 34px; padding: 5px 10px; font-size: 13.5px; border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; }
.fx-set .fx-vol { accent-color: var(--accent); }
.fx-set .fx-why { font-size: 12.5px; }
/* a face-down card passed from one player to another */
.fx-cardback { position: fixed; width: 22px; height: 34px; border-radius: 3px; pointer-events: none; z-index: 60; transform: rotate(-8deg);
  background: repeating-linear-gradient(45deg, rgba(243,234,214,.28) 0 1px, transparent 1px 3px), repeating-linear-gradient(-45deg, rgba(243,234,214,.28) 0 1px, transparent 1px 3px), #7a1f2b;
  box-shadow: inset 0 0 0 2px #f3ead6, 0 3px 8px rgba(0,0,0,.55); }
/* Animations off (Settings): everything on the page is still */
html.fx-still *, html.fx-still *::before, html.fx-still *::after { animation: none !important; transition: none !important; }
