/* Two soft opening accents, confined to the existing glass edge and woofers.
   Outline/unused ::after do not replace the speakers' ongoing beat animation. */
.table-arena[data-open-flash]::after{
  outline:2px solid transparent;outline-offset:2px;
  animation:ktv-open-edge-a 1200ms ease-in-out both;
}
.table-arena[data-open-flash=b]::after{animation-name:ktv-open-edge-b}
.ktv-stage[data-open-flash] .speaker-woofer::after{
  content:'';position:absolute;inset:-23%;border:2px solid #a7fff5;border-radius:50%;
  opacity:0;pointer-events:none;box-shadow:0 0 8px #80f9e870,inset 0 0 5px #ba93ed45;
  animation:ktv-open-halo-a 1200ms ease-in-out both;
}
.ktv-stage[data-open-flash=b] .speaker-woofer::after{animation-name:ktv-open-halo-b}
@keyframes ktv-open-edge-a{0%,43%,100%{outline-color:#8ef9ef00;outline-offset:2px}18%{outline-color:#a7fff5b8;outline-offset:4px}68%{outline-color:#cdb2f4a3;outline-offset:4px}}
@keyframes ktv-open-edge-b{0%,43%,100%{outline-color:#8ef9ef00;outline-offset:2px}18%{outline-color:#a7fff5b8;outline-offset:4px}68%{outline-color:#cdb2f4a3;outline-offset:4px}}
@keyframes ktv-open-halo-a{0%,43%,100%{opacity:0;scale:.92}18%{opacity:.68;scale:1.04}68%{opacity:.55;scale:1.08}}
@keyframes ktv-open-halo-b{0%,43%,100%{opacity:0;scale:.92}18%{opacity:.68;scale:1.04}68%{opacity:.55;scale:1.08}}
body:is(.ktv-motion-off,.ktv-page-hidden) .table-arena[data-open-flash]::after{animation:none;outline-color:transparent}
body:is(.ktv-motion-off,.ktv-page-hidden) .ktv-stage[data-open-flash] .speaker-woofer::after{display:none;animation:none}
@media(prefers-reduced-motion:reduce){
  .table-arena[data-open-flash]::after{animation:none;outline-color:transparent}
  .ktv-stage[data-open-flash] .speaker-woofer::after{display:none;animation:none}
}

/* KTV overlays only. Keep the existing responsive grids, scrolling and controls. */
body:is(.depth-theme,.first-person-demo){
  --ktv-panel-bg:#101024;
  --ktv-panel-surface:#221637;
  --ktv-panel-text:#f7f6ff;
  --ktv-panel-muted:#b9b5d0;
  --ktv-panel-dim:#9894b5;
  --ktv-panel-line:#b9a8e32e;
  --ktv-panel-pink:#ee64d8;
  --ktv-panel-cyan:#64e4ee;
}

/* The lobby owns its complete layout and palette in lobby-ui.css. */
body:is(.depth-theme,.first-person-demo).in-lobby{background:#101426;color:var(--ktv-panel-text)}

/* Shared modal surfaces; these selectors also beat later dynamic stylesheets. */
body:is(.depth-theme,.first-person-demo) :is(.dialog,.social-dialog,.lobby-wallet-dialog){
  --social-cream:var(--ktv-panel-text);--social-muted:var(--ktv-panel-muted);--social-line:var(--ktv-panel-line);
  color:var(--ktv-panel-text);border-color:#c9a7e451;
  background:radial-gradient(ellipse at 90% 0,#ee64d812,transparent 55%),linear-gradient(150deg,#28203e,#17192e 72%);
  box-shadow:inset 0 1px 0 #fff3ff17,0 28px 90px #040411b8,0 0 30px #bc68df09;
  scrollbar-color:#8971ac66 transparent;color-scheme:dark;
}
body:is(.depth-theme,.first-person-demo) :is(.dialog,.social-dialog,.lobby-wallet-dialog)::backdrop{background:#060615b8;backdrop-filter:blur(9px);-webkit-backdrop-filter:blur(9px)}
body:is(.depth-theme,.first-person-demo) :is(.dialog h2,.social-dialog .social-dialog-header h2,.lobby-wallet-top h2){color:var(--ktv-panel-text);text-shadow:none}
body:is(.depth-theme,.first-person-demo) :is(.dialog>.section-index,.dialog .section-index,.social-eyebrow,.lobby-wallet-top .lobby-eyebrow){color:#bfa8de}
body:is(.depth-theme,.first-person-demo) :is(.dialog>p,.dialog .result-panel p,.dialog .rules-list p,.dialog .match-score){color:var(--ktv-panel-muted)}
body:is(.depth-theme,.first-person-demo) .dialog .settings-note{color:var(--ktv-panel-muted)!important}
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close){color:#e5ddf5;border-color:#c7b9e333;background:#242139;box-shadow:inset 0 1px 0 #ffffff0d}
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close):hover{color:#fff;border-color:#ee64d880;background:#3d2949}
body:is(.depth-theme,.first-person-demo) :is(.game-lobby,.dialog,.social-dialog,.lobby-wallet-dialog) :is(button,a,input,select):focus-visible{outline:2px solid var(--ktv-panel-cyan);outline-offset:3px}
body:is(.depth-theme,.first-person-demo) :is(.social-primary-button,.dialog .primary-button){
  color:#fff5fe;border-color:#ee64d885;background:linear-gradient(150deg,#a7369d,#753282);
  box-shadow:inset 0 1px 0 #ffc9f33b,0 2px 0 #3e1a54,0 5px 16px #ee64d812;text-shadow:none;
}
body:is(.depth-theme,.first-person-demo) :is(.social-primary-button,.dialog .primary-button):hover:not(:disabled){background:linear-gradient(150deg,#b240a9,#843b90);border-color:#f59ae7}
body:is(.depth-theme,.first-person-demo) :is(.social-primary-button,.dialog .primary-button):not(:disabled):active{background:#74317d;box-shadow:inset 0 2px 4px #240d353d,0 1px 0 #3e1a54}
body:is(.depth-theme,.first-person-demo) :is(.social-primary-button,.dialog .primary-button):disabled{box-shadow:inset 0 1px 0 #ffffff14;text-shadow:none}
body:is(.depth-theme,.first-person-demo) :is(.dialog .challenge-button,.dialog .quiet-button,.social-soft-button){color:#ebe6f7;border-color:#a89dc547;background:linear-gradient(145deg,#2b263f,#212138);box-shadow:inset 0 1px 0 #ffffff0c;text-shadow:none}
body:is(.depth-theme,.first-person-demo) :is(.dialog .challenge-button,.dialog .quiet-button,.social-soft-button):hover:not(:disabled){color:#fff;border-color:#64e4ee73;background:#293345}
body:is(.depth-theme,.first-person-demo) :is(.dialog .challenge-button[aria-pressed=true],.social-soft-button[aria-expanded=true]){color:#cbfbff;border-color:#64e4ee87;background:#213c49;box-shadow:inset 0 0 0 1px #64e4ee0c}
body:is(.depth-theme,.first-person-demo) .dialog .challenge-button:disabled{box-shadow:none;text-shadow:none}
body:is(.depth-theme,.first-person-demo) :is(.lobby-error,.lobby-wallet-error){color:#ffd0e1;border-color:#ed83b455;background:#5c284433}

/* Rules, settings, activity and result sheets. Table dice are deliberately untouched. */
body:is(.depth-theme,.first-person-demo) .dialog .rules-list li{color:var(--ktv-panel-pink)}
body:is(.depth-theme,.first-person-demo) .dialog .rules-list strong{color:#eee9f7}
body:is(.depth-theme,.first-person-demo) .dialog .rules-note{border-color:var(--ktv-panel-line)}
body:is(.depth-theme,.first-person-demo) .dialog .activity-tabs button{color:var(--ktv-panel-muted);border-color:var(--ktv-panel-line);background:#1b1b30;box-shadow:none}
body:is(.depth-theme,.first-person-demo) .dialog .activity-tabs button[aria-pressed=true]{color:#fff1fc;border-color:#ee64d885;background:linear-gradient(145deg,#4a2954,#30233f);box-shadow:inset 0 1px 0 #ffffff0e}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-panel{color:#d9d3e8;background:transparent;border-color:var(--ktv-panel-line);box-shadow:none}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-panel h2{color:var(--ktv-panel-text)}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-panel :is(.panel-heading>span,.history-empty){color:var(--ktv-panel-muted)}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-panel li{color:#d1cce2;border-color:#ada1c51f}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-panel li>strong{color:#ebc0e8}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-avatar{color:#cceff5;border-color:#64e4ee3b;background:#203343}
body:is(.depth-theme,.first-person-demo) .history-dialog .history-panel li:first-child .history-avatar{color:#ffe0f8;border-color:#ee64d861;background:#442444}
body:is(.depth-theme,.first-person-demo) .dialog .result-summary{color:#ddd5ec;border-color:#b598d63d;background:#1b1a31;box-shadow:inset 0 1px 0 #ffffff08}
body:is(.depth-theme,.first-person-demo) .dialog .result-summary strong{color:var(--ktv-panel-cyan)}
body:is(.depth-theme,.first-person-demo) .dialog .reveal-player-name{color:#ded9ec}
body:is(.depth-theme,.first-person-demo) .dialog .reveal-player-name strong{color:var(--ktv-panel-pink)}
body:is(.depth-theme,.first-person-demo) .dialog .die.matched{outline-color:var(--ktv-panel-cyan)}

/* Wallet: readable totals and local test-coin activity. */
body:is(.depth-theme,.first-person-demo) .lobby-wallet-available{color:#f8f6ff;border-color:#b085d14d;background:linear-gradient(145deg,#49305b,#29233f);box-shadow:inset 0 1px 0 #f0caff1c}
body:is(.depth-theme,.first-person-demo) .lobby-wallet-available>span{color:#d2c2e3}
body:is(.depth-theme,.first-person-demo) .lobby-wallet-table{border-color:#64e4ee30;background:linear-gradient(145deg,#22303e,#1c2236);box-shadow:inset 0 1px 0 #d0ffff0c}
body:is(.depth-theme,.first-person-demo) .lobby-wallet-table>strong{color:var(--ktv-panel-cyan)}
body:is(.depth-theme,.first-person-demo) :is(.lobby-wallet-table>span,.lobby-wallet-table>small,.lobby-topup>p,.lobby-wallet-footnote){color:var(--ktv-panel-muted)}
body:is(.depth-theme,.first-person-demo) :is(.lobby-topup h3,.lobby-ledger h3){color:var(--ktv-panel-text)}
body:is(.depth-theme,.first-person-demo) .lobby-topup-options button{color:#f0daed;border-color:#d086d34f;background:linear-gradient(145deg,#402a4b,#2b233d);box-shadow:inset 0 1px 0 #ffe5ff10}
body:is(.depth-theme,.first-person-demo) .lobby-topup-options button:hover:not(:disabled){border-color:#ee64d8ad;background:#4d2a53}
body:is(.depth-theme,.first-person-demo) .lobby-topup-options span{color:#c0abcd}
body:is(.depth-theme,.first-person-demo) .lobby-ledger-title button{color:var(--ktv-panel-cyan)}
body:is(.depth-theme,.first-person-demo) .lobby-ledger li{border-color:var(--ktv-panel-line)}
body:is(.depth-theme,.first-person-demo) .lobby-entry-icon{color:#c4bbdc;border-color:#ac9bce38;background:#2b253e}
body:is(.depth-theme,.first-person-demo) .lobby-entry-icon.is-credit{color:var(--ktv-panel-cyan);border-color:#64e4ee35;background:#203541}
body:is(.depth-theme,.first-person-demo) .lobby-entry-icon.is-debit{color:#ffb0d7;border-color:#ee64d838;background:#41273f}
body:is(.depth-theme,.first-person-demo) .lobby-entry-copy>strong{color:#e9e4f3}
body:is(.depth-theme,.first-person-demo) .lobby-entry-copy>span{color:var(--ktv-panel-muted)}
body:is(.depth-theme,.first-person-demo) .lobby-entry-copy>time{color:var(--ktv-panel-dim)}
body:is(.depth-theme,.first-person-demo) .lobby-entry-amount{color:#c6bfd9}
body:is(.depth-theme,.first-person-demo) .lobby-entry-amount.is-credit{color:var(--ktv-panel-cyan)}
body:is(.depth-theme,.first-person-demo) .lobby-entry-amount.is-debit{color:#f8a4d0}
body:is(.depth-theme,.first-person-demo) .lobby-ledger .lobby-ledger-empty{color:var(--ktv-panel-muted)}

/* Social sheets, without changing any avatar or bubble on the game table. */
body:is(.depth-theme,.first-person-demo) .social-dialog .social-avatar{background:linear-gradient(145deg,#554467,#312b48);box-shadow:inset 0 0 0 1px #d5bdeb47,0 2px 5px #06061055}
body:is(.depth-theme,.first-person-demo) .social-dialog .social-profile-avatar{border-color:#ee64d89c;box-shadow:0 0 0 3px #ee64d812,0 6px 20px #0b081b50}
body:is(.depth-theme,.first-person-demo) .social-avatar-fieldset legend{color:#ded6ed}
body:is(.depth-theme,.first-person-demo) .social-avatar-option{color:#d9d2e9;border-color:#b5a5d633;background:#171a2d;box-shadow:inset 0 1px 0 #ffffff08}
body:is(.depth-theme,.first-person-demo) .social-avatar-option:hover{border-color:#ee64d87a;background:#30223f}
body:is(.depth-theme,.first-person-demo) .social-avatar-option[aria-pressed=true]{color:#fff0fc;border-color:var(--ktv-panel-pink);background:linear-gradient(145deg,#50284f,#30243d);box-shadow:0 0 0 1px #ee64d86b,inset 0 1px 0 #ffcef01a}
body:is(.depth-theme,.first-person-demo) .social-avatar-check{color:#28112c;background:#f58cde}
body:is(.depth-theme,.first-person-demo) .social-text-button{color:var(--ktv-panel-cyan)}
body:is(.depth-theme,.first-person-demo) .social-feedback{color:#afe5e8}
body:is(.depth-theme,.first-person-demo) :is(.social-feedback.is-error,.social-character-count.is-error){color:#ffb2cb}
body:is(.depth-theme,.first-person-demo) .social-bubble-switch{color:#d4cde6}
body:is(.depth-theme,.first-person-demo) .social-bubble-switch input{accent-color:var(--ktv-panel-pink)}
body:is(.depth-theme,.first-person-demo) .social-messages{border-color:#ada0d02b;background:#0f12248c;scrollbar-color:#8f77b34d transparent}
body:is(.depth-theme,.first-person-demo) .social-message-avatar{border-color:#bca1da61}
body:is(.depth-theme,.first-person-demo) .social-message-meta{color:#d2c8e4}
body:is(.depth-theme,.first-person-demo) .social-message-meta time{color:var(--ktv-panel-dim)}
body:is(.depth-theme,.first-person-demo) .social-person-tag{color:#e5b9de;background:#ee64d817}
body:is(.depth-theme,.first-person-demo) .social-person-tag.is-bot{color:#ade6eb;background:#64e4ee12}
body:is(.depth-theme,.first-person-demo) .social-message-body:not(.is-sticker){color:#f0ebf8;border-color:#ada0d02e;background:#29263e;box-shadow:0 2px 4px #0506121f}
body:is(.depth-theme,.first-person-demo) .social-message.is-mine .social-message-body:not(.is-sticker){color:#fff3fe;border-color:#d47bc75e;background:linear-gradient(135deg,#653165,#433053);box-shadow:inset 0 1px 0 #ffc8f00d}
body:is(.depth-theme,.first-person-demo) .social-chat-empty{color:var(--ktv-panel-muted)}
body:is(.depth-theme,.first-person-demo) .social-chat-empty strong{color:#e9d8f0}
body:is(.depth-theme,.first-person-demo) .social-character-count{color:var(--ktv-panel-dim)}
body:is(.depth-theme,.first-person-demo) :is(.social-sticker-panel,.social-quick-panel){border-color:var(--ktv-panel-line);background:#15182b}
body:is(.depth-theme,.first-person-demo) .social-sticker-panel button{color:#d9cee8}
body:is(.depth-theme,.first-person-demo) .social-sticker-panel button:hover{border-color:#ee64d859;background:#ee64d812}
body:is(.depth-theme,.first-person-demo) .social-quick-panel button{color:#e8e1f4;border-color:#b3a1d140;background:#29243e}
body:is(.depth-theme,.first-person-demo) .social-quick-panel button:hover{color:#fff;border-color:#64e4ee80;background:#253d48}
body:is(.depth-theme,.first-person-demo) .social-composer input{color:#f5f2ff;border-color:#b4a2d24d;background:#111529;caret-color:var(--ktv-panel-cyan)}
body:is(.depth-theme,.first-person-demo) .social-composer input::placeholder{color:#a6a0bc}

/* Toasts belong to the same overlay layer; no table geometry is changed here. */
body:is(.depth-theme,.first-person-demo) :is(.network-notice,.mp-toast){color:#f0e5fa;border-color:#c290df70;background:linear-gradient(145deg,#362545,#1d2135);box-shadow:inset 0 1px 0 #ffedff12,0 8px 22px #04051166;text-shadow:none}

@media(prefers-reduced-motion:reduce){
  body:is(.depth-theme,.first-person-demo) :is(.game-lobby,.dialog,.social-dialog,.lobby-wallet-dialog) *{transition:none!important}
}

/* The close target has its own geometry; font baselines never position the X. */
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close),
body #social-chat-dialog.social-compact-chat .social-close{
  position:relative;display:inline-grid;place-items:center;align-self:center;
  flex:0 0 44px;width:44px;min-width:44px;max-width:44px;
  height:44px;min-height:44px;max-height:44px;margin:0;padding:0;
  border-radius:12px;box-sizing:border-box;overflow:hidden;
  appearance:none;-webkit-appearance:none;font-size:0!important;line-height:0!important;
}
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close)::before,
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close)::after{
  content:'';position:absolute;left:50%;top:50%;width:19px;height:2px;
  border-radius:2px;background:currentColor;pointer-events:none;
  transform:translate(-50%,-50%) rotate(45deg);
}
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close)::after{
  transform:translate(-50%,-50%) rotate(-45deg);
}
body:is(.depth-theme,.first-person-demo) :is(.dialog .close-button,.social-close,.lobby-wallet-close):not(:disabled):active{
  transform:none;
}

/* Full-width sticky headers keep the close control available during scrolling. */
body:is(.depth-theme,.first-person-demo) :is(.dialog:has(>.dialog-top),.social-dialog:not(.social-compact-chat),.lobby-wallet-dialog){
  --modal-header-gutter:20px;
  padding:var(--modal-header-gutter);scroll-padding-block-start:88px;
}
body:is(.depth-theme,.first-person-demo) :is(.dialog>.dialog-top,.social-dialog:not(.social-compact-chat)>.social-dialog-header,.lobby-wallet-dialog>.lobby-wallet-top){
  position:sticky;top:calc(-1 * var(--modal-header-gutter));z-index:3;display:flex;align-items:center;justify-content:space-between;
  gap:12px;min-height:72px;flex:none;
  margin:calc(-1 * var(--modal-header-gutter)) calc(-1 * var(--modal-header-gutter)) 12px;
  padding:14px var(--modal-header-gutter);
  border-bottom:1px solid var(--ktv-panel-line);background:#242039;
  box-shadow:0 5px 12px #090d1b22;
}
body:is(.depth-theme,.first-person-demo) :is(.dialog>.dialog-top,.social-dialog:not(.social-compact-chat)>.social-dialog-header,.lobby-wallet-dialog>.lobby-wallet-top)>:not(button){
  min-width:0;overflow-wrap:anywhere;
}
body:is(.depth-theme,.first-person-demo) :is(.dialog>.dialog-top,.social-dialog:not(.social-compact-chat)>.social-dialog-header,.lobby-wallet-dialog>.lobby-wallet-top) h2{
  margin:0;line-height:1.25;
}
body #social-chat-dialog.social-compact-chat .social-dialog-header{min-height:44px}
body #social-chat-dialog.social-compact-chat.is-short-sheet{gap:3px;padding-top:6px;padding-bottom:6px}
@media(max-width:480px),(max-height:600px){
  body:is(.depth-theme,.first-person-demo) :is(.dialog:has(>.dialog-top),.social-dialog:not(.social-compact-chat),.lobby-wallet-dialog){--modal-header-gutter:16px}
}
