:root {
  --bg: #f4f1ea;
  --ink: #1f2a44;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #d6d2c8;
  --correct: #3a8f5c;
  --present: #d4a72c;
  --absent: #8a8f98;
  --accent: #2f5bd3;
  --p0: #2f5bd3;
  --p1: #c2410c;
  --key: #e3dfd5;
  --danger: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --ink: #eceff4;
    --muted: #9aa3b2;
    --card: #1e2129;
    --line: #353a46;
    --absent: #4b515d;
    --key: #3a3f4b;
    --accent: #6d8ff0;
    --p0: #6d8ff0;
    --p1: #f08a54;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 520px; margin: 0 auto; padding: 12px 16px;
}
.logo { font-weight: 800; font-size: 1.25rem; color: var(--ink); text-decoration: none; letter-spacing: 0.02em; }
.room-tag { font-family: ui-monospace, monospace; font-size: 0.9rem; color: var(--muted); }

main { max-width: 520px; margin: 0 auto; padding: 0 16px 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.lede { margin-top: 0; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; }
.card > h2:first-child { margin-top: 0; }
label { display: block; font-size: 0.9rem; color: var(--muted); margin: 10px 0; }
input, select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
}
#home-code { text-transform: uppercase; font-family: ui-monospace, monospace; letter-spacing: 0.2em; }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--key); color: var(--ink); width: 100%;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: 0.5; cursor: default; }
.split { display: grid; gap: 4px 20px; grid-template-columns: 1fr; }
@media (min-width: 480px) { .split { grid-template-columns: 1fr 1fr; } }
.error { color: var(--danger); margin-bottom: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.share { display: flex; gap: 8px; }
.share input { margin: 0; font-size: 0.85rem; }
.share button { width: auto; }

/* Game */
.players { display: flex; gap: 8px; }
.player {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px; border: 2px solid transparent;
  background: var(--card); font-size: 0.9rem; min-width: 0;
}
.player .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player.active { border-color: var(--pc); }
.player .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--absent); flex: none; }
.player.online .dot { background: var(--correct); }
.player .you { color: var(--muted); font-size: 0.8rem; }

.status-line { display: flex; align-items: center; justify-content: space-between; margin: 12px 2px 10px; font-weight: 600; min-height: 1.6em; }
.pill { font-size: 0.8rem; font-weight: 600; background: var(--card); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }

.board { display: grid; gap: 6px; margin: 0 auto; width: fit-content; }
.row { display: grid; gap: 6px; grid-auto-flow: column; position: relative; }
.row .who { position: absolute; left: -14px; top: 50%; width: 6px; height: 60%; transform: translateY(-50%); border-radius: 3px; background: var(--pc); }
.tile {
  --size: min(13vw, 3.2rem);
  width: var(--size); height: var(--size);
  display: grid; place-items: center;
  font-weight: 800; font-size: calc(var(--size) * 0.5); text-transform: uppercase;
  border: 2px solid var(--line); border-radius: 6px; background: var(--card);
}
.board.len7 .tile { --size: min(11.2vw, 3rem); }
.tile.filled { border-color: var(--muted); }
.tile.correct, .tile.present, .tile.absent { color: #fff; border-color: transparent; }
.tile.flip { animation: flip 0.35s ease both; }
.tile.correct { background: var(--correct); }
.tile.present { background: var(--present); }
.tile.absent { background: var(--absent); }
.row.shake { animation: shake 0.35s; }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.toast { text-align: center; color: var(--danger); font-weight: 600; margin: 10px 0 0; }

.end { margin-top: 14px; text-align: center; }
.end h2 { font-size: 1.4rem; margin: 0 0 6px; }
.end label { text-align: left; }

.keyboard { margin-top: 14px; display: grid; gap: 7px; user-select: none; }
.keyboard.locked { opacity: 0.45; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1; max-width: 44px; height: 54px; padding: 0; width: auto;
  font-size: 1rem; text-transform: uppercase; border: none; border-radius: 6px;
}
.key.wide { flex: 1.6; max-width: 68px; font-size: 0.75rem; }
.key.correct { background: var(--correct); color: #fff; }
.key.present { background: var(--present); color: #fff; }
.key.absent { background: var(--absent); color: #fff; }

/* ---------- Shared additions ---------- */
:root { --lv1: #f4c9a3; --lv2: #a7d9cd; --lv3: #ecb5c8; --lv4: #d3cbb8; --lv-ink: #1b1d24; --good: #3a8f5c; }
@media (prefers-color-scheme: dark) { :root { --lv1: #b9845a; --lv2: #4f8f82; --lv3: #a86a82; --lv4: #8a8170; --good: #5fbf85; } .g-group { color: var(--ink); } }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.conn {
  max-width: 520px; margin: 0 auto 8px; padding: 8px 12px; text-align: center;
  background: #fff4d6; color: #6b4e00; border: 1px solid #e8cf86; border-radius: 10px; font-weight: 600; font-size: 0.9rem;
}
@media (prefers-color-scheme: dark) { .conn { background: #3a3220; color: #f3d98a; border-color: #6b5a2c; } }
@media (max-width: 552px) { .conn { margin: 0 16px 8px; } }
.mode-desc { margin: -4px 0 6px; }
.player .pstatus { margin-left: auto; color: var(--muted); font-size: 0.75rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
button.small { width: auto; padding: 8px 14px; font-size: 0.9rem; }
.howto { margin: 10px 2px 0; font-size: 0.92rem; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }
.howto p { margin: 4px 0 0; }

/* ---------- Groups ---------- */
.g-solved { display: grid; gap: 6px; margin-bottom: 6px; }
.g-group { border-radius: 10px; padding: 10px 12px; color: var(--lv-ink); text-align: center; }
.g-group.lv1 { background: var(--lv1); }
.g-group.lv2 { background: var(--lv2); }
.g-group.lv3 { background: var(--lv3); }
.g-group.lv4 { background: var(--lv4); }
.g-cat { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.03em; }
.g-lv { font-size: 0.72rem; font-weight: 700; opacity: 0.75; display: block; letter-spacing: 0.05em; }
.g-words { font-weight: 600; margin-top: 2px; }
.g-why { font-size: 0.85rem; margin-top: 4px; opacity: 0.85; }

.g-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.g-tile {
  position: relative; min-width: 0; min-height: 64px; padding: 6px 3px; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-weight: 800; font-size: clamp(0.68rem, 3.3vw, 0.95rem); letter-spacing: 0.01em;
  text-transform: uppercase; line-height: 1.1; overflow-wrap: normal; word-break: normal; hyphens: none;
  background: var(--key); border: 2px solid transparent; border-radius: 10px; color: var(--ink);
}
.g-tile.long { font-size: clamp(0.62rem, 2.9vw, 0.88rem); letter-spacing: 0; }
.g-tile.xlong { font-size: clamp(0.56rem, 2.55vw, 0.8rem); letter-spacing: -0.01em; }
.g-tile.selected { background: var(--ink); color: var(--bg); }
.g-tile.proposed { border: 2px dashed var(--accent); }
.g-tile.selected.proposed { border-style: solid; border-color: var(--present); }
.g-word { display: block; width: 100%; text-align: center; }
.g-mark { position: absolute; top: 3px; left: 6px; font-size: 0.75rem; }
.g-flag { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.03em; color: var(--accent); text-transform: lowercase; }
.g-tile.selected .g-flag { color: var(--present); }
.g-tile:disabled { opacity: 1; }

.g-toast { text-align: center; font-weight: 700; margin: 10px 0 0; padding: 8px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.g-toast.good { color: var(--good); }
.g-toast.bad { color: var(--danger); }

.g-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; margin-top: 12px; }
.g-proposal { margin-top: 12px; border: 2px solid var(--accent); }
.g-proposal h2 { margin: 0 0 8px; }
.g-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.g-chip { background: var(--key); border-radius: 8px; padding: 6px 10px; font-weight: 800; text-transform: uppercase; font-size: 0.85rem; }
.g-agree { list-style: none; padding: 0; margin: 10px 0; font-size: 0.92rem; }
.g-agree li { padding: 2px 0; }
.g-agree .yes { color: var(--good); font-weight: 600; }
.g-agree .wait { color: var(--muted); }
.g-prop-buttons { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.g-proposal .muted { margin: 8px 0 0; }

.g-hints { margin-top: 12px; padding: 12px 14px; }
.g-hints h2 { margin: 0; }
.g-hint-list { margin: 8px 0 0; padding-left: 22px; }
.g-hint-list li { padding: 2px 0; font-weight: 600; }
.g-hint-list li.done { color: var(--muted); font-weight: 400; }
.g-hints .muted { margin: 6px 0 0; }
.g-tried { margin-top: 10px; font-size: 0.9rem; }
.g-tried summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.g-tried ul { margin: 4px 0 0; padding-left: 20px; }

.g-feedback { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--card); border: 2px solid var(--line); font-size: 0.9rem; text-align: center; }
.g-feedback strong { display: block; font-size: 1.05rem; }
.g-feedback span { color: var(--muted); }
.g-feedback.good { border-color: var(--good); }
.g-feedback.good strong { color: var(--good); }
.g-feedback.bad { border-color: var(--danger); }
.g-feedback.bad strong { color: var(--danger); }
.g-feedback.warn { border-color: var(--present); border-style: dashed; }
.g-feedback.warn strong { color: #8a6500; }
@media (prefers-color-scheme: dark) { .g-feedback.warn strong { color: var(--present); } }

/* ---------- Header + room chat ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); }
.top-right { display: flex; align-items: center; gap: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat-open { width: auto; padding: 7px 12px; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; }
.chat-badge { background: var(--danger); color: #fff; border-radius: 999px; min-width: 1.4em; padding: 0 6px; font-size: 0.75rem; line-height: 1.4em; text-align: center; }
.chat {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  max-width: 520px; margin: 0 auto; height: min(58dvh, 520px);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-bottom: none;
  border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  padding-bottom: env(safe-area-inset-bottom);
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; }
.chat-sub { font-size: 0.75rem; flex: 1; }
.chat-list { list-style: none; margin: 0; padding: 10px 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.chat-empty { color: var(--muted); text-align: center; margin: auto 0; font-size: 0.9rem; }
.chat-divider { text-align: center; font-size: 0.75rem; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.chat-divider::before, .chat-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.msg { max-width: 85%; align-self: flex-start; background: var(--key); border-radius: 12px 12px 12px 4px; padding: 7px 10px; border-left: 4px solid var(--pc); }
.msg.mine { align-self: flex-end; border-radius: 12px 12px 4px 12px; border-left: none; border-right: 4px solid var(--pc); }
.msg-meta { font-size: 0.72rem; color: var(--muted); display: flex; gap: 6px; }
.msg-meta strong { color: var(--ink); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.msg-ref { font-size: 0.75rem; font-weight: 700; margin-top: 4px; padding: 3px 6px; border-radius: 6px; background: var(--card); border: 1px dashed var(--accent); }
.msg-state { font-size: 0.72rem; margin-top: 3px; color: var(--muted); }
.msg-state.failed { color: var(--danger); font-weight: 600; }
.msg-state button { width: auto; padding: 2px 8px; font-size: 0.72rem; margin-left: 4px; }
.chat-jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; width: auto; padding: 6px 12px; font-size: 0.8rem; background: var(--accent); color: #fff; border: none; border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.chat-form { border-top: 1px solid var(--line); padding: 8px 10px; }
.chat-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-row textarea {
  flex: 1; margin: 0; resize: none; max-height: 96px; font: inherit; font-size: 16px;
  padding: 9px 11px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.chat-row button { flex: none; }
.chat-ref { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; padding: 4px 8px; border: 1px dashed var(--accent); border-radius: 8px; }
.chat-ref span { flex: 1; }
.chat-ref button { width: auto; padding: 2px 8px; font-size: 0.8rem; }
.chat-note { margin: 4px 2px 0; font-size: 0.75rem; color: var(--muted); min-height: 1em; }
.chat-note.bad { color: var(--danger); }
body.chat-on main { padding-bottom: min(58dvh, 520px); }
.g-proposal .explain { width: 100%; margin-top: 8px; background: transparent; border: 1px dashed var(--accent); color: var(--accent); }

/* ---------- Word Hunt ---------- */
.h-theme { margin: 10px 0 0; padding: 10px 14px; text-align: center; }
.h-theme-label { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.h-theme strong { font-size: 1.15rem; }
.h-wrap { position: relative; width: min(100%, 380px); margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.h-grid { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); gap: 4px; }
.h-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.h-lines polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ln-found { stroke: var(--h-found-line); stroke-width: 10; opacity: 0.55; }
.ln-span { stroke: var(--h-span-line); stroke-width: 10; opacity: 0.6; }
.ln-mine { stroke: var(--p-me, var(--accent)); stroke-width: 8; opacity: 0.55; }
.ln-partner { stroke: var(--p-other, var(--p1)); stroke-width: 4; stroke-dasharray: 6 6; opacity: 0.9; }
.h-cell {
  position: relative; aspect-ratio: 1; width: 100%; padding: 0; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: clamp(1rem, 5.6vw, 1.35rem);
  background: transparent; border: 2px solid transparent; color: var(--ink); touch-action: none; z-index: 1;
}
.h-hit { position: absolute; inset: 18%; border-radius: 50%; }
.h-letter { position: relative; pointer-events: none; }
.h-mark { position: absolute; top: -2px; right: 0; font-size: 0.7rem; font-weight: 800; pointer-events: none; }
.h-order { position: absolute; bottom: 0; right: 2px; font-size: 0.58rem; font-weight: 700; opacity: 0.85; pointer-events: none; }
.h-cell.found { background: var(--h-found); }
.h-cell.found.span { background: var(--h-span); }
.h-cell.mine { background: var(--p-me, var(--accent)); color: #fff; }
.h-cell.partner { border: 2px dashed var(--p-other, var(--p1)); }
.h-cell.partner .h-mark { color: var(--p-other, var(--p1)); background: var(--card); border-radius: 50%; min-width: 1.1em; line-height: 1.1em; }
.h-cell.hint { box-shadow: 0 0 0 3px var(--present); animation: pulse 1.6s ease-in-out infinite; }
.h-cell.hint .h-mark { color: #8a6500; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--present) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { .h-cell.hint { animation: none; } }
.h-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; margin: 10px 0 0; font-size: 0.78rem; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; vertical-align: -2px; }
.lg-mine::before { background: var(--p-me, var(--accent)); }
.lg-partner::before { border: 2px dashed var(--p-other, var(--p1)); width: 9px; height: 9px; }
.lg-found::before { background: var(--h-found); }
.lg-span::before { background: var(--h-span); }
.h-current { text-align: center; margin-top: 8px; min-height: 1.8em; font-size: 1.25rem; letter-spacing: 0.08em; }
.h-current .muted { font-size: 0.8rem; letter-spacing: 0; }
.h-current.shake { animation: shake 0.35s; }
.h-found, .h-bonus { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.h-found li, .h-bonus li { background: var(--key); border-radius: 8px; padding: 5px 9px; font-weight: 700; font-size: 0.85rem; }
.h-found li { background: var(--h-found); color: var(--lv-ink); }
.h-found li.span { background: var(--h-span); }
.h-found li .muted { font-weight: 400; color: inherit; opacity: 0.7; }
.h-bonus li { font-weight: 600; text-transform: lowercase; }
:root { --h-found: #cfe6bd; --h-found-line: #5c8f3f; --h-span: #f5bba6; --h-span-line: #c9573a; }
@media (prefers-color-scheme: dark) { :root { --h-found: #44613a; --h-found-line: #9fd07f; --h-span: #7f4434; --h-span-line: #f08f6f; } .h-found li, .h-cell.found { color: var(--ink); } }

/* ---------- Chat visibility ---------- */
.chat-open.has-unread { background: var(--accent); border-color: var(--accent); color: #fff; }
.chat-open.has-unread .chat-badge { background: #fff; color: var(--accent); }
.chat-open.pulse { animation: chatpulse 0.9s ease-out 2; }
@keyframes chatpulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
.chat-banner {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%);
  top: calc(var(--header-h, 56px) + env(safe-area-inset-top) + 4px);
  width: calc(min(520px, 100vw) - 24px);
  display: flex; align-items: stretch; gap: 0;
  background: var(--accent); color: #fff; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); animation: bannerin 0.25s ease-out;
}
@keyframes bannerin { from { transform: translate(-50%, -10px); } to { transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .chat-banner, .chat-open.pulse { animation: none; } }
.chat-banner button { background: transparent; border: none; color: inherit; width: auto; }
.chat-banner-main { flex: 1; display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px 6px 12px 14px; font-weight: 400; min-height: 56px; }
.cb-icon { font-size: 1.3rem; flex: none; }
.cb-body { flex: 1; min-width: 0; font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
.cb-body strong { font-weight: 800; }
.cb-more { display: block; font-size: 0.78rem; opacity: 0.9; margin-top: 2px; }
.cb-cta { flex: none; font-weight: 800; font-size: 0.85rem; background: rgba(255,255,255,0.22); border-radius: 999px; padding: 4px 10px; }
.chat-banner-close { flex: none; padding: 0 14px; font-size: 1rem; border-left: 1px solid rgba(255,255,255,0.3) !important; border-radius: 0 14px 14px 0; min-width: 44px; }
.chat-divider.unread { color: var(--danger); }
.chat-divider.unread::before, .chat-divider.unread::after { border-top-color: var(--danger); }
.chat-sound { font-weight: 600; }

/* Wide screens: chat docked beside the board */
body.chat-docked { padding-right: 360px; }
body.chat-docked .chat {
  left: auto; right: 0; top: 0; bottom: 0; margin: 0; width: 360px; max-width: none; height: 100dvh;
  border-radius: 0; border: none; border-left: 1px solid var(--line); box-shadow: none;
}
body.chat-docked .chat-banner { display: none; }

/* ---------- Puzzle library ---------- */
.seen-note { margin: 10px 2px 0; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px dashed var(--line); font-size: 0.88rem; color: var(--muted); }
.library-note { margin: 4px 0 10px; }
.library-note.done { padding: 10px 12px; border-radius: 10px; border: 2px solid var(--accent); background: var(--bg); }

/* ---------- Game switcher ---------- */
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; padding: 8px 10px 8px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.gb-label { font-size: 0.95rem; }
.switch-open { width: auto; white-space: nowrap; }
.switch-banner { margin: 0 0 12px; padding: 14px; border-radius: 14px; background: var(--card); border: 3px solid var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,0.12); }
.sb-text { margin: 0; font-weight: 800; font-size: 1.1rem; }
.sb-note { margin: 6px 0 10px; color: var(--muted); font-size: 0.9rem; }
.sb-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.sb-actions button:only-child { grid-column: 1 / -1; }
.switch-toast { margin: 0 0 10px; padding: 10px 12px; text-align: center; font-weight: 700; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
body.switch-pending main .screen { opacity: 0.5; pointer-events: none; user-select: none; }
.switcher {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; max-width: 520px; margin: 0 auto;
  background: var(--card); border: 1px solid var(--line); border-bottom: none; border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.2); padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}
.sw-head { display: flex; align-items: center; justify-content: space-between; }
.sw-head h2 { margin: 0; }
.sw-sub { color: var(--muted); font-size: 0.9rem; margin: 6px 0 10px; }
.sw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sw-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; min-height: 60px; }
.sw-item.current { border: 2px solid var(--accent); }
.sw-item.current .sw-status::before { content: "● "; color: var(--accent); }
.sw-name { display: flex; flex-direction: column; }
.sw-name strong { font-size: 1.05rem; }
.sw-status { font-size: 0.85rem; color: var(--muted); }
.sw-item button { width: auto; min-width: 92px; min-height: 44px; }
.sw-note { color: var(--danger); font-size: 0.9rem; margin: 8px 0 0; min-height: 1em; }
body.cb-on main { padding-top: var(--cb-h, 72px); }

/* ---------- Your rooms ---------- */
.rooms-open { width: auto; padding: 7px 12px; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rooms-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); display: inline-block; }
.gb-room { display: block; font-size: 0.75rem; color: var(--muted); font-family: ui-monospace, monospace; }
@media (max-width: 440px) { .room-tag { display: none !important; } }
.rooms { max-height: 85dvh; overflow-y: auto; }
.rooms #rooms-new { margin-top: 10px; }
.sw-item.ended .sw-status { color: var(--danger); }
.room-new { display: inline-block; margin-top: 4px; font-size: 0.78rem; font-weight: 800; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 8px; align-self: flex-start; }
.rooms-create { margin-top: 10px; padding: 12px; border: 2px solid var(--accent); border-radius: 12px; }
.rc-confirm { margin: 0 0 6px; font-weight: 700; }
.rooms-create .muted { margin: 0 0 4px; }
.rc-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 10px; }
.linklike { display: inline; width: auto; padding: 0; border: none; background: none; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.home-rooms { margin-top: 8px; }
.player.away .dot { background: var(--present); }
/* "away — in another room" is long: give it its own line so the name stays readable */
.player.away { flex-wrap: wrap; row-gap: 0; }
.player.away .pstatus { flex-basis: 100%; margin-left: 17px; }
