:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #12161b;
  --surface-2: #191f26;
  --surface-3: #222a33;
  --line: rgba(238, 243, 248, 0.12);
  --line-strong: rgba(238, 243, 248, 0.22);
  --text: #f4f6f8;
  --muted: #9da7b3;
  --muted-strong: #c3cad2;
  --red: #c83d4b;
  --red-soft: rgba(200, 61, 75, 0.14);
  --mint: #55d6b2;
  --mint-soft: rgba(85, 214, 178, 0.13);
  --amber: #e6ad58;
  --amber-soft: rgba(230, 173, 88, 0.14);
  --blue: #72a8ff;
  --danger: #ff6570;
  --font: "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --nav-height: 72px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

button,
input { font: inherit; }

button { cursor: pointer; }

button,
input,
dialog { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

h1,
h2,
h3,
p { margin-top: 0; }

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 110;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 0 28px 72px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand-mark {
  position: relative;
  display: block;
  width: 38px;
  height: 38px;
  margin-right: 11px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.brand-mark i {
  position: absolute;
  display: block;
  width: 6px;
  height: 26px;
  background: var(--red);
  transform: rotate(35deg);
}

.brand-mark i:nth-child(1) { left: 8px; top: -3px; }
.brand-mark i:nth-child(2) { left: 17px; top: 6px; background: var(--mint); }
.brand-mark i:nth-child(3) { right: 5px; bottom: -5px; background: var(--amber); }

.brand-copy b {
  display: block;
  font-size: 16px;
  font-weight: 800;
}

.brand-copy small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font: 10px/1.3 var(--mono);
}

.connection {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 12px;
}

.connection-dot,
.live-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}

.connection.online .connection-dot,
.live-dot {
  background: var(--mint);
  box-shadow: 0 0 0 4px var(--mint-soft);
}

.connection.offline .connection-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--red-soft);
}

.view {
  animation: view-in 220ms cubic-bezier(.2, .8, .2, 1);
}

@keyframes view-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--mint);
  font: 700 11px/1.4 var(--font);
}

.hall-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 56px 0 44px;
}

.hall-head h1 {
  max-width: 760px;
  margin-bottom: 10px;
  font-size: 68px;
  line-height: 1.06;
  font-weight: 850;
}

.hall-copy {
  margin-bottom: 0;
  color: var(--muted-strong);
  font-size: 17px;
}

.primary-btn,
.secondary-btn,
.host-btn,
.text-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 8px;
  border-radius: var(--radius);
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, opacity 180ms ease;
  touch-action: manipulation;
}

.primary-btn {
  padding: 0 20px;
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  font-weight: 800;
}

.primary-btn:hover:not(:disabled) { background: #cf3f4e; }
.primary-btn:active:not(:disabled) { background: #b93644; }

.secondary-btn {
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

.secondary-btn:hover:not(:disabled) {
  border-color: rgba(238, 243, 248, 0.35);
  background: var(--surface-3);
}

.host-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(224, 82, 96, 0.55);
  background: var(--red-soft);
  color: #ff929a;
  font-size: 13px;
  font-weight: 750;
}

.host-btn:hover:not(:disabled) { background: rgba(224, 82, 96, 0.22); }

.text-btn {
  min-width: 48px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--mint);
  font-size: 13px;
}

.icon-btn {
  width: 48px;
  min-width: 48px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.full-btn { width: 100%; }

.continue-section {
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.library-section { padding-top: 42px; }

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.section-heading.compact { align-items: center; }

.section-heading h2,
.page-title h1,
.room-summary h2,
.join-panel h2,
.panel-head h2,
.phase-banner h2 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.2;
}

.search-box {
  display: flex;
  align-items: center;
  width: min(300px, 42vw);
  height: 46px;
  padding: 0 13px;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.search-box svg { width: 18px; }

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-box:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(114, 168, 255, 0.12);
}

.filter-row {
  display: flex;
  gap: 8px;
  padding: 20px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted-strong);
  font-size: 13px;
  touch-action: manipulation;
}

.filter-chip.selected {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
}

.script-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.script-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.script-card:hover {
  border-color: rgba(238, 243, 248, 0.3);
  background: var(--surface-2);
}

.script-card.featured { grid-column: span 2; }

.script-card-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.poster-art,
.mini-poster,
.detail-poster {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: #262d38;
}

.poster-art {
  aspect-ratio: 1.32 / 1;
  border-bottom: 1px solid var(--line);
}

.script-card.featured .poster-art { aspect-ratio: 2.1 / 1; }

.poster-art::before,
.mini-poster::before,
.detail-poster::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 65%;
  height: 180%;
  top: -40%;
  right: 8%;
  border: 1px solid rgba(255, 255, 255, 0.17);
  transform: rotate(29deg);
}

.poster-art::after,
.mini-poster::after,
.detail-poster::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 24%;
  height: 150%;
  left: 14%;
  top: -25%;
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(29deg);
}

.poster-art > span,
.mini-poster > span,
.detail-poster > span {
  position: absolute;
  left: 14px;
  bottom: 10px;
  font: 800 34px/1 var(--mono);
  color: rgba(255, 255, 255, 0.9);
}

.poster-art > i,
.mini-poster > i,
.detail-poster > i {
  position: absolute;
  right: 13px;
  top: 13px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.1);
}

.poster-theme-0 { background: #8d3742; color: #ffbdc2; }
.poster-theme-1 { background: #2d6671; color: #7de3da; }
.poster-theme-2 { background: #66502e; color: #ffd078; }
.poster-theme-3 { background: #384563; color: #9dc0ff; }
.poster-theme-4 { background: #48603c; color: #9bdf8c; }
.poster-theme-5 { background: #6a3d67; color: #f0a6e9; }
.poster-theme-6 { background: #704531; color: #ffb38c; }
.poster-theme-7 { background: #3f4b52; color: #b6d0dd; }

.poster-art.poster-photo {
  background-image: linear-gradient(0deg, rgba(7, 9, 12, 0.75), rgba(7, 9, 12, 0.04)), url("/assets/case-cover.webp");
  background-position: center 52%;
  background-size: cover;
}

.poster-art.poster-photo::before,
.poster-art.poster-photo::after { display: none; }

.poster-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(11, 13, 16, 0.78);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  backdrop-filter: blur(8px);
}

.script-card-copy { padding: 15px; }

.script-card-copy h3 {
  display: -webkit-box;
  min-height: 46px;
  margin-bottom: 7px;
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  line-height: 1.35;
  font-weight: 800;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.script-card-copy p {
  display: -webkit-box;
  min-height: 40px;
  margin-bottom: 14px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.script-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 12px;
}

.script-meta strong { color: var(--mint); font-weight: 750; }

.empty-state {
  display: grid;
  min-height: 200px;
  place-items: center;
  align-content: center;
  color: var(--muted);
}

.empty-state svg { width: 28px; height: 28px; margin-bottom: 10px; }
.empty-state p { margin-bottom: 0; }

.recent-games {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.recent-room {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 72px;
  padding: 12px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.recent-room:hover { border-color: var(--line-strong); background: var(--surface-2); }

.recent-room-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--red-soft);
  color: #ff8c95;
}

.recent-room-copy { min-width: 0; flex: 1; }
.recent-room-copy b { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.recent-room-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.recent-room > svg { flex: 0 0 auto; width: 16px; color: var(--muted); }

.page-head,
.game-head {
  display: flex;
  align-items: center;
  min-height: 88px;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.page-title,
.game-title { min-width: 0; flex: 1; }

.page-title h1,
.game-title h1 {
  overflow: hidden;
  margin-bottom: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-title h1 { font-size: 24px; }

.lobby-layout {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 30px 0;
}

.room-summary {
  display: flex;
  align-items: center;
  min-height: 128px;
  gap: 18px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.mini-poster {
  flex: 0 0 auto;
  width: 82px;
  height: 104px;
  border-radius: var(--radius);
}

.mini-poster > span { left: 10px; bottom: 9px; font-size: 24px; }
.mini-poster > i { right: 10px; top: 10px; }

.room-summary-copy { min-width: 0; }
.room-summary-copy h2 { margin: 9px 0 5px; font-size: 26px; }
.room-summary-copy p { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 9px;
  border: 1px solid rgba(114, 168, 255, 0.38);
  border-radius: 999px;
  background: rgba(114, 168, 255, 0.1);
  color: #a9c8ff;
  font-size: 11px;
  font-weight: 750;
}

.status-badge.ready {
  border-color: rgba(85, 214, 178, 0.38);
  background: var(--mint-soft);
  color: #8be7cd;
}

.invite-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 86px;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.invite-strip span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
}

.invite-strip strong {
  font: 800 24px/1.2 var(--mono);
}

.seat-section { padding-top: 30px; }

.section-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.seat {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 118px;
  flex-direction: column;
  justify-content: space-between;
  padding: 13px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
}

.seat.active {
  border-style: solid;
  border-color: rgba(85, 214, 178, 0.35);
  background: var(--mint-soft);
  color: var(--text);
}

.seat.mine { box-shadow: inset 0 0 0 1px var(--mint); }

.seat-index { font: 700 10px/1.4 var(--mono); color: var(--muted); }
.seat-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--muted-strong); font-weight: 800; }
.seat.active .seat-avatar { background: var(--mint); color: #08120f; }
.seat-name { display: block; overflow: hidden; font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.seat-provider { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.join-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 34px;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.join-panel h2 { font-size: 20px; }

.join-form {
  display: flex;
  width: min(430px, 60%);
  gap: 8px;
}

.join-form input,
.dialog-body > input,
.composer input {
  min-width: 0;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: 0;
  background: var(--bg);
  color: var(--text);
}

.join-form input:focus,
.dialog-body > input:focus,
.composer input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(114, 168, 255, 0.12);
}

.joined-panel {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 28px;
  padding: 17px;
  border: 1px solid rgba(85, 214, 178, 0.3);
  border-radius: var(--radius);
  background: var(--mint-soft);
}

.joined-check { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; background: var(--mint); color: #08120f; }
.joined-panel b { display: block; font-size: 14px; }
.joined-panel p { margin: 2px 0 0; color: var(--muted-strong); font-size: 12px; }

.lobby-action-bar {
  position: sticky;
  z-index: 4;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(780px, 100%);
  min-height: 76px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(18, 22, 27, 0.94);
  backdrop-filter: blur(12px);
}

.lobby-action-bar p { margin: 0 12px 0 0; color: var(--muted-strong); font-size: 13px; }

.game-head { min-height: 76px; }

.game-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-title p { margin-bottom: 1px; color: var(--mint); font-size: 11px; font-weight: 700; }
.game-title h1 { font-size: 18px; }

.round-button {
  display: flex;
  align-items: center;
  min-width: 58px;
  min-height: 48px;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.round-button span { font: 800 14px/1 var(--mono); }
.round-button small { color: var(--muted); font-size: 10px; }

.game-frame {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 20px;
  padding-top: 20px;
}

.game-nav {
  position: sticky;
  top: 20px;
  display: flex;
  height: max-content;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  position: relative;
  display: flex;
  min-height: 64px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
  touch-action: manipulation;
}

.nav-item:hover { color: var(--text); background: var(--surface); }

.nav-item.selected {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.selected svg { color: var(--red); }

.nav-count,
.nav-alert {
  position: absolute;
  top: 7px;
  right: 12px;
  display: grid;
  min-width: 17px;
  height: 17px;
  place-items: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
  border-radius: 999px;
  background: var(--amber);
  color: #171006;
  font: 800 9px/1 var(--mono);
}

.nav-alert { width: 10px; min-width: 10px; height: 10px; top: 10px; right: 17px; padding: 0; background: var(--red); }

.play-area { min-width: 0; }

.phase-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 112px;
  gap: 20px;
  padding: 20px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.phase-banner::after {
  content: "";
  position: absolute;
  top: -90px;
  right: 17%;
  width: 1px;
  height: 280px;
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(38deg);
  box-shadow: 28px 0 0 rgba(255, 255, 255, 0.04), 56px 0 0 rgba(255, 255, 255, 0.02);
}

.phase-banner-copy { position: relative; z-index: 1; min-width: 0; }
.phase-banner h2 { margin-bottom: 5px; }
.phase-banner-copy > p:last-child { max-width: 680px; margin-bottom: 0; color: var(--muted-strong); font-size: 13px; }
.phase-actions { position: relative; z-index: 1; display: flex; flex: 0 0 auto; gap: 8px; }

.role-notice {
  margin-top: 14px;
  padding: 11px 14px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  color: #e8d5b6;
  font-size: 12px;
}

.game-tab {
  min-height: 520px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  gap: 16px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 { font-size: 22px; }

.message-feed {
  min-height: 350px;
  max-height: 55vh;
  padding: 4px 20px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 11px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.message-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--mint);
  font-size: 12px;
  font-weight: 800;
}

.message-copy { min-width: 0; }
.message-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.message-meta b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.message-meta span { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.message-provider { margin-left: 6px; color: var(--muted); font-size: 10px; font-weight: 500; }
.message-copy p { margin: 6px 0 0; color: #e3e7ea; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }

.message.system {
  grid-template-columns: 1fr;
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid rgba(230, 173, 88, 0.26);
  border-radius: var(--radius);
  background: var(--amber-soft);
}

.message.system .message-avatar { display: none; }
.message.system .message-meta b { color: var(--amber); }

.composer {
  position: sticky;
  z-index: 3;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(18, 22, 27, 0.96);
  backdrop-filter: blur(12px);
}

.composer button {
  display: grid;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
}

.private-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--amber);
  font-size: 11px;
}

.private-badge svg { width: 15px; height: 15px; }

.role-panel,
.evidence-list,
.people-list,
.vote-panel { padding: 20px; }

.role-empty,
.content-empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.role-empty svg,
.content-empty svg { width: 32px; height: 32px; margin-bottom: 12px; }
.role-empty p,
.content-empty p { max-width: 360px; margin-bottom: 0; font-size: 13px; }

.role-identity {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.7fr);
  gap: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.role-label { display: inline-flex; margin-bottom: 10px; color: var(--mint); font-size: 11px; font-weight: 800; }
.role-identity h3 { margin-bottom: 8px; font-size: 36px; line-height: 1.15; }
.role-intro { margin-bottom: 0; color: var(--muted-strong); font-size: 14px; }
.role-objective { padding: 17px; border-left: 3px solid var(--red); background: var(--red-soft); }
.role-objective span { display: block; margin-bottom: 5px; color: #ff929a; font-size: 11px; font-weight: 800; }
.role-objective p { margin-bottom: 0; color: #f4d8db; font-size: 13px; line-height: 1.65; }

.role-script-action { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 0 0; }
.role-script-action p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.role-script { max-width: 760px; margin: 28px auto 8px; }
.role-script h3 { margin-bottom: 14px; color: var(--amber); font-size: 14px; }
.role-script > p { color: #eceeef; font-size: 16px; line-height: 1.9; white-space: pre-wrap; }
.fact-list { display: grid; gap: 8px; margin-top: 20px; }
.fact-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--muted-strong); font-size: 13px; }
.fact-item span { color: var(--red); font: 800 11px/1.6 var(--mono); }

.evidence-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.evidence-item {
  display: flex;
  min-width: 0;
  min-height: 92px;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.evidence-icon {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(230, 173, 88, 0.36);
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber);
}

.evidence-icon svg { width: 19px; }
.evidence-copy { min-width: 0; flex: 1; }
.evidence-copy b { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.evidence-copy small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.evidence-item button { flex: 0 0 auto; min-width: 48px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--text); font-size: 12px; }
.evidence-item.inspected { border-color: rgba(85, 214, 178, 0.28); }
.evidence-item.inspected .evidence-icon { border-color: rgba(85, 214, 178, 0.32); background: var(--mint-soft); color: var(--mint); }

.people-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.person-item {
  display: flex;
  min-width: 0;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.person-avatar { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--mint); font-weight: 800; }
.person-copy { min-width: 0; flex: 1; }
.person-copy b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-copy small { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.person-status { flex: 0 0 auto; color: var(--mint); font-size: 11px; }
.person-status.eliminated { color: var(--red); }

.vote-intro { max-width: 560px; margin: 0 auto 20px; color: var(--muted-strong); font-size: 13px; text-align: center; }
.vote-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.vote-option { display: flex; min-height: 70px; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--text); text-align: left; }
.vote-option:hover { border-color: var(--line-strong); }
.vote-option.selected { border-color: var(--red); background: var(--red-soft); }
.vote-option .person-avatar { width: 38px; height: 38px; }
.vote-option b { display: block; }
.vote-option small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.vote-confirm { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px -20px -20px; padding: 12px 20px; border-top: 1px solid var(--line); background: rgba(18, 22, 27, 0.96); }
.vote-confirm p { margin-bottom: 0; color: var(--muted-strong); font-size: 12px; }

.reveal-panel {
  margin: 16px 20px 0;
  padding: 20px;
  border: 1px solid rgba(224, 82, 96, 0.4);
  border-radius: var(--radius);
  background: var(--red-soft);
}

.reveal-panel span { color: #ff929a; font-size: 11px; font-weight: 800; }
.reveal-panel h3 { margin: 6px 0 8px; font-size: 22px; }
.reveal-panel p { margin-bottom: 0; color: #f3dadd; font-size: 13px; line-height: 1.7; }
.reveal-tally { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.reveal-tally i { padding: 5px 8px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; color: var(--muted-strong); font-size: 11px; font-style: normal; }

.sheet-dialog {
  width: min(520px, calc(100% - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.sheet-dialog::backdrop { background: rgba(0, 0, 0, 0.68); backdrop-filter: blur(3px); }
.dialog-body { padding: 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.dialog-head h2 { margin-bottom: 0; font-size: 25px; }
.dialog-close { border-color: transparent; background: transparent; }
.dialog-body > label { display: block; margin-bottom: 8px; color: var(--muted-strong); font-size: 13px; }
.dialog-body > input { margin-bottom: 12px; text-transform: lowercase; }

.detail-hero { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 18px; }
.detail-poster { width: 112px; height: 144px; border-radius: var(--radius); }
.detail-hero p { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.detail-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 22px 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); }
.detail-stats div { padding: 12px; background: var(--surface-2); }
.detail-stats span { display: block; color: var(--muted); font-size: 10px; }
.detail-stats b { display: block; margin-top: 4px; font-size: 13px; }

.clue-document {
  position: relative;
  min-height: 230px;
  margin-bottom: 16px;
  padding: 24px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #ece7dc;
  color: #202326;
}

.clue-document::after { content: ""; position: absolute; right: -28px; bottom: -28px; width: 80px; height: 80px; border: 16px solid rgba(184, 61, 71, 0.18); transform: rotate(20deg); }
.clue-index { display: inline-block; padding-bottom: 4px; border-bottom: 2px solid #b83d47; color: #8e2932; font: 800 10px/1.4 var(--mono); }
.clue-document p { margin: 22px 0 0; font-size: 16px; line-height: 1.85; }

.phase-list { padding: 0; margin: 0; list-style: none; }
.phase-list li { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; min-height: 62px; color: var(--muted); }
.phase-list li::after { content: ""; position: absolute; left: 14px; top: 28px; bottom: 0; width: 1px; background: var(--line-strong); }
.phase-list li:last-child::after { display: none; }
.phase-list i { display: grid; z-index: 1; width: 29px; height: 29px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--muted); font: 800 10px/1 var(--mono); font-style: normal; }
.phase-list b { display: block; padding-top: 3px; color: var(--muted-strong); font-size: 13px; }
.phase-list small { font-size: 11px; }
.phase-list li.current i { border-color: var(--red); background: var(--red); color: #fff; }
.phase-list li.current b { color: var(--text); }
.phase-list li.done i { border-color: var(--mint); background: var(--mint-soft); color: var(--mint); }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #edf1f3;
  color: #13171b;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.in-game .toast { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 14px); }

@media (max-width: 960px) {
  .hall-head h1 { font-size: 52px; }
  .script-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .seat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { padding: 0 16px 48px; }
  .topbar { height: 66px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-copy b { font-size: 15px; }
  .connection { font-size: 11px; }

  .hall-head { align-items: center; padding: 32px 0 28px; }
  .hall-head h1 { margin-bottom: 8px; font-size: 38px; }
  .hall-copy { font-size: 14px; }
  .join-room-trigger { width: 48px; padding: 0; font-size: 0; }
  .join-room-trigger svg { width: 21px; height: 21px; }

  .library-section { padding-top: 32px; }
  .section-heading h2 { font-size: 22px; }
  .search-box { width: 44px; padding: 0 12px; transition: width 180ms ease; }
  .search-box input { width: 0; opacity: 0; }
  .search-box:focus-within { width: min(210px, 62vw); }
  .search-box:focus-within input { width: 100%; opacity: 1; }
  .filter-row { margin: 0 -16px; padding: 18px 16px 14px; }

  .script-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .script-card.featured { grid-column: span 2; }
  .script-card.featured .poster-art { aspect-ratio: 1.9 / 1; }
  .poster-art { aspect-ratio: 1.1 / 1; }
  .script-card-copy { padding: 12px; }
  .script-card-copy h3 { min-height: 44px; font-size: 15px; }
  .script-card-copy p { display: none; }
  .script-meta { align-items: flex-start; flex-direction: column; }
  .script-card.featured .script-meta { align-items: center; flex-direction: row; }

  .recent-games { display: flex; margin-right: -16px; padding-right: 16px; overflow-x: auto; scroll-snap-type: x mandatory; }
  .recent-room { flex: 0 0 84%; scroll-snap-align: start; }

  .page-head { min-height: 72px; }
  .page-title h1 { font-size: 20px; }
  .lobby-layout { padding: 22px 0 118px; }
  .room-summary-copy h2 { font-size: 22px; }
  .invite-strip strong { font-size: 20px; }
  .seat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seat { min-height: 108px; }
  .join-panel { align-items: stretch; flex-direction: column; gap: 18px; padding: 18px; }
  .join-form { width: 100%; }
  .lobby-action-bar { position: fixed; right: 0; bottom: 0; left: 0; width: 100%; min-height: calc(74px + env(safe-area-inset-bottom)); margin: 0; padding: 11px 16px calc(11px + env(safe-area-inset-bottom)); border-right: 0; border-bottom: 0; border-left: 0; border-radius: 0; }
  .lobby-action-bar p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .in-game { overflow: hidden; }
  .in-game .app-shell { width: 100%; height: 100dvh; padding: 0; }
  .in-game .topbar { display: none; }
  .game-view { display: flex; height: 100dvh; flex-direction: column; }
  .game-head { flex: 0 0 auto; min-height: 68px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: var(--bg); }
  .game-title h1 { max-width: 48vw; font-size: 15px; }
  .game-title p { font-size: 10px; }
  .game-frame { display: block; min-height: 0; flex: 1; padding: 0; overflow: hidden; }
  .play-area { height: 100%; padding: 12px 12px calc(var(--nav-height) + env(safe-area-inset-bottom) + 10px); overflow-y: auto; overscroll-behavior: contain; }

  .game-nav { position: fixed; z-index: 30; top: auto; right: 0; bottom: 0; left: 0; display: grid; height: calc(var(--nav-height) + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; padding: 5px 6px env(safe-area-inset-bottom); border-top: 1px solid var(--line-strong); background: rgba(11, 13, 16, 0.96); backdrop-filter: blur(16px); }
  .nav-item { min-width: 0; min-height: 62px; padding: 5px 2px; border: 0; border-radius: 6px; }
  .nav-item.selected { border: 0; background: var(--surface-2); }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-count { top: 5px; right: calc(50% - 24px); }
  .nav-alert { top: 8px; right: calc(50% - 21px); }

  .phase-banner { min-height: 102px; padding: 16px; }
  .phase-banner h2 { font-size: 21px; }
  .phase-banner-copy > p:last-child { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .phase-actions .icon-btn { display: none; }
  .host-btn { min-width: 44px; padding: 0 11px; font-size: 0; }
  .host-btn svg { margin: 0; }
  .role-notice { font-size: 11px; }
  .game-tab { min-height: calc(100dvh - 240px); margin-top: 12px; }
  .panel-head { min-height: 72px; padding: 14px 15px; }
  .panel-head h2 { font-size: 20px; }
  .message-feed { min-height: calc(100dvh - 390px); max-height: none; padding: 3px 15px 20px; }
  .message { grid-template-columns: 34px minmax(0, 1fr); gap: 9px; }
  .message-avatar { width: 34px; height: 34px; }
  .message-copy p { font-size: 14px; }
  .composer { bottom: 0; padding: 10px; }
  .role-panel, .evidence-list, .people-list, .vote-panel { padding: 15px; }
  .role-identity { grid-template-columns: 1fr; gap: 18px; }
  .role-identity h3 { font-size: 31px; }
  .role-script-action { align-items: stretch; flex-direction: column; gap: 12px; }
  .role-script-action .secondary-btn { width: 100%; }
  .evidence-list, .people-list, .vote-options { grid-template-columns: 1fr; }
  .vote-confirm { margin: 16px -15px -15px; padding: 10px 15px; }

  .sheet-dialog { width: 100%; max-width: none; max-height: 88dvh; margin: auto 0 0; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 8px 8px 0 0; }
  .dialog-body { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .detail-hero { grid-template-columns: 94px minmax(0, 1fr); }
  .detail-poster { width: 94px; height: 124px; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
  .in-game .toast { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px); }
}

@media (max-width: 390px) {
  .hall-head h1 { font-size: 34px; }
  .hall-copy { max-width: 240px; }
  .script-card-copy h3 { font-size: 14px; }
  .script-meta { font-size: 11px; }
  .join-form { flex-direction: column; }
  .join-form .primary-btn { width: 100%; }
  .room-summary { align-items: flex-start; }
  .mini-poster { width: 70px; height: 92px; }
  .invite-strip { align-items: stretch; flex-direction: column; }
  .invite-strip .secondary-btn { width: 100%; }
  .detail-stats div { padding: 10px 8px; }
  .phase-banner-copy > p:last-child { font-size: 12px; }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 960px) {
  .in-game { overflow: hidden; }
  .in-game .app-shell { width: 100%; height: 100dvh; padding: 0; }
  .in-game .topbar { display: none; }
  .game-view { display: flex; height: 100dvh; flex-direction: column; }
  .in-game .game-head { flex: 0 0 auto; min-height: 58px; padding: 6px 12px; background: var(--bg); }
  .game-title h1 { max-width: 50vw; font-size: 15px; }
  .game-title p { font-size: 10px; }
  .game-frame { display: block; min-height: 0; flex: 1; padding: 0; overflow: hidden; }
  .in-game .play-area { height: 100%; padding: 8px 12px calc(var(--nav-height) + env(safe-area-inset-bottom) + 8px); overflow-y: auto; overscroll-behavior: contain; }
  .game-nav { position: fixed; z-index: 30; top: auto; right: 0; bottom: 0; left: 0; display: grid; height: calc(var(--nav-height) + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; padding: 5px 6px env(safe-area-inset-bottom); border-top: 1px solid var(--line-strong); background: rgba(11, 13, 16, 0.96); backdrop-filter: blur(16px); }
  .nav-item { min-width: 0; min-height: 62px; padding: 5px 2px; border: 0; border-radius: 6px; }
  .nav-item.selected { border: 0; background: var(--surface-2); }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-count { top: 5px; right: calc(50% - 24px); }
  .nav-alert { top: 8px; right: calc(50% - 21px); }
  .phase-banner { min-height: 84px; }
  .game-tab { min-height: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
