/* City Killer — 1960s noir: ink, case-file paper, one red. Mobile first. */

:root {
  --ink: #14110f;
  --ink2: #1f1a16;
  --ink3: #2b241e;
  --paper: #e9dcc0;
  --paper2: #d8c7a2;
  --sepia: #8a7556;
  --blood: #a3161a;
  --blood2: #cf2a30;
  --teal: #2a8c8f;
  --mustard: #d9a441;
  --text: #efe6d2;
  --muted: #a89a82;
  --head: 'Oswald', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --body: 'PT Serif', Georgia, 'Times New Roman', serif;
  --mono: 'PT Mono', 'Courier New', monospace;
  --bs: min(100vw - 12px, 100dvh - 150px, 620px); /* board side */
  --hdr: 46px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 16px/1.45 var(--body);
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
/* film grain and a vignette over everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body.locked { overflow: hidden; }
h1, h2, h3 { font-family: var(--head); text-transform: uppercase; letter-spacing: .04em; margin: 0; line-height: 1.1; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: .4em 0; }
small { font-size: .78em; color: var(--muted); }
ul { list-style: none; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
[role=button], button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--mustard); outline-offset: 2px; }

/* ------------------------------------------------------------ controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: .45em 1em;
  background: var(--ink3); color: var(--text);
  border: 1px solid #4a3f33; border-radius: 3px;
  font-family: var(--head); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; line-height: 1.15;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { background: #3a3027; border-color: var(--sepia); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn.primary:hover:not(:disabled) { background: #fff3d6; }
.btn.danger { background: var(--blood); border-color: var(--blood2); color: #fff; }
.btn.danger:hover:not(:disabled) { background: var(--blood2); }
.btn.accent { background: #173f47; border-color: var(--teal); text-transform: none; letter-spacing: 0; font-family: var(--body); text-align: left; }
.btn.ghost { background: transparent; }
.btn.on { background: var(--blood); border-color: var(--blood2); color: #fff; }
.btn.small { min-height: 34px; font-size: .8rem; padding: .3em .7em; }
.btn.wide { width: 100%; }
.btn.big { min-height: 58px; font-size: 1.3rem; flex: 1; }
.btn .ic { width: 1.3em; height: 1.3em; color: var(--teal); flex: none; }
.link { background: none; border: 0; padding: 0; color: var(--mustard); text-decoration: underline; text-underline-offset: 3px; font-family: var(--body); }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; padding: 0 .3em; color: inherit; opacity: .7; }
.x:hover { opacity: 1; }
.hint { color: var(--muted); font-size: .85rem; font-style: italic; }
.pad { padding: .6rem .8rem; }
.col { display: flex; flex-direction: column; gap: .5rem; margin: .7rem 0; }
.yn { display: flex; gap: .6rem; margin: .7rem 0; flex-wrap: wrap; }
.yn > .btn { flex: 1; }
.tick { width: 26px; height: 26px; flex: none; border: 2px solid var(--sepia); border-radius: 3px; background: transparent; position: relative; }
.tick.on { background: var(--blood); border-color: var(--blood2); }
.tick.on::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 16px; }
input, textarea {
  width: 100%; padding: .6em .7em; background: #fffaf0; color: var(--ink);
  border: 1px solid var(--sepia); border-radius: 2px; font-family: var(--mono);
}
textarea { resize: vertical; min-height: 5em; }

/* a sheet of case-file paper */
.paper {
  background: linear-gradient(170deg, var(--paper), var(--paper2));
  color: #2a2119; padding: .9rem; border-radius: 2px;
  box-shadow: 0 1px 0 #fff6 inset, 0 8px 24px #0009;
  margin: .7rem 0;
}
.paper small, .paper .hint { color: #6b5a44; }
.paper h3 { color: #3a1210; border-bottom: 1px solid #0003; padding-bottom: .25em; margin-bottom: .5em; }
.paper .btn:not(.primary):not(.danger) { background: #3a2f26; }
.paper .btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.paper .btn.ghost:not(.primary):not(.danger) { background: transparent; color: #3a2f26; border-color: #6b5a44; }
.paper .link { color: var(--blood); }

/* ------------------------------------------------------------ home */

.home, .wait, .lobby { min-height: 100dvh; position: relative; overflow: hidden; }
.home, .wait {
  display: grid; place-items: center; padding: 1.2rem;
  background: radial-gradient(ellipse at 50% 30%, #0000 0, #000d 75%), url(assets/board.webp) center/cover;
  background-color: #0b0908;
  background-blend-mode: normal, luminosity;
}
.home::before, .wait::before { content: ''; position: absolute; inset: 0; background: #0f0c0ad9; }
/* light through venetian blinds */
.blinds {
  position: absolute; inset: -20%; pointer-events: none; opacity: .5; transform: rotate(-12deg);
  background: repeating-linear-gradient(180deg, #f6d99a14 0 22px, #0000 22px 58px);
  mask-image: radial-gradient(ellipse at 60% 40%, #000 0, #0000 62%);
  animation: sway 9s ease-in-out infinite alternate;
}
@keyframes sway { to { transform: rotate(-10deg) translateY(12px); } }
.hero { position: relative; width: min(100%, 460px); text-align: center; }
.kicker { font-family: var(--head); text-transform: uppercase; letter-spacing: .28em; font-size: .72rem; color: var(--mustard); margin: 0 0 .6rem; }
.hero h1, .lobby-h h1 { font-size: clamp(3rem, 15vw, 5.2rem); font-weight: 700; letter-spacing: .01em; line-height: .88; text-shadow: 0 4px 30px #000; }
.hero h1 span, .lobby-h h1 span { display: block; font-size: .5em; letter-spacing: .32em; font-weight: 400; color: var(--paper); margin-left: .32em; }
.hero h1 em, .lobby-h h1 em, .logo em { font-style: normal; color: var(--blood2); }
.blurb { margin: 1rem auto 1.3rem; max-width: 34em; color: #cfc3aa; }
.notice { color: #ffb4a8; font-family: var(--mono); font-size: .9rem; }
.door { text-align: left; padding: 1.1rem; transform: rotate(-.4deg); }
.door label { display: block; font-family: var(--head); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; color: #5a4a37; margin-bottom: .8rem; }
.door label input { margin-top: .3rem; font-size: 1.05rem; }
.or { display: flex; align-items: center; gap: .7rem; margin: .8rem 0; color: #6b5a44; font-style: italic; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: #0003; }
.join { display: flex; gap: .5rem; }
.join input { text-transform: uppercase; letter-spacing: .25em; text-align: center; font-size: 1.05rem; }
.meta { font-family: var(--mono); font-size: .75rem; color: var(--muted); margin-top: 1rem; }
.links { color: var(--muted); }
.shake { animation: shake .4s; border-color: var(--blood) !important; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ------------------------------------------------------------ lobby */

.lobby { overflow: visible; background: radial-gradient(ellipse at 50% 0, #2a211a, var(--ink) 70%); }
.lobby-in { width: min(100% - 1.4rem, 760px); margin: 0 auto; padding-bottom: 1rem; }
#lobby > .lobby-in { padding: 1.6rem 0 0; }
.lobby-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.lobby-h h1 { font-size: 2.6rem; text-align: left; }
.lobby-h > span { color: var(--muted); font-size: .9rem; }
.invite { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1rem; align-items: center; }
.invite small { display: block; text-transform: uppercase; letter-spacing: .1em; font-family: var(--head); }
.code { font-family: var(--mono); font-size: 2rem; letter-spacing: .14em; color: var(--blood); line-height: 1; }
.invite-link { min-width: 0; }
.invite-link code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: .8rem; }
.invite-btns { grid-column: 1 / -1; display: flex; gap: .5rem; }
.invite-btns .btn { flex: 1; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.seat { border: 1px solid #3d3329; border-top: 4px solid var(--sepia); background: var(--ink2); padding: .8rem; display: flex; flex-direction: column; gap: .6rem; }
.seat-killer { border-top-color: var(--blood2); }
.seat-det { border-top-color: var(--teal); }
.seat-spec { margin-top: .7rem; }
.seat.mine { background: #2a221b; box-shadow: 0 0 0 1px var(--sepia); }
.seat h3 { font-size: 1.25rem; }
.seat ul { flex: 1; min-height: 2.2em; }
.seat li, .plist li { display: flex; align-items: center; gap: .4rem; padding: .15rem 0; flex-wrap: wrap; }
.seat li.none { color: var(--muted); font-style: italic; }
.seat li .x { margin-left: auto; font-size: 1.2rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5fc27e; flex: none; }
.off .dot { background: #6b5a44; }
.off { color: var(--muted); }
.opts.ro { opacity: .92; }
.opt-row { margin: .9rem 0; }
.seg { display: inline-flex; border: 1px solid #3a2f26; border-radius: 3px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: .5em 1.1em; font-family: var(--head); text-transform: uppercase; letter-spacing: .08em; color: #3a2f26; min-height: 40px; }
.seg button.on { background: var(--ink); color: var(--paper); }
.check { display: flex; gap: .7rem; align-items: flex-start; }
.mini { display: inline-flex; gap: .4rem; margin-left: .4rem; }
.start { margin: 1rem 0; text-align: center; }
.start .btn { font-size: 1.2rem; min-height: 56px; }

/* motives */
.motive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; margin-top: .6rem; }
.motive { position: relative; background: #f4ead2; color: #2a2119; border-radius: 2px; overflow: hidden; box-shadow: 0 2px 6px #0006; display: flex; flex-direction: column; }
.motive img { width: 100%; aspect-ratio: 9 / 5; object-fit: cover; }
.motive > div { padding: .4rem .5rem .5rem; }
.motive b { font-family: var(--head); text-transform: uppercase; letter-spacing: .04em; font-size: 1rem; display: block; }
.motive p { font-size: .76rem; line-height: 1.25; margin: .15rem 0 0; }
.motive.pick { transition: opacity .15s, transform .1s; }
.motive.pick.off { opacity: .38; filter: grayscale(1); }
.motive.pick.on { outline: 3px solid var(--blood2); }
.motive.na { opacity: .2; pointer-events: none; }
.motive.own { outline: 3px solid var(--blood2); }
.motive.crossed { opacity: .4; filter: grayscale(1); }
.motive.crossed::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top right, #0000 48%, var(--blood) 48% 52%, #0000 52%); }

/* chat */
.chat-list { max-height: 30dvh; overflow-y: auto; padding: .5rem .7rem; font-size: .92rem; }
.chat-list li { padding: .12rem 0; overflow-wrap: anywhere; }
.chat-list li b { font-family: var(--head); letter-spacing: .03em; margin-right: .4em; }
.chat-list li.sys { color: var(--muted); font-style: italic; }
.chat-list li.team span { color: var(--mustard); }
.c-killer { color: #ff7b72; }
.c-det { color: #6fd0d3; }
.c-spec { color: var(--muted); }
.chat-form { display: flex; gap: .4rem; padding: .5rem; align-items: center; }
.chat-form .btn { min-height: 40px; }
.lobby .chat, .lobby #lchat { background: var(--ink2); border: 1px solid #3d3329; }

/* ------------------------------------------------------------ game layout */

.game { display: grid; grid-template-columns: 100%; padding-top: var(--hdr); }
#top { position: fixed; top: 0; left: 0; right: 0; height: var(--hdr); z-index: 20; background: #0d0b0af2; border-bottom: 1px solid #3d3329; backdrop-filter: blur(6px); }
.hdr { height: 100%; display: flex; align-items: center; gap: .7rem; padding: 0 .6rem; }
.logo { font-family: var(--head); text-transform: uppercase; letter-spacing: .08em; font-size: 1.05rem; white-space: nowrap; }
.round { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.role { font-family: var(--head); text-transform: uppercase; font-size: .75rem; letter-spacing: .1em; padding: .2em .6em; border-radius: 2px; background: #3d3329; }
.role-killer { background: var(--blood); }
.role-det { background: #17555c; }
.burger { background: none; border: 0; font-size: 1.5rem; padding: 0 .3rem; line-height: 1; }
.left { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px; min-width: 0; }
.left > div { width: var(--bs); }
.right { min-width: 0; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem .7rem; min-height: 56px; border-left: 4px solid var(--sepia); background: var(--ink2); }
.banner h2 { font-size: 1.05rem; font-weight: 500; }
.banner p { font-size: .82rem; color: #cfc3aa; margin: .15rem 0 0; line-height: 1.3; }
.banner.mine { border-left-color: var(--mustard); background: linear-gradient(90deg, #3a2c12, var(--ink2) 70%); }
.banner.mine h2 { color: var(--mustard); }
.banner.pick { border-left-color: var(--teal); background: #12333a; }
.fx { display: inline-block; font-family: var(--mono); font-size: .7rem; background: #3a1512; color: #ffcfc7; padding: .1em .5em; margin: .25rem .3rem 0 0; border-radius: 2px; }
.dots { display: inline-flex; gap: 4px; flex: none; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ------------------------------------------------------------ the board */

#board { position: relative; }
.board {
  width: var(--bs); height: var(--bs);
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr);
  background: #b9a37e url(assets/board.webp) center/100% 100%;
  box-shadow: 0 0 0 2px #2a2119, 0 10px 40px #000c;
  user-select: none; -webkit-user-select: none;
  --cell: calc(var(--bs) / 4);
}
.cell { position: relative; min-width: 0; min-height: 0; overflow: hidden; outline-offset: -3px; transition: box-shadow .15s, filter .2s; }
.cell-h {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 2px;
  padding: 2px 2px 0 4px; min-height: 24%;
  background: linear-gradient(#ead9b4f5 62%, #ead9b400);
  font-family: var(--head); text-transform: uppercase; font-weight: 500;
  font-size: clamp(7.5px, calc(var(--cell) * .095), 14px); line-height: 1.02; letter-spacing: .02em; color: #2a2119;
}
.cell-h span { padding-top: 2px; overflow-wrap: anywhere; }
.bld { width: calc(var(--cell) * .3); flex: none; filter: drop-shadow(0 1px 2px #0008); }
.chips { position: absolute; left: 0; right: 0; bottom: 5%; display: flex; justify-content: center; gap: 2%; z-index: 3; padding: 0 2%; }
.chip {
  position: relative; width: calc(var(--cell) * .36); aspect-ratio: 1; flex: none;
  border-radius: 50%; border: calc(var(--cell) * .028) solid var(--g); background: var(--g);
  box-shadow: 0 2px 5px #000a; transition: transform .2s;
}
.chips.n3 .chip { width: calc(var(--cell) * .3); }
.chip img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.chip.scared img { filter: grayscale(1) contrast(1.15) brightness(.85); }
.chip.scared { border-style: dashed; }
.chip.sel { box-shadow: 0 0 0 3px #fff, 0 0 12px 4px var(--blood2); transform: scale(1.08); }
.chip.hot { box-shadow: 0 0 0 2px var(--blood2), 0 0 10px 3px var(--blood2); animation: pulse 1.4s infinite; }
.chip.go { box-shadow: 0 0 0 2px var(--mustard), 0 0 10px 2px var(--mustard); }
.chip.is-me::after { content: '★'; position: absolute; left: -18%; top: -22%; color: #fff; background: var(--blood); border-radius: 50%; width: 46%; aspect-ratio: 1; display: grid; place-items: center; font-size: calc(var(--cell) * .11); border: 1px solid #fff; }
.chip.is-fig::after { content: 'F'; position: absolute; left: -18%; top: -22%; color: var(--ink); background: var(--mustard); border-radius: 50%; width: 46%; aspect-ratio: 1; display: grid; place-items: center; font: 700 calc(var(--cell) * .11) var(--head); border: 1px solid #fff; }
.chip.is-ally::before { content: ''; position: absolute; left: 50%; bottom: -16%; width: 26%; aspect-ratio: 1; transform: translateX(-50%); background: var(--mustard); border-radius: 50%; border: 1px solid #000; }
@keyframes pulse { 50% { box-shadow: 0 0 0 2px var(--blood2), 0 0 16px 7px var(--blood2); } }
.badge { position: absolute; right: -16%; top: -20%; width: 50%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font: 700 calc(var(--cell) * .12) var(--head); font-style: normal; }
.b-scared { background: #111; color: #fff; border: 1px solid #fff; }
.b-surv { right: auto; left: -16%; top: auto; bottom: -18%; color: #17555c; background: none; width: 56%; filter: drop-shadow(0 1px 2px #000); }
.car { position: absolute; z-index: 4; width: calc(var(--cell) * .52); right: 1%; top: 26%; filter: drop-shadow(0 3px 4px #000b); animation: arrive .5s ease-out; pointer-events: none; }
@keyframes arrive { from { transform: translateX(40%); opacity: 0; } }
.cell.det { box-shadow: inset 0 0 0 3px #2a8c8fcc; }
.cell.scene { background: radial-gradient(circle, #5a0d10cc, #1a0606e6); }
.chalk { position: absolute; inset: 22% 0 0; display: grid; place-items: center; z-index: 1; }
.chalk img { height: 100%; width: auto; opacity: .85; mix-blend-mode: screen; }
.chalk b { position: absolute; right: 6%; bottom: 4%; font: 700 calc(var(--cell) * .2) var(--head); color: #f0d9c0; text-shadow: 0 2px 6px #000; }
.cell.cordon::after { content: ''; position: absolute; inset: 0; z-index: 5; pointer-events: none; border: calc(var(--cell) * .05) solid; border-image: repeating-linear-gradient(45deg, #f2c200 0 8px, #111 8px 16px) 8; }
.cell.stubborn::before { content: ''; position: absolute; inset: 0; z-index: 1; background: repeating-linear-gradient(45deg, #0005 0 6px, #0000 6px 12px); pointer-events: none; }
.cell.open { box-shadow: inset 0 0 0 3px var(--mustard); }
.cell.reach:hover, .cell:hover { filter: brightness(1.08); }
.cell.reach { box-shadow: inset 0 0 0 2px #2a8c8f88; }
.cell.det.open { box-shadow: inset 0 0 0 3px var(--mustard); }
.cell.dim { filter: brightness(.45) saturate(.6); cursor: default; }
.cell.hl { box-shadow: inset 0 0 0 4px var(--mustard), inset 0 0 30px #d9a44188; animation: glow 1.1s infinite alternate; z-index: 6; }
@keyframes glow { to { box-shadow: inset 0 0 0 4px #fff, inset 0 0 40px #d9a441cc; } }
.cell.flash { animation: stab 2.4s ease-out; }
@keyframes stab { 0%, 30% { background: #cf2a30; filter: brightness(1.6); } 100% { filter: none; } }
.murder-flash { position: absolute; inset: 0; z-index: 10; pointer-events: none; display: grid; place-items: center; background: radial-gradient(circle, #a3161a66, #0000 70%); animation: fadeout 2.6s forwards; }
.murder-flash span { font: 700 clamp(1.6rem, 8vw, 3.4rem) var(--head); text-transform: uppercase; letter-spacing: .1em; color: #fff; text-shadow: 0 0 20px var(--blood), 0 4px 0 #000; transform: rotate(-6deg); border: 4px solid #fff; padding: .1em .5em; background: #a3161acc; }
@keyframes fadeout { 0% { opacity: 0; transform: scale(1.3); } 12% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* victims */
.slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.slot { position: relative; min-height: 48px; background: #0c0a09; border: 1px dashed #4a3f33; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px; padding: 3px 2px 14px; }
.slot > b { position: absolute; left: 4px; top: 1px; font: 500 .8rem var(--head); color: #5a4a37; }
.slot.full { border: 1px solid var(--blood); background: #2a0c0c; }
.slot.full > b { color: var(--blood2); }
.slot .thumb { width: 30px; height: 30px; filter: grayscale(.7); }
.slot .real .thumb { filter: none; box-shadow: 0 0 0 2px #fff; }
.slot small { position: absolute; bottom: 1px; left: 2px; right: 2px; text-align: center; font: .58rem/1 var(--head); text-transform: uppercase; color: #e9c9c0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiny { font: .68rem var(--mono); color: var(--muted); margin: 3px 0 0; text-align: center; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions .btn { flex: 1 1 auto; }
.meters { flex: 1 1 100%; display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; font: .78rem var(--head); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pips { color: var(--mustard); letter-spacing: .15em; font-size: 1.05rem; }
.slot-a { display: inline-block; min-width: 4.5em; text-align: center; border: 1px dashed #4a3f33; padding: 0 .5em; margin-left: .3em; color: #6b5a44; }
.slot-a.used { border: 1px solid var(--mustard); color: var(--mustard); }
.card-btn { border-style: dashed; }

/* ------------------------------------------------------------ tabs */

#tabs { display: flex; position: sticky; top: var(--hdr); z-index: 15; background: var(--ink); border-bottom: 1px solid #3d3329; }
#tabs button { flex: 1; position: relative; background: none; border: 0; border-bottom: 3px solid transparent; padding: .7em .2em; font: .82rem var(--head); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-height: 44px; }
#tabs button.on { color: var(--paper); border-bottom-color: var(--blood2); }
.unread { position: absolute; top: 8px; right: 12%; width: 8px; height: 8px; border-radius: 50%; background: var(--blood2); }
.tb { padding: 0 .6rem; min-height: 30dvh; }
.tb-log, .tb-test, .tb-res, .tb-chat { padding: 0; }
#tab-foot { padding: 0 .6rem; }

.log { font: .8rem/1.4 var(--mono); padding: .5rem .7rem; max-height: 60dvh; overflow-y: auto; }
.log li { padding: .12rem 0; border-bottom: 1px dotted #3d3329; }
.log .lr { font: 500 .85rem var(--head); text-transform: uppercase; letter-spacing: .1em; color: var(--mustard); border: 0; margin-top: .5rem; }
.log .l-murder { color: #ff8a80; font-weight: 700; }
.log .l-answer, .log .l-surveil, .log .l-profile, .log .l-confession { color: #9be0e2; }
.log .l-res_move, .log .l-det_move { color: var(--muted); }

.res-list { display: flex; flex-direction: column; }
.res { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border-bottom: 1px solid #3d332955; }
.res.none, li.none { color: var(--muted); font-style: italic; padding: .8rem; }
.thumb { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; border: 3px solid var(--g, #555); flex: none; background: var(--g, #555); }
.res.scared .thumb, .res.dead .thumb { filter: grayscale(1); }
.res-m { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .5rem; }
.res-m > b { font: 500 1.02rem var(--head); text-transform: uppercase; letter-spacing: .03em; flex: 1 1 100%; }
.res-b { display: flex; flex-direction: column; gap: .3rem; align-items: stretch; flex: none; }
.res-b .btn { min-height: 38px; font-size: .82rem; padding: .3em .7em; }
.res-w { font: .72rem var(--mono); color: var(--muted); text-align: right; max-width: 34%; }
.res.dead { opacity: .5; }
.res.out { opacity: .32; }
.res.out .res-m > b { text-decoration: line-through; }
.res.pickable:hover, .res-list.all .res:hover { background: #ffffff10; }
.res.sel { background: #d9a44133; box-shadow: inset 4px 0 var(--mustard); }
.done { color: var(--muted); font-style: italic; }
.tags { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: .25rem; }
.tag { font: normal .66rem var(--mono); padding: .05em .45em; border-radius: 2px; background: #3d3329; color: var(--text); }
.tag.scared { background: #111; border: 1px dashed #aaa; }
.tag.surv { background: #17555c; }
.tag.me { background: var(--blood); }
.tag.fig, .tag.ally { background: var(--mustard); color: #111; }
.gpill { display: inline-flex; align-items: center; gap: .3em; font: .68rem var(--head); text-transform: uppercase; letter-spacing: .05em; background: var(--g); color: #fff; padding: .1em .55em .1em .15em; border-radius: 9px; white-space: nowrap; }
.gpill img { width: 15px; height: 15px; border-radius: 50%; }
.gdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--g); margin-right: .4em; }
.traits { display: inline-flex; gap: 3px; align-items: center; }
.tr { font: 700 .72rem var(--mono); font-style: normal; min-width: 21px; height: 21px; display: inline-grid; place-items: center; border-radius: 3px; background: #e9dcc0; color: #2a2119; padding: 0 3px; }
.sex-m { background: #a9c6d6; border-radius: 50%; }
.sex-f { background: #eab0c4; border-radius: 50%; }
.h-S { background: #2f7d43; color: #fff; }
.h-M { background: #4a78a8; color: #fff; }
.h-L { background: #b3261e; color: #fff; }
.tr svg { height: 15px; width: auto; }
.b-thin { background: #e9dcc0; }
.b-thin svg { fill: #2f7d43; transform: scaleX(.6); }
.b-medium svg { fill: #25506e; transform: scaleX(.88); }
.b-strong svg { fill: #b3261e; transform: scaleX(1.2); }

.tt { width: 100%; border-collapse: collapse; font-size: .82rem; }
.tt th { font: .7rem var(--head); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: left; padding: .4rem .5rem; border-bottom: 1px solid #3d3329; }
.tt td { padding: .4rem .5rem; border-bottom: 1px dotted #3d3329; vertical-align: top; }
.tt td small { display: block; }
.tt td:first-child { font-family: var(--mono); color: var(--muted); width: 1.6em; }
.a-true { color: #7fe0a0; font: 700 .9rem var(--head); text-transform: uppercase; }
.a-false { color: #ff8a80; font: 700 .9rem var(--head); text-transform: uppercase; }
.a-null { color: var(--muted); font-style: italic; }

.dossier { border-top: 5px solid var(--blood); }
.dos-id { display: flex; gap: .7rem; align-items: center; margin-bottom: .6rem; }
.dos-id > img { width: 76px; border-radius: 2px; box-shadow: 0 2px 8px #0008; transform: rotate(-2deg); }
.dos-id b { display: block; font: 700 1.5rem var(--head); text-transform: uppercase; }
.dos-id > div { display: flex; flex-direction: column; gap: .25rem; align-items: flex-start; }
.dos-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.dos-row small { flex: 1 1 100%; }
.dossier .motive { flex-direction: row; margin: .2rem 0 .5rem; }
.dossier .motive img { width: 104px; aspect-ratio: 1; flex: none; }
.nb-row { display: flex; align-items: center; gap: .35rem; margin: .35rem 0; flex-wrap: wrap; }
.nb-row small { width: 5.6em; flex: none; font-family: var(--head); text-transform: uppercase; letter-spacing: .05em; }
.mk { background: #fff9; border: 1px solid #8a7556; border-radius: 3px; padding: .35em .6em; min-height: 36px; font: .82rem var(--head); text-transform: uppercase; letter-spacing: .04em; color: #2a2119; display: inline-flex; align-items: center; gap: .3em; }
.mk.yes { background: #2f7d43; border-color: #1c5a2c; color: #fff; }
.mk.yes::after { content: '✓'; }
.mk.no { background: #0000; color: #8a7556; text-decoration: line-through; border-style: dashed; }
.mk.no::after { content: '✗'; color: var(--blood); text-decoration: none; }
.mk.g img { width: 18px; height: 18px; border-radius: 50%; }
.mk.g { border-left: 6px solid var(--g); }
.nb-groups { display: flex; flex-wrap: wrap; gap: .35rem; }

.pcard { display: flex; gap: .6rem; background: #f4ead2; color: #2a2119; border-radius: 2px; overflow: hidden; margin: .4rem 0; box-shadow: 0 2px 6px #0006; border-left: 5px solid #1f3f7d; }
.pcard.k { border-left-color: var(--blood); }
.pcard img { width: 84px; object-fit: cover; flex: none; }
.pcard-t { padding: .4rem .5rem .5rem 0; flex: 1; min-width: 0; }
.pcard-t b { font: 500 1rem var(--head); text-transform: uppercase; }
.pcard-t p { font-size: .78rem; line-height: 1.25; margin: .15rem 0 .35rem; }
.star { color: var(--blood); font-style: normal; }
.clue { display: inline-block; width: 26px; vertical-align: middle; }
.clue-pick { display: flex; gap: .6rem; }
.clue-pick .btn { flex: 1; flex-direction: column; text-transform: none; }
.clue-pick .clue { width: 64px; }

/* ------------------------------------------------------------ quarter sheet */

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; max-height: 58dvh; overflow-y: auto;
  background: #1a1512f7; border-top: 3px solid var(--mustard); box-shadow: 0 -12px 40px #000c;
  padding: .6rem .2rem calc(.8rem + env(safe-area-inset-bottom)); animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-h { display: flex; justify-content: space-between; align-items: flex-start; padding: 0 .7rem .3rem; }
.sheet-h h3 { font-size: 1.35rem; margin-bottom: .2rem; }
.mark { font: .68rem var(--mono); background: #3d3329; padding: .1em .5em; border-radius: 2px; margin-right: .3rem; white-space: nowrap; }
.mark.blood { background: var(--blood); }
.bld-line { display: flex; gap: .6rem; align-items: center; padding: 0 .7rem; font-size: .85rem; color: #cfc3aa; }
.bld-line img { width: 40px; flex: none; }
.sheet > .btn { margin: .4rem .7rem; width: calc(100% - 1.4rem); }

/* ------------------------------------------------------------ modals, toasts */

.modal-back { position: fixed; inset: 0; z-index: 50; background: #000b; display: grid; place-items: center; padding: .6rem; overflow-y: auto; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { position: relative; width: min(100%, 440px); max-height: calc(100dvh - 1.2rem); overflow-y: auto; background: var(--ink2); border: 1px solid #4a3f33; border-top: 4px solid var(--blood); padding: 1rem; box-shadow: 0 20px 60px #000; }
.modal.wide { width: min(100%, 720px); }
.modal.slim { width: min(100%, 330px); padding: .5rem; }
.modal > .x { position: absolute; right: .3rem; top: .2rem; z-index: 2; }
.modal h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.modal h3 { margin: .6rem 0 .3rem; }
.modal > .link { display: block; margin: .6rem auto 0; }
.modal .res { padding-left: 0; padding-right: 0; }
.confirm-t { font-size: 1.1rem; margin: .4rem 0 1rem; }
.q-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.q-head .thumb { width: 60px; height: 60px; }
.quote { font: italic 1.35rem/1.25 var(--body); color: var(--paper); border-left: 3px solid var(--mustard); padding-left: .7rem; margin: .8rem 0; }
.q-row { margin: .55rem 0; }
.q-row small { display: block; font-family: var(--head); text-transform: uppercase; letter-spacing: .1em; }
.q-row > div { display: flex; flex-direction: column; gap: .35rem; margin-top: .25rem; }
.btn.q { text-transform: none; letter-spacing: 0; font-family: var(--body); justify-content: flex-start; text-align: left; min-height: 40px; }
.btn.true { box-shadow: inset 0 -4px #2f7d43; }
.btn.lie { box-shadow: inset 0 -4px var(--blood); }
.ally-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: .5rem; margin: .6rem 0; }
.gbtn { flex-direction: column; background: var(--g) !important; border-color: #fff4; color: #fff; padding: .7em .4em; }
.gbtn img { width: 40px; height: 40px; border-radius: 50%; }
.gbtn small { color: #fffc; text-transform: none; letter-spacing: 0; font-family: var(--body); }
.bigcard { background: var(--g); padding: 6px; border-radius: 6px; }
.bigcard img { width: 100%; border-radius: 3px; }
.bigcard-t { background: var(--paper); color: #2a2119; padding: .6rem; margin-top: 6px; border-radius: 3px; display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; }
.bigcard-t h3 { font-size: 1.5rem; flex: 1 1 100%; margin: 0; }
.bigcard-t p { font-size: .8rem; flex: 1 1 100%; margin: 0; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: .4rem; margin: .6rem 0; }
.acc { background: var(--ink3); border: 2px solid transparent; border-radius: 3px; padding: .4rem .2rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; font: .68rem var(--head); text-transform: uppercase; }
.acc.on { border-color: var(--blood2); background: #3a1512; }
.acc span { overflow-wrap: anywhere; text-align: center; line-height: 1.05; }
.over { text-align: center; }
.over h2 { font-size: clamp(1.8rem, 8vw, 2.8rem); }
.over.killer h2 { color: var(--blood2); }
.over.det h2 { color: #6fd0d3; }
.over .paper { text-align: left; }
.verdict { font: 700 1.1rem var(--head); text-transform: uppercase; letter-spacing: .2em; }
.verdict.win { color: #7fe0a0; }
.verdict.lose { color: var(--muted); }
.right { color: #1c6b34; }
.wrong { color: var(--blood); text-decoration: line-through; }
.rules { font-size: .92rem; }
.rules h3 { color: var(--mustard); margin-top: 1rem; }
.rules ol, .rules ul { padding-left: 1.2rem; list-style: revert; }
.rules li { margin: .3rem 0; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; font-size: .85rem; }
.plist { margin-top: .6rem; font-size: .9rem; }

#toasts { position: fixed; left: 50%; top: calc(var(--hdr) + 8px); transform: translateX(-50%); z-index: 70; width: min(100% - 1rem, 460px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: #f4ead2; color: #2a2119; padding: .5rem .8rem; font: .85rem/1.3 var(--mono); border-left: 5px solid var(--sepia); box-shadow: 0 6px 20px #000a; animation: drop .25s ease-out; }
.toast.bad { border-left-color: var(--blood); }
.toast.blood { background: var(--blood); color: #fff; border-left-color: #fff; font-weight: 700; }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }
.conn { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: var(--blood); color: #fff; text-align: center; padding: .4rem; font: .85rem var(--mono); }

/* ------------------------------------------------------------ wide screens: board left, case file right */

@media (min-width: 940px) {
  :root { --bs: clamp(380px, calc(100dvh - 276px), 58vw); }
  .actions .btn.wide { width: auto; flex: 3 1 auto; }
  .game { grid-template-columns: auto minmax(340px, 1fr); height: 100dvh; overflow: hidden; }
  .left { padding: 10px 14px; gap: 8px; overflow-y: auto; }
  .right { height: calc(100dvh - var(--hdr)); overflow-y: auto; border-left: 1px solid #3d3329; background: #181411; display: flex; flex-direction: column; }
  #tabs { top: 0; flex: none; }
  #tab-body:has(.tb-chat) { flex: 1; }
  #tab-foot:has(.chat-form) { position: sticky; bottom: 0; background: #181411; }
  .log { max-height: none; }
  .chat-list { max-height: none; }
  .sheet { left: auto; top: var(--hdr); bottom: 0; max-height: none; width: calc(100vw - var(--bs) - 30px); min-width: 340px; border-top: 0; border-left: 3px solid var(--mustard); animation-name: slide; }
  @keyframes slide { from { transform: translateX(24px); opacity: 0; } }
  .motive-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .q-row > div { flex-direction: row; flex-wrap: wrap; }
  .q-row .btn.q { flex: 1 1 30%; }
}
@media (max-width: 420px) {
  .seats { grid-template-columns: 1fr; }
  .logo { font-size: .9rem; }
  .motive-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
