:root {
  color-scheme: dark;
  --ui: "Gowun Dodum", "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --serif: "Cinzel", "Palatino", "Bodoni 72", "Baskerville", Georgia, serif;
  --korean-serif: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", var(--serif);

  /* Clean Dark Broadcast Studio Chrome & Sidebar (Option B) */
  --bg: #0b0d14;
  --surface: #121520;
  --panel-bg: #0e111b;
  --panel-card: #151927;
  --text: #eef1f8;
  --muted: #939db6;
  --accent: #e8c77a;
  --rose: #b79ff7;
  --line: #252b3d;
  --rule: #e8c77a38;

  /* Deck A Celestial Royal Purple Stage Palette */
  --stage-bg: #100922;
  --stage-gold: #f4d384;
  --stage-text: #fbf4e6;
  --stage-muted: #cbbfe6;
  --paper: #f7ecd6;
  --ink: #24193d;

  --panel-width: 396px;
  font-family: var(--ui);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  overflow-x: clip;
}

body {
  min-width: 300px;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: radial-gradient(ellipse at 32% -12%, #2229424d 0, transparent 48rem), var(--bg);
}

button, select, input { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4, p, ol, ul { margin: 0; }
svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =========================================
   UNIFIED SHELL: LEFT 16:9 STAGE + SIDEBAR
   ========================================= */
.app-shell {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: hidden;
  position: relative;
}

body[data-panel="collapsed"] {
  --panel-width: 0px;
}

.stage-shell {
  min-width: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
}

.stage-frame {
  width: min(100%, calc((100vh - 28px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #3c2b66;
  box-shadow: 0 22px 54px #04050cc9, 0 0 0 1px #f4d3841f;
  background: var(--stage-bg);
}

/* =========================================
   16:9 CELESTIAL ROYAL PURPLE STAGE (1:1 WYSIWYG)
   ========================================= */
.stage-canvas {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  container-type: inline-size;
  background: var(--stage-bg);
}

.table {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 42%, #3f1d77 0%, #200f41 55%, #0f0820 100%);
}

.table::before,
.stage-canvas:has(.table[data-phase="complete"])::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background-image:
    radial-gradient(circle at 50% 46%, #a67bff2b 0%, transparent 48%),
    radial-gradient(ellipse at 12% 88%, #5b28a238 0%, transparent 42%),
    radial-gradient(ellipse at 88% 88%, #5b28a238 0%, transparent 42%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='152' viewBox='0 0 96 152'%3E%3Cpath d='M48 0 L96 76 L48 152 L0 76 Z' fill='none' stroke='%23f4d384' stroke-opacity='0.14' stroke-width='0.9'/%3E%3Ccircle cx='48' cy='76' r='1.3' fill='%23f4d384' fill-opacity='0.22'/%3E%3Ccircle cx='0' cy='0' r='1.1' fill='%23f4d384' fill-opacity='0.18'/%3E%3C/svg%3E");
  background-size: 100% 100%, 100% 100%, 100% 100%, 72px 114px;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat;
  background-position: center;
  pointer-events: none;
}

.stage-canvas:has(.table[data-phase="complete"]) {
  background: radial-gradient(ellipse at 50% 42%, #3a1a6d 0%, #1c0e3a 58%, #0e071e 100%);
}

.table::after,
.stage-canvas:has(.table[data-phase="complete"])::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 9px;
  border: 1px solid #f4d3844a;
  border-radius: 4px;
  box-shadow: inset 0 0 0 3px #12092699, inset 0 0 0 4px #f4d38422;
  pointer-events: none;
}

.table-heading {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  padding: 18px 26px 0;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.table-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid #f4d38470;
  background: #27154ae6;
  color: var(--stage-gold);
  font-family: var(--korean-serif);
  font-size: clamp(0.68rem, 0.9cqw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.table[data-phase="clarifying"] .stage-badge {
  border-color: #cda2ff99;
  background: #3a1d6de6;
  color: #f0e3ff;
}

.table-heading h2 {
  color: var(--stage-text);
  font-family: var(--korean-serif);
  font-size: clamp(1.08rem, 2.25cqw, 1.54rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px #0b041aad;
}

.progress {
  text-align: right;
  color: var(--stage-gold);
  white-space: nowrap;
}

#progress-count {
  font: 400 clamp(1.1rem, 1.8cqw, 1.45rem)/1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.025em;
}

#progress-track {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
  max-width: 170px;
}

#progress-track i {
  width: 8px;
  height: 8px;
  border: 1px solid #f4d38478;
  transform: rotate(45deg) scale(0.78);
}

#progress-track .filled {
  background: var(--stage-gold);
  border-color: var(--stage-gold);
  box-shadow: 0 0 6px #f4d38466;
}

/* =========================================
   ARENA, 1-ROW / 2-ROW FAN & REMOTE POINTER
   ========================================= */
.arena {
  position: relative;
  isolation: isolate;
  flex: 1 1 0;
  min-height: 0;
  container-type: inline-size;
}

.fan {
  position: absolute;
  inset: 0;
  --card-width: clamp(54px, 9.2cqw, 220px);
  touch-action: manipulation;
}

.table[data-fan-rows="2"] .fan {
  --card-width: clamp(42px, 6.2cqw, 145px);
}

.table[data-phase="waiting"] .fan {
  --card-width: clamp(78px, 10.8cqw, 240px);
}

.fan-card {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: var(--card-width);
  aspect-ratio: 1024 / 1751;
  transform: translate(-50%, -50%);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 5px;
  background: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.fan-card:disabled { pointer-events: none; }
.fan-card.extracted { visibility: hidden; pointer-events: none; }
.fan-card:focus-visible { z-index: 140 !important; outline-offset: 2px; }
.fan[data-motion] .fan-card { will-change: transform, opacity; }

.card-back,
.card-front {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
}

.card-back {
  display: grid;
  place-items: center;
  pointer-events: none;
  background: url("cards/card_back.webp") center / 100% 100% no-repeat, url("nocturne/back.webp") center / 100% 100% no-repeat, radial-gradient(ellipse at center, #3b1c6d, #150b2b);
  border: 1px solid #e6c274;
  color: var(--stage-gold);
  box-shadow: -2px 4px 12px #070312b8, 0 0 10px #9666ff24;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1), filter 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card-back > span { visibility: hidden; }
.card-back::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(125deg, #ffeec312, transparent 33%, transparent 65%, #12082648);
}

.table[data-phase="waiting"] .fan-card .card-back {
  border-color: #d9b25e;
  border-bottom-color: #f4d384;
  border-left-color: #caa052;
  box-shadow: -1px 1px 0 #130829;
}

.table[data-phase="waiting"] .fan-card:first-child .card-back {
  box-shadow: -7px 14px 24px #05020ee8, -2px 6px 11px #090318cc;
}

.table[data-phase="waiting"] .fan-card:last-child .card-back {
  border-color: #f4d384;
  box-shadow: -1px 2px 4px #120726b8, 0 0 22px #f4d38436;
}

.table[data-phase="drawing"] .fan-card:not(.extracted) .card-back {
  filter: brightness(0.72) saturate(0.76);
}

@media (hover: hover) {
  .fan-card:enabled:hover .card-back {
    transform: translateY(-16%);
    filter: brightness(1.18);
    border-color: #ffeaad;
    box-shadow: -3px 8px 16px #070312d4, 0 0 12px #f4d3845e;
  }
}

.fan-card:enabled:focus-visible .card-back,
.fan-card.hand-hover .card-back,
.fan-card.remote-hover .card-back {
  transform: translateY(-16%);
  filter: brightness(1.18);
  border-color: #ffeaad;
  box-shadow: -3px 8px 16px #070312d4, 0 0 12px #f4d3845e;
}

/* Synchronized Starlight Pointer on Broadcast Screen */
.remote-pointer {
  position: absolute;
  z-index: 200;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff5d4;
  font-size: 16px;
  line-height: 1;
  text-shadow: 0 0 10px #f4d384, 0 0 18px #c39bff;
  background: radial-gradient(circle, #f4d3844d 0%, #9b6cff24 46%, transparent 72%);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.75);
  transition: left 30ms linear, top 30ms linear, opacity 160ms ease, transform 160ms ease;
}

.remote-pointer[data-active="true"] {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.fan-hover-indicator {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 3.2cqw, 26px);
  z-index: 160;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  font-family: var(--korean-serif);
  font-size: clamp(0.88rem, 1.5cqw, 1.18rem);
  font-weight: 400;
  letter-spacing: 0.14em;
  color: rgba(255, 252, 255, 0.68);
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.44),
    0 0 18px rgba(236, 228, 255, 0.28),
    0 0 30px rgba(208, 192, 255, 0.16);
  opacity: 0;
  transform: translate(-50%, 6px) scale(0.97);
  filter: blur(4px);
  transition:
    opacity 0.24s ease,
    transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.24s ease;
}

.fan-hover-indicator::before {
  content: "";
  position: absolute;
  inset: -10px -28px;
  z-index: -1;
  border-radius: 999px;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 252, 255, 0.16) 0%,
    rgba(235, 226, 255, 0.07) 44%,
    transparent 74%
  );
  filter: blur(9px);
  pointer-events: none;
}

.fan-hover-indicator[data-active="true"] {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  filter: blur(0.15px);
}

.fan-hover-indicator[data-active="true"]::before {
  animation: mistDrift 4.6s ease-in-out infinite;
}

@keyframes mistDrift {
  0%, 100% {
    opacity: 0.85;
    transform: scale(0.98, 0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.06, 1.04);
  }
}

.table[data-fan-rows="2"] .fan-hover-indicator {
  bottom: clamp(4px, 1.1cqw, 10px);
  font-size: clamp(0.76rem, 1.18cqw, 0.96rem);
}

.table:not([data-phase="ready"]):not([data-phase="clarifying"]) .fan-hover-indicator {
  opacity: 0 !important;
}

.fan-hover-num {
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  font-size: 1.08em;
  color: rgba(255, 255, 255, 0.82);
  letter-spacing: 0.04em;
  margin-right: 0.06em;
}

.fan-hover-row {
  color: rgba(244, 236, 255, 0.62);
  letter-spacing: 0.08em;
  margin-right: 0.14em;
}

.fan-hover-total {
  font-size: 0.84em;
  color: rgba(235, 228, 250, 0.48);
  letter-spacing: 0.06em;
  margin-left: 0.2em;
}

/* =========================================
   SPREAD TRAY & COMPLETE EXPANSION (BOTH VIEWS)
   ========================================= */
.spread-tray {
  flex: 0 0 28%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px 22px 8px;
  background: linear-gradient(180deg, #130c25, #0e0a1b);
  border-top: 1px solid #f4d38433;
}

.slots-scroll {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.slots {
  --slot-width: clamp(38px, 4.4cqw, 64px);
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  width: max-content;
  gap: 10px clamp(10px, 1.8cqw, 26px);
  margin: 0 auto;
  padding: 2px 4px;
}

.slot-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.slot-cluster {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.slot {
  width: var(--slot-width);
  min-width: 0;
  text-align: center;
}

.slot.slot-detail { width: calc(var(--slot-width) * 0.9); }
.slot.slot-clarifier { width: calc(var(--slot-width) * 0.86); }

.slot-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1024 / 1751;
  border-radius: 5px;
  border: 1px solid #9677c852;
  background: #231442a6;
  color: #b7a9d9;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.slot-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid #f4d38433;
  border-radius: 2px;
  pointer-events: none;
}

.slot-frame > span {
  font: 400 1.25rem/1 var(--serif);
}

.slot.next .slot-frame {
  border-color: var(--stage-gold);
  color: var(--stage-gold);
  background: #311b5d;
  box-shadow: 0 0 18px #f4d38438;
}

.slot.slot-clarifier.slot-placeholder .slot-frame {
  border-style: dashed;
  border-color: var(--rose);
  color: #f3e4ff;
  background: #2f1a57;
  animation: pulseSlot 1.3s ease-in-out infinite;
}

@keyframes pulseSlot {
  0%, 100% { box-shadow: 0 0 0 0 #b79ff72e; }
  50% { box-shadow: 0 0 16px 2px #b79ff759; }
}

.slot.has-card .slot-frame {
  border: none;
  background: transparent;
  box-shadow: none;
}

.slot.has-card .slot-frame::before { display: none; }

.slot-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 9px;
  color: var(--stage-muted);
  font-family: var(--korean-serif);
  font-size: clamp(0.68rem, 1.05cqw, 0.9rem);
  line-height: 1.3;
  letter-spacing: 0.03em;
  word-break: keep-all;
}

.slot.next .slot-name { color: var(--stage-gold); font-weight: 600; }

.slot-mini-tag {
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid #f4d38452;
  color: var(--stage-gold);
  background: #211342;
}

.slot-clarifier .slot-mini-tag {
  border-color: #b79ff766;
  color: #eadfff;
}

.slot.has-card .slot-frame {
  perspective: 780px;
}

.slot-card {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: inherit;
  background: none;
  box-shadow: 0 6px 16px #050210bd, 0 0 12px #8e5cff22;
  transform: translateY(var(--ty, 0px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.slot-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at var(--mx, 50%) var(--my, 50%), #fff8de70, #f4d3842b 35%, transparent 68%);
  mix-blend-mode: screen;
  transition: opacity 0.18s ease;
}

.slot-card.is-tilting {
  transition: transform 0.08s ease-out, box-shadow 0.18s ease;
  box-shadow: 0 14px 28px #050210e6, 0 0 22px #f4d38452;
}

.slot-card.is-tilting::after {
  opacity: 1;
}

@media (hover: hover) {
  .slot-card:not(.is-tilting):hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px #050210de, 0 0 16px #f4d38440;
  }
}

/* Complete phase expands drawn spread identically on Operator & Audience */
.table[data-phase="complete"] {
  flex: 0 0 auto;
  min-height: 0;
  background: transparent;
}

.table[data-phase="complete"]::before,
.table[data-phase="complete"]::after,
.table[data-phase="complete"] .arena {
  display: none;
}

.table[data-phase="complete"] .table-heading {
  padding: 14px 24px 0;
}

.table[data-phase="complete"] + .spread-tray {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: transparent;
  border-top: 0;
  padding: 8px 24px 16px;
}

.table[data-phase="complete"] + .spread-tray .slots-scroll {
  justify-content: center;
  overflow-y: auto;
}

.table[data-phase="complete"] + .spread-tray .slots {
  width: auto;
  max-width: 100%;
  flex-wrap: wrap;
  justify-content: center;
  --slot-width: clamp(64px, 9.2cqw, 140px);
  gap: 10px clamp(10px, 1.4cqw, 20px);
  animation: display-spread 0.42s cubic-bezier(0.15, 0.7, 0.25, 1) both;
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="1"] {
  --slot-width: clamp(132px, 20.5cqw, 296px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="2"] {
  --slot-width: clamp(124px, 19.5cqw, 282px);
  gap: 16px clamp(22px, 3.6cqw, 52px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="3"] {
  --slot-width: clamp(116px, 18.6cqw, 268px);
  gap: 14px clamp(18px, 3cqw, 44px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="4"] {
  --slot-width: clamp(108px, 17.5cqw, 250px);
  gap: 14px clamp(16px, 2.4cqw, 34px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="5"] {
  --slot-width: clamp(94px, 14.8cqw, 212px);
  gap: 12px clamp(14px, 2cqw, 28px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="6"] {
  --slot-width: clamp(82px, 12.6cqw, 182px);
  gap: 12px clamp(12px, 1.6cqw, 22px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-density="7"] {
  --slot-width: clamp(72px, 10.4cqw, 152px);
  gap: 10px clamp(10px, 1.3cqw, 18px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-spread="choice"] {
  width: max-content;
  display: grid;
  grid-template-columns: repeat(3, auto);
  align-items: center;
  justify-content: center;
  --slot-width: clamp(70px, 9.2cqw, 140px);
  gap: 10px clamp(14px, 2.2cqw, 32px);
}

.table[data-phase="complete"] + .spread-tray .slots[data-spread="choice"] .slot-group:first-child {
  grid-row: span 2;
}

.table[data-phase="complete"] + .spread-tray .slot-name {
  margin-top: 16px;
  gap: 6px;
  font-family: var(--korean-serif);
  font-size: clamp(0.82rem, 1.3cqw, 1.08rem);
  letter-spacing: 0.04em;
  color: #f6effe;
  font-weight: 700;
}

@keyframes display-spread {
  from { opacity: 0.35; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   CARD FRONT ARTWORK & PIPS
   ========================================= */
.card-front {
  container-type: inline-size;
  aspect-ratio: 1024 / 1751;
  padding: 4.5%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #d5ae68;
}

.card-front.reversed { transform: rotate(180deg); }
.card-front.has-original { padding: 0; border-color: #f4d38466; background: #140b29; }
.original-art { display: block; width: 100%; height: 100%; object-fit: contain; }

.face-print {
  position: relative;
  display: grid;
  grid-template-rows: 1fr 6.25fr 1.1fr;
  align-items: stretch;
  height: 100%;
  border: 1px solid #59397a;
  overflow: hidden;
  background: repeating-linear-gradient(101deg, transparent 0 2px, #351b5a08 2px 3px), #f6e9cf;
}

.face-rank {
  display: grid;
  place-items: center;
  font: 700 10cqw/1 var(--serif);
  letter-spacing: 0.07em;
}

.face-art {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-block: 1px solid #59397a;
  background: radial-gradient(ellipse at center, #3b1c6d, #160b2e);
}

.face-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
}

.face-art::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 3%;
  border: 1px solid #ffe4ad5c;
  pointer-events: none;
}

.narrow-art::before {
  content: "";
  position: absolute;
  inset: -5%;
  background: var(--card-image) center / cover;
  filter: blur(8px) brightness(0.28);
}

.narrow-art img {
  position: relative;
  width: auto;
  max-width: 100%;
  margin-inline: auto;
  object-fit: contain;
  mask-image: linear-gradient(90deg, transparent, black 8%, black 92%, transparent);
}

.pip-art img { filter: brightness(0.45) saturate(0.7); }

.face-pips {
  position: absolute;
  inset: 0;
  padding: 11% 8%;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  background: radial-gradient(ellipse at center, #180d31a6, #110824b3);
}

.pip-row { display: flex; align-items: center; justify-content: center; gap: 7%; }
.pip-row i {
  display: block;
  width: min(22%, 32cqw);
  aspect-ratio: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--pip-image) center / 170% auto;
  box-shadow: 0 1px 4px #080416dc;
}
.pip-row:has(i:nth-child(4)) { gap: 4%; }

.face-name {
  display: grid;
  place-items: center;
  padding: 0 3%;
  text-align: center;
  font: 700 7.6cqw/1 var(--serif);
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.face-backup {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--stage-gold);
  font: 500 42cqw/1 var(--serif);
}

/* =========================================
   RIGHT COLLAPSIBLE DARK-STUDIO SIDEBAR
   ========================================= */
.edge-panel-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border: 1px solid #3d4868;
  border-right: none;
  border-radius: 8px 0 0 8px;
  background: #141826f2;
  color: var(--accent);
  box-shadow: -4px 6px 22px #04060cb8;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.16s ease;
}

.edge-panel-tab:hover { background: #1e2438; }

.edge-text {
  writing-mode: vertical-rl;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
}

body[data-panel="open"] .edge-panel-tab {
  opacity: 0;
  pointer-events: none;
  transform: translate(16px, -50%);
}

.streamer-panel {
  width: var(--panel-width);
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  transition: width 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

body[data-panel="collapsed"] .streamer-panel {
  border-left: none;
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  min-width: min(396px, 92vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #121622;
  flex-shrink: 0;
}

.panel-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.wordmark {
  display: flex;
  gap: 7px;
  align-items: center;
  color: #f3f5fc;
  font: 650 0.92rem/1 var(--serif);
  letter-spacing: 0.18em;
}

.wordmark-star {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid #e8c77a54;
  background: #171c2b;
  color: var(--accent);
  border-radius: 50%;
  font-size: 13px;
  letter-spacing: 0;
}

.version-pill {
  font-family: var(--ui);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
  border: 1px solid #363f59;
  background: #1a1f30;
  border-radius: 999px;
  padding: 2px 7px;
}

.off-air-badge {
  font-size: 0.66rem;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid #3a4461;
  background: #1a2031;
  color: #b5c0de;
  white-space: nowrap;
}

.panel-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.panel-icon-btn {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #2e364f;
  border-radius: 6px;
  background: #161b29;
  color: #cbd5ee;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.panel-icon-btn svg {
  width: 17px;
  height: 17px;
}

.panel-icon-btn:hover {
  border-color: var(--accent);
  background: #20283d;
  color: var(--accent);
  transform: translateY(-0.5px);
}

.panel-broadcast-btn .status-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #616d8a;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

.panel-broadcast-btn.is-connected {
  border-color: #74e28b78;
  background: #162621;
  color: #b4f4c0;
}

.panel-broadcast-btn.is-connected .status-dot {
  background: #74e28b;
  box-shadow: 0 0 7px #74e28bcc;
}

.panel-audio-btn.is-open {
  border-color: #e8c77a99;
  background: #242b42;
  color: var(--accent);
}

.panel-audio-btn.is-muted {
  color: var(--muted);
}

.panel-audio-btn.is-muted .spk-waves {
  display: none;
}

.panel-audio-btn:not(.is-muted) .spk-mute {
  display: none;
}

.fallback-close-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #2e364f;
  border-radius: 4px;
  background: #161b29;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}

.fallback-close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panel-scroll {
  min-width: min(396px, 92vw);
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
}

.panel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.panel-section-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.tray-status-pill {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1c2235;
  border: 1px solid #323c57;
  color: #d6deef;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Action Controls inside Sidebar */
.action-card {
  background: linear-gradient(180deg, #171c2c, #131725);
  border-color: #2f3852;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-status {
  font-size: 0.79rem;
  line-height: 1.45;
  color: #d5ddf0;
  word-break: keep-all;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.shuffle-button,
.reset-button,
.clarify-button,
.clarify-cancel-button {
  flex: 1 1 auto;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 5px;
  padding: 6px 11px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.16s, box-shadow 0.16s, transform 0.16s, border-color 0.16s, color 0.16s;
}

.shuffle-button {
  border: 1px solid #e8c77a;
  background: linear-gradient(135deg, #f0d28b, #d8b35e);
  color: #1c152e;
  box-shadow: 0 4px 14px #0608128c;
}

.shuffle-button:enabled:hover {
  background: linear-gradient(135deg, #fae0a0, #e5c16d);
  transform: translateY(-1px);
}

.shuffle-button:enabled:active { transform: translateY(1px); }
.shuffle-button:disabled { opacity: 0.55; }

.reset-button {
  border: 1px solid #3c4666;
  background: #1a2033;
  color: #d6def2;
}

.reset-button svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reset-button:enabled:hover {
  border-color: var(--accent);
  background: #232b42;
  color: var(--accent);
  transform: translateY(-1px);
}

.reset-button:enabled:active { transform: translateY(1px); }
.reset-button:disabled { opacity: 0.42; }

body:has(.table:is([data-phase="ready"], [data-phase="drawing"])) .shuffle-button {
  background: #1d2336;
  border-color: #3a4563;
  color: var(--accent);
  box-shadow: none;
}

.clarify-button {
  flex: 1 1 100%;
  border: 1px solid #f4d3848a;
  background: linear-gradient(135deg, #4a2682, #2b1554);
  color: #fff6dc;
}

.clarify-button:enabled:hover {
  border-color: var(--stage-gold);
  background: linear-gradient(135deg, #5a3099, #361b66);
  transform: translateY(-1px);
}

.clarify-button:disabled { opacity: 0.55; }

.clarify-cancel-button {
  border: 1px solid #414c6b;
  background: #181d2c;
  color: var(--muted);
}

.clarify-cancel-button:enabled:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Setup Card inside Sidebar */
.sidebar-details {
  display: flex;
  flex-direction: column;
}

.sidebar-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.sidebar-summary::-webkit-details-marker { display: none; }

.sidebar-summary-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sidebar-summary-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.summary-chevron {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--accent);
  transition: transform 0.18s ease;
}

.sidebar-details:not([open]) .summary-chevron {
  transform: rotate(-90deg);
}

.setup-fields {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.control-label {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.deck-mode-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  background: #0c0f18;
  padding: 3px;
  border: 1px solid #2a3147;
  border-radius: 5px;
}

.deck-mode-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 30px;
  padding: 4px 5px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 560;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.deck-mode-btn:enabled:hover {
  color: var(--text);
  background: #1b2133;
}

.deck-mode-btn.is-active {
  background: #232a40;
  border-color: #e8c77a66;
  color: var(--accent);
  font-weight: 680;
}

.deck-mode-btn:disabled { opacity: 0.55; }

.rec-badge {
  font-size: 0.58rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  background: #e8c77a24;
  border: 1px solid #e8c77a5e;
  color: var(--accent);
  font-weight: 650;
}

.question-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.setup-field select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  padding: 6px 24px 6px 9px;
  border: 1px solid #2c334a;
  border-radius: 5px;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) calc(100% - 13px) 50% / 5px 5px no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) calc(100% - 8px) 50% / 5px 5px no-repeat,
    #0d1019;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  min-height: 34px;
  cursor: pointer;
  text-overflow: ellipsis;
}

.setup-field select:enabled:hover {
  border-color: #e8c77a6e;
  color: var(--accent);
}

.setup-field select:disabled { opacity: 0.58; cursor: default; }
.setup-field option { color: var(--text); background: var(--surface); }

.custom-mode-btn {
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #353f5e;
  border-radius: 5px;
  background: #191f30;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 620;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.custom-mode-btn:enabled:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.custom-mode-btn[aria-pressed="true"] {
  background: #272245;
  border-color: var(--accent);
  color: var(--accent);
}

.custom-mode-btn:disabled { opacity: 0.55; }

.custom-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 5px;
  background: #10131e;
  border: 1px solid #2b3248;
}

.custom-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.custom-field label {
  font-size: 0.7rem;
  color: var(--muted);
}

.custom-field select,
.custom-field input {
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid #2f3750;
  border-radius: 4px;
  background: #0b0e17;
  color: var(--text);
  font-size: 0.8rem;
}

.custom-field input::placeholder { color: #677290; }

.custom-note {
  font-size: 0.71rem;
  color: var(--rose);
  line-height: 1.4;
  word-break: keep-all;
}

.sidebar-spread-detail {
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
  word-break: keep-all;
}

/* Broadcast Card */
.broadcast-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.broadcast-status {
  font-size: 0.71rem;
  color: var(--muted);
  text-align: right;
}

.broadcast-status.is-connected {
  color: #9ce6a8;
  font-weight: 600;
}

.broadcast-actions {
  display: flex;
  gap: 6px;
}

.broadcast-button {
  flex: 1;
  min-height: 35px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid #e8c77a5c;
  border-radius: 5px;
  padding: 5px 10px;
  color: var(--accent);
  background: #1c2236;
  font-size: 0.8rem;
  font-weight: 650;
  transition: all 0.16s ease;
}

.broadcast-button:enabled:hover {
  border-color: var(--accent);
  background: #252c44;
}

.broadcast-focus-btn {
  min-height: 35px;
  padding: 0 10px;
  border: 1px solid #384361;
  border-radius: 5px;
  background: #191f30;
  color: var(--text);
  font-size: 0.76rem;
  white-space: nowrap;
}

.broadcast-focus-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.broadcast-sub-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.broadcast-sub-btn {
  min-height: 30px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #323c58;
  border-radius: 5px;
  background: #141928;
  color: #cbd4eb;
  font-size: 0.74rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.broadcast-sub-btn:hover {
  border-color: var(--accent);
  background: #1e253b;
  color: var(--accent);
}

.broadcast-sub-btn.is-copied {
  border-color: #74e28b80;
  background: #162822;
  color: #a8f0b7;
}

.broadcast-sub-btn.is-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #e8c77a38;
  color: #fff3d2;
}

.broadcast-hint {
  margin-top: 7px;
  font-size: 0.71rem;
  line-height: 1.45;
  color: #8791ab;
  word-break: keep-all;
}

/* Combined Audio & BGM Card */
.audio-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audio-sfx-row,
.bgm-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-toggle,
.bgm-toggle-btn {
  min-height: 30px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid #353f5e;
  border-radius: 4px;
  background: #1a2033;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 620;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.sound-toggle:hover,
.bgm-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sound-toggle[aria-pressed="true"],
.bgm-toggle-btn[aria-pressed="true"] {
  background: #252e47;
  border-color: #e8c77a78;
  color: var(--accent);
}

:is(.sound-toggle, .bgm-toggle-btn)[aria-pressed="false"] .sound-on,
:is(.sound-toggle, .bgm-toggle-btn)[aria-pressed="true"] .sound-off {
  display: none;
}

.volume-slider {
  flex: 1;
  width: auto;
  min-width: 60px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.volume-label {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}

.audio-divider {
  height: 1px;
  background: var(--line);
}

.bgm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bgm-track-name {
  font-size: 0.71rem;
  color: var(--muted);
  max-width: 215px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: right;
}

.bgm-track-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  background: #0c0f18;
  padding: 3px;
  border: 1px solid #2a3147;
  border-radius: 5px;
}

.bgm-track-btn {
  min-height: 28px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 560;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.bgm-track-btn:hover {
  color: var(--text);
  background: #1b2133;
}

.bgm-track-btn.is-active {
  background: #232a40;
  border-color: #e8c77a66;
  color: var(--accent);
  font-weight: 680;
}

.bgm-file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bgm-mini-btn {
  min-height: 27px;
  padding: 2px 9px;
  border: 1px solid #2b334a;
  border-radius: 4px;
  background: #10131e;
  color: var(--muted);
  font-size: 0.72rem;
  transition: all 0.16s ease;
}

.bgm-mini-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.bgm-mini-btn.is-active {
  background: #232a40;
  border-color: #e8c77a66;
  color: var(--accent);
  font-weight: 640;
}

/* Mode Banner & Balance Summary */
.mode-banner-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: #171c2b;
  border-color: #323b54;
}

.mode-banner-card.is-custom {
  border-color: #5b498c;
  background: #18172b;
}

.mode-banner-title {
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--text);
}

.mode-banner-desc {
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
  word-break: keep-all;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-headline {
  font-size: 0.8rem;
  line-height: 1.45;
  color: #f3e4bd;
  font-weight: 600;
  word-break: keep-all;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.summary-chip {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0f131f;
  border: 1px solid #2f3852;
  color: var(--muted);
}

.element-bars {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
}

.el-bar-item { display: flex; flex-direction: column; gap: 3px; }
.el-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.71rem;
  color: var(--muted);
}
.el-bar-track {
  height: 5px;
  border-radius: 999px;
  background: #0d1019;
  overflow: hidden;
}
.el-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.summary-tip {
  font-size: 0.74rem;
  line-height: 1.48;
  color: #cdd5ea;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  word-break: keep-all;
}

/* Guide Cards */
.guide-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guide-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.guide-count { font-size: 0.74rem; color: var(--muted); }
.guide-list { display: flex; flex-direction: column; gap: 9px; }

.guide-empty {
  padding: 16px 13px;
  border: 1px dashed #2e3750;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
  word-break: keep-all;
}

.guide-card {
  background: var(--panel-card);
  border: 1px solid #283044;
  border-radius: 6px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.guide-card.is-detail { border-left: 3px solid var(--accent); }
.guide-card.is-clarifier { border-left: 3px solid var(--rose); }

.guide-card-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.guide-pos-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.guide-pos-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: #21283d;
  color: var(--accent);
}

.guide-dir-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #37415e;
  color: #c7d0e8;
}

.guide-dir-badge.is-reversed {
  border-color: #b79ff778;
  color: #e6daff;
  background: #251e42;
}

.guide-el-badge { font-size: 0.68rem; color: var(--muted); }
.guide-card-title { margin-top: 3px; font-family: var(--korean-serif); font-size: 0.96rem; font-weight: 700; letter-spacing: 0.01em; color: #f4f7ff; }
.guide-card-eng { font-size: 0.72rem; font-family: var(--serif); color: #95a0bd; }
.guide-card-actions { display: flex; gap: 5px; flex-shrink: 0; }

.guide-mini-btn {
  min-height: 25px;
  padding: 2px 8px;
  border: 1px solid #35405c;
  border-radius: 4px;
  background: #1c2233;
  color: var(--text);
  font-size: 0.7rem;
  white-space: nowrap;
}

.guide-mini-btn:enabled:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.guide-mini-btn:disabled { opacity: 0.45; }

.guide-keywords { display: flex; flex-wrap: wrap; gap: 4px; }
.guide-keyword {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: #0f131f;
  border: 1px solid #2c354c;
  color: #e8d5a3;
}

.guide-block {
  font-size: 0.77rem;
  line-height: 1.5;
  color: #d4dbef;
  word-break: keep-all;
}

.guide-block-label {
  display: block;
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--rose);
  margin-bottom: 2px;
}

.guide-script {
  padding: 7px 9px;
  border-radius: 5px;
  background: #101420;
  border: 1px solid #2f3852;
  font-size: 0.75rem;
  line-height: 1.48;
  color: #f5dfb0;
  word-break: keep-all;
}

/* =========================================
   FLIGHT ANIMATION & SPOTLIGHT DIALOG
   ========================================= */
#flight-layer {
  position: fixed;
  z-index: 40;
  inset: 0;
  pointer-events: none;
  perspective: 1000px;
}

#flight-layer.is-skippable {
  pointer-events: auto;
  cursor: pointer;
}

.flight-veil { position: absolute; inset: 0; opacity: 0; background: #080514de; }
.flying-card {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 7px;
  transform-style: preserve-3d;
  will-change: transform;
}
.flying-card .card-front { border-radius: inherit; }
.flying-card .original-art,
.flying-card .face-art img { image-rendering: auto; }
.flight-face { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flight-front { transform: rotateY(180deg); box-shadow: 0 12px 38px #050210bd; }
.flight-front::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(120deg, transparent 26%, #fff4cf 49%, transparent 66%);
  opacity: var(--foil-active, 0);
  mix-blend-mode: screen;
}

.flight-title {
  position: absolute;
  transform: translate(-50%, 0);
  color: #fbf4e6;
  text-align: center;
  text-shadow: 0 3px 12px #090316;
  font-family: var(--korean-serif);
  font-size: clamp(1.12rem, 1.8vw, 1.46rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.flight-title small {
  display: block;
  margin-top: 5px;
  font-family: var(--ui);
  color: var(--stage-gold);
  font-size: clamp(0.8rem, 1.15vw, 0.96rem);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.flight-skip-hint {
  display: block;
  margin-top: 8px;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 500;
  color: #cbbfe6cc;
  letter-spacing: 0.01em;
}

body[data-view="audience"] .flight-skip-hint {
  display: none;
}

.reveal-ring {
  position: absolute;
  border-radius: 50%;
  aspect-ratio: 1;
  opacity: 0;
  border: 1px solid #f4d3849f;
  box-shadow: 0 0 40px #a67bff4a, inset 0 0 54px #8d5cff35;
  background: radial-gradient(circle, #f4d38424, transparent 65%), repeating-conic-gradient(from 0deg, #f4d3841a 0 1deg, transparent 1deg 15deg);
  mask-image: radial-gradient(ellipse, transparent 0, #000 40%, #000 70%, transparent 71%);
}

.reveal-ring::before,
.reveal-ring::after {
  content: "";
  position: absolute;
  inset: 7%;
  border: 1px dashed #f4d38494;
  border-radius: 50%;
}

.reveal-ring::after { inset: 15%; border-style: solid; opacity: 0.5; }

.reveal-spark {
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 30%;
  opacity: 0;
  background: #fff2c4;
  box-shadow: 0 0 8px 2px #f4d38482;
}

.landing-light {
  position: absolute;
  width: 85px;
  aspect-ratio: 1;
  border: 1px solid #f4d384;
  border-radius: 50%;
  box-shadow: 0 0 19px #f4d38466, inset 0 0 18px #b79ff766;
  animation: landing 0.5s ease-out both;
}

@keyframes landing {
  from { transform: translate(-50%, -50%) scale(0.5); opacity: 0.6; }
  to { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}

dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 22px;
  border: 1px solid #f4d38452;
  border-radius: 8px;
  background: radial-gradient(ellipse at 25% 15%, #231445, #120c24 72%);
  color: var(--text);
  box-shadow: 0 24px 80px #04010ed6;
}

dialog::backdrop { background: #080514db; backdrop-filter: blur(5px); }
.dialog-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; }
#inspect-position { color: var(--stage-gold); font-size: 0.92rem; font-weight: 650; }
.icon-button.close {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #49387a;
  border-radius: 5px;
  background: #1b1236;
  color: var(--stage-muted);
  font: 400 1.45rem/1 var(--serif);
}
.icon-button.close:hover { border-color: var(--stage-gold); color: var(--stage-gold); }
.inspect-body { display: grid; grid-template-columns: 0.85fr 1fr; gap: 24px; align-items: center; }
.inspect-art { perspective: 850px; border-radius: 7px; }
.inspect-foil {
  position: relative;
  border-radius: inherit;
  aspect-ratio: 1024 / 1751;
  transition: transform 0.22s ease;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  box-shadow: 0 14px 34px #060212cc, 0 0 24px #8d5cff24;
}
.inspect-foil::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at var(--mx, 50%) var(--my, 50%), #fff8de66, #f4d38428 34%, transparent 66%);
  mix-blend-mode: screen;
  transition: opacity 0.2s;
}
@media (hover: hover) { .inspect-foil:hover::after { opacity: 1; } }
.inspect-art.is-tilting .inspect-foil {
  transition: transform 0.08s ease-out;
}
.inspect-art.is-tilting .inspect-foil::after {
  opacity: 1;
}
.inspect-copy h2 { margin-top: 4px; font-family: var(--korean-serif); font-size: clamp(1.6rem, 4.2vw, 2.45rem); line-height: 1.25; letter-spacing: 0.01em; color: #fbf5ff; }
.inspect-subtitle { font: 500 1rem/1.45 var(--serif); color: var(--stage-muted); margin-top: 4px; }
.inspect-keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.inspect-keywords span {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: #1d1438;
  border: 1px solid #49387a;
  color: #f4dfae;
}

/* =========================================
   RESPONSIVE BREAKPOINTS
   ========================================= */
@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .stage-shell {
    padding: 10px;
  }
  .stage-frame {
    width: min(100%, calc((100vh - 20px) * 16 / 9));
  }
  .streamer-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(396px, 92vw);
    z-index: 35;
    box-shadow: -12px 0 40px #04060ed9;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  }
  body[data-panel="collapsed"] .streamer-panel {
    transform: translateX(102%);
  }
}

@media (max-width: 760px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .stage-shell {
    height: auto;
    min-height: 100vh;
    padding: 8px;
  }
  .stage-frame {
    width: 100%;
    aspect-ratio: auto;
  }
  body:not([data-view="audience"]) .stage-canvas { height: auto; overflow: visible; }
  body:not([data-view="audience"]) .table { flex: none; }
  body:not([data-view="audience"]) .table-heading { min-height: 60px; padding: 14px 14px 0; }
  body:not([data-view="audience"]) .arena { flex: none; height: clamp(220px, 50vw, 300px); }
  body:not([data-view="audience"]) .table[data-fan-rows="2"] .arena { height: clamp(265px, 56vw, 355px); }
  body:not([data-view="audience"]) .table[data-fan-rows="2"] .fan { --card-width: clamp(38px, 9cqw, 64px); }
  body:not([data-view="audience"]) .spread-tray { flex: none; padding: 12px 12px 16px; }
  body:not([data-view="audience"]) .slots-scroll { overflow: visible; }
  body:not([data-view="audience"]) .slots { flex-wrap: wrap; width: auto; --slot-width: clamp(54px, 14.5vw, 74px); gap: 14px 9px; }
  .inspect-body { grid-template-columns: 1fr; gap: 16px; }
  .inspect-art { width: min(56%, 200px); margin-inline: auto; }
}

/* =========================================
   DUAL-WINDOW SEPARATED AUDIENCE VIEW (16:9)
   ========================================= */
body[data-view="audience"] {
  background: #0c0718;
  height: 100vh;
  overflow: hidden;
}

body[data-view="audience"] .app-shell {
  grid-template-columns: minmax(0, 1fr);
  height: 100vh;
}

body[data-view="audience"] :is(
  .dialog-top form,
  .streamer-panel,
  .edge-panel-tab
) {
  display: none !important;
}

body[data-view="audience"] .stage-shell {
  height: 100vh;
  padding: 0;
}

body[data-view="audience"] .stage-frame {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  border: none;
  border-radius: 0;
  box-shadow: none;
}

body[data-view="audience"] .slot-card { pointer-events: none; }

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