/* Game placement only. Header and bag use the same site styles and controls. */
:root { --game-site-header-height: var(--site-header-height, 102px); }
html[data-theme] body#top[data-page='play'] .site-header { position: fixed !important; inset: 0 0 auto; z-index: 100001 !important; }
#game-site-audio { position: absolute; right: calc(var(--site-header-edge) + 60px); top: var(--site-header-center-y, 50%); transform: translateY(-50%); }
.site-header .ghdr-right { flex: 0 0 auto; gap: 10px; }
.site-header :is(.audio-toggle-btn, #btn-exit-game) { color: var(--header-ink); background: var(--header-control); border-color: var(--header-line); }
.site-header #btn-exit-game { visibility: hidden; pointer-events: none; }
body.game-active .site-header #btn-exit-game { visibility: visible; pointer-events: auto; }
.game-header-title, .setup-audio-group { display: none !important; }
#action-bar-wrapper { margin-top: calc(var(--game-site-header-height) + (clamp(68px, 7.5vw, 110px) * 1.06 - 64px) / 2 + 4px) !important; }
.site-header .game-site-mode { position: absolute; top: var(--site-header-center-y, 50%); left: calc(var(--site-header-content) + 82px); transform: translateY(-50%); color: var(--header-ink); padding-left: 14px; border-left: 1px solid var(--header-line); font: 600 12px/1.5 ScalarNavigation, Orbitron, sans-serif; letter-spacing: .7px; white-space: nowrap; }
.site-header .game-site-mode[hidden] { display: none; }
/* Reference rails attach to the perimeter like the main site's chapter dock. */
:is(#left-sidebar, #rb-sidebar) {
  --reference-bg: #191b22; --reference-line: #43504b; --reference-ink: #f0f2ec;
  --dock-line: var(--reference-line); --dock-bg: var(--reference-bg);
  top: 50% !important; width: 56px !important; padding: 9px 4px !important; gap: 4px !important;
  align-items: center !important; border: 0 !important; border-radius: 0 !important;
  background: transparent !important; backdrop-filter: none !important; box-shadow: none !important; isolation: isolate;
}
#left-sidebar {
  --reference-accent: #eeb82b; left: var(--screen-frame-side, 24px) !important;
  --dock-shape: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
  --dock-inner-shape: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
}
#rb-sidebar {
  --reference-accent: #38dbb4; left: calc(var(--site-header-viewport-width, 100vw) - var(--screen-frame-side, 24px) - 56px) !important; right: auto !important;
  --dock-shape: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
  --dock-inner-shape: polygon(7px 0, 100% 0, 100% 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
}
:is(#left-sidebar, #rb-sidebar) .rb-hover-btn {
  display: grid !important; place-items: center !important; width: 48px !important; min-width: 48px !important; height: 44px !important; min-height: 44px !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; clip-path: none !important;
  background: transparent !important; box-shadow: none !important; transform: none !important;
}
:is(#left-sidebar, #rb-sidebar) .rb-hover-btn .lt-icon { font: 600 12px/1 ScalarNavigation, Orbitron, sans-serif !important; opacity: 1 !important; text-shadow: none !important; }
:is(#left-sidebar, #rb-sidebar) .rb-help-icon { width: 48px !important; height: 28px !important; margin: 0 !important; }
:is(#left-sidebar, #rb-sidebar) .rb-hover-btn:is(:hover, :focus-visible) { background: color-mix(in srgb, var(--reference-accent) 14%, var(--reference-bg)) !important; }
:is(#left-sidebar, #rb-sidebar) .rb-hover-btn:focus-visible { outline: 2px solid var(--reference-accent); outline-offset: -2px; }
html[data-theme='light'] :is(#left-sidebar, #rb-sidebar) { --reference-bg: #e7eee5; --reference-line: #a5b0a7; --reference-ink: #182520; }
:is([id^='rb-img-'], [id^='left-img-']) { top: calc((100dvh + var(--game-site-header-height)) / 2) !important; max-height: calc(100dvh - var(--game-site-header-height) - 32px) !important; }
[id^='rb-img-'] { width: min(90%, calc(var(--site-header-viewport-width, 100vw) - 2 * (var(--screen-frame-side, 24px) + 72px))) !important; }
/* Both expanded and collapsed log states meet the bottom perimeter. */
body#top[data-page='play'] #log-panel {
  --log-bg: #191b22; --log-line: #43504b; --log-ink: #f0f2ec;
  --dock-line: var(--log-line); --dock-bg: var(--log-bg);
  --dock-shape: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%, 0 8px);
  --dock-inner-shape: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%, 0 7px);
  left: calc(var(--site-header-viewport-width, 100vw) / 2) !important; bottom: var(--screen-frame-inset, 12px) !important; transform: translateX(-50%) !important;
  width: min(420px, calc(var(--site-header-viewport-width, 100vw) - 2 * (var(--screen-frame-side, 24px) + 72px))) !important;
  height: min(300px, calc(100dvh - var(--game-site-header-height) - 40px)) !important;
  border: 0 !important; border-radius: 0 !important; clip-path: none !important; padding: 1px;
  background: transparent !important; backdrop-filter: none !important; box-shadow: none !important;
  isolation: isolate; overflow: hidden; transition: height .3s cubic-bezier(.2,.8,.2,1) !important;
}
html[data-theme='light'] body#top[data-page='play'] #log-panel { --log-bg: #e7eee5; --log-line: #a5b0a7; --log-ink: #182520; }
body#top[data-page='play'] #log-panel.collapsed { height: 38px !important; transform: translateX(-50%) !important; }
body#top[data-page='play'] #log-panel .log-toggle-btn {
  flex: 0 0 36px; height: 36px !important; border-radius: 0 !important; background: transparent !important;
  border-bottom: 1px solid var(--log-line) !important; color: var(--log-ink) !important; font: 600 10px/1.5 ScalarNavigation, Orbitron, sans-serif !important;
}
body#top[data-page='play'] #log-panel.collapsed .log-toggle-btn { border-bottom: 0 !important; }
body#top[data-page='play'] #log-panel .lt-icon { font: inherit !important; letter-spacing: 1px; }
body#top[data-page='play'] #log-panel .chat-msg { font-size: 9px; padding: 5px 8px; }
html[data-theme='light'] body#top[data-page='play'] #log-panel .chat-p1 { color: #006ba8; }
html[data-theme='light'] body#top[data-page='play'] #log-panel .chat-p2 { color: #a61c7c; }
html[data-theme='light'] body#top[data-page='play'] #log-panel .chat-sys { color: var(--log-ink); }
body#top[data-page='play'] #game-log { min-height: 0; }
/* Draw the angled strokes on pseudo elements so preview tooltips stay unclipped. */
body#top[data-page='play'] :is(#left-sidebar, #rb-sidebar, #log-panel)::before {
  content: ''; position: absolute; inset: 0; z-index: -2; background: var(--dock-line); clip-path: var(--dock-shape); pointer-events: none;
}
body#top[data-page='play'] :is(#left-sidebar, #rb-sidebar, #log-panel)::after {
  content: ''; position: absolute; inset: 1px; z-index: -1; background: var(--dock-bg); clip-path: var(--dock-inner-shape); pointer-events: none;
}
#setup-screen.modal { top: var(--game-site-header-height); flex-direction: column; justify-content: flex-start; overflow-y: auto; padding: 28px 20px; }
#setup-screen .subscribe-wrapper { flex: 0 0 auto; height: auto !important; margin-block: auto !important; align-items: flex-start; }
#scalar-preloader { display: none !important; }
/* Colour exceptions preserve original game controls and geometry. */
html[data-theme='light'] :is(.btn-primary, .popup-p1 .btn-primary, .popup-p2 .btn-primary) { color: #fff !important; }
html[data-theme='light'] .unit-shape text { fill: #fff; }
html[data-theme='light'] .chip-pending-val { color: #fff; }
html[data-theme='light'] #core-group svg { color: #745417 !important; filter: none !important; }
html[data-theme='light'] :is(#setup-screen, #mobile-blocker) img[src$='scalar_core_logo.svg'] { filter: brightness(0) !important; }
html[data-theme='light'] .setup-bg-glass { background-color: rgba(244, 237, 252, .72) !important; }
@media (max-width: 768px), (max-height: 480px) {
  #game-site-audio { display: none; }
  .site-header .game-site-mode { display: none; }
  #mobile-blocker { padding-top: var(--game-site-header-height); }
}
@media (min-width: 769px) and (max-width: 1200px) { .site-header .game-site-mode { left: calc(50% + 48px); } }
