/* G8L-211 P2-C lobby: the stage is the whole page, the player's game background (body, fixed) shows through where no film is. */
#lobby.panel.active { display: block; }
.lobby-stage { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
/* A click on the film plays its shock segment, so the stage must be hit-testable: it sits at z-index 0 beneath the chrome,
 * which is all positioned (the top bar is fixed at z-index 30, P1-A), so nothing needs lifting. */
.lobby-stage.lobby-scene { background: center / cover no-repeat var(--lobby-poster, none); }
/* A reaction clip (the film's chest tap, film-stage react) lies over the film, invisible until its reaction plays; film-stage sets the transition length. */
.lobby-stage > video.lobby-film-reaction { opacity: 0; transition: opacity 0.2s ease-out; }
.lobby-stage > video.lobby-film-reaction.is-on { opacity: 1; }
/* Every showcase video (sin films and NPC stages) fills the stage; a sin film also carries its own object-position. */
.lobby-stage > video, .lobby-stage.kafra-film-scene > video.kafra-film { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
/* A portrait film in a box wider than itself (film-stage sets the whole-frame rectangle on the videos): the sides are a small canvas of the same film, enlarged, blurred and dimmed.
 * It runs past the stage so the blur has no soft edge. The flash and the quake are the shock of a portrait film without a cutout; film-stage drives the opacity from the video's clock. */
.lobby-stage > canvas.lobby-film-backdrop { position: absolute; left: -40px; top: -40px; width: calc(100% + 80px); height: calc(100% + 80px); object-fit: cover; filter: blur(24px) brightness(0.45); pointer-events: none; }
.lobby-stage > canvas.lobby-film-backdrop[hidden] { display: none; }
.lobby-stage > canvas.lobby-film-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lobby-stage > .lobby-film-flash { position: absolute; inset: 0; opacity: 0; background: radial-gradient(circle, #fff 0, #fff 30%, rgb(255 255 255 / 60%) 100%); pointer-events: none; }
.lobby-stage.lobby-film-impact.lobby-quake { animation: lobby-impact-quake 0.6s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
/* Enlarged a little throughout, so the shift never bares the page behind the stage. */
@keyframes lobby-impact-quake {
  0%, 100% { transform: none; }
  12% { transform: translate(-5px, 3px) scale(1.03); }
  28% { transform: translate(5px, -4px) scale(1.03); }
  44% { transform: translate(-4px, -2px) scale(1.03); }
  60% { transform: translate(3px, 3px) scale(1.03); }
  80% { transform: translate(-2px, 1px) scale(1.02); }
}

/* Controls: top left, under the top bar. Two keys (眾神殿, 隱藏) drawn like the bottom bar's keys (.ui-key, mobile-nav.css); 眾神殿 unfolds the glass flyout to its right. */
.lobby-controls {
  position: fixed;
  z-index: 15;
  left: max(4px, var(--edge-x), env(safe-area-inset-left));
  top: calc(var(--top-bar-group-h, 58px) + var(--nav-strip-h, 0px) + var(--top-edge) + 8px); /* under the top bar's real height (two capsule rows), not the 44px --top-bar-h */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--card-gap);
}
/* Short landscape screens (height <= 300px): a column of two would run under the bottom bar, so the same keys sit in one row. */
@media (max-height: 300px) { .lobby-controls { flex-direction: row; align-items: center; } }
.lobby-flyout {
  position: absolute;
  left: calc(64px + 6px);
  top: 0;
  max-height: calc(100dvh - var(--top-bar-group-h, 58px) - var(--nav-strip-h, 0px) - var(--top-edge) - 8px - var(--bottom-reserve));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--card-gap);
}
.lobby-flyout[hidden], .lobby-list[hidden] { display: none; }
/* The three mode buttons: dark text on the glass (the keys on the film are light text; the glass is light). */
.lobby-panel { display: flex; padding: 4px; border-radius: 22px; }
.lobby-pane-btn {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  width: 58px;
  min-height: 52px;
  padding: 2px 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--glass-ink, #1c2a3a);
  font: 600 11px/1.1 var(--glass-font, sans-serif);
  cursor: pointer;
}
.lobby-pane-ico svg { display: block; width: 28px; height: 28px; }
.lobby-pane-btn.is-on { background: rgb(255 255 255 / 55%); }
/* A greyed-out look is gone (r3c): 我的角色 is as bright as the others and only announces 即將開放 when tapped. */
.lobby-list {
  box-sizing: border-box;
  width: min(264px, calc(100vw - 64px - 6px - 64px - 2px)); /* right edge stays left of the right rail (64px) */
  max-height: min(60dvh, calc(100dvh - var(--top-bar-h) - var(--bottom-bar-h) - var(--top-edge) - var(--bottom-edge) - 120px));
  padding: 4px;
  border-radius: 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--glass-ink, #1c2a3a);
  font: 600 14px/1.2 var(--glass-font, sans-serif);
}
.lobby-row { display: flex; align-items: center; border-radius: 14px; }
.lobby-item, .lobby-back {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #fff;
  /* Fixed white ink and a zero-blur black edge, independent of the playing film. */
  text-shadow: -1px -1px 0 #000, 0 -1px 0 #000, 1px -1px 0 #000, -1px 0 0 #000, 1px 0 0 #000, -1px 1px 0 #000, 0 1px 0 #000, 1px 1px 0 #000;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.lobby-item:active, .lobby-back:active, .lobby-pane-btn:active { background: rgb(255 255 255 / 45%); }
.lobby-item[aria-current="true"] { background: rgb(255 255 255 / 55%); }
.lobby-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-item-text { display: flex; flex: 1; flex-direction: column; gap: 1px; min-width: 0; }
.lobby-item-text > .lobby-item-label { flex: none; }
.lobby-item-tag { font-size: 10px; font-weight: 500; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-item-now { flex: none; font-size: 11px; font-weight: 700; opacity: 0.8; }
.lobby-item-more { flex: none; font-size: 18px; opacity: 0.7; }
.lobby-back { gap: 10px; min-height: 40px; }
.lobby-back-arrow { flex: none; font-size: 12px; opacity: 0.8; }
.lobby-back-name { font-weight: 700; }
/* Fixed size so a late-loading poster never moves the rows. */
.lobby-thumb { flex: none; display: block; width: 44px; height: 28px; border-radius: 6px; object-fit: cover; background: rgb(28 42 58 / 20%); }
/* 貢獻 frame: the current guardian's card (name, 貢獻, level bar) and the number pad / confirm step under it (the list rows carry no 貢獻). Layout only: no fill or shadow of its own (the glass look is another piece of work). */
.lobby-card { flex-direction: column; gap: 6px; box-sizing: border-box; width: min(264px, calc(100vw - 64px - 6px - 64px - 2px)); padding: 8px 10px; }
.lobby-card[hidden] { display: none; }
.lobby-card-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lobby-card-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.lobby-contrib {
  flex: none; display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 0 8px;
  border: 0; border-radius: 14px; background: rgb(255 255 255 / 30%); color: inherit; font: 600 12px/1 var(--glass-font, sans-serif);
}
.lobby-contrib:active { background: rgb(255 255 255 / 55%); }
.lobby-contrib-coin { flex: none; width: 16px; height: 16px; object-fit: contain; }
.lobby-dialog { flex-direction: column; box-sizing: border-box; width: min(264px, calc(100vw - 64px - 6px - 64px - 2px)); padding: 10px; color: var(--glass-ink, #1c2a3a); font: 600 14px/1.2 var(--glass-font, sans-serif); }
.lobby-dialog[hidden], .lobby-calc[hidden], .lobby-confirm[hidden] { display: none; }
.lobby-flyout.is-dialog > :is(.lobby-modes, .lobby-list) { display: none; } /* the pad takes the place of the buttons and the list while it is open */
.lobby-calc, .lobby-confirm { display: flex; flex-direction: column; gap: 8px; }
.lobby-calc-title { font-size: 12px; opacity: 0.8; }
.lobby-calc-display { min-height: 36px; padding: 0 10px; border-radius: 12px; background: rgb(28 42 58 / 18%); font: 700 22px/36px var(--glass-font, sans-serif); text-align: right; letter-spacing: 1px; }
.lobby-calc-display.is-empty::before { content: '0'; opacity: 0.35; }
.lobby-calc-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.lobby-calc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lobby-calc-key { min-height: 40px; border: 0; border-radius: 14px; background: rgb(255 255 255 / 30%); color: inherit; font: inherit; cursor: pointer; }
.lobby-calc-key:active { background: rgb(255 255 255 / 55%); }
.lobby-calc-key.is-fn { font-size: 13px; }
.lobby-calc-key.is-ok { background: #f2b43c; }
.lobby-calc-key:disabled { opacity: 0.4; cursor: default; }
.lobby-confirm-text { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; line-height: 1.5; }
.lobby-dialog-coin { flex: none; width: 18px; height: 18px; object-fit: contain; }
.lobby-level { display: flex; align-items: center; gap: 6px; }
.lobby-level-lv { flex: none; font-size: 11px; font-weight: 700; }
.lobby-level-track { flex: 1; height: 6px; border-radius: 3px; overflow: hidden; background: rgb(28 42 58 / 25%); }
.lobby-level-fill { height: 100%; background: #f2b43c; }
.lobby-hint {
  position: fixed;
  z-index: 16;
  left: 50%;
  bottom: calc(var(--bottom-bar-h) + var(--bottom-edge) + 16px);
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 14px;
  border-radius: 20px;
  font: 600 12px/1.2 var(--glass-font, sans-serif);
  color: var(--glass-ink, #1c2a3a);
  opacity: 0;
  pointer-events: none;
}
.lobby-hint.show { animation: lobby-hint-fade 2.4s ease-out forwards; }
@keyframes lobby-hint-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
/* Glass that floats over the film is more see-through than the shared 30%: the one shared fill (--glass-pane-fill, game-glass.css) is set here
 * and nowhere else, on the lobby's glass pieces only (the avatar, the flyout; the top bar's round buttons and text capsules use the dark --glass-icon-fill / --glass-chip-fill). Other pages keep the default. */
body.lobby-live :is(#game > #topBar .top-bar-avatar, .lobby-panel, .lobby-list, .lobby-hint) {
  --glass-pane-fill: rgb(255 255 255 / 16%);
}

/* The lobby's chrome: top bar, chat icon (expanded or not), bottom bar with 更多, right rail, and the controls above.
 * Two states act on it through variables set on <body>: the eye (hidden) and the shock segment (stepped back: smaller and
 * darker, "buttons in the background, the film in front"). Defaults are `none`/1 so nothing is touched outside those states
 * (a filter, or opacity below 1, on a container would turn it into the backdrop root of its glass children).
 * Prefers-reduced-motion dims but does not scale. P1-A/D/E name their parts: the top bar #topBar.top-bar, #chatDock(Toggle),
 * .side-rail. */
body.lobby-live :is(#game > #topBar.top-bar, #game .tabs, #chatDock, #chatDockToggle, #lobby .side-rail, #lobby .lobby-controls > :not(.lobby-hint)) {
  transform: var(--lobby-chrome-transform, none);
  filter: var(--lobby-chrome-filter, none);
  opacity: var(--lobby-chrome-opacity, 1);
  visibility: var(--lobby-chrome-visibility, visible);
  transition: transform 0.35s ease, filter 0.35s ease, opacity var(--lobby-chrome-fade, 0.35s) ease;
}
/* pointer-events is set only while the eye is closed: a default `auto` here would outrank (the :is() above weighs as its heaviest part, two ids)
 * the bar's and the top bar's own `pointer-events: none` containers, and give them back the taps they pass to the page. */
body.lobby-live.lobby-eye-off :is(#game > #topBar.top-bar, #game .tabs, #chatDock, #chatDockToggle, #lobby .side-rail, #lobby .lobby-controls > :not(.lobby-hint)) { pointer-events: var(--lobby-chrome-events, auto); }
body.lobby-shock-back {
  --lobby-chrome-transform: scale(0.82);
  --lobby-chrome-filter: brightness(0.6);
  --lobby-chrome-opacity: 0.55;
}
/* A portrait film without a cutout, from its hit to its return: the UI leaves altogether, the film has the screen. The fade lengths are film-stage's RECEDE_IN and RECEDE_OUT; the return one
 * (lobby-shock-fade) stays set after the class is gone. Opacity, not visibility, so the fade is seen; the taps go to the stage meanwhile. */
body.lobby-shock-fade { --lobby-chrome-fade: 0.2s; }
body.lobby-shock-hide { --lobby-chrome-opacity: 0; --lobby-chrome-fade: 0.12s; }
body.lobby-live.lobby-shock-hide :is(#game > #topBar.top-bar, #game .tabs, #chatDock, #chatDockToggle, #lobby .side-rail, #lobby .lobby-controls > :not(.lobby-hint)) { pointer-events: none; }
body.lobby-live.lobby-shock-hide :is(#game > #topBar.top-bar, #game .tabs, #chatDock, #chatDockToggle, #lobby .side-rail, #lobby .lobby-controls > :not(.lobby-hint)) * { pointer-events: none; }
body.lobby-live.lobby-shock-hide :is(.lobby-hint, .side-rail-hint, #petCompanion, .pet-reaction-message) { opacity: 0; pointer-events: none; animation: none; }   /* a hint's own fade would outrank this opacity */
body.lobby-shock-hide .lobby-controls { pointer-events: none; }
/* The bar's bottom gradient (P1-I, ::after) is a child of the scaled bar: stepped back it would show as a faint box. It fades out instead. */
body.lobby-live #game .tabs::after { transition: opacity 0.35s ease; }
body.lobby-shock-back #game .tabs::after { opacity: 0; }
body.lobby-eye-off {
  --lobby-chrome-opacity: 0;
  --lobby-chrome-visibility: hidden;
  --lobby-chrome-events: none;
}
/* Hidden mode suppresses asynchronous chrome, never system dialogs or their actions. */
body.lobby-live.lobby-eye-off :is(.lobby-hint, .side-rail-hint, #worldMapArrivalToast, #supportDebugBanner, #petCompanion, .pet-reaction-message, .skill-tree-tooltip, .csr-edge-particles, #topBarCharacter, #topBarMenu, #worldMapOverlay, #worldMapDetail, #worldMapDetailBackdrop, #worldMapConfirm, #worldMapTravelCinematic, #cardArtPreview, #cardMergeDialog, #characterResetConfirm, #connectionLock, #chatChannelSettings, .service-entry-cinematic, .world-tree-travel-overlay, .town-service-surface, .town-service-quantity, .hs-sheet, .csr-stage, .service-audio-open, .odin-eye-open):not(dialog, [role="dialog"], [role="alertdialog"], #stateStreamTakenDialog, dialog *, [role="dialog"] *, [role="alertdialog"] *, #stateStreamTakenDialog *),
body.lobby-live.lobby-eye-off :is(#game > #topBar, #game .tabs, #chatDock, #chatDockToggle, #lobby .side-rail, .lobby-hint, .side-rail-hint, #worldMapArrivalToast, #supportDebugBanner, #petCompanion) :not(dialog, [role="dialog"], [role="alertdialog"], #stateStreamTakenDialog, dialog *, [role="dialog"] *, [role="alertdialog"] *, #stateStreamTakenDialog *) {
  visibility: hidden !important;
  pointer-events: none !important;
}
body.lobby-eye-off .lobby-controls { pointer-events: none; }
/* The return key is reachable only until its replaceable three-second deadline. */
body.lobby-eye-off #lobby .lobby-controls > .lobby-eye {
  --lobby-chrome-opacity: 0.8;
  --lobby-chrome-visibility: visible;
  --lobby-chrome-events: auto;
}
body.lobby-eye-off #lobby .lobby-controls > .lobby-eye.is-autohidden {
  --lobby-chrome-visibility: hidden;
  --lobby-chrome-opacity: 0;
  --lobby-chrome-events: none;
  transition: none;
}
@media (prefers-reduced-motion: reduce) {
  body.lobby-shock-back { --lobby-chrome-transform: none; }
}

/* P3 breakout: the cutout of a sin's shock frame sits over the whole UI (above the bottom bar, z 20, below sheets, z 1000) for the
 * shock segment only, so the buttons stay behind it. Geometry and transform are set by film-stage from the film's own camera. */
.lobby-cutout { position: fixed; z-index: 40; max-width: none; pointer-events: none; user-select: none; }
.lobby-cutout[hidden] { display: none; }
/* Depth separation (shock segment, only while a cutout is up): dim the full-viewport film without shrinking it and exposing its rectangular edges.
 * The cutout floats over the buttons and film with a soft shadow. No blur. film-stage sets --breakout-k (0-1) on the video; scale and filter only. */
:root { --breakout-recede-scale: 1; --breakout-recede-brightness: 0.8; --breakout-shadow: 0 10px 18px rgb(0 0 0 / 45%); }
.lobby-film-recede {
  scale: calc(1 - (1 - var(--breakout-recede-scale)) * var(--breakout-k, 0));
  filter: brightness(calc(1 - (1 - var(--breakout-recede-brightness)) * var(--breakout-k, 0)));
}
/* Finite cutout canvases can enter the viewport during camera motion: fade their alpha into the film, not a hard rectangle. */
.lobby-cutout {
  --breakout-cutout-feather: 3%;
  --breakout-cutout-mask: linear-gradient(to right, transparent, #000 var(--breakout-cutout-feather)),
    linear-gradient(to left, transparent, #000 var(--breakout-cutout-feather)),
    linear-gradient(to bottom, transparent, #000 var(--breakout-cutout-feather)),
    linear-gradient(to top, transparent, #000 var(--breakout-cutout-feather));
  -webkit-mask-image: var(--breakout-cutout-mask);
  mask-image: var(--breakout-cutout-mask);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
  filter: drop-shadow(var(--breakout-shadow));
}
