/* MusicSpy interface. Rules: DESIGN.md. Tokens: tokens.css.
   Every screen fits the window: the page never scrolls, only lists inside panels do. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: rgb(var(--base));
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
img { display: block; }
p, h1, h2, h3 { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#app { height: 100%; }

/* text sitting right on the coloured backdrop gets a soft shadow for light covers */
.on-bg, .wordmark, .lead, .src-title, .src-sub, .src-kind, .track-title, .track-artist, .track-pos, .timer-text, .choice-note,
.verdict, .split, .set-name, .shelf-head, .slot span, .face-text, .bar-brand, .bar-meta, .room-info, .people li, .start-note, .mode-card {
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.28);
}

/* ---------- backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: rgb(var(--base)); }
.backdrop .fx { position: absolute; inset: 0; width: 100%; height: 100%; }
.backdrop img {
  position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: cover;
  filter: blur(80px) saturate(1.3) brightness(0.55);
  opacity: 0; transition: opacity 1s ease;
}
.backdrop img.on { opacity: 1; }
.backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.18)); }

/* ---------- screen frame ---------- */
.screen { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--r-btn); padding: 11px 18px; min-height: 42px;
  background: var(--fill); font-weight: 600; white-space: nowrap;
  transition: background var(--m-out) var(--ease), opacity var(--m-out), transform var(--m-out) var(--ease);
}
.btn:disabled { opacity: 0.4; }
a.btn { color: inherit; text-decoration: none; }
.btn.primary { background: var(--ink); color: rgb(var(--base)); }
.btn.quiet { background: transparent; color: var(--ink-2); }
.btn.big { padding: 15px 24px; font-size: 17px; border-radius: var(--r-big); }
.btn.small { padding: 7px 12px; min-height: 34px; font-size: 14px; border-radius: var(--r-sm); }
.btn.danger { color: var(--del); }
.btn svg { width: 18px; height: 18px; flex: none; }
.text-btn { border: 0; background: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; border: 0; border-radius: var(--r-sm); background: var(--fill); color: var(--ink);
  transition: background var(--m-out) var(--ease), transform var(--m-out) var(--ease);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.plain { background: transparent; color: var(--ink-2); }
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--ink); color: rgb(var(--base)); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: var(--fill-2); transform: translateY(-1px); transition-duration: var(--m-in); }
  .btn.primary:hover:not(:disabled) { background: #fff; }
  .btn.quiet:hover:not(:disabled) { background: var(--fill); color: var(--ink); }
  .text-btn:hover { color: var(--ink); }
  .icon-btn:hover { background: var(--fill-2); color: var(--ink); }
}
.btn:active:not(:disabled), .icon-btn:active { transform: scale(0.98); transition-duration: var(--m-press); }

/* ---------- inputs ---------- */
input:not([type]), input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%; min-height: 44px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-btn);
  padding: 11px 14px; outline: none; transition: border-color 140ms;
}
input:focus, textarea:focus { border-color: var(--ink-2); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[type="range"] { accent-color: var(--ink); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--ink-2); }

/* ---------- avatars ---------- */
.avatar {
  --c: #999;
  flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center;
  background: var(--c); color: #141210; font-weight: 700; font-size: 15px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }

.struck { text-decoration: line-through; text-decoration-color: var(--del); text-decoration-thickness: 0.09em; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--fill-2); border-top-color: var(--ink); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-screen { height: 100%; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--ink-2); }
.wait { color: var(--ink-2); animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.5; } }
@keyframes arrive { from { opacity: 0; transform: scale(0.96); } }
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--fill); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.tag.solid { background: var(--ink); color: rgb(var(--base)); }

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 80;
  transform: translate(-50%, 16px); opacity: 0;
  background: var(--ink); color: rgb(var(--base));
  padding: 11px 20px; border-radius: var(--r-btn); font-weight: 500;
  transition: 0.25s var(--ease); pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.action { pointer-events: auto; display: flex; gap: 12px; align-items: center; }
#toast.action button { border: 0; border-radius: 8px; padding: 5px 10px; background: rgb(var(--base)); color: var(--ink); font-weight: 600; }

.offline-bar { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 70; text-align: center; padding: 6px; background: var(--del); color: #2a0709; font-size: 14px; font-weight: 600; }
.offline .offline-bar { display: block; }

/* ---------- top bar ---------- */
.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 14px var(--gutter); min-height: 66px; }
.bar-brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; }
.bar-brand small { font-weight: 500; font-size: 14px; color: var(--ink-2); letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; }
.bar-center { justify-self: center; min-width: 0; }
.bar-meta { color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-actions { justify-self: end; display: flex; align-items: center; gap: 6px; }
.room-btn { border: 0; border-radius: var(--r-sm); padding: 8px 12px; min-height: 38px; background: var(--fill); font-weight: 700; letter-spacing: 0.08em; white-space: nowrap; }
.leave-btn { border: 0; background: none; color: var(--ink-2); padding: 8px 10px; min-height: 38px; border-radius: var(--r-sm); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
  .room-btn:hover { background: var(--fill-2); }
  .leave-btn:hover { color: var(--ink); background: var(--fill); }
}
.vol { display: flex; align-items: center; gap: 6px; color: var(--ink-2); margin-right: 6px; }
.vol svg { width: 20px; height: 20px; }
.vol input { width: 84px; }
.theme-chip { display: inline-flex; align-items: baseline; gap: 8px; padding: 7px 14px; border-radius: var(--r-btn); background: var(--panel); max-width: min(46vw, 520px); }
.theme-chip span { color: var(--ink-3); font-size: 13px; }
.theme-chip b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- home ---------- */
.home {
  height: 100%; max-width: 1120px; margin: 0 auto; padding: 4vh 28px;
  display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 56px; align-items: center;
}
.wordmark { font-size: clamp(52px, 9vw, 112px); font-weight: 800; line-height: 0.95; letter-spacing: -0.045em; }
.lead { margin-top: 20px; font-size: 19px; color: var(--ink-2); max-width: 30em; }
.modes { margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 620px; }
.mode-card {
  display: grid; gap: 6px; align-content: start; text-align: left;
  padding: 18px; border-radius: var(--r-panel); border: 1.5px solid transparent; background: var(--panel);
  transition: border-color var(--m-out), transform var(--m-out) var(--ease), background var(--m-out);
}
.mode-card b { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.mode-card > span { color: var(--ink-2); font-size: 14px; line-height: 1.4; }
.mode-card small { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.mode-card[aria-pressed="true"] { border-color: var(--ink); background: rgba(0, 0, 0, 0.36); }
@media (hover: hover) and (pointer: fine) { .mode-card:hover { transform: translateY(-2px); background: rgba(0, 0, 0, 0.36); } }
.join { display: grid; gap: 14px; background: var(--panel); border-radius: 20px; padding: 24px; }
.who { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.who-text { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.who-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: var(--ink-3); font-size: 13px; }
.or { text-align: center; color: var(--ink-3); font-size: 14px; margin-top: 2px; }
.code-row { display: flex; gap: 8px; }
.code-row input { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 700; text-align: center; }
.code-row input::placeholder { letter-spacing: normal; font-weight: 400; text-transform: none; }
.invite-note { color: var(--ink-2); }
.invite-note b { color: var(--ink); letter-spacing: 0.08em; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }

/* ---------- lobby (shared frame) ---------- */
.lobby { display: grid; grid-template-rows: minmax(0, 1fr) auto; width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px) 18px; min-height: 0; }
.lob-main { --c: min(52vh, 36vw, 460px); display: grid; grid-template-columns: var(--c) minmax(0, 540px); gap: clamp(28px, 5vw, 72px); align-items: center; justify-content: center; min-height: 0; }
.lob-cover { width: var(--c); height: var(--c); }
.lob-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-cover); box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45); animation: arrive 0.5s var(--ease); }
.lob-cover img.round { border-radius: 50%; }
.cover-ph { width: 100%; height: 100%; border: 1.5px dashed var(--fill-2); border-radius: var(--r-cover); background: none; display: grid; place-content: center; justify-items: center; gap: 6px; color: var(--ink-2); text-align: center; padding: 12px; }
.cover-ph span { font-size: 56px; font-weight: 300; line-height: 1; color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { button.cover-ph:hover { border-color: var(--ink-2); color: var(--ink); } }
.mode-mark {
  width: 100%; height: 100%; border-radius: var(--r-cover); background: var(--panel);
  display: grid; align-content: end; gap: 10px; padding: clamp(18px, 3vw, 32px); overflow: hidden;
}
.mode-mark b { font-size: clamp(56px, 8vw, 120px); font-weight: 800; letter-spacing: -0.05em; line-height: 1; padding-bottom: 0.08em; }
.mode-mark span { color: var(--ink-2); font-size: 15px; max-width: 22em; }
.mode-mark .mark-dots { display: flex; gap: 8px; margin-bottom: auto; }
.mode-mark .mark-dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--fill-2); }
.mode-mark .mark-dots i.odd { background: transparent; border: 2px dashed var(--ink-3); }
.lob-side { display: grid; gap: 24px; align-content: center; min-width: 0; min-height: 0; max-height: 100%; }
.src-kind { color: var(--ink-2); font-size: 15px; }
.src-title { font-size: clamp(32px, 4.4vw, 58px); font-weight: 800; line-height: 1.02; letter-spacing: -0.035em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.src-sub { color: var(--ink-2); font-size: 17px; margin-top: 8px; }
.lob-source .text-btn { margin-top: 10px; }
.settings { display: grid; gap: 10px; align-content: start; min-height: 0; overflow-y: auto; padding: 2px; margin: -2px; }
.set-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 12px; }
.set-name { color: var(--ink-2); font-size: 15px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 0; border-radius: var(--r-opt); padding: 7px 0; min-width: 42px; min-height: 36px; background: var(--fill); font-size: 15px; font-weight: 500; text-align: center; transition: background var(--m-out); }
.opt.wide { padding: 7px 14px; }
@media (hover: hover) and (pointer: fine) { .opt:hover:not(:disabled) { background: var(--fill-2); } }
.opt.active, .opt.active:hover:not(:disabled) { background: var(--ink); color: rgb(var(--base)); font-weight: 700; }
.opt:disabled:not(.active) { opacity: 0.3; }
.start { display: grid; gap: 8px; justify-items: start; }
.start-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.start-note { color: var(--ink-3); font-size: 14px; }
.lob-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.room-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.room-info > span { color: var(--ink-2); }
.room-info b { font-size: 26px; font-weight: 800; letter-spacing: 0.08em; }
.people { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.people li { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.people li small { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.people li .ready { color: var(--keep); }
.people li.away { opacity: 0.45; }
.people li.lonely { color: var(--ink-3); font-weight: 400; font-size: 14px; }
.people .kick { border: 0; background: none; color: var(--ink-3); padding: 2px 4px; border-radius: 6px; font-size: 13px; }
@media (hover: hover) and (pointer: fine) { .people .kick:hover { color: var(--del); background: var(--fill); } }

/* ---------- sheets (dialogs) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.sheet[hidden] { display: none; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity 0.18s; }
.sheet-panel {
  position: relative; width: min(760px, calc(100vw - 32px)); max-height: min(660px, calc(100dvh - 48px));
  display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 14px;
  padding: 20px; border-radius: var(--r-panel); background: var(--sheet); border: 1px solid var(--line);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(10px); transition: opacity 0.18s, transform 0.18s var(--ease);
}
.sheet-panel.tall { height: min(660px, calc(100dvh - 48px)); }
.sheet-panel.narrow { width: min(460px, calc(100vw - 32px)); }
.sheet.open .sheet-scrim { opacity: 1; }
.sheet.open .sheet-panel { opacity: 1; transform: none; }
.sheet-content { min-height: 0; overflow-y: auto; margin: -2px; padding: 2px; }
.sheet-content > .sheet-search { height: 100%; }
.sheet-content > .sheet-body { overflow: visible; margin: 0; padding: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.sheet-body { display: grid; gap: 14px; align-content: start; min-height: 0; overflow-y: auto; padding: 2px; margin: -2px; }
.sheet-search { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 14px; min-height: 0; }
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-btn); background: rgba(0, 0, 0, 0.3); }
.tabs button { border: 0; background: none; padding: 7px 14px; min-height: 34px; border-radius: var(--r-opt); color: var(--ink-2); font-weight: 500; }
.tabs button.active { background: var(--ink); color: rgb(var(--base)); font-weight: 600; }
.search { display: flex; gap: 8px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px; align-content: start; overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px; }
.results-grid .hint { grid-column: 1 / -1; color: var(--ink-3); font-size: 14px; padding: 4px 2px; }
.result { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-btn); border: 1px solid transparent; background: none; text-align: left; min-width: 0; }
@media (hover: hover) and (pointer: fine) { .result:hover { background: var(--fill); } }
.result.selected { background: var(--fill-2); border-color: var(--ink-3); }
.result.loading { animation: breathe 1s ease-in-out infinite; }
.result img { width: 56px; height: 56px; border-radius: 4px; object-fit: cover; flex: none; background: var(--fill); }
.result.round img { border-radius: 50%; }
.result span { display: grid; min-width: 0; }
.result b, .result small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.result b { font-size: 15px; font-weight: 600; }
.result small { font-size: 13px; color: var(--ink-2); }
.result small.meta { color: var(--ink-3); font-size: 12px; }
.result.ghost { pointer-events: none; }
.result.ghost i { width: 56px; height: 56px; border-radius: 4px; background: var(--fill); flex: none; animation: breathe 1.2s infinite; }
.result.ghost b, .result.ghost small { display: block; height: 10px; border-radius: 5px; background: var(--fill); animation: breathe 1.2s infinite; }
.result.ghost b { width: 120px; margin-bottom: 8px; }
.result.ghost small { width: 70px; }

/* account + friends */
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-head div { display: grid; min-width: 0; }
.profile-head b { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-head small { color: var(--ink-3); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.stat { padding: 12px 14px; border-radius: var(--r-btn); background: var(--panel); display: grid; gap: 2px; }
.stat b { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: 13px; }
.section-label { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.oauth { display: grid; gap: 8px; }
.oauth .btn { justify-content: flex-start; }
.form-grid { display: grid; gap: 10px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.friend-list { display: grid; gap: 4px; }
.friend { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-btn); }
.friend .who-text small.on { color: var(--keep); }
.friend .row-actions { margin-left: auto; flex-wrap: nowrap; }
.empty-note { color: var(--ink-3); font-size: 14px; padding: 4px 2px; }

/* ---------- chat ---------- */
.chat {
  position: fixed; top: 66px; right: var(--gutter); bottom: 18px; z-index: 40; width: min(340px, calc(100vw - 32px));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px;
  padding: 14px; border-radius: var(--r-panel); background: var(--sheet); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  animation: rise 0.18s var(--ease);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; }
.chat-head b { font-weight: 700; }
.chat-list { overflow-y: auto; display: grid; gap: 8px; align-content: start; min-height: 0; padding-right: 4px; }
.msg { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; }
.msg p { font-size: 14px; overflow-wrap: anywhere; }
.msg b { font-size: 13px; font-weight: 600; color: var(--ink-2); display: block; }
.msg.mine b { color: var(--ink); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { min-height: 40px; padding: 9px 12px; }

/* ---------- shared game bits ---------- */
.faces { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }
.faces li { display: flex; align-items: center; gap: 8px; }
.faces .avatar { box-shadow: 0 0 0 2px transparent; transition: box-shadow 0.2s; }
.faces li.thinking .avatar { animation: breathe 1.6s ease-in-out infinite; }
.faces li.done .avatar, .faces li.now .avatar { box-shadow: 0 0 0 2px rgb(var(--base)), 0 0 0 4px var(--ink); }
.faces li.k .avatar { box-shadow: 0 0 0 2px rgb(var(--base)), 0 0 0 4px var(--keep); }
.faces li.d .avatar { box-shadow: 0 0 0 2px rgb(var(--base)), 0 0 0 4px var(--del); }
.faces li.away { opacity: 0.45; }
.face-text { display: grid; line-height: 1.2; }
.face-text b { font-size: 13px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.face-text small { font-size: 12px; color: var(--ink-2); }
.faces li.k small { color: var(--keep); }
.faces li.d small { color: var(--del); }
.faces.many .face-text { display: none; }

.stage { display: grid; justify-items: center; text-align: center; gap: 12px; min-width: 0; }
.track { display: grid; justify-items: center; gap: 4px; max-width: 100%; }
.track-pos { color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.cover { width: var(--cover); height: var(--cover); object-fit: cover; border-radius: var(--r-cover); box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5); background: var(--fill); }
.cover-wait { width: var(--cover); height: var(--cover); border-radius: var(--r-cover); border: 1.5px dashed var(--fill-2); display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--ink-2); padding: 16px; }
.cover-wait .avatar { width: 72px; height: 72px; font-size: 30px; }
.track.enter .cover { animation: arrive 0.5s var(--ease); }
.track-title { margin-top: 14px; max-width: calc(var(--cover) + 160px); font-size: clamp(24px, 3.4vw, 36px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-title span { font-size: 0.5em; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.track-artist { color: var(--ink-2); font-size: 17px; max-width: calc(var(--cover) + 160px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { width: min(440px, 88vw); display: grid; gap: 4px; margin-top: 4px; }
.progress-line { height: 4px; border-radius: 2px; background: var(--fill-2); overflow: hidden; }
.progress-line i { display: block; height: 100%; width: 0; background: rgb(var(--tint-hi)); transition: width 0.1s linear; }
.progress-line i.urgent { background: var(--del); }
.progress-line i.after { background: var(--ink-3); }
.timer-text { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.sound-btn { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 45; border: 0; border-radius: var(--r-btn); padding: 14px 22px; background: var(--ink); color: rgb(var(--base)); font-weight: 600; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4); }

.thumb { position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; overflow: hidden; background: var(--fill); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; fill: #fff; opacity: 0; transition: opacity 0.15s; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }
.thumb:hover svg, .thumb.on svg, .thumb:focus-visible svg { opacity: 1; }
.thumb:hover img, .thumb.on img { filter: brightness(0.55); }
.thumb .i-pause { display: none; }
.thumb.on .i-play { display: none; }
.thumb.on .i-pause { display: inline; }

/* ---------- K5D5 game ---------- */
.game {
  --cover: min(42vh, 380px);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px); align-items: center;
  padding: 0 var(--gutter) 16px; min-height: 0;
}
.choice { width: min(460px, 92vw); }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick { display: grid; justify-items: center; gap: 2px; border: 0; border-radius: var(--r-big); padding: 14px 10px; min-height: 56px; transition: transform 0.12s var(--ease), opacity 0.2s, box-shadow 0.2s; }
.pick.keep { background: var(--keep-bg); color: var(--keep-ink); }
.pick.del { background: var(--del-bg); color: var(--del-ink); }
@media (hover: hover) and (pointer: fine) { .pick:hover:not(:disabled) { transform: translateY(-2px); } }
.pick:active:not(:disabled) { transform: scale(0.98); }
.pick:disabled { opacity: 0.32; }
.pick.picked { opacity: 1; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 0 5px var(--ink); }
.pick.keep.picked { background: var(--keep); }
.pick.del.picked { background: var(--del); }
.pick-label { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.pick-left { font-size: 13px; opacity: 0.72; }
.pick kbd { font-family: inherit; font-size: 11px; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; opacity: 0.6; font-weight: 600; }
.choice-note { color: var(--ink-2); font-size: 14px; margin-top: 8px; min-height: 20px; }
.reveal-box { min-height: 38px; }
.reveal { display: inline-block; padding: 8px 14px; border-radius: var(--r-sm); background: rgba(0, 0, 0, 0.26); animation: arrive 0.3s ease both; }
.reveal.quiet { color: var(--ink-2); font-size: 14px; }

.shelf { width: min(300px, 100%); align-self: center; }
.shelf.keep { justify-self: end; }
.shelf.del { justify-self: start; }
.shelf-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.shelf.keep .shelf-head { justify-content: flex-end; }
.shelf-head b { font-weight: 700; }
.shelf-head span { color: var(--ink-3); font-size: 14px; }
.shelf ol { display: grid; gap: 8px; }
.shelf ol.two { grid-template-columns: 1fr 1fr; }
.slot { display: flex; align-items: center; gap: 10px; min-width: 0; height: 48px; }
.shelf.keep .slot { flex-direction: row-reverse; text-align: right; }
.slot img, .slot.empty i { width: 48px; height: 48px; flex: none; border-radius: 3px; }
.slot img { object-fit: cover; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.slot.empty i { display: block; border: 1.5px dashed var(--fill-2); }
.slot span { display: grid; min-width: 0; line-height: 1.25; }
.slot b, .slot small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot b { font-size: 14px; font-weight: 600; }
.slot small { font-size: 12px; color: var(--ink-2); }
.shelf.del .slot img { filter: grayscale(1) brightness(0.7); opacity: 0.75; }
.shelf.del .slot b { text-decoration: line-through; text-decoration-color: var(--ink-3); }
.slot.new img { animation: drop 0.4s var(--ease); }

/* ---------- results (both modes) ---------- */
.results {
  --rc: min(34vh, 300px);
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(24px, 4vw, 64px); align-items: center;
  width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px) 20px; min-height: 0;
}
.res-hero { display: grid; gap: 20px; align-content: center; min-width: 0; }
.res-cover { width: var(--rc); height: var(--rc); object-fit: cover; border-radius: var(--r-cover); box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45); }
.res-cover.round { border-radius: 50%; }
.verdict { margin-top: 16px; color: var(--ink-2); font-size: 17px; }
.verdict b { display: block; color: var(--ink); font-size: clamp(40px, 5vw, 60px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin-bottom: 4px; }
.verdict-solo { margin-top: 14px; color: var(--ink-2); }
.split { margin-top: 8px; color: var(--ink-2); font-size: 15px; }
.res-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; align-items: center; }
.res-boards { display: grid; gap: 12px; align-content: center; max-height: 100%; overflow-y: auto; min-height: 0; padding: 4px; }
.board { padding: 16px 18px; border-radius: 16px; background: rgba(0, 0, 0, 0.22); }
.board h2 { display: flex; align-items: center; gap: 10px; font-size: 17px; margin-bottom: 6px; }
.board h2 small { color: var(--ink-3); font-size: 13px; font-weight: 400; }
.row { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: start; gap: 10px; margin-top: 10px; }
.row-label { color: var(--ink-2); font-size: 14px; padding-top: 4px; }
.row ol { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 64px)); gap: 8px; }
.row li { display: grid; gap: 4px; min-width: 0; }
.row li span { font-size: 11px; line-height: 1.25; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.res-boards.many .row li span { display: none; }
.row.del li span { text-decoration: line-through; text-decoration-color: var(--ink-3); }
.row.del .thumb img { filter: grayscale(1) brightness(0.7); opacity: 0.8; }
.res-hint { color: var(--ink-3); font-size: 13px; text-align: center; }

/* ---------- Spy: turn ---------- */
.spy-game {
  --cover: min(40vh, 360px);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px); align-items: center;
  padding: 0 var(--gutter) 16px; min-height: 0;
}
.turns { justify-self: end; width: min(260px, 100%); display: grid; gap: 6px; }
.turns h3, .played h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.turns h3 small, .played h3 small { color: var(--ink-3); font-weight: 400; font-size: 13px; margin-left: 6px; }
.turn { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); min-width: 0; }
.turn b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn small { margin-left: auto; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.turn.now { background: var(--panel); }
.turn.now small { color: var(--ink); }
.turn.done { opacity: 0.6; }
.turn.away { opacity: 0.4; }
.played { justify-self: start; width: min(300px, 100%); display: grid; gap: 8px; align-content: center; min-height: 0; max-height: 100%; }
.played ol { display: grid; gap: 8px; overflow-y: auto; min-height: 0; }
.played .slot img, .played .slot i { width: 44px; height: 44px; }
.played .slot { height: 44px; }
.spy-actions { display: grid; gap: 10px; justify-items: center; width: min(480px, 92vw); }
.reactions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.react { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 6px 12px; min-height: 38px; background: var(--fill); font-size: 17px; transition: background var(--m-out), transform var(--m-out) var(--ease); }
.react small { font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.react.on { background: var(--ink); color: rgb(var(--base)); }
.react.on small { color: rgb(var(--base)); }
.react:disabled { opacity: 0.4; }
@media (hover: hover) and (pointer: fine) { .react:hover:not(:disabled):not(.on) { background: var(--fill-2); transform: translateY(-1px); } }
.host-tools { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding-top: 6px; border-top: 1px solid var(--line); }
.picked-by { color: var(--ink-3); font-size: 14px; margin-top: 2px; }

/* Spy role card (start of a game) */
.role-overlay { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); animation: rise 0.25s var(--ease); padding: 16px; }
.role-card { width: min(560px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; padding: clamp(24px, 5vw, 44px); border-radius: 22px; background: var(--sheet); border: 1px solid var(--line); }
.role-card p { color: var(--ink-2); }
.role-card h1 { font-size: clamp(36px, 6vw, 64px); font-weight: 800; letter-spacing: -0.04em; line-height: 1; overflow-wrap: anywhere; }

/* ---------- Spy: vote ---------- */
.vote {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 18px;
  width: 100%; max-width: 1200px; margin: 0 auto; padding: clamp(8px, 3vh, 32px) clamp(20px, 4vw, 56px) 18px; min-height: 0;
}
.vote-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.vote-head h1 { font-size: clamp(32px, 4.4vw, 52px); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02; }
.vote-head p { color: var(--ink-2); margin-top: 6px; }
.vote-timer { min-width: 200px; }
.suspects { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 270px)); justify-content: center; gap: 12px; align-content: center; overflow-y: auto; min-height: 0; padding: 4px; }
.suspect {
  display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: rgba(0, 0, 0, 0.22); border: 1.5px solid transparent; text-align: left;
  transition: border-color var(--m-out), transform var(--m-out) var(--ease);
}
.suspect.mine { border-color: var(--ink); }
.suspect.out { opacity: 0.4; }
.suspect-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.suspect-head b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suspect-head .count { margin-left: auto; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.suspect ol { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.suspect .btn { width: 100%; }
.vote-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--ink-2); }

/* ---------- Spy: results ---------- */
.spy-verdict h1 { font-size: clamp(44px, 6vw, 76px); font-weight: 800; letter-spacing: -0.045em; line-height: 0.95; }
.spy-verdict p { color: var(--ink-2); font-size: 17px; margin-top: 12px; }
.spy-verdict p b { color: var(--ink); }
.facts { display: grid; gap: 6px; margin-top: 16px; }
.facts div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; }
.facts dt, .facts span { color: var(--ink-3); font-size: 14px; }
.facts b { font-weight: 600; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; margin-top: 4px; }
.comments { display: grid; gap: 6px; }
.comments p { font-size: 14px; color: var(--ink-2); }
.comments p b { color: var(--ink); font-weight: 600; }
.votes-line { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: 14px; }
.votes-line b { color: var(--ink); font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .vol { display: none; }
}
@media (max-width: 860px) {
  .home { grid-template-columns: 1fr; gap: 22px; align-content: center; padding: 3vh 16px; }
  .lead { font-size: 16px; margin-top: 12px; }
  .modes { margin-top: 18px; gap: 8px; }
  .mode-card { padding: 14px; }
  .mode-card b { font-size: 18px; }
  .mode-card span { font-size: 13px; }
  .mode-card small { display: none; }
  .join { padding: 18px; gap: 12px; }

  .bar { grid-template-columns: 1fr auto; padding: 10px 16px; gap: 8px 12px; min-height: 0; }
  .bar-center { grid-column: 1 / -1; grid-row: 2; }
  .theme-chip { max-width: calc(100vw - 32px); }

  .lobby { padding: 0 16px 14px; }
  .lob-main {
    --c: 104px;
    grid-template-columns: var(--c) minmax(0, 1fr);
    grid-template-areas: "cover source" "set set" "start start";
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-content: center; justify-content: stretch; gap: 18px 16px;
  }
  .lob-side { display: contents; }
  .lob-cover { grid-area: cover; }
  .lob-source { grid-area: source; align-self: center; }
  .settings { grid-area: set; align-self: stretch; }
  .start { grid-area: start; justify-items: stretch; }
  .start-row .btn { flex: 1; }
  .mode-mark { padding: 12px; }
  .mode-mark b { font-size: 34px; }
  .mode-mark span, .mode-mark .mark-dots { display: none; }
  .src-title { font-size: 26px; }
  .src-sub { font-size: 15px; margin-top: 4px; }
  .lob-source .text-btn { margin-top: 6px; font-size: 14px; }
  .cover-ph span { font-size: 28px; }
  .cover-ph { font-size: 12px; gap: 2px; }
  .set-row { grid-template-columns: 84px minmax(0, 1fr); gap: 10px; }
  .set-name { font-size: 14px; line-height: 1.2; }
  .opt { min-width: 38px; }
  .room-info b { font-size: 20px; }
  .lob-foot { gap: 10px 16px; padding-top: 12px; }

  .game, .spy-game {
    --cover: min(30vh, 62vw);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 8px; padding: 0 16px 12px; align-items: end;
  }
  .stage { grid-row: 1; align-self: center; gap: 8px; }
  .track-title { font-size: 24px; margin-top: 8px; max-width: 100%; }
  .track-artist { max-width: 100%; font-size: 15px; }
  .pick { padding: 12px 8px; }
  .pick-label { font-size: 18px; }
  .pick kbd { display: none; }
  .shelf { width: 100%; display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 8px; }
  .shelf.keep, .shelf.del { justify-self: stretch; }
  .shelf.keep { grid-row: 2; }
  .shelf.del { grid-row: 3; }
  .shelf-head, .shelf.keep .shelf-head { margin: 0; display: grid; gap: 0; justify-content: start; line-height: 1.2; }
  .shelf-head b { font-size: 14px; }
  .shelf-head span { font-size: 12px; }
  .shelf ol, .shelf ol.two { grid-template-columns: repeat(var(--n), minmax(0, 40px)); gap: 4px; }
  .slot, .shelf.keep .slot { height: auto; display: block; }
  .slot img, .slot.empty i { width: 100%; height: auto; aspect-ratio: 1; }
  .slot span { display: none; }

  .turns { grid-row: 2; justify-self: stretch; width: 100%; display: flex; gap: 6px; overflow-x: auto; }
  .turns h3 { display: none; }
  .turn { flex: none; padding: 4px 8px 4px 4px; }
  .turn small { display: none; }
  .played { grid-row: 3; justify-self: stretch; width: 100%; }
  .played h3 { display: none; }
  .played ol { display: flex; overflow-x: auto; gap: 4px; }
  .played .slot { width: 40px; flex: none; }
  .played .slot img, .played .slot i { width: 40px; height: 40px; }
  .host-tools .btn { padding: 6px 10px; }

  .results { --rc: 96px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 16px; align-items: stretch; padding: 0 16px 14px; }
  .res-hero { grid-template-columns: var(--rc) minmax(0, 1fr); gap: 16px; align-items: center; row-gap: 2px; }
  .res-hero .src-title { font-size: 26px; }
  .verdict { margin-top: 8px; font-size: 14px; }
  .verdict b { font-size: 32px; }
  .split { font-size: 13px; }
  .res-actions { grid-column: 1 / -1; margin-top: 12px; }
  .res-text { display: contents; }
  .res-hero .res-cover { grid-row: 1 / span 3; align-self: center; }
  .res-text > .src-kind, .res-text > .src-title, .res-text > .src-sub { grid-column: 2; }
  .res-text > .verdict, .res-text > .split, .res-text > .verdict-solo { grid-column: 1 / -1; }
  .res-hero.spy-verdict { grid-template-columns: minmax(0, 1fr); }
  .spy-verdict h1 { font-size: 40px; }
  .res-boards { align-content: start; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .row-label { padding-top: 0; font-size: 13px; }
  .row ol { grid-template-columns: repeat(var(--n), minmax(0, 52px)); gap: 6px; }

  .vote { padding: 4px 16px 14px; gap: 12px; }
  .suspects { grid-template-columns: 1fr 1fr; justify-content: stretch; gap: 8px; align-content: start; }
  .reactions { gap: 4px; }
  .react { padding: 5px 9px; min-height: 36px; font-size: 16px; }
  .suspect { padding: 12px; gap: 8px; }
  .suspect ol { display: none; }

  .chat { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(70dvh, 520px); }
}
@media (min-width: 861px) and (max-height: 800px) {
  .game, .spy-game { --cover: min(36vh, 320px); }
  .stage { gap: 8px; }
  .track-pos { margin-bottom: 2px; }
  .track-title { margin-top: 8px; font-size: 28px; }
  .pick { padding: 11px 10px; }
  .choice-note { margin-top: 6px; }
  .reveal-box { min-height: 34px; }
  .results { --rc: min(26vh, 240px); }
  .res-hero { gap: 12px; }
  .verdict { margin-top: 8px; }
  .verdict b { font-size: 44px; }
  .res-actions { margin-top: 12px; }
  .lob-main { --c: min(46vh, 34vw, 420px); }
  .lob-side { gap: 18px; }
}
@media (max-width: 560px) {
  .bar .room-btn { display: none; }
  .bar-brand { font-size: 15px; }
  .bar-brand small { display: none; }
  .modes { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) and (max-height: 700px) {
  .game, .spy-game { --cover: min(24vh, 56vw); }
  .wordmark { font-size: 44px; }
  .lead { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
