/* Deception - crime scene theme
   Dried-blood walls, bone-white ink, fresh blood for anything that matters.
   Colour-blind friendly by default: every red was checked against red-, green- and blue-blind
   simulations, and nothing important is shown by colour alone (ticks, labels, shapes, underlines). */
/* Fonts are bundled in public/fonts (both are free, open-licence fonts) */
@font-face { font-family: 'Big Shoulders Display'; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/big-shoulders-display-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Big Shoulders Display'; font-weight: 800; font-style: normal; font-display: swap; src: url(fonts/big-shoulders-display-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Big Shoulders Display'; font-weight: 900; font-style: normal; font-display: swap; src: url(fonts/big-shoulders-display-latin-900-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-style: normal; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-style: normal; font-display: swap; src: url(fonts/barlow-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/barlow-latin-400-italic.woff2) format('woff2'); }

:root {
  --night: #120707;        /* page */
  --wall: #1b0b0a;         /* panels */
  --wall-2: #241010;       /* raised / inputs */
  --rust: #57261f;         /* borders - bright enough to see the edges of every box */
  --blood: #8e1616;        /* button fill */
  --blood-hi: #f2503f;     /* big red text, timers, bars */
  --blood-text: #ff6a52;   /* small red text */
  --edge: #c98d82;         /* light edge on red buttons, so they stand out by brightness, not just colour */
  --bone: #e8ddca;         /* text, paper */
  --ash: #c4b5a9;          /* secondary text */
  --ink: #1d0c0b;          /* text on paper */
  --accent: var(--blood-hi);
  --accent-2: var(--bone);
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--bone);
  font: 17px/1.45 var(--body);
  overflow: hidden;   /* every screen fits the window; long lists scroll inside their own box */
  background:
    radial-gradient(900px 520px at 50% -120px, rgba(150, 24, 20, .28), transparent 70%),
    radial-gradient(140% 100% at 50% 40%, transparent 55%, rgba(0, 0, 0, .65)),
    var(--night);
}

/* ---------- Blood overlay ---------- */
.gore { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.gore .drips {
  position: absolute; left: 0; right: 0; top: 0; height: 120px;
  background: url(img/drips.svg) top center / auto 120px repeat-x;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .6));
  animation: bleed 1.6s cubic-bezier(.3, .7, .4, 1) both;
}
.gore .stain { position: absolute; opacity: .26; }
.gore .stain-a { width: 520px; right: -160px; top: 120px; transform: rotate(18deg); }
.gore .stain-b { width: 440px; left: -150px; bottom: -120px; transform: rotate(-30deg); opacity: .2; }
.gore .grain {
  position: absolute; inset: -50%; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes bleed { from { transform: translateY(-110px); } to { transform: none; } }

/* ---------- Page frame ---------- */
main {
  position: relative; z-index: 1;
  max-width: 1180px; margin: 0 auto;
  height: 100vh; height: 100dvh;
  padding: 70px 24px 20px;
  display: flex; flex-direction: column;
}

/* ---------- Type ---------- */
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1; margin: 0; letter-spacing: .01em; }
h2 { font-size: 34px; margin-bottom: 6px; }
h3 { font-size: 24px; margin-bottom: 8px; }
p { margin: 0 0 10px; }
a { color: var(--bone); }
.muted { color: var(--ash); }
.small { font-size: 15px; }
.center { text-align: center; }
b, strong { font-weight: 700; }
.screen-title { font-size: 36px; margin: 0; }

/* ---------- Panels ---------- */
.card {
  position: relative;
  background: rgba(27, 11, 10, .95);
  border: 1px solid var(--rust);
  border-radius: 3px;
  padding: 16px 18px;
}
.card.fill { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.card.fill .scroll { flex: 1; min-height: 0; overflow-y: auto; margin-right: -8px; padding-right: 8px; }
.card-head { margin-bottom: 4px; }
.card-head h3 { margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 140px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.scroll { scrollbar-width: thin; scrollbar-color: var(--rust) transparent; }

/* ---------- Forms ---------- */
input, select {
  width: 100%; background: #0d0404; color: var(--bone);
  border: 1px solid var(--rust); border-radius: 2px; padding: 11px 13px; font: inherit;
}
input::placeholder { color: #8a7a70; }
input:focus, select:focus { outline: 2px solid var(--bone); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: 15px; color: var(--ash); margin-bottom: 4px; }
.check { display: flex; gap: 10px; align-items: center; color: var(--bone); font-size: 16px; cursor: pointer; margin: 0; }
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--blood-hi); }

/* ---------- Buttons ---------- */
button {
  font: 600 17px var(--body); cursor: pointer;
  background: transparent; color: var(--bone);
  border: 1px solid #7a3a31; border-radius: 2px; padding: 11px 18px;
  transition: background .15s, border-color .15s;
}
button:hover { background: var(--wall-2); border-color: var(--edge); }
button:focus-visible, [data-act]:focus-visible { outline: 3px solid var(--bone); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--blood); border: 2px solid var(--edge); color: #fff4ea; }
button.primary:hover { background: #a61d18; }
button.big { width: 100%; padding: 14px; font-size: 19px; }
button.link { background: none; border: 0; color: var(--ash); padding: 2px 4px; font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--bone); }

/* ---------- Home: one centred composition that scales with the window height ---------- */
.home {
  flex: 1; min-height: 0; width: 100%; max-width: 980px; margin: 0 auto;
  display: flex; flex-direction: column; justify-content: center;
  gap: clamp(14px, 2.6vh, 30px);
}
.hero { text-align: center; flex: none; }
.logo { margin: 0 auto; line-height: 0; }
.logo img {
  display: block; margin: 0 auto;
  height: clamp(70px, 17vh, 220px); width: auto; max-width: min(100%, 900px);
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .7));
}
.tagline { font: 700 clamp(22px, 3.4vh, 34px)/1.1 var(--display); margin: clamp(10px, 2.4vh, 24px) 0 6px; }
.blurb { max-width: 52ch; margin: 0 auto; }
.home-play { flex: none; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; align-items: center; gap: 12px; max-width: 460px; width: 100%; margin: 0 auto; }
.field label { margin: 0; white-space: nowrap; font-size: 16px; color: var(--bone); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mode {
  text-align: left; padding: clamp(12px, 2vh, 20px) 18px; border-radius: 2px;
  background: var(--wall); border: 1px solid var(--rust); border-top: 5px solid var(--blood-hi);
  display: flex; flex-direction: column; gap: 6px;
}
.mode:hover { background: #2a100e; border-top-color: var(--bone); }
.mode b { font: 900 clamp(30px, 4.6vh, 44px)/1 var(--display); color: var(--bone); }
.mode .desc { font: 500 15px/1.35 var(--body); color: var(--ash); }
.mode .count { font: 600 14px var(--body); color: var(--bone); margin-top: auto; }
.home-bottom { flex: 0 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.home-bottom .card { min-height: 0; max-height: 100%; display: flex; flex-direction: column; }
.lobbies-card { max-height: clamp(150px, 30vh, 320px) !important; }
.lobbies-card .scroll { overflow-y: auto; min-height: 0; margin-right: -8px; padding-right: 8px; }
.lobbies { list-style: none; padding: 0; margin: 0; }
.lobbies li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--rust); }
.lobbies li:last-child { border-bottom: 0; }
.lobbies .info { flex: 1; min-width: 0; }
.lobbies .info b { display: block; font-size: 17px; }
.lobbies .info span { color: var(--ash); font-size: 14px; }
.lobbies button { padding: 7px 16px; flex: none; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; border: 2px solid var(--bone); vertical-align: middle; }
.dot.busy { border-radius: 1px; border-color: var(--blood-hi); background: var(--blood-hi); }   /* open = ring, in a game = filled square */
.friends { gap: 10px; }
.friends h3 { margin: 0; }
.friends-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.friends .create { width: 100%; }
#code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }

/* ---------- In a room ---------- */
.topbar {
  flex: none; display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
  background: rgba(18, 7, 7, .88); border: 1px solid var(--rust); border-radius: 3px; padding: 10px 14px;
}
.topbar .room { min-width: 0; flex: 1; }
.topbar .room b { display: block; font: 800 24px/1.1 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .room span { color: var(--ash); font-size: 14px; }
.code-inline { color: var(--blood-hi); letter-spacing: .08em; }
button.leave { flex: none; padding: 8px 16px; font-size: 15px; border-color: var(--edge); color: #f6c9bb; }
button.leave.armed { background: #a51c18; color: #fff; border: 2px solid var(--bone); }
.screen {
  flex: 1; min-height: 0; display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr);
  grid-template-rows: minmax(0, max-content);   /* only as tall as the content... */
  align-content: center;                        /* ...and centred on tall screens */
}
.col { min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.col-side { overflow: hidden; }

.room-card { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.room-code { text-align: center; }
.code { font: 900 60px/1 var(--display); letter-spacing: .14em; color: var(--blood-hi); margin: 2px 0; }
.vis-note { margin: 0; }
.settings summary { cursor: pointer; font: 800 24px var(--display); list-style: none; display: flex; align-items: center; gap: 8px; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::before { content: '+'; display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--edge); font: 700 16px var(--body); }
.settings[open] summary::before { content: '−'; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 12px; }
.settings-grid .wide { grid-column: 1 / -1; }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 2px; font-size: 14px;
  background: var(--wall-2); border: 1px solid var(--rust); color: var(--ash); white-space: nowrap;
}
.pill.hot { background: rgba(201, 42, 36, .18); border-color: var(--blood-hi); color: #ffd0c4; }
.pill.ok { border-color: var(--bone); color: var(--bone); }
.pill.time { background: var(--bone); border-color: var(--bone); color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--rust); }
.players li:last-child { border-bottom: 0; }
.players .name { flex: 1; font-weight: 600; min-width: 0; }
.players .off { opacity: .5; }
.score { font: 800 22px var(--display); min-width: 2ch; text-align: right; }
.votes-n { min-width: 2ch; text-align: right; color: var(--ash); font: 700 18px var(--display); }
.clue-list { display: block; font-size: 14px; color: #f0b3a3; font-weight: 500; }
.voted { display: block; font-size: 13px; color: var(--ash); font-weight: 500; }

.timer { font: 900 40px/1 var(--display); font-variant-numeric: tabular-nums; }
.timer.low { color: var(--blood-hi); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.timer.sm { font-size: 24px; }
.timer.top { font-size: 34px; flex: none; }

/* Your secret: a scrap of paper for civilians, a blood-soaked one for the imposter */
.secret {
  position: relative; overflow: hidden; flex: none;
  background: var(--bone); color: var(--ink);
  border-radius: 2px; padding: 22px 20px; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.secret .muted { color: #5e4a40; }
.secret .word { font: 900 clamp(42px, 6vw, 72px)/1 var(--display); margin: 6px 0 8px; word-break: break-word; }
.secret button.link { color: #5e4a40; }
.secret.imp { background: #5e0b0b url(img/splatter-b.svg) 120% -40% / 320px no-repeat; color: #fbe9dc; outline: 2px solid var(--bone); outline-offset: -7px; }
.secret.imp .muted, .secret.imp button.link { color: #f0c6b8; }
.secret.compact { padding: 12px 16px; }
.secret.compact .word { font-size: clamp(34px, 5vw, 52px); margin: 2px 0 4px; }
.secret.video { padding: 12px; }
.hidden-card {
  cursor: pointer; padding: 34px 20px;
  background: var(--wall-2) repeating-linear-gradient(-45deg, transparent 0 14px, rgba(0, 0, 0, .25) 14px 28px);
  color: var(--bone); border: 2px dashed var(--edge); box-shadow: none;
}
.hidden-card .muted { color: var(--ash); }
.hidden-card .word { font-size: 32px; }
.hidden-card:hover { border-color: var(--bone); }

.video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: 42vh; border-radius: 2px; overflow: hidden; background: #000; margin: 8px auto; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.turn.mine { border: 2px solid var(--bone); }
.guess-card label { color: var(--bone); font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.guess-card .vote-grid button { font-size: 16px; }
.reminder { margin: 0; padding: 8px 12px; background: var(--bone); color: var(--ink); border-radius: 2px; font-size: 16px; }
.reminder.imp { background: #5e0b0b; color: #fbe9dc; border: 2px solid var(--bone); }
.col-side > .big, .col-side > p { flex: none; }
.vote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.vote-grid button { padding: 16px 10px; text-align: center; background: var(--wall); font-size: 18px; }
.vote-grid button.sel { background: #a51c18; border: 3px solid var(--bone); color: #fff; padding: 12px 8px; }
.vote-mark { display: block; font-size: 14px; font-weight: 700; margin-top: 2px; }

.banner { text-align: center; padding: 18px 16px; border-radius: 2px; flex: none; }
.banner h2 { font-size: clamp(36px, 5vw, 56px); font-weight: 900; margin-bottom: 6px; }
.banner.win { background: var(--bone); color: var(--ink); }
.banner.lose { background: #5e0b0b url(img/splatter-a.svg) -60px -80px / 300px no-repeat; color: #fbe9dc; outline: 2px solid var(--bone); outline-offset: -7px; }
.reveal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: none; }
.reveal { background: rgba(27, 11, 10, .95); border: 1px solid var(--rust); border-radius: 3px; padding: 12px 14px; }
.reveal.imp { border: 2px solid var(--blood-hi); }
.reveal .muted { display: block; }
.big-word { display: block; font: 900 30px/1.05 var(--display); margin-top: 2px; }
.next-in { text-align: center; margin: 0; display: flex; gap: 8px; align-items: baseline; justify-content: center; }

.status-card { text-align: center; }
.status-card .timer { display: block; margin-top: 6px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--rust); border-top-color: var(--blood-hi); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented button { text-align: left; padding: 10px 12px; }
.segmented button b { display: block; font-size: 17px; }
.segmented button span { display: block; font: 400 14px var(--body); color: var(--ash); margin-top: 2px; }
.segmented button.on { border: 2px solid var(--bone); background: rgba(142, 22, 22, .35); }
.segmented button.on span { color: var(--bone); }

.error { color: #ffd2c6; background: rgba(142, 22, 22, .35); border-left: 4px solid var(--bone); padding: 10px 14px; margin: 0; }

/* ---------- Timer mode ---------- */
.stop-card { display: flex; flex-direction: column; align-items: center; }
.stopwatch {
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  width: 160px; height: 160px; border-radius: 50%;
  font: 900 38px var(--display); letter-spacing: .04em; color: #fff4ea;
  background: radial-gradient(circle at 40% 35%, #b3221c, #6e0d0d 70%);
  border: 4px solid var(--bone); box-shadow: 0 0 0 6px rgba(0, 0, 0, .4), 0 12px 30px rgba(0, 0, 0, .5);
}
.stopwatch:hover { background: radial-gradient(circle at 40% 35%, #c92a24, #7a0f0f 70%); border-color: var(--bone); }
.stopwatch.stop:not(:disabled) { animation: throb 1.1s ease-in-out infinite; }
.stopwatch:disabled { opacity: .35; filter: grayscale(.5); }
@keyframes throb { 50% { box-shadow: 0 0 0 6px rgba(0, 0, 0, .4), 0 0 0 14px rgba(201, 42, 36, .25), 0 12px 30px rgba(0, 0, 0, .5); } }
.countdown { font: 800 24px var(--display); color: var(--ash); min-height: 30px; margin-bottom: 8px; }
.countdown.big { font-size: 64px; font-weight: 900; color: var(--blood-hi); line-height: 1; min-height: 64px; }
.runclock { display: block; margin-bottom: 10px; }
.board { display: flex; flex-direction: column; gap: 10px; }
.board-row { display: grid; grid-template-columns: minmax(70px, 130px) 1fr 64px; align-items: center; gap: 10px; }
.board-row.me .board-name { color: #ffd0c4; }
.board-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-track { height: 12px; background: #160807; border: 1px solid var(--rust); border-radius: 1px; overflow: hidden; }
.board-bar { display: block; height: 100%; background: var(--blood-hi); transition: width .4s; }
.board-time { text-align: right; font: 800 20px var(--display); font-variant-numeric: tabular-nums; }

/* ---------- Chat ---------- */
.chat-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 30;
  width: 60px; height: 60px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; color: #fff4ea;
  background: var(--blood); border: 2px solid var(--bone);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
}
.chat-fab:hover { background: #a61d18; border-color: var(--bone); }
.chat-fab[hidden], .chat-panel[hidden] { display: none; }
.chat-fab.pulse { animation: throb 1.1s ease-in-out infinite; }
.fab-badge {
  position: absolute; top: -5px; right: -5px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 99px; background: var(--bone); color: var(--ink); font: 700 12px/22px var(--body); text-align: center;
}
.chat-panel {
  position: fixed; right: 20px; bottom: 92px; z-index: 30;
  width: 370px; height: min(560px, calc(100vh - 120px));
  display: flex; flex-direction: column;
  background: #160808; border: 1px solid var(--edge); border-radius: 3px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--rust); font: 800 22px var(--display); }
.icon-btn { background: none; border: 0; padding: 6px; color: var(--ash); display: grid; place-items: center; }
.icon-btn:hover { background: var(--wall-2); color: var(--bone); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { font-size: 16px; line-height: 1.4; word-wrap: break-word; }
.msg .who { font-weight: 700; margin-right: 6px; color: #f0b3a3; }
.msg.mine .who { color: var(--bone); text-decoration: underline; text-underline-offset: 3px; }
.msg.system { color: var(--ash); font-size: 14px; text-align: center; padding: 2px 0; }
.msg.clue { background: rgba(142, 22, 22, .22); border-left: 3px solid var(--bone); padding: 6px 10px; }
.msg.clue .tag { font-size: 13px; color: var(--blood-text); font-weight: 700; margin-right: 6px; }
.chat-hint { padding: 8px 16px; font-size: 15px; border-top: 1px solid var(--rust); color: var(--ash); }
.chat-hint:empty { display: none; }
.chat-hint.myturn { background: var(--blood); color: #fff4ea; font-weight: 600; border-top: 2px solid var(--edge); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--rust); }
.chat-form input { flex: 1; min-width: 0; }
.chat-form button { flex: none; }
.chat-form.myturn input { outline: 2px solid var(--bone); }

/* ---------- How to play ---------- */
.hero-links { display: flex; justify-content: center; align-items: center; gap: 4px 14px; margin-top: 8px; flex-wrap: wrap; }
.howto-link { font-size: 16px; color: var(--bone); }
.sound-link { display: inline-grid; place-items: center; color: var(--bone); text-decoration: none; padding: 4px; }
.sound-label { font-size: 15px; color: var(--ash); margin-left: -10px; }
.icon-square[aria-pressed="true"] { color: var(--ash); }
.icon-square { flex: none; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font: 800 20px var(--display); }
.howto {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0;
  background: var(--wall); color: var(--bone); border: 2px solid var(--edge); border-radius: 3px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .8);
}
.howto::backdrop { background: rgba(8, 2, 2, .78); }
.howto-inner { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: calc(100dvh - 28px); }
.howto-head { display: flex; justify-content: space-between; align-items: center; }
.howto-head h2 { font-size: 38px; margin: 0; }
.howto-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.howto-steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; line-height: 1.4; }
.howto-steps li::before {
  content: counter(step); display: grid; place-items: center; width: 34px; height: 34px;
  background: var(--blood); border: 2px solid var(--edge); color: #fff4ea; font: 900 20px var(--display);
}
.howto-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.howto-modes div { background: var(--wall-2); border: 1px solid var(--rust); border-top: 4px solid var(--blood-hi); padding: 10px 12px; }
.howto-modes b { display: block; font: 900 26px var(--display); margin-bottom: 4px; }
.howto-modes span { font-size: 14px; color: var(--ash); line-height: 1.35; display: block; }
.howto-score { margin: 0; font-size: 15px; color: var(--ash); }
@media (max-width: 640px) {
  .howto-modes { grid-template-columns: 1fr; }
  .howto-head h2 { font-size: 32px; }
  .howto-inner { padding: 16px; gap: 10px; }
}

#toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 40; transform: translateX(-50%) translateY(20px);
  background: var(--bone); color: var(--ink); font-weight: 600; padding: 10px 16px; border-radius: 2px;
  opacity: 0; transition: .2s; pointer-events: none; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- Living blood (drawn by blood.js) ---------- */
.blood-back, .blood-front { position: fixed; left: 0; top: 0; pointer-events: none; }
.blood-back { z-index: 0; }
.blood-front { z-index: 25; }
.blood-pulse { position: fixed; inset: 0; z-index: 26; pointer-events: none; opacity: 0; box-shadow: inset 0 0 180px 50px rgba(201, 42, 36, .9); }

/* Shorter computer screens (e.g. 1366x768 laptops): a little tighter so the front page fits */
@media (min-width: 900px) and (max-height: 860px) {
  main { padding-top: 56px; padding-bottom: 14px; }
  .home { gap: 14px; }
  .logo img { height: 15vh; }
  .tagline { margin: 8px 0 4px; font-size: 26px; }
  .blurb { font-size: 16px; }
  .mode { padding: 12px 16px; gap: 4px; }
  .mode b { font-size: 32px; }
}

/* Wide screens: the top bar and the game sit together as one block, centred in the window */
@media (min-width: 900px) {
  main.room-view { justify-content: center; }
  main.room-view .screen { flex: 0 1 auto; align-content: start; }
}

/* ---------- Phones and narrow windows: one compact column ---------- */
@media (max-width: 899px) {
  main { padding: 48px 12px 12px; }
  .gore .drips { height: 70px; background-size: auto 70px; }
  .gore .stain-a { width: 340px; right: -150px; top: 70px; }
  .gore .stain-b { width: 300px; }
  .blood-pulse { box-shadow: inset 0 0 90px 24px rgba(201, 42, 36, .9); }

  .home { justify-content: flex-start; gap: 12px; }
  .logo img { height: auto; width: min(100%, 420px); }
  .tagline { font-size: 23px; margin: 12px 0 2px; }
  .blurb { font-size: 15px; }
  .field label { font-size: 15px; }
  .quick { gap: 8px; }
  .mode { padding: 10px 10px 8px; border-top-width: 4px; gap: 2px; }
  .mode b { font-size: 26px; }
  .mode .desc { display: none; }
  .mode .count { font-size: 12px; }
  .home-bottom { grid-template-columns: 1fr; flex: 1 1 auto; align-content: start; gap: 10px; }
  .lobbies-card { max-height: none !important; flex: 0 1 auto; }
  .home-bottom { display: flex; flex-direction: column; align-items: stretch; }
  .home-bottom .card { padding: 12px 14px; }
  .friends { flex: none; }
  .friends h3 { display: none; }
  .card.fill .scroll { padding-bottom: 54px; }   /* room for the chat button */

  .topbar { padding: 8px 10px; gap: 10px; margin-bottom: 10px; }
  .topbar .room b { font-size: 21px; }
  .topbar .room span { font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar { gap: 6px; }
  .topbar .icon-square { width: 34px; height: 34px; font-size: 18px; }
  .topbar button.leave { padding: 7px 10px; }
  .timer.top { font-size: 28px; }
  .screen { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
  .col { overflow: visible; gap: 10px; flex: none; }
  .col-side { flex: none; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
  .col-side .card.fill { flex: none; }
  .card { padding: 12px 14px; }
  .room-card { grid-template-columns: 1fr; gap: 10px; }
  .code { font-size: 48px; }
  .secret { padding: 16px 14px; }
  .secret .word { font-size: clamp(36px, 11vw, 52px); }
  .secret.compact .word { font-size: clamp(30px, 9vw, 42px); }
  .hidden-card { padding: 22px 14px; }
  .video-wrap { max-height: 30vh; }
  .banner { padding: 14px 12px; }
  .banner h2 { font-size: 36px; }
  .big-word { font-size: 24px; }
  .stopwatch { width: 112px; height: 112px; font-size: 30px; }
  .countdown { font-size: 20px; margin-bottom: 4px; }
  .countdown.big { font-size: 42px; min-height: 42px; }
  .stop-card .small { display: none; }
  .board { gap: 7px; }
  .board-row { grid-template-columns: minmax(60px, 100px) 1fr 58px; }
  .vote-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .vote-grid button { padding: 12px 8px; }
  .screen-title { font-size: 30px; }
  .chat-panel { left: 0; right: 0; bottom: 0; width: auto; height: 75vh; border-radius: 3px 3px 0 0; border-bottom: 0; }
  .chat-fab { width: 52px; height: 52px; right: 12px; bottom: 12px; }
  body.chat-open .chat-fab { display: none; }
}
/* Short phone screens: tighter spacing so everything still fits */
@media (max-width: 899px) and (max-height: 800px) {
  main { padding-top: 40px; }
  .gore .drips { height: 56px; background-size: auto 56px; }
  .topbar { padding: 6px 10px; margin-bottom: 8px; }
  .topbar .room b { font-size: 19px; }
  .topbar .room span { font-size: 12px; }
  button.leave { padding: 6px 12px; }
  .screen, .col { gap: 8px; }
  .card { padding: 10px 12px; }
  h3 { font-size: 21px; margin-bottom: 4px; }
  .players li { padding: 5px 0; }
  .score { font-size: 19px; }
  .col-side { min-height: 150px; }
  .secret, .secret.compact { padding: 10px 12px; }
  .secret .word, .secret.compact .word { font-size: 32px; margin: 2px 0; }
  .secret .small { font-size: 13px; }
  .hidden-card { padding: 16px 12px; }
  .hidden-card .word { font-size: 26px; }
  .stopwatch { width: 104px; height: 104px; font-size: 28px; border-width: 3px; }
  .countdown { font-size: 18px; min-height: 22px; margin-bottom: 4px; }
  .countdown.big { font-size: 38px; min-height: 38px; }
  .stop-card .small { display: none; }
  .board { gap: 6px; }
  .banner { padding: 10px; }
  .banner h2 { font-size: 30px; margin-bottom: 4px; }
  .banner p { font-size: 15px; }
  .reveal { padding: 8px 10px; }
  .big-word { font-size: 22px; }
  .code { font-size: 40px; }
  .room-card { gap: 8px; }
  .segmented button { padding: 8px 10px; }
  .segmented button span { display: none; }
  button.big { padding: 11px; font-size: 17px; }
  .vote-grid button { padding: 10px 6px; font-size: 16px; }
  .screen-title { font-size: 26px; }
  .clue-list, .voted { font-size: 12px; }
}
@media (max-width: 899px) and (max-height: 720px) {
  .blurb { display: none; }
  .tagline { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
