/* Codenames. Every color comes from one background color (themeVars in common.ts sets the --vars on :root). */

@font-face { font-family: 'Bricolage'; src: url('/client/fonts/bricolage-grotesque.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Pixelify'; src: url('/client/fonts/pixelify-sans-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Pixelify'; src: url('/client/fonts/pixelify-sans-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
/* Pixel digits are hard to read (a 2 looks backwards, an 8 like a B), so numbers come from Bricolage, as in Infuno. */
@font-face { font-family: 'CN Digits'; src: url('/client/fonts/bricolage-grotesque.woff2') format('woff2'); font-weight: 200 800; font-display: swap; unicode-range: U+0030-0039, U+002B, U+221E, U+2013, U+003A; }

:root {
  --bg: #2b2d5c; --ink: #fff; --ink-soft: #b9bad0; --panel: #3d3f6b; --panel-edge: #8f90b0;
  --card: #d6d6e2; --card-ink: #0e0e12; --card-edge: #5e5e68;
  --neutral: #474970; --neutral-ink: #fff; --neutral-edge: #9fa0b9; --offset: #fff;
  --blob1: #3c3f8a; --blob2: #5a2f7a; --blob3: #2f6a63;
  --red: #e0443b; --red-ink: #fff; --red-edge: #6e1712;
  --blue: #2f6ad8; --blue-ink: #fff; --blue-edge: #0f2b66;
  --black: #050506;
  --radius: 12px;
  --off: 5px;
  --line: 2.5px;
  color-scheme: dark light;
}
:root:has(.page-party) { font-size: clamp(14px, 1.05vw, 30px); }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Bricolage', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h2 { font-size: 1.25rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 800; }
.muted { color: var(--ink-soft); }
.small, small { font-size: 0.82rem; }
.center { text-align: center; }
.t-red { color: var(--red); }
.t-blue { color: var(--blue); }
.team-red { --team: var(--red); --team-ink: var(--red-ink); --team-edge: var(--red-edge); }
.team-blue { --team: var(--blue); --team-ink: var(--blue-ink); --team-edge: var(--blue-edge); }
.turn-red { --turn: var(--red); }
.turn-blue { --turn: var(--blue); }

/* ---------------------------------------------------------------- background */

.bg-art { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.bg-art i { position: absolute; display: block; }
.bg-art .b1, .bg-art .b2, .bg-art .b3 { width: 90vmax; height: 90vmax; border-radius: 50%; opacity: 0.55; will-change: transform; }
.bg-art .b1 { background: radial-gradient(circle at center, var(--blob1) 0%, transparent 62%); left: -30vmax; top: -35vmax; animation: drift1 47s ease-in-out infinite alternate; }
.bg-art .b2 { background: radial-gradient(circle at center, var(--blob2) 0%, transparent 60%); right: -35vmax; bottom: -40vmax; animation: drift2 61s ease-in-out infinite alternate; }
.bg-art .b3 { background: radial-gradient(circle at center, var(--blob3) 0%, transparent 58%); left: 20vw; top: 30vh; width: 60vmax; height: 60vmax; opacity: 0.35; animation: drift3 73s ease-in-out infinite alternate; }
.bg-art .swirl {
  inset: -50vmax;
  background: repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 7deg, color-mix(in srgb, var(--ink) 4%, transparent) 7deg 8deg);
  animation: spin 240s linear infinite;
  mask-image: radial-gradient(circle at 50% 50%, transparent 8%, #000 55%);
}
.bg-art .grain {
  inset: 0; opacity: 0.12; mix-blend-mode: overlay;
  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='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift1 { to { transform: translate(25vw, 18vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-22vw, -15vh) scale(0.9); } }
@keyframes drift3 { to { transform: translate(-30vw, -25vh) scale(1.3); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- cards */

.k-hidden { --c-bg: var(--card); --c-ink: var(--card-ink); --c-edge: var(--card-edge); }
.k-red { --c-bg: var(--red); --c-ink: var(--red-ink); --c-edge: var(--red-edge); }
.k-blue { --c-bg: var(--blue); --c-ink: var(--blue-ink); --c-edge: var(--blue-edge); }
.k-neutral { --c-bg: var(--neutral); --c-ink: var(--neutral-ink); --c-edge: var(--neutral-edge); }
.k-assassin { --c-bg: var(--black); --c-ink: #fff; --c-edge: #000; }

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(7px, 1.3vw, 16px);
  padding: 0 var(--off) var(--off) 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.card {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1.55;
  border-radius: var(--radius);
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
/* The misprinted second outline, nudged down and right, behind the face. */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border: var(--line) solid var(--offset);
  border-radius: inherit;
  transform: translate(var(--off), var(--off));
  pointer-events: none;
}
.card .face {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4%;
  background-color: var(--c-bg);
  color: var(--c-ink);
  border: var(--line) solid var(--c-edge);
  border-radius: inherit;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(.3,1.5,.6,1), background-color 0.3s;
}
/* A thin inner frame, like a printed index card. */
.card .face::before {
  content: '';
  position: absolute;
  inset: 6%;
  border: 1px solid currentColor;
  border-radius: calc(var(--radius) * 0.5);
  opacity: 0.18;
}
.card .word {
  position: relative;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: center;
  padding: 0 7%;
  overflow-wrap: normal;
  word-break: keep-all;
  max-width: 100%;
}
.card .mark:empty { display: none; }
.card .mark { height: 40%; display: grid; place-items: center; }
.card .mark .skull { height: 100%; width: auto; color: #fff; }
.k-assassin .word { font-size: min(12cqi, 1em) !important; }
.k-assassin .face::before { opacity: 0.3; }

/* Turned over: the face presses into its outline, the word fades, and it gets hatched. */
.card.revealed .face {
  transform: translate(calc(var(--off) - 1px), calc(var(--off) - 1px));
  background-image: repeating-linear-gradient(-45deg, transparent 0 8px, rgba(0, 0, 0, 0.16) 8px 10px);
}
.card.revealed .word { opacity: 0.5; }
.card.revealed.k-assassin .word { opacity: 0.8; }
.card.revealed .mark { height: 46%; }
.board.over .card:not(.revealed) .face { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--c-ink) 35%, transparent); }

/* Holding a card: a fill rises up it over two seconds, with the holder's name. */
.card .fill {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: linear-gradient(to top, color-mix(in srgb, var(--turn, #888) 80%, transparent), color-mix(in srgb, var(--turn, #888) 55%, transparent));
  transform: scaleY(0);
  transform-origin: bottom;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.card .holder:empty { display: none; }
.card .holder {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 0;
  transform: translate(-50%, -55%);
  background: var(--turn, #333);
  color: #fff;
  border: 2px solid var(--offset);
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 110%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card.held .face, .card.holding .face { transform: translate(2px, 2px); }
.card.holding .face { animation: shake 0.12s linear infinite; animation-delay: 1.2s; }
@keyframes holdfill { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes shake { 0%, 100% { translate: 0 0; } 25% { translate: 1px -1px; } 75% { translate: -1px 1px; } }
.card.holdable { cursor: pointer; }
.card.holdable:hover .face { transform: translate(-1px, -1px); }
.card.holdable.holding:hover .face { transform: translate(2px, 2px); }
.card.picked .face { animation: pop 0.5s ease-out; }
@keyframes pop { 30% { transform: scale(1.08); } }

.card.mini { width: 74px; display: inline-block; }
.card.mini .word { font-size: 15cqi; }

/* ---------------------------------------------------------------- panels and controls */

.panel {
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  border: 2px solid var(--panel-edge);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--offset) 22%, transparent);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel.center { align-items: center; text-align: center; }

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 11px 16px;
  border-radius: 12px;
  border: var(--line) solid var(--ink);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s, box-shadow 0.08s;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active:not([disabled]) { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn small { font-weight: 500; opacity: 0.8; font-size: 0.78rem; }
.btn-go { background: var(--card); color: var(--card-ink); }
.btn-big { width: 100%; font-size: 1.08rem; padding: 14px 16px; }
.btn-small { padding: 6px 10px; font-size: 0.85rem; box-shadow: 2px 2px 0 var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-soft); }
.btn.danger { border-color: var(--red); box-shadow: 3px 3px 0 var(--red); }
.team-red-btn { background: var(--red); color: #fff; }
.team-blue-btn { background: var(--blue); color: #fff; }

.hold-btn { position: relative; overflow: hidden; width: 100%; }
.hold-btn span { position: relative; z-index: 1; }
.hold-btn i { position: absolute; inset: 0; background: var(--turn, var(--ink)); opacity: 0.45; transform: scaleX(0); transform-origin: left; }
.hold-btn.danger i { background: var(--red); }
.hold-btn.holding i { transform: scaleX(1); transition: transform var(--hold-ms, 2s) linear; }

input[type=text] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: var(--line) solid var(--panel-edge);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  font-size: 1.05rem;
  outline: none;
}
input[type=text]:focus { border-color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.error { color: #ff8a80; font-weight: 700; min-height: 0; font-size: 0.9rem; }
.error:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 8px;
  border-radius: 10px;
  border: 2px solid var(--panel-edge);
  background: transparent;
  font-family: 'CN Digits', 'Pixelify', 'Bricolage', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
}
.chip-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-btn[disabled] { cursor: default; opacity: 0.6; }
.chip-btn.on[disabled] { opacity: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--c-bg);
  color: var(--c-ink);
  border: 1.5px solid var(--c-edge);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}
.chip .skull { height: 1.1em; width: auto; color: #fff; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .switch { flex: none; width: 46px; height: 28px; border-radius: 99px; border: 2px solid var(--ink); position: relative; transition: background 0.2s; }
.toggle .switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); transition: transform 0.2s; }
.toggle input:checked + .switch { background: var(--card); }
.toggle input:checked + .switch::after { transform: translateX(18px); background: var(--card-ink); }
.toggle b { display: block; }
.toggle small { color: var(--ink-soft); }
.toggle.readonly { cursor: default; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--sw); border: 2px solid var(--panel-edge);
  cursor: pointer; position: relative; padding: 0;
  display: grid; place-items: center;
}
.swatch.on { border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.swatch-pick { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch-pick.on { background: var(--sw); }
.swatch-pick span { font-weight: 800; color: #fff; text-shadow: 0 0 3px #000; }
.swatch-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: var(--line) solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { padding: 10px; border: 0; background: transparent; font-weight: 800; cursor: pointer; }
.seg button.on { background: var(--ink); color: var(--bg); }

.dots i { font-style: normal; animation: blink 1.4s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.2; } 30% { opacity: 1; } }

.qr { background: #fff; padding: 8px; border-radius: 10px; width: 112px; flex: none; line-height: 0; }
.qr svg { width: 100%; height: auto; }

.conn { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--red); color: #fff; font-weight: 800; padding: 6px 14px; border-radius: 99px; }
.toast { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--bg); font-weight: 700; padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: 4px 4px 0 color-mix(in srgb, var(--offset) 30%, transparent); animation: rise 0.25s ease-out; }
@keyframes rise { from { transform: translate(-50%, 20px); opacity: 0; } }

.sheet-back { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); }
.sheet {
  position: fixed; left: 50%; bottom: 0; z-index: 41;
  transform: translateX(-50%);
  width: min(520px, 100vw);
  background: var(--bg);
  border: var(--line) solid var(--ink); border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  animation: sheet-up 0.22s ease-out;
}
.sheet-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@keyframes sheet-up { from { transform: translate(-50%, 100%); } }

/* ---------------------------------------------------------------- splashes */

.splash { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.splash-inner {
  position: absolute;
  left: -10vw;
  right: -10vw;
  top: 50%;
  translate: 0 -50%;
  padding: 3vh 10vw;
  background: var(--team, var(--ink));
  color: var(--team-ink, var(--bg));
  border-block: 6px solid var(--offset);
  transform: rotate(-4deg);
  text-align: center;
  box-shadow: 0 10px 0 color-mix(in srgb, var(--offset) 35%, transparent);
  animation: slam 0.45s cubic-bezier(.2,1.6,.4,1);
}
.splash-text { font-family: 'CN Digits', 'Pixelify', sans-serif; font-weight: 700; font-size: clamp(44px, 10vw, 180px); line-height: 1; text-transform: uppercase; text-shadow: 5px 5px 0 rgba(0, 0, 0, 0.35); }
.splash-sub { font-weight: 800; font-size: clamp(16px, 2.6vw, 44px); opacity: 0.9; margin-top: 0.3em; }
.splash-clue .splash-text { font-family: 'Bricolage', sans-serif; font-weight: 800; }
.splash-assassin .splash-inner { background: var(--black); color: #fff; }
.splash-skull { height: clamp(70px, 16vw, 260px); margin: 0 auto 1vh; animation: wobble 0.6s ease-in-out 2; }
.splash-skull .skull { height: 100%; width: auto; color: #fff; }
.splash-timeout .splash-inner { background: var(--ink); color: var(--bg); }
.splash.out .splash-inner { animation: leave 0.45s ease-in forwards; }
@keyframes slam { from { transform: rotate(-4deg) scale(2.2); opacity: 0; } }
@keyframes leave { to { transform: rotate(-4deg) translateX(-130vw); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }

/* ---------------------------------------------------------------- start page */

.start { max-width: 520px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.start-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 4px; }
.logo { font-family: 'CN Digits', 'Pixelify', sans-serif; font-weight: 700; font-size: clamp(48px, 13vw, 72px); letter-spacing: 0.01em; text-transform: uppercase; line-height: 0.95; }
.logo span { color: transparent; -webkit-text-stroke: 2px var(--ink); text-shadow: 4px 4px 0 color-mix(in srgb, var(--ink) 30%, transparent); }
.logo-cards { display: flex; justify-content: center; padding: 10px 0 6px; }
.logo-cards .card { margin: 0 -6px; transform: rotate(calc((var(--i) - 1.5) * 8deg)); }
.logo-cards .card:first-child, .logo-cards .card:last-child { translate: 0 8px; }
.choice { display: flex; flex-direction: column; gap: 6px; }
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-row .btn { flex: 1 1 140px; }
.code-input { text-align: center; font-family: 'CN Digits', 'Pixelify', sans-serif !important; font-size: 2rem !important; letter-spacing: 0.3em; text-transform: uppercase; }

/* ---------------------------------------------------------------- top bar, lobby */

.topbar { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.topbar-title { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-chip { font-family: 'CN Digits', 'Pixelify', sans-serif; font-weight: 700; font-size: 1.15rem; letter-spacing: 0.12em; padding: 3px 10px; border: 2px solid var(--ink); border-radius: 8px; box-shadow: 2px 2px 0 var(--ink); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; background: var(--team, var(--panel)); color: var(--team-ink, var(--ink)); font-size: 0.88rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }

.lobby { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 14px 40px; display: flex; flex-direction: column; gap: 14px; }
.invite { flex-direction: row; align-items: center; justify-content: space-between; }
.invite-code { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.invite-code b { font-family: 'CN Digits', 'Pixelify', sans-serif; font-size: 3rem; letter-spacing: 0.14em; line-height: 1; }
.invite-code .muted { overflow-wrap: anywhere; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-col.bench { grid-column: 1 / -1; }
.team-col h3 { display: flex; align-items: center; gap: 6px; color: var(--team, var(--ink-soft)); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.team-col h3 small { font-family: 'CN Digits', 'Pixelify', sans-serif; color: var(--ink-soft); }
.team-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bench ul { flex-direction: row; flex-wrap: wrap; }
.team-col li {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--team, var(--panel-edge)) 22%, var(--panel));
  border: 2px solid var(--team, var(--panel-edge));
  font-weight: 700; min-width: 0;
}
.team-col li .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.team-col li.tappable { cursor: pointer; }
.team-col li.tappable:active { transform: translate(2px, 2px); }
.team-col li.offline { opacity: 0.55; }
.team-col li.is-you { box-shadow: 3px 3px 0 var(--offset); }
.team-col li.empty { background: transparent; border-style: dashed; color: var(--ink-soft); font-weight: 500; }
.tag { font-size: 0.66rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
.tag.spy { background: var(--ink); color: var(--bg); }
.tag.vip { background: #f5c542; color: #2a2000; }
.rounds-line { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- the round (phones and PCs) */

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom));
  max-width: 1500px;
  margin: 0 auto;
}
.game .topbar { grid-column: 1 / -1; }
.game-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.game-board { min-width: 0; }

.scorebar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.score-side {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--team);
  color: var(--team-ink);
  border: var(--line) solid var(--team-edge);
  opacity: 0.6;
  transition: opacity 0.3s, transform 0.3s;
}
.score-side.team-blue { flex-direction: row-reverse; text-align: right; }
.score-side.active, .score-side.won { opacity: 1; box-shadow: 4px 4px 0 var(--offset); transform: translate(-2px, -2px); }
.score-left { font-family: 'CN Digits', 'Pixelify', sans-serif; font-weight: 700; font-size: 2.1rem; line-height: 1; }
.score-label { font-weight: 800; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.1; }
.score-rounds { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 4px; }
.score-rounds small { color: var(--ink-soft); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; }
.score-rounds b { font-family: 'CN Digits', 'Pixelify', sans-serif; font-size: 1.3rem; }

.cluebox {
  position: relative;
  padding: 12px 14px 12px 20px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: var(--line) solid var(--team);
  box-shadow: 4px 4px 0 var(--team);
  overflow: hidden;
}
.cluebox::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--team); }
.clue-sub { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; color: var(--team); filter: brightness(1.25); }
.clue-word { font-weight: 800; font-size: 1.9rem; line-height: 1.1; text-transform: uppercase; overflow-wrap: anywhere; }
.clue-word b, .clue-word em, .preview-clue b, .preview-clue em, .h-clue b, .h-clue em { font-family: 'CN Digits', 'Pixelify', sans-serif; font-style: normal; }
.clue-word em, .h-clue em, .preview-clue em { color: var(--ink-soft); }
.clue-word.thinking { font-size: 1.15rem; text-transform: none; font-weight: 700; color: var(--ink-soft); }
.clue-left { font-weight: 700; color: var(--ink-soft); }
.cluebox.done .clue-word { font-family: 'CN Digits', 'Pixelify', sans-serif; }
.timer { position: absolute; top: 10px; right: 12px; font-family: 'CN Digits', 'Pixelify', sans-serif; font-size: 1.4rem; font-weight: 700; }
.timer.low { color: var(--red); animation: blink 1s infinite; }

.clue-form input[name=word] { font-weight: 800; text-transform: uppercase; font-size: 1.3rem; letter-spacing: 0.04em; }
.clue-preview { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 1.6em; }
.preview-clue { font-weight: 800; font-size: 1.3rem; }
.round-end .btn small { display: block; }
.view-toggle p { margin: 0; }

.history-panel summary { cursor: pointer; font-weight: 800; list-style: none; }
.history-panel summary::-webkit-details-marker { display: none; }
.history-panel summary::after { content: ' ▾'; color: var(--ink-soft); }
.history-panel:not([open]) summary::after { content: ' ▸'; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0 6px 12px; border-left: 5px solid var(--team); }
.h-clue { font-weight: 800; text-transform: uppercase; }
.h-guesses { display: flex; flex-wrap: wrap; gap: 4px; }
.h-end { font-size: 0.75rem; color: var(--ink-soft); font-weight: 700; margin-left: auto; }
.h-end.live { color: var(--team); filter: brightness(1.3); }
.history-empty { margin: 0; }

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .game { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); align-items: start; padding-top: 14px; }
  .game-board .board { width: min(100%, calc((100dvh - 96px) * 1.48)); margin: 0 auto; }
  .game-side { position: sticky; top: 14px; max-height: calc(100dvh - 28px); overflow: auto; padding: 0 6px 6px 0; }
}
@media (max-width: 600px) {
  :root { --off: 3px; --line: 2px; --radius: 8px; }
  .card { aspect-ratio: 1.22; }
  .board { gap: 6px; }
  .card .word { padding: 0 3%; letter-spacing: 0; }
  .card .holder { font-size: 0.62rem; padding: 0 5px; }
  .clue-word { font-size: 1.6rem; }
  .score-left { font-size: 1.7rem; }
  .teams { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- party view (the TV) */

.page-party { overflow: hidden; height: 100dvh; }
.party-game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 27vw, 620px);
  gap: 2vw;
  height: 100dvh;
  padding: 2.5vh 2vw;
  align-items: center;
}
.party-board { display: grid; place-items: center; min-width: 0; height: 100%; }
.party-board .board { width: min(100%, calc((95dvh) * 1.5)); }
.page-party .card .holder { font-size: 0.85rem; }
.party-side { display: flex; flex-direction: column; gap: 1.6vh; height: 100%; min-height: 0; }
.party-side .history-panel { flex: 1; min-height: 0; overflow: auto; }
.party-side .clue-word { font-size: 2.6rem; }
.party-side .score-left { font-size: 2.8rem; }
.party-foot { display: flex; flex-direction: column; gap: 8px; }
.roster { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.9rem; }
.roster b { color: var(--team); text-transform: uppercase; filter: brightness(1.25); }
.roster span { padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--team) 30%, transparent); font-weight: 700; }
.roster span.spy { background: var(--team); color: var(--team-ink); }
.roster span.offline { opacity: 0.5; }
.party-mini { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--ink-soft); }
.party-mini .qr { width: 4.5rem; padding: 4px; border-radius: 6px; }
.party-mini b { font-family: 'CN Digits', 'Pixelify', sans-serif; font-size: 1.5rem; color: var(--ink); letter-spacing: 0.12em; }

.party-lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 4vw; height: 100dvh; padding: 6vh 5vw; align-items: center; }
.party-join { display: flex; flex-direction: column; align-items: center; gap: 2.5vh; text-align: center; }
.party-join .logo { font-size: 5.5rem; }
.party-code { display: flex; flex-direction: column; align-items: center; }
.party-code small { font-size: 1.1rem; color: var(--ink-soft); }
.party-code small b { color: var(--ink); }
.party-code > b { font-family: 'CN Digits', 'Pixelify', sans-serif; font-size: 8rem; letter-spacing: 0.16em; line-height: 1; text-shadow: 6px 6px 0 color-mix(in srgb, var(--offset) 30%, transparent); }
.qr.big { width: min(30vh, 22vw); padding: 12px; border-radius: 14px; box-shadow: 6px 6px 0 var(--offset); }
.party-teams { display: flex; flex-direction: column; gap: 3vh; }
.party-teams .teams { gap: 1.5vw; }
.party-teams .team-col h3 { font-size: 1.6rem; }
.party-teams .team-col li { font-size: 1.2rem; padding: 0.6em 0.8em; }
.rounds-line.big { font-size: 1.4rem; justify-content: center; }

@media (max-aspect-ratio: 1/1) {
  .page-party { overflow: auto; height: auto; }
  .party-game { grid-template-columns: 1fr; height: auto; }
  .party-lobby { grid-template-columns: 1fr; height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-art i { animation: none !important; }
  .splash-inner, .splash-skull { animation: none; }
}
