/* Familiar 3x4 table, stretched to fill the viewport without scrolling. */
.table-page {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-topbar {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) var(--page-gutter) 6px;
  border-bottom: var(--hairline);
  background: #0b0b0d;
}
.table-brand { display: flex; align-items: center; gap: 9px; }
.crest { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(162,28,54,0.55); border-radius: 10px; color: var(--accent-text); background: #151115; }
.crest .icon { width: 18px; height: 18px; }
.table-brand strong { font-size: 12px; letter-spacing: 0.16em; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; align-items: center; gap: 1px; }
.ghost-icon { width: 32px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: #ded7d2; }
.ghost-icon .icon { width: 18px; height: 18px; }
.ghost-icon.is-off { color: #ff5b6e; }
.ghost-icon.is-on { color: #3ddc84; }
.ghost-icon:hover { background: rgba(255,255,255,0.06); }
.spectator-pill { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 4px; color: #ded7d2; font-size: 11px; font-variant-numeric: tabular-nums; }
.spectator-pill .icon { width: 15px; height: 15px; color: #ded7d2; }
.signal-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; margin: 0 3px 0 1px; }
.signal-bars i { display: block; width: 3px; border-radius: 1px 1px 0 0; background: #3b3b40; transition: background-color 160ms ease; }
.signal-bars i:nth-child(1) { height: 5px; }
.signal-bars i:nth-child(2) { height: 9px; }
.signal-bars i:nth-child(3) { height: 13px; }
.signal-bars[data-level="3"] i { background: #4ade80; }
.signal-bars[data-level="2"] i:nth-child(-n+2) { background: #facc15; }
.signal-bars[data-level="1"] i:nth-child(1) { background: #ff5b6e; }
.signal-bars[data-level="0"] i { background: #5a2a32; }
.live-pill { padding: 5px 7px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }
.sound-meter { position: absolute; z-index: 2; left: 0; right: 0; bottom: -1px; height: 3px; background: rgba(61,220,132,0.09); pointer-events: none; }
.sound-meter span { display: block; height: 100%; width: 0; border-radius: 0 3px 3px 0; background: linear-gradient(90deg, #16a34a, #4ade80, #bbf7d0); box-shadow: 0 0 8px rgba(74,222,128,0.5); transition: width 90ms linear; }
/* Spectators watch other players' media but do not publish their own devices. */
.table-page.is-spectator #open-camera,
.table-page.is-spectator #toggle-mic-top,
.table-page.is-spectator .sound-meter { display: none; }

.table-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px var(--page-gutter) 0;
}
.oval-outline {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(96vw, 620px);
  height: min(92%, 560px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(212,172,91,0.09);
  border-radius: 50%;
  pointer-events: none;
}
.seat-grid {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}
.center-filler { display: none; }
.table-center { grid-column: 2; grid-row: 2 / span 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
.center-circle {
  width: 100%;
  aspect-ratio: 1;
  max-width: 146px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #211c20, #0e0d0f 70%);
  text-align: center;
}
.phase-icon { width: 17px; height: 17px; color: var(--gold); }
.phase-name { font-family: var(--font-serif); font-size: 17px; font-weight: 600; }
.speaker-line { max-width: 100%; overflow: hidden; color: var(--text-muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.timer { margin-top: 1px; font-size: clamp(20px, 6.5vw, 28px); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.center-action { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: #ded7d2; font-size: 11px; }
.center-action .icon { width: 14px; height: 14px; }

.seat-slot {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #111012;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.seat-slot::after { content: none; }
.seat-head { position: absolute; z-index: 3; inset: 5px 5px auto; display: flex; align-items: center; gap: 4px; }
.seat-number { width: 17px; height: 17px; display: grid; place-items: center; flex: none; border: 1px solid #555055; border-radius: 50%; background: rgba(8,8,10,0.85); color: #cfc7c2; font-size: 9px; font-variant-numeric: tabular-nums; }
.seat-name-wrap { min-width: 0; flex: 1; }
.seat-name { display: inline-block; max-width: 100%; overflow: hidden; font-size: 10px; font-weight: 600; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
.seat-flags { margin-left: auto; display: flex; align-items: center; gap: 2px; flex: none; }
.seat-flags .icon { width: 12px; height: 12px; color: #b8b0ad; }
.mic-shell { position: relative; width: 12px; height: 12px; display: grid; place-items: center; }
.mic-meter { position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; overflow: hidden; border-radius: 2px; background: #2a2a2e; }
.mic-meter-fill { display: block; width: 0; height: 100%; background: #4ade80; transition: width 90ms linear; }
.seat-slot[data-mic="on"] [data-flag="mic"] { color: #ded7d2; }
.seat-slot.mic-active [data-flag="mic"] { color: #86efac; filter: drop-shadow(0 0 4px rgba(74,222,128,0.85)); }
.seat-frame { position: absolute; inset: 0; display: grid; place-items: center; }
.seat-avatar { width: 42px; height: 42px; font-size: 14px; }
.seat-role { position: absolute; z-index: 2; bottom: 5px; left: 0; right: 0; color: #8c8689; font-size: 9px; text-align: center; }
.seat-slot video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.seat-slot.has-video .seat-frame { display: none; }
.seat-slot.has-video .seat-name { text-shadow: 0 1px 4px #000; }
.seat-slot.has-video .seat-name-wrap { position: absolute; z-index: 4; inset: auto 0 0; padding: 12px 5px 4px; background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent); }
.seat-slot.is-speaking { border-color: #e5ddd2; box-shadow: 0 0 0 1px rgba(245,239,232,0.3); }
.seat-slot.is-speaking::before { content: ""; position: absolute; z-index: 5; inset: 0; border-radius: inherit; background: conic-gradient(from 0deg, var(--gold) var(--speak-progress, 0deg), transparent 0); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; padding: 2px; pointer-events: none; }
.seat-slot.is-dead { opacity: 0.55; background: repeating-linear-gradient(135deg, #141315 0 6px, #0e0d0f 6px 12px); }
.seat-slot.is-dead .seat-avatar { filter: grayscale(1); }
.seat-slot.is-empty { border-style: dashed; border-color: #333033; background: rgba(10,10,12,0.45); }
.seat-slot.is-offline .seat-avatar { opacity: 0.45; }
.seat-slot .seat-state { position: absolute; z-index: 3; bottom: 5px; right: 5px; color: #8c8689; font-size: 8px; text-transform: uppercase; letter-spacing: 0.06em; }

.table-footnote {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px var(--page-gutter) calc(8px + var(--safe-bottom));
  color: var(--text-muted);
  font-size: 11px;
}
.demo-tag { padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; }

.copy-link { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: none; color: var(--accent-text); font-size: 11px; }
.copy-link .icon { width: 13px; height: 13px; }

.side-panel { position: fixed; z-index: 75; inset: auto 0 0; max-height: 62vh; display: flex; flex-direction: column; padding: 12px var(--page-gutter) calc(20px + var(--safe-bottom)); border: 1px solid var(--border); border-bottom: 0; border-radius: 20px 20px 0 0; background: var(--surface); animation: sheet-up 200ms ease; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: var(--hairline); }
.panel-head strong { font-size: 14px; }
.panel-body { overflow: auto; padding-top: 10px; }
.chat-empty { color: var(--text-muted); font-size: 12px; text-align: center; padding: 28px 0; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #0f0f11; color: var(--text); font-size: 13px; }
.chat-form button { padding: 0 14px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 13px; }
.log-entry { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(43,41,45,0.6); color: #cfc8c4; font-size: 12px; }
.log-entry time { color: #777176; font-variant-numeric: tabular-nums; }
.host-row { display: grid; gap: 8px; margin-top: 10px; }
.host-row p { color: var(--text-muted); font-size: 12px; }
.host-step { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #121214; font-size: 12px; }

.host-dock { position: fixed; z-index: 76; inset: auto 8px calc(8px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding: 10px; border: 1px solid var(--border); border-radius: 18px; background: rgba(16,16,18,0.96); backdrop-filter: blur(14px); }
.host-dock[hidden] { display: none; }
.host-button { min-height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-raised); font-size: 11px; }
.host-button.danger { grid-column: 1 / -1; border-color: rgba(162,28,54,0.6); color: var(--accent-text); }
.host-toggle { position: fixed; z-index: 75; right: 12px; bottom: calc(12px + var(--safe-bottom)); display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-raised); font-size: 11px; }
.host-toggle .icon { width: 14px; height: 14px; }

.media-preview { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,0.78); }
.preview-card { width: min(100%, 380px); padding: 16px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.preview-head strong { font-size: 15px; }
.preview-card video { width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; background: #050506; object-fit: cover; transform: scaleX(-1); }
.preview-card p { margin-top: 10px; color: var(--text-muted); font-size: 12px; }
.preview-controls { display: flex; gap: 8px; margin: 12px 0; }
.preview-toggle { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border: 1px solid var(--border); border-radius: 10px; background: #111113; font-size: 12px; }
.preview-toggle.is-off { color: #777176; border-color: #3a363a; }
.preview-toggle .icon { width: 15px; height: 15px; }
.preview-card .text-link { display: block; margin: 12px auto 0; }

@media (max-width: 370px) {
  .seat-grid { gap: 6px; }
  .center-circle { max-width: 126px; }
  .seat-avatar { width: 36px; height: 36px; }
  .seat-name { max-width: 54px; font-size: 9px; }
  .table-stage { padding-inline: 10px; }
}

@media (min-width: 768px) {
  .table-page { padding-inline: 24px; }
  .table-topbar { margin-inline: -24px; padding-inline: 24px; }
  .table-stage { padding-inline: 0; }
  .seat-grid { max-width: 720px; gap: 10px; }
  .seat-name { max-width: 110px; font-size: 11px; }
  .seat-avatar { width: 54px; height: 54px; font-size: 16px; }
  .center-circle { max-width: 170px; }
  .side-panel { inset: 68px 24px 24px auto; width: 320px; max-height: none; border-radius: 18px; border-bottom: 1px solid var(--border); }
  .host-dock { inset: auto 24px 24px auto; width: 320px; }
  .host-toggle { right: 24px; bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .side-panel { animation: none; }
}
