/* One neutral material for the header and interface cards. Layout remains in the original styles. */
:root {
  --radius: 6px;
  --r-xs: var(--radius); --r-s: var(--radius); --r-l: var(--radius);
  --icon-corner: 1px;
  --owner-marker-radius: 2px;
  --portfolio-radius: 1px;
  --glass-rgb: 245 244 244;
  --glass-alpha: .18;
  --glass-fill: rgb(var(--glass-rgb) / var(--glass-alpha));
  --glass-blur: 32px;
  --glass-diffusion: .55;
  --glass-grain: url('/static/hub/material/bayer.svg');
  --glass-grain-size: 8px;
  --glass-grain-opacity: .012;
  --glass-edge: var(--line);
  --glass-motion: 180ms;
  --overlay-alpha: .82;
  --overlay-blur: 36px;
  --overlay-dense-alpha: .88;
  --overlay-dense-blur: 40px;
  --overlay-muted: #514D4D;
  --header-alpha: .74;
  --header-blur: 36px;
  --header-muted: #3C3939;
  --surface: var(--glass-fill);
  --surface-2: color-mix(in srgb, var(--ink) 5%, var(--glass-fill));
  --surface-3: color-mix(in srgb, var(--ink) 9%, var(--glass-fill));
  --bg-2: rgb(var(--glass-rgb) / .26);
  --button-surface: #FDFCFC; --button-surface-2: #F1EFEF; --button-surface-3: #E7E4E4;
  --button-bg-2: #EEECEC;
}
:root[data-theme='dark'] {
  --glass-rgb: 13 13 13;
  --overlay-muted: #C8C5C5;
  --header-muted: #D2D2D2;
  --surface: var(--glass-fill);
  --surface-2: color-mix(in srgb, var(--ink) 5%, var(--glass-fill));
  --surface-3: color-mix(in srgb, var(--ink) 9%, var(--glass-fill));
  --bg-2: rgb(var(--glass-rgb) / .26);
  --button-surface: #161616; --button-surface-2: #202020; --button-surface-3: #2B2B2B;
  --button-bg-2: #080808;
}
:is(.btn, .way-btn, .roll-btn) {
  --surface: var(--button-surface); --surface-2: var(--button-surface-2);
  --surface-3: var(--button-surface-3); --bg-2: var(--button-bg-2);
}
:is(button, .btn, .way-btn) { border-radius: var(--radius); }
.portfolio-slot { border-radius: var(--portfolio-radius); }
html[data-dotgrid] body {
  background-image: var(--hub-grid-image);
  background-size: var(--hub-grid-period) var(--hub-grid-period);
}
:is(input:not([type='range']):not([type='checkbox']):not([type='radio']), textarea, select, .search, .room-search) {
  background: var(--glass-fill); border-radius: var(--radius); caret-color: var(--ink);
}
.search input, .room-search input { background: transparent; }

/* Header and cards literally reference the same fill token. Buttons keep incumbent paint. */
:is(.top, .sidebar-section, .hub-content .room, .hub-content .lobby, .panel,
    .sheet-card, .settings-dialog, .person-menu, .me-menu, .more-menu,
    .modal-card, .ps-card, .mini-profile, .pay-card, .store-card, .board,
    .pcard:not(.active), .team-group, .rx-menu.grid) {
  background: var(--glass-fill);
  border-color: var(--glass-edge);
  border-radius: var(--radius);
}

/* Each room needs an edge to group its seats and action. Sidebar sections have
   their own headings and spacing. Keep the border box for the existing layout. */
html[data-hub-refresh] { --hub-panel-edge: color-mix(in srgb, var(--line) 72%, transparent); }
.hub-layout .sidebar-section { border-color: transparent; }
.hub-content :is(.room, .lobby) { border-color: var(--hub-panel-edge); }
#community-page .store-card { box-shadow: inset 0 0 0 1px var(--hub-panel-edge); }
html[data-hub-refresh] :is(.me-menu, .person-menu) {
  --glass-edge: var(--hub-panel-edge);
  box-shadow: var(--shadow-pop), inset 0 0 0 1px var(--glass-edge);
}

/* Cards do not sample an animated canvas through independent backdrop-filter layers.
   material-scene.js copies and blurs the live background once, below the interface. */
:is(.sidebar-section, .hub-content .room, .hub-content .lobby, .panel,
    .sheet-card, .settings-dialog, .person-menu, .me-menu, .more-menu,
    .modal-card, .ps-card, .mini-profile, .pay-card, .store-card, .board,
    .pcard:not(.active), .team-group, .rx-menu.grid) {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.top {
  --glass-fill: rgb(var(--glass-rgb) / var(--header-alpha));
  --muted: var(--header-muted);
  transition: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.top::after {
  content: none;
}
.header-glass-backdrop {
  position: fixed; left: 0; top: 0; z-index: 19; pointer-events: none;
  border-radius: var(--radius); background: transparent;
  -webkit-backdrop-filter: blur(var(--header-blur)); backdrop-filter: blur(var(--header-blur));
  transform: translateZ(0); backface-visibility: hidden;
}


:is(.sidebar-section, .hub-content .room, .hub-content .lobby, .panel,
    .sheet-card, .pay-card, .store-card, .team-group) { position: relative; }
:is(.top, .sidebar-section, .hub-content .room, .hub-content .lobby, .panel,
    .sheet-card, .settings-dialog, .person-menu, .me-menu, .more-menu,
    .modal-card, .ps-card, .mini-profile, .pay-card, .store-card, .board,
    .pcard:not(.active), .team-group, .rx-menu.grid)::before {
  content: ''; position: absolute; inset: 0; z-index: 10; pointer-events: none;
  border-radius: inherit; opacity: var(--glass-grain-opacity);
  background: var(--glass-grain) repeat 0 0 / var(--glass-grain-size) var(--glass-grain-size);
}

/* The flat backing is reused by nested panels. No extra blur or duplicate texture. */
:is(.hub-content .lobby, .panel, .sheet-card, .settings-dialog, .modal-card, .ps-card, .popover, .board, .team-group)
  :is(.panel, .pcard:not(.active), .mini-profile) { background: transparent; }
:is(.hub-content .lobby, .panel, .sheet-card, .settings-dialog, .modal-card, .ps-card, .popover, .board, .team-group)
  :is(.panel, .pcard:not(.active), .mini-profile)::before { content: none; }
.board .stage { background: transparent; }
.board .cell { background-color: rgb(var(--glass-rgb) / .22); }
.cell .owner-tag { border-radius: var(--owner-marker-radius); }
/* Company tiles meet the outer price tab flush; only the edge facing the centre is rounded. */
.board .cell.s-top:has(.logo.brand:not(.tax)) { border-radius: 0 0 var(--radius) var(--radius); }
.board .cell.s-bottom:has(.logo.brand:not(.tax)) { border-radius: var(--radius) var(--radius) 0 0; }
.board .cell.s-left:has(.logo.brand:not(.tax)) { border-radius: 0 var(--radius) var(--radius) 0; }
.board .cell.s-right:has(.logo.brand:not(.tax)) { border-radius: var(--radius) 0 0 var(--radius); }
.board .cell.s-top > .cat { border-radius: var(--radius) var(--radius) 0 0; }
.board .cell.s-bottom > .cat { border-radius: 0 0 var(--radius) var(--radius); }
.board .cell.s-left > .cat { border-radius: var(--radius) 0 0 var(--radius); }
.board .cell.s-right > .cat { border-radius: 0 var(--radius) var(--radius) 0; }
.set-head, .set-nav, .sheet .actions { background-color: rgb(var(--glass-rgb) / .4); }
:root, :root[data-theme='dark'] {
  --cell: rgb(var(--glass-rgb) / .22);
  --cell-hover: var(--surface-2);
  --corner: var(--glass-fill);
  --stage: transparent;
  --chip: var(--glass-fill);
}
:root[data-theme='dark'] .login-art { background: var(--glass-fill); }

/* The window itself samples the scene behind it, rather than a negative pseudo
   inside an isolated/animated window. Text and icons remain unfiltered. */
:is(.sheet-card, .settings-dialog, .person-menu, .me-menu, .more-menu, .modal-card, .ps-card,
    .popover, .property-preview, .card, .chance-card, .jp-dialog, .jp-help, .jp-observer, .jp-target-prompt, .rx-menu:where(.grid)):not([data-glass-nested]) {
  --glass-fill: rgb(var(--glass-rgb) / var(--overlay-alpha));
  --surface: var(--glass-fill);
  --surface-2: color-mix(in srgb, var(--ink) 5%, var(--glass-fill));
  --surface-3: color-mix(in srgb, var(--ink) 9%, var(--glass-fill));
  --muted: var(--overlay-muted);
  isolation: auto;
  color: var(--ink);
  background: var(--glass-fill);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(var(--overlay-blur)); backdrop-filter: blur(var(--overlay-blur));
}
:is(.property-preview, .stage-main > .card, .chance-card, .modal-card, .sheet-card, .jp-dialog, .jp-help) {
  --overlay-alpha: var(--overlay-dense-alpha);
  --overlay-blur: var(--overlay-dense-blur);
}
.chance-card.chance-card { background: transparent; }
.chance-card .face {
  background-color: var(--glass-fill);
  box-shadow: inset 0 0 0 1px var(--glass-edge), var(--shadow-pop);
}
/* Nested cards share their outer window's material instead of filtering it twice. */
[data-glass-nested] {
  background: transparent !important;
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
[data-glass-nested]::before { content: none; }
.gooey-liquid, .gooey-liquid.gooey-settled {
  background: var(--glass-fill) !important;
  box-shadow: inset 0 0 0 1px var(--glass-edge), var(--shadow-pop) !important;
}
.gooey-surface, .gooey-ghost { display: none; }

/* Opacity animations on an ancestor form a backdrop root even at their filled
   final frame. Fade the scrim as a sibling so the window can sample the game. */
.modal, .sheet, .sheet.out { background: transparent; animation: none; }
.modal::before, .sheet::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: var(--scrim); animation: fade var(--t-ui) ease both;
}
.sheet.out::before { animation: fade-out 150ms ease both; }
.modal-card { position: relative; }
.modal.picking::before { content: none; }

/* One preblurred live scene, clipped with a plain CSS path. No SVG clip references,
   backdrop snapshots, mask filters, refraction, lens highlights or animated noise. */
.material-scene-clip { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: var(--glass-diffusion); }
.material-scene {
  position: absolute; inset: 0; pointer-events: none;
  background-color: var(--bg);
  background-image: var(--hub-grid-image, none);
  background-size: var(--hub-grid-period, 242px) var(--hub-grid-period, 242px);
  filter: blur(var(--glass-blur));
}
.material-scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
:root[data-material='lite'] { --glass-blur: 24px; --overlay-blur: 24px; --overlay-dense-blur: 28px; }
:root[data-material='solid'] { --glass-alpha: 1; --header-alpha: 1; --overlay-alpha: 1; --overlay-dense-alpha: 1; --overlay-blur: 0px; --overlay-dense-blur: 0px; --glass-grain-opacity: 0; }
:root[data-material='solid'] .material-scene-clip { display: none; }
:root[data-material='solid'] .header-glass-backdrop { display: none; }
:root[data-graphics-quality='balanced'] {
  --glass-blur: 16px; --header-blur: 12px; --overlay-blur: 12px; --overlay-dense-blur: 14px;
  --header-alpha: .9; --overlay-alpha: .94; --overlay-dense-alpha: .96;
}
:root[data-graphics-quality='balanced'] .material-scene canvas { display: none; }
:root:is([data-graphics-quality='balanced'], [data-graphics-quality='low']) {
  --shadow-2: 0 2px 6px rgb(0 0 0 / .18);
  --shadow-pop: 0 3px 12px rgb(0 0 0 / .24);
  --glass-grain-opacity: 0;
}
:root[data-graphics-quality='low'] {
  --glass-alpha: .95; --header-alpha: 1; --overlay-alpha: 1; --overlay-dense-alpha: 1;
  --overlay-blur: 0px; --overlay-dense-blur: 0px;
}
:root[data-graphics-quality='low'] :is(.material-scene-clip, .header-glass-backdrop) { display: none; }
:root[data-graphics-quality='low'] .desk-edge-glass { backdrop-filter: none; }
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-alpha: 1; --header-alpha: 1; --overlay-alpha: 1; --overlay-dense-alpha: 1; --overlay-blur: 0px; --overlay-dense-blur: 0px; --glass-grain-opacity: 0; }
  .material-scene-clip, .header-glass-backdrop { display: none; }
}
@media (forced-colors: active) {
  :root { --glass-fill: Canvas; --glass-grain-opacity: 0; }
  .material-scene-clip { display: none; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --overlay-alpha: .96; --overlay-dense-alpha: .96; }
}
