/* Shared finishes. All popup windows use the same fixed 2px chrome rim.
   Existing notification, HUD and ornament finishes stay independent. */
:root {
  --fcs-chrome:linear-gradient(135deg,#fff,#8fa1ae 25%,#f6f9fb 49%,#7a8c99 73%,#e9eef2);
  /* One broad reflection per window, normalized to its own dimensions.
     No repeated bands: rounded corners follow the same continuous finish. */
  --fcs-window-chrome:linear-gradient(135deg,#f8fbfd 0%,#a5b3bd 52%,#e7edf1 100%);
  --fcs-rim-dialog:2px;
  --fcs-rim-window:var(--fcs-rim-dialog);
  --fcs-rim-notice:2px;
  --fcs-rim-micro:1px;
  --fcs-action:linear-gradient(125deg,#385f63,#28464f);
  --fcs-action-hover:linear-gradient(125deg,#447277,#315862);
  --fcs-action-ink:#f5ffff;
  --fcs-danger:linear-gradient(125deg,#81535b,#633e49);
  --fcs-danger-hover:linear-gradient(125deg,#95616b,#754a57);
  --fcs-secondary:#30495624;
  --fcs-secondary-ink:#293e49;
  --fcs-action-shadow:inset 0 1px #ffffff30,0 2px 5px #183f4620;
}

/* Touch feedback uses the game's pressed styles. */
:where(button, a[href], summary, [role="button"], [role="tab"], [role="slider"]) {
  -webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;
  user-select:none;
}
/* A layer gives this preference priority over individual popup outlines. */
@layer control-focus {
  :where(button, a[href], summary, [role="button"], [role="tab"], [role="slider"], [tabindex]):focus-visible {
    outline:none!important;
  }
}

/* Retain the last rendered content only for the downward exit, without input. */
body #snooker-preview #decisionBanner[data-notice-exiting][hidden]{display:block!important}
body #snooker-preview #onlineReconnect[data-notice-exiting][hidden],
body :is(#matchmakingBar,#tournamentSearch)[data-notice-exiting][hidden]{display:flex!important}
body [data-notice-exiting]{pointer-events:none!important}
body #snooker-preview #decisionBanner{animation:none}
/* Toasts remain mounted: a transition also reverses cleanly mid-flight. */
body #snooker-preview>.toast{
 transform:translateY(calc(100% + 20px));opacity:0;visibility:hidden;
 transition:transform 240ms cubic-bezier(.4,0,1,1),opacity 240ms ease,visibility 0s 240ms;
}
body #snooker-preview>.toast.on:not(.notice-suppressed){
 transform:translateY(0);opacity:1;visibility:visible;
 transition:transform 340ms cubic-bezier(.16,1,.3,1),opacity 340ms ease,visibility 0s;
}
body #snooker-preview>.toast.notice-suppressed{pointer-events:none}
@media(prefers-reduced-motion:reduce){
 body #snooker-preview>.toast,body #snooker-preview>.toast.on:not(.notice-suppressed){transform:none;transition:none}
}

/* Shared silver tile: only the fill is translucent; chrome and content stay opaque. */
body .fbs-popup {
  --text:#262626; --muted:#262626; --line:#71889480; --raised:#eef3f680;
  isolation:isolate;
  touch-action:pan-x pan-y;
  overflow:visible!important;
  border:0!important;
  outline:none!important;
  border-radius:22px!important;
  background:linear-gradient(160deg,rgba(255,255,255,.5),rgba(238,243,246,.5) 34%,rgba(223,231,237,.5) 67%,rgba(207,217,225,.5)) padding-box!important;
  color:#262626!important;
  box-shadow:0 12px 28px rgba(12,27,37,.18)!important;
  -webkit-backdrop-filter:blur(16px)!important;backdrop-filter:blur(16px)!important;
  text-shadow:none!important;
  clip-path:none!important;
}
body .fbs-popup::after {
  content:"";position:absolute;inset:0;padding:var(--fcs-rim-dialog);border-radius:inherit;
  background:var(--fcs-chrome);
  -webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);
  -webkit-mask-composite:xor;mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask-composite:exclude;
  pointer-events:none;z-index:2;
}
/* Window rims share a fixed width; docked notifications retain their open edge. */
body :is(dialog,[role=dialog]).fbs-popup::after,body .snk-modal .fbs-popup::after {
  padding:var(--fcs-rim-window);
  background:var(--fcs-window-chrome) 0 0 / 100% 100% no-repeat;
}
body dialog.fbs-popup::backdrop,body #modal,body .fbs-popup-backdrop {
  background:transparent!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;
}
body .fbs-popup :is(button,.snk-btn) {
  background:var(--fcs-secondary)!important;
  border:0!important;border-radius:10px;
  color:#262626!important;text-shadow:none!important;box-shadow:none!important;
  touch-action:manipulation;
}
body .fbs-popup button:hover {border-color:#fff!important}
body .fbs-popup button:active {background:#c5d6dfb3!important}
body .fbs-popup button:focus-visible {outline:2px solid #707b83;outline-offset:3px}
body .fbs-popup button[aria-pressed=true]:not(.free-ball-choice) {
  background:var(--fcs-secondary)!important;border-color:transparent!important;color:#262626!important;
}
body .fbs-popup :is(h2,.match-controls,#breakInfo,#mobileNote) {color:#262626!important;text-shadow:none!important}
body .fbs-popup textarea {color:#262626;background:#f5f8fa80;border-color:#7f95a380}
body .snk-modal .fbs-popup {position:relative;max-height:calc(100dvh - 32px);box-sizing:border-box}
body .snk-modal .fbs-popup textarea {min-height:60px;flex:1}
body #snooker-preview>.toast.fbs-popup,body #snooker-preview>#decisionBanner.fbs-popup,body #snooker-preview #onlineReconnect.fbs-popup {
  border-radius:10px 10px 0 0!important;border-bottom:0!important;background-clip:border-box!important;
}
/* Docked notices stay open at the screen edge; only top and sides carry chrome. */
body #snooker-preview>.toast.fbs-popup::after,body #snooker-preview>#decisionBanner.fbs-popup::after,body #snooker-preview #onlineReconnect.fbs-popup::after {padding:var(--fcs-rim-notice) var(--fcs-rim-notice) 0}
body #snooker-preview>.toast.fbs-popup {box-shadow:inset 0 2px 0 var(--notice-accent),0 12px 28px rgba(12,27,37,.18)!important}
/* Spin remains a free-standing ball over the original darkened backdrop. */
.spin-surface {position:relative}
/* One recessed channel, with independently selectable, fully opaque game balls. */
body #freeBallDialog.fbs-popup {width:min(560px,calc(100vw - 32px));padding:18px 18px 14px;overflow:auto}
body .free-ball-tray {position:relative;isolation:isolate}
body #freeBallChoices {position:relative;display:flex;gap:4px;overflow-x:auto;padding:5px 7px 7px;border-radius:32px;scrollbar-width:thin;scrollbar-color:#728a87 transparent}
body .free-ball-tray::before {content:"";position:absolute;left:0;right:0;top:0;height:60px;border-radius:32px;z-index:-1;pointer-events:none;background:linear-gradient(180deg,#6c9b888c,#a2c6ae80);box-shadow:inset 0 3px 6px #173e3d59,inset 0 1px 2px #204a4a66,0 1px 0 #ffffffb3}
body .fbs-popup .free-ball-choice {position:relative;isolation:isolate;display:flex;flex:1 0 48px;min-width:48px;min-height:0;flex-direction:column;gap:8px;padding:0 2px 3px;border:0!important;border-radius:0;background:none!important;box-shadow:none!important;font:600 13px/1.15 'Barlow Condensed',sans-serif;text-align:center}
body .fbs-popup .free-ball-choice:hover,body .fbs-popup .free-ball-choice:active,body .fbs-popup .free-ball-choice[aria-pressed=true] {background:none!important}
body .free-ball-choice .free-ball-swatch {display:block;flex:none;box-sizing:border-box;width:48px;height:48px;border:0;border-radius:50%;background:none;box-shadow:none}
body .free-ball-choice[aria-pressed=true] .free-ball-swatch {outline:none}
body .free-ball-choice[aria-pressed=true]::before {content:"";position:absolute;top:-3px;left:0;right:0;height:60px;border-radius:30px;background:radial-gradient(ellipse at center,#ffffffb3 0%,#ffffff70 48%,#ffffff00 76%);z-index:-1;pointer-events:none}
body .free-ball-choice .free-ball-swatch[data-kind=none] {width:48px;height:48px;background:none;border:0;position:relative}
body .free-ball-swatch[data-kind=none]::before {content:"";position:absolute;inset:11px;border:1px solid #416966;border-radius:50%;background:linear-gradient(135deg,transparent 48%,#416966 49%,#416966 52%,transparent 53%)}
body .free-ball-choice canvas {pointer-events:none}
body .free-ball-choice span:last-child {min-height:2.3em;display:grid;place-items:start center}

/* The frame scrim is a viewport sibling of the scaled, clipped menu surface. */
body .fbs-popup-backdrop.frame-backdrop {background:rgba(9,18,25,.48)!important}
body #frame-dialog .frame-options {margin:14px 0}
body #frame-dialog .frame-option {padding:8px 7px 12px;touch-action:manipulation;-webkit-touch-callout:none;user-select:none}
/* Frame choices retain their light glass finish independently of action buttons. */
body #frame-dialog .frame-option {background:linear-gradient(160deg,#ffffff70,#dce6ed70)!important}
body #frame-dialog .frame-option[aria-pressed=true] {background:linear-gradient(150deg,#ffffff66,#b9cdca30)!important}
body #frame-dialog .frame-rack {display:block;width:120px;max-width:100%;height:72px;object-fit:contain;margin:0 auto 4px;pointer-events:none}
body #frame-dialog .frame-rack {border-radius:16px;background:linear-gradient(165deg,#697e8a20,#b2c0c72e 52%,#f3f7fa45);box-shadow:inset 0 2px 5px #22384330,inset 0 1px 2px #22384324,0 1px 0 #ffffff99}
body #frame-dialog .frame-rack[src$="frame-15-reds.webp"] {box-sizing:border-box;padding:4px}
body #frame-dialog .frame-option strong {font-size:30px}
body #frame-dialog .frame-option small:empty {display:none}

/* Neutral text and consistent light/dark button treatments. */
body .fbs-popup :where(h1,h2,h3,p,span,small,strong,label,div,em,li) {color:inherit!important}
body .snk-btn {background:var(--fcs-secondary)!important;border-color:transparent!important;color:#262626!important;text-shadow:none}
body .fbs-popup button[aria-pressed=true]:not(.free-ball-choice) {
  background:var(--fcs-secondary)!important;border-color:transparent!important;color:#262626!important;
}
body .fbs-popup .free-ball-choice {color:#262626!important}

body #snooker-preview>.toast.fbs-popup {background-image:linear-gradient(160deg,rgba(255,255,255,.5),rgba(247,249,251,.5) 34%,rgba(239,243,246,.5) 67%,rgba(231,236,240,.5))!important}

/* Geometrically centred close icons, independent of font baselines. */
body .fbs-popup .popup-close{display:inline-flex;align-items:center;justify-content:center;flex:0 0 34px;box-sizing:border-box;width:34px;height:34px;min-height:34px;padding:0!important;line-height:0!important}
body .fbs-popup .popup-close svg{display:block;flex:none;width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
/* Keep the game menu within its viewport; permit only vertical scrolling. */
body #snooker-preview #gameMenu{box-sizing:border-box;max-width:calc(100vw - 24px);max-height:calc(100dvh - 24px);overflow-x:hidden!important;overflow-y:auto!important}
body #snooker-preview #gameMenu .mobile-bar,body #gameMenu .online-menu-actions{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
body #gameMenu :is(.mobile-bar,.mobile-bar>*,#onlineMenuPanel,#onlineMenuPanel *,#newFrame){min-width:0;max-width:100%;box-sizing:border-box}
body #gameMenu :is(p,output,#mobileNote){overflow-wrap:anywhere}

/* Game menu uses the shared translucent glass; preserve its content inset. */
body #snooker-preview #gameMenu{
  border:0!important;padding:21px;outline:none!important;
  background:linear-gradient(160deg,rgba(255,255,255,.5),rgba(238,243,246,.5) 34%,rgba(223,231,237,.5) 67%,rgba(207,217,225,.5)) padding-box!important;
  -webkit-backdrop-filter:blur(16px)!important;backdrop-filter:blur(16px)!important;
}
body #gameMenu.fbs-popup::after{inset:0}

body #snooker-preview #onlineReconnect.fbs-popup{box-shadow:inset 0 2px 0 #b9863b,0 12px 28px rgba(12,27,37,.18)!important}
/* Shared button finish, including pressed and disabled states: no black fills. */
body :is(dialog,.fbs-popup,#gameMenu,#profileDialog,.online-card,.egs-screen,.vs-screen) :is(button,.snk-btn):not(.frame-option):not(.free-ball-choice):not([data-tone]):not(:where(.cue-popup-header [data-action],.trophy-popup-header [data-action],.hub-subtabs button,.hub-career-metrics button,.avatar-medal,.challenge-picker nav button,.popup-rim-controls button,.hub-picker-options button)),
body :is(dialog,.fbs-popup,#gameMenu,#profileDialog,.online-card,.egs-screen,.vs-screen) :is(button,.snk-btn):is(:active,:disabled,[aria-pressed=true]):not(.frame-option):not(.free-ball-choice):not([data-tone]):not(:where(.cue-popup-header [data-action],.trophy-popup-header [data-action],.hub-subtabs button,.hub-career-metrics button,.avatar-medal,.challenge-picker nav button,.popup-rim-controls button,.hub-picker-options button)){background:var(--fcs-secondary)!important;color:#262626!important;border-color:transparent!important}
body :is(dialog,.fbs-popup,#gameMenu,#profileDialog) button:disabled{opacity:.5}

body .fbs-popup img{-webkit-user-drag:none;user-select:none;-webkit-user-select:none}

/* Persistent game selections use the Wallet action finish. Navigation keeps
   its own tab treatment; the rendered snooker balls retain their real colours. */
body #snooker-preview .fbs-popup button[aria-pressed=true]:not(.free-ball-choice),
body #snooker-preview .fbs-popup button[aria-selected=true]:not(.free-ball-choice) {
  background:var(--fcs-action)!important;color:var(--fcs-action-ink)!important;
  border-color:transparent!important;box-shadow:var(--fcs-action-shadow)!important;
}
body #snooker-preview .fbs-popup .free-ball-choice span:last-child {
  align-items:center;border-radius:11px;padding:3px 5px;box-sizing:border-box;
}
body #snooker-preview .fbs-popup .free-ball-choice[aria-pressed=true] span:last-child {
  background:var(--fcs-action)!important;color:var(--fcs-action-ink)!important;
  box-shadow:var(--fcs-action-shadow);
}
body #snooker-preview .free-ball-choice[aria-pressed=true]::before {
  background:radial-gradient(ellipse at center,#385f6359 0%,#385f6326 48%,#385f6300 76%);
}

/* Meaningful actions share the Wallet finish; secondary actions remain quiet. */
body :is(.fbs-popup,.online-card) button[data-tone],
body :is(#communityHub,#playerProfilePopup) .hub-content button[data-tone],
body :is(#cueDetailPopup,#hubActionConfirmation) button[data-tone],
body #rematchBtn[data-tone] {
  border:0!important;border-radius:8px!important;
  background:var(--fcs-action)!important;color:var(--fcs-action-ink)!important;
  box-shadow:var(--fcs-action-shadow)!important;text-shadow:none!important;
}
body :is(.fbs-popup,.online-card) button[data-tone]:hover:not(:disabled),
body :is(#communityHub,#playerProfilePopup) .hub-content button[data-tone]:hover:not(:disabled),
body :is(#cueDetailPopup,#hubActionConfirmation) button[data-tone]:hover:not(:disabled),
body #rematchBtn[data-tone]:hover:not(:disabled) {background:var(--fcs-action-hover)!important}
body :is(.fbs-popup,.online-card) button[data-tone=danger],
body :is(#communityHub,#playerProfilePopup) .hub-content button[data-tone=danger],
body dialog#hubActionConfirmation.fbs-popup button[data-confirm][data-tone=danger]:is(:enabled,:disabled) {
  background:var(--fcs-danger)!important;color:#fff7f7!important;
}
body :is(.fbs-popup,.online-card) button[data-tone=danger]:hover:not(:disabled),
body :is(#communityHub,#playerProfilePopup) .hub-content button[data-tone=danger]:hover:not(:disabled),
body dialog#hubActionConfirmation.fbs-popup button[data-confirm][data-tone=danger]:hover:not(:disabled) {background:var(--fcs-danger-hover)!important}
body :is(.fbs-popup,.online-card) button[data-tone]:disabled {opacity:.45;cursor:default}
body :is(.fbs-popup,.online-card) button[data-tone]:focus-visible {outline:2px solid #28464f;outline-offset:2px}

/* Tone changes colour, never the geometry of neighbouring actions. */
body #gameMenu :is(.mobile-bar,.online-menu-actions) button,
body :is(#onlineConcedeDialog,#concedeDialog,#leaveGame,#frameDialog) button,
body #hubActionConfirmation footer button {box-sizing:border-box;min-height:32px;border-radius:8px!important;padding:6px 12px!important;font:600 12px/1.2 Barlow,sans-serif!important}
body :is(#communityHub,#playerProfilePopup) .hub-content .hub-actions button[data-action]:is(:enabled,:disabled) {box-sizing:border-box;min-height:32px;padding:6px 12px!important;border-radius:8px!important;font:600 12px/1.2 Barlow,sans-serif!important}


/* Small game confirmations use the same proportions as hub confirmations. */
body :is(#onlineConcedeDialog,#concedeDialog,#leaveGame,#frameDialog).fbs-popup{box-sizing:border-box;width:min(400px,92vw);max-height:calc(100dvh - 20px);padding:18px 20px;border-radius:16px!important;font:14px/1.45 Barlow,sans-serif}
body :is(#onlineConcedeDialog,#concedeDialog,#leaveGame,#frameDialog).fbs-popup::after{padding:var(--fcs-rim-window)}
body :is(#onlineConcedeDialog,#concedeDialog,#leaveGame,#frameDialog) h2{margin:0 0 10px;font:600 24px/1.15 'Barlow Condensed',sans-serif}
body :is(#onlineConcedeDialog,#concedeDialog,#leaveGame,#frameDialog) p{margin:0 0 14px}
body :is(#onlineConcedeDialog>footer,#concedeDialog>div,#leaveGame>div,#frameDialog>.snk-row){display:flex;justify-content:flex-end;align-items:center;gap:8px}
body :is(#onlineConcedeDialog,#concedeDialog,#leaveGame,#frameDialog) button{min-height:32px;padding:6px 12px;border-radius:11px;font:600 12px/1.2 Barlow,sans-serif;cursor:pointer}

/* Window controls shared by equipment and trophy details in every shell. */
body :is(#cueDetailPopup,#trophyDetailPopup) :is(.cue-popup-header,.trophy-popup-header) button:is([data-action=modal-close],[data-action=modal-resize]):is(:enabled,:disabled){display:grid;place-items:center;flex:0 0 34px;width:34px;height:34px;min-height:34px;padding:7px!important;border:0!important;background:transparent!important;box-shadow:none!important;border-radius:0!important;color:#314651!important}
:is(#cueDetailPopup,#trophyDetailPopup) :is(.cue-popup-header,.trophy-popup-header) button svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;filter:drop-shadow(0 1px 0 #ffffff80)}
body :is(#cueDetailPopup,#trophyDetailPopup) :is(.cue-popup-header,.trophy-popup-header) button:is([data-action=modal-close],[data-action=modal-resize]):is(:enabled,:disabled){position:absolute;right:0;top:0;z-index:3;outline-offset:-3px}
body :is(#cueDetailPopup,#trophyDetailPopup) :is(.cue-popup-header,.trophy-popup-header) button[data-action=modal-resize]:is(:enabled,:disabled){right:34px}
