:root {
    /* ✅ Boot-splash palette (loading screen only - NOT the page chrome). */
    --gold: #d7aa52;
    --gold-soft: #f6dd96;
    --deep: #050403;
    --velvet: #25040a;
    --line: rgba(246, 221, 150, .28);
    --progress: 0;

    /* ✅ Neon Vegas kit tokens for the page-level chrome (bar / rail / press scale).
       Values are copied 1:1 from Assets/Scripts/UI/Kit/UiKitTokens.cs + UiKitTheme.cs so the
       DOM controls and the in-game kit are ONE design system. Never hand-pick a colour
       here - add a token with its C# name instead. */
    --neon-cyan: #2de2ff;                            /* UiKitTokens.Cyan */
    --neon-mag: #ff3df2;                             /* UiKitTokens.Mag */
    --neon-violet: #8a3dff;                          /* UiKitTokens.Violet */
    --neon-night: #0b0620;                           /* UiKitTokens.Night */
    --neon-plate: #08041a;                           /* UiKitTokens.Plate */
    --neon-ink: #f6f3ff;                             /* UiKitTokens.Ink */
    --neon-glass: rgba(255, 255, 255, .06);          /* UiKitTokens.Glass (bg-glass fill) */
    --neon-glass-border: rgba(255, 255, 255, .14);   /* UiKitTokens.GlassBorder (gb hairline) */
    --neon-pressed-scale: .94;                       /* UiMotion.PressedScale (UiKitPressFx) */

    /* ✅ Valorant close box (the page close / fullscreen buttons - see the "Valorant close box"
       section). They copy UiKit.CloseMedallion's Valorant branch (UiKitChrome.cs +
       UiKitTopBar.StyleCloseValorant), i.e. the in-game Store X, so every value below is a
       UiKitTokens / UiKitTopBar constant under its C# name. Colour names and values match
       ui-kit.css's .mmo-ui-kit tokens exactly. */
    --kit-deep: #111a22;                             /* UiKitTokens.Deep (= PanelDeep) - box fill */
    --kit-ink: #ece8e1;                              /* UiKitTokens.Ink - the X / glyph, hover frame, focus outline */
    --kit-line-strong: rgba(236, 232, 225, .34);     /* UiKitTokens.HairlineStrong - 1px frame (same name + value as ui-kit.css) */
    --kit-panel: #1b2733;                            /* UiKitTokens.Panel - hover fill (ui-kit.css .kit-button:hover precedent) */
    --kit-cut-button: 8px;                           /* UiKitTokens.CutButton - TR + BL chamfer, every size */

    /* ✅ Visible box: UiKitTopBar.CloseBoxCssValorant 40 desktop / 36 phone portrait / 32 phone
       landscape, switched below on exactly UiKitBreakpoints.Classify's rule (w <= 600 ->
       portrait, else h <= 500 -> landscape) - the same rule as
       js/iframe-chrome-layout.js medallionSizeFor(), which sets the buttons' inline size while
       docked; this var sizes the undocked buttons so the two can never disagree.
       Hit padding = (44 - size) / 2, so size + 2 * pad = 44 at every breakpoint: the tap area
       is IframeChromeLayout.TOUCH_TARGET_PX (hitPadPx()). index.html adds it as transparent
       content-box padding and cancels it with an equal negative margin, so the visible box
       stays exactly where the layout puts it. */
    --kit-close-size: 40px;                          /* UiKitTopBar.CloseBoxCssValorant (desktop) */
    --kit-close-hit-pad: 2px;                        /* (44 - 40) / 2 */

    /* ✅ The close X glyph, painted through the .picto mask (mask-image: var(--picto)) over
       currentColor (Ink). viewBox 64: on the 64% glyph box of a 40 box (25.6 px, scale .4) the
       7 -> 57 bars span exactly UiKitTopBar.CloseXSpanCss = 20 px and the 6.5 stroke is exactly
       UiKit.Btn_ThinStrokeCss = 2.6 px; it scales with the box on phones (36 / 32).
       WHY not PictoIcon_Mark_X.png for these buttons: that PNG is an X CUT OUT of a filled
       disc, so as a tinted mask it paints a solid disc with a hole, not the Store's thin X.
       The other picto glyphs (window max/min, settings) keep their PNGs. */
    --kit-close-x-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M7 7L57 57M57 7L7 57' fill='none' stroke='black' stroke-width='6.5' stroke-linecap='butt'/%3E%3C/svg%3E");
}

@media (max-width: 600px) {
    :root {
        --kit-close-size: 36px;                      /* phone portrait */
        --kit-close-hit-pad: 4px;                    /* (44 - 36) / 2 */
    }
}

@media (max-height: 500px) and (min-width: 601px) {
    :root {
        --kit-close-size: 32px;                      /* phone landscape */
        --kit-close-hit-pad: 6px;                    /* (44 - 32) / 2 */
    }
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #111;
    font-family: Arial, sans-serif;
}

#unity-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* When #unity-container is the fullscreen element, html/body are no longer
   painted behind it, so it needs its own background and explicit sizing. */
#unity-container:fullscreen,
#unity-container:-webkit-full-screen {
    width: 100%;
    height: 100%;
    background: #111;
}

#game-wrapper {
    position: relative;
    width: min(100%, calc(100vh * 16 / 9));
    height: min(100%, calc(100vw * 9 / 16));
}

/* Focusable but invisible. Not display:none or [hidden] - neither can take focus, which is
   the only thing this element is for. */
#keyboard-anchor {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    padding: 0;
    border: 0;
    background: none;
    pointer-events: none;
}

/* When the wrapper is fullscreen, stretch to fill.
   We use a JS-managed class instead of :fullscreen pseudo-class so the rule
   reliably stops applying when fullscreen exits across all browsers. */
#game-wrapper.fullscreen-mode {
    width: 100%;
    height: 100%;
    background: #111;
}

#unity-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    touch-action: none;
}

/* ✅ Rect (top/left/width/height) is set inline by main.js/webview.jslib to
   track the real iframe placement in both regular and fullscreen game
   modes. While the game is in iframe-fullscreen, webview.jslib shrinks the
   inline top/height by the #floor-chrome-bar's height via
   GetIframeTopInsetPx() (see index.html <style> + main.js) so the bar
   isn't covered - no rule here needs to change for that. */
#unity-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 10;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

/* ✅ Visibility toggle */
#unity-iframe.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ✅ WHY: the DOM iframe sits at z-index 10, above the Unity canvas, so the Unity settings
   panel is unreadable unless the frame is hidden while that panel is open. `visibility`
   (not `display`) is used so the game's layout size doesn't change - a resize would make
   Unity think its canvas changed and could interrupt the running game. */
#game-wrapper.iframe-obscured #unity-iframe,
#game-wrapper.iframe-obscured #close-button,
#game-wrapper.iframe-obscured #fullscreen-button,
#game-wrapper.iframe-obscured #floor-chrome-bar,
#game-wrapper.iframe-obscured #floor-chrome-rail {
    visibility: hidden;
    pointer-events: none;
}

/* ✅ Quiet floor chrome: visual look for the reserved top bar / phone-landscape right
   rail (structural rules - display/position/size - live in index.html's inline <style>,
   set inline every frame by main.js's PositionIframeButtons()). Bar and rail are the
   same neutral frame: one flat UiKitTokens.Night fill and the kit's 1px GlassBorder
   hairline ONLY on the edge each one borders the game on (bottom edge for the bar,
   left edge for the rail), so rotating a phone between the two never looks like a
   different surface. No gradient, no glow, no neon accent - the game is the colour.
   The hairline is an INSET box-shadow, not a border, so the strip's box stays exactly
   the --floor-chrome-h / --floor-rail-w thickness that js/iframe-chrome-layout.js
   computeInsets reads (a border would grow the box 1px onto the game). */
#floor-chrome-bar {
    background: var(--neon-night);
    box-shadow: inset 0 -1px 0 var(--neon-glass-border);
}

#floor-chrome-rail {
    background: var(--neon-night);
    box-shadow: inset 1px 0 0 var(--neon-glass-border);
}

/* ✅ Valorant close box - the page-level copy of UiKit.CloseMedallion's Valorant branch
   (Assets/Scripts/UI/Kit/UiKitChrome.cs + UiKitTopBar.StyleCloseValorant), i.e. the SAME
   X the in-game Store shows: a chamfered box (top-right + bottom-left corners cut by
   UiKitTokens.CutButton, 8 px at every size), a flat UiKitTokens.Deep fill, a 1px
   UiKitTokens.HairlineStrong frame and a thin UiKitTokens.Ink X. No glow, no ring, no
   sheen, no drop shadow, no hover lift. LIT (desktop :hover only): the frame goes Ink and
   the fill goes UiKitTokens.Panel (the ui-kit.css .kit-button:hover precedent). FOCUS
   (:focus-visible): a 1px Ink outline 2 px outside the visible box. PRESS (:active, touch
   included): UiKitPressFx scale .94. The close/fullscreen pair only ever paints while
   #game-wrapper has "iframe-mode" (main.js - they are iframe-only controls);
   #login-close / #cashier-close are the same control on the sign-in / cashier surfaces.
   index.html's inline <style> keeps the structural position/size/display/box-sizing
   rules. The picto glyphs paint currentColor through a mask, so `color` here is the
   glyph colour.
   ✅ Geometry: index.html makes each button content-box with width/height =
   --kit-close-size (40 / 36 / 32, or the inline size main.js sets from
   IframeChromeLayout.medallionSizeFor() while docked), padding = --kit-close-hit-pad
   (2 / 4 / 6) and an equal negative margin. So the CONTENT box is the visible box and
   sits exactly where top/left/right put it, while the border box - the hit box - is
   size + 2 * pad = 44 px (IframeChromeLayout.TOUCH_TARGET_PX) at every breakpoint.
   The button itself paints nothing: the frame and fill are ::before / ::after layers
   inset by the hit pad onto the content box. The button has NO clip-path (it would clip
   the transparent tap padding and the focus outline); only the pseudo layers are
   chamfered. Do NOT set box-sizing here - index.html owns it (content-box).
   ✅ Stacking: isolation: isolate makes each button its own stacking context so the
   ::before frame / ::after fill (z 0) / .picto-shadow glyph (z 1) order can't leak into
   the page's z-index scheme. */
#game-wrapper.iframe-mode #close-button,
#game-wrapper.iframe-mode #fullscreen-button,
#login-close,
#cashier-close {
    isolation: isolate;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    color: var(--kit-ink);
    cursor: pointer;
    /* ✅ First-tap guarantees: no 300ms double-tap-zoom wait, no grey OS tap flash, no
       accidental text selection on a long press. */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    /* ✅ Release to rest: UiMotion.PressRelease bounces past 1.0 over 80ms then settles over
       100ms - one overshoot curve over the same 180ms total. */
    transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
}

/* ✅ Frame layer: ::before fills the visible box (inset = hit pad) with HairlineStrong,
   chamfered by CutButton at top-right and bottom-left. The ::after fill sits 1px inside
   it, so only a 1px frame of this layer shows. pointer-events: none on both layers, so
   every click / tap lands on the button itself (first tap works, as before). */
#game-wrapper.iframe-mode #close-button::before,
#game-wrapper.iframe-mode #fullscreen-button::before,
#login-close::before,
#cashier-close::before {
    content: "";
    position: absolute;
    inset: var(--kit-close-hit-pad);
    z-index: 0;
    background: var(--kit-line-strong);
    clip-path: polygon(0 0, calc(100% - var(--kit-cut-button)) 0, 100% var(--kit-cut-button), 100% 100%, var(--kit-cut-button) 100%, 0 calc(100% - var(--kit-cut-button)));
    pointer-events: none;
}

/* ✅ Fill layer: Deep, 1px inside the frame. Its cut is CutButton - 0.586px
   (= 2 - sqrt(2)): moving both diagonal ends in by 1px on each axis and shortening the cut
   by that amount keeps the diagonal hairline exactly 1px thick, like the straight edges
   (closex.html's .vx rounds it to .6). Painted after ::before at the same z 0. */
#game-wrapper.iframe-mode #close-button::after,
#game-wrapper.iframe-mode #fullscreen-button::after,
#login-close::after,
#cashier-close::after {
    content: "";
    position: absolute;
    inset: calc(var(--kit-close-hit-pad) + 1px);
    z-index: 0;
    background: var(--kit-deep);
    clip-path: polygon(0 0, calc(100% - (var(--kit-cut-button) - 0.586px)) 0, 100% calc(var(--kit-cut-button) - 0.586px), 100% 100%, calc(var(--kit-cut-button) - 0.586px) 100%, 0 calc(100% - (var(--kit-cut-button) - 0.586px)));
    pointer-events: none;
}

/* ✅ Glyph box = 64% of the content box (UiKitRoundIcon.Relayout's Valorant icon ratio .64;
   the content box IS the visible box), centred by index.html's flex rule, so the X and the
   fullscreen glyphs match the in-game close box at every breakpoint. position + z-index 1
   lift the glyph above the frame / fill layers (z 0). No filter / drop shadow: the Store X
   is a flat Ink stroke.
   ✅ One icon family: the glyph is painted as a CSS mask over currentColor (Ink) by the
   inner .picto span. The fullscreen button keeps the kit's Layer Lab picto PNGs
   (TemplateData/icons/, same files UiKitIcons uses in-game); the close X uses the
   --kit-close-x-mask SVG instead (see :root for why and for its exact geometry). */
#game-wrapper.iframe-mode #close-button .picto-shadow,
#game-wrapper.iframe-mode #fullscreen-button .picto-shadow,
#login-close .picto-shadow,
#cashier-close .picto-shadow {
    display: block;
    position: relative;
    z-index: 1;
    width: 64%;
    height: 64%;
}

/* ✅ Picto glyph: the PNG's alpha is the mask, currentColor is the paint. url() resolves
   against this stylesheet, which sits next to index.html at the template root, so
   TemplateData/icons/... is the right base. */
.picto {
    display: block;
    width: 100%;
    height: 100%;
    background-color: currentColor;
    -webkit-mask-image: var(--picto);
    mask-image: var(--picto);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.picto-window-max { --picto: url("TemplateData/icons/PictoIcon_Window_Max.png"); }
.picto-window-min { --picto: url("TemplateData/icons/PictoIcon_Window_Min.png"); }
.picto-mark-x     { --picto: url("TemplateData/icons/PictoIcon_Mark_X.png"); }
.picto-setting    { --picto: url("TemplateData/icons/PictoIcon_Setting_2.png"); }

/* ✅ The thin Store X (UiKitTopBar.CloseXSpanCss 20 px span, UiKit.Btn_ThinStrokeCss 2.6 px
   stroke on a 40 box) for the three close buttons only - every other .picto-mark-x keeps
   the PNG above. */
#game-wrapper.iframe-mode #close-button .picto-mark-x,
#login-close .picto-mark-x,
#cashier-close .picto-mark-x {
    --picto: var(--kit-close-x-mask);
}

/* ✅ Desktop-only hover: UiKitPressFx strips hover colours on touch so a finger never
   leaves a sticky highlight - the (hover: hover) gate is the CSS equivalent. LIT = the
   frame goes Ink and the fill goes Panel (ui-kit.css .kit-button:hover). Colour only: no
   transform, no glow. */
@media (hover: hover) {
    #game-wrapper.iframe-mode #close-button:hover::before,
    #game-wrapper.iframe-mode #fullscreen-button:hover::before,
    #login-close:hover::before,
    #cashier-close:hover::before {
        background: var(--kit-ink);
    }

    #game-wrapper.iframe-mode #close-button:hover::after,
    #game-wrapper.iframe-mode #fullscreen-button:hover::after,
    #login-close:hover::after,
    #cashier-close:hover::after {
        background: var(--kit-panel);
    }
}

/* ✅ Keyboard focus (all devices): a 1px Ink outline 2px outside the VISIBLE box. The
   outline is drawn around the 44px border box, so the offset subtracts the hit pad:
   2 - pad = 0 / -2 / -4 at 40 / 36 / 32 puts it 2px off the 40 / 36 / 32 box. No glow,
   no scale. The #login-modal / #cashier-modal / #game-wrapper.iframe-mode ancestors keep
   this at the specificity of the old focus rules. */
#game-wrapper.iframe-mode #close-button:focus-visible,
#game-wrapper.iframe-mode #fullscreen-button:focus-visible,
#login-modal #login-close:focus-visible,
#cashier-modal #cashier-close:focus-visible {
    outline: 1px solid var(--kit-ink);
    outline-offset: calc(2px - var(--kit-close-hit-pad));
}

/* ✅ Press (all devices, touch included): UiMotion.PressDown -> PressedScale (.94) over
   60ms. Declared LAST, at the focus rules' specificity (hence #login-modal #login-close
   here too), so it wins while any other state applies; on release the transform eases
   back to 1.0 on the rest rule's PressRelease curve. */
#game-wrapper.iframe-mode #close-button:active,
#game-wrapper.iframe-mode #fullscreen-button:active,
#login-modal #login-close:active,
#cashier-modal #cashier-close:active {
    transform: scale(var(--neon-pressed-scale));
    transition: transform .06s ease-out;
}

/* ✅ UiMotion honours MotionPreferences.ReduceMotion by skipping the press tween entirely.
   Hover / focus colour changes still apply (they're state, not motion); only the press
   transform and the transitions go. */
@media (prefers-reduced-motion: reduce) {
    #game-wrapper.iframe-mode #close-button,
    #game-wrapper.iframe-mode #fullscreen-button,
    #login-close,
    #cashier-close {
        transition: none;
    }

    #game-wrapper.iframe-mode #close-button:active,
    #game-wrapper.iframe-mode #fullscreen-button:active,
    #login-modal #login-close:active,
    #cashier-modal #cashier-close:active {
        transform: none;
        transition: none;
    }
}

/* ✅ CS-NEW-1: layered fallback so the loading screen reads as a lit casino
   floor even at 0 bytes of image (background-image on .cinema-bg hasn't
   decoded yet, or fails to load). Radial glow from --velvet at centre-bottom
   fading to --deep at the edges, roughly matching where the real backdrop's
   warm floor light sits. isolation/z-index stacking is unchanged. */
#loading-screen {
    position: absolute;
    inset: 0;
    overflow: hidden;
    isolation: isolate;
    background:
        radial-gradient(ellipse at 50% 85%, var(--velvet), transparent 60%),
        #020101;
    color: #fff;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    z-index: 1;
    transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
}

/* ✅ Finish sequence. Runs once Unity is up, across the hold that lets the game's
   Addressable content download behind this screen (CONTENT_PRELOAD_HOLD_MS in main.js):
   the loading chrome retires, the 21 swells, and the last stretch is the fade off the
   game. The two durations are handed down from main.js so the animation and the hold it
   has to fill cannot drift apart; the fallbacks match the defaults there. */

#loading-screen.finishing {
    transition: opacity var(--finish-fade-ms, 1200ms) ease;
}

/* The progress ring, the flavor text and the HUD have nothing left to report once Unity
   is loaded, so they leave early and hand the frame to the logo. */
#loading-screen.finishing .progress-orbit,
#loading-screen.finishing .metal-disc,
#loading-screen.finishing .copy-block,
#loading-screen.finishing .minimal-hud {
    opacity: 0;
    transition: opacity .7s ease;
}

#loading-screen.finishing .crest {
    transform: scale(1.5);
    transition: transform var(--finish-grow-ms, 3800ms) cubic-bezier(.16,.66,.3,1);
}

#loading-screen.finishing .logo {
    filter: drop-shadow(0 0 34px rgba(190,255,121,.4)) drop-shadow(0 16px 26px rgba(0,0,0,.6));
    transition: filter var(--finish-grow-ms, 3800ms) ease-out;
}

.cinema-bg {
    position: absolute;
    inset: -4%;
    /* ✅ CS-NEW-1: this layer is never transparent-black before the jpg
       decodes (or if it fails to load). background-color is the ultimate
       fallback; the radial-gradient is a second background-image layer
       sitting behind the jpg (a failed/undecoded image layer paints as
       transparent, letting the layer below it show through), so the
       velvet-to-deep glow is visible until the real photo is ready. */
    background-color: var(--velvet);
    background-image:
        url('img/casino-bg.jpg'),
        radial-gradient(ellipse at 50% 60%, var(--velvet), var(--deep) 75%);
    background-size: cover;
    background-position: center 53%;
    transform: scale(1.04);
    filter: contrast(1.08) saturate(.92) brightness(.72);
    animation: slowPush 18s ease-in-out infinite alternate;
    z-index: -8;
}

.cinema-grade {
    position: absolute;
    inset: 0;
    z-index: -6;
    background:
        radial-gradient(circle at 50% 45%, rgba(255,190,88,.15), transparent 24%),
        radial-gradient(circle at 48% 70%, rgba(115,12,20,.30), transparent 32%),
        linear-gradient(90deg, rgba(0,0,0,.82), rgba(0,0,0,.16) 34%, rgba(0,0,0,.16) 66%, rgba(0,0,0,.82)),
        linear-gradient(180deg, rgba(0,0,0,.48), transparent 30%, rgba(0,0,0,.88));
}

.cinema-grade:after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 100% 3px;
    mix-blend-mode: overlay;
    opacity: .18;
    pointer-events: none;
}

.volumetric-light {
    position: absolute;
    top: -20%;
    width: 34vw;
    height: 115vh;
    z-index: -5;
    opacity: .32;
    filter: blur(22px);
    background: linear-gradient(180deg, rgba(255,226,147,.48), rgba(255,194,91,.10) 40%, transparent 70%);
    transform-origin: top;
    animation: breathe 5.5s ease-in-out infinite;
}

.light-left { left: 15%; transform: rotate(14deg); }
.light-right { right: 12%; transform: rotate(-12deg); animation-delay: -2s; }

.floor-glass {
    position: absolute;
    left: 7%;
    right: 7%;
    bottom: -16%;
    height: 34%;
    z-index: -3;
    background: radial-gradient(ellipse at center, rgba(255,207,109,.16), transparent 62%);
    filter: blur(18px);
    opacity: .75;
    animation: floorPulse 6s ease-in-out infinite;
}

.gold-dust, .gold-dust:before, .gold-dust:after {
    position: absolute;
    inset: 0;
    content: "";
    z-index: -2;
    pointer-events: none;
    opacity: .55;
    background-image:
        radial-gradient(circle, rgba(255,219,143,.8) 0 1px, transparent 1.7px),
        radial-gradient(circle, rgba(255,255,255,.45) 0 1px, transparent 1.5px);
    background-size: 180px 180px, 260px 260px;
    background-position: 10% 20%, 70% 30%;
    animation: dustMove 22s linear infinite;
}

.gold-dust:before { opacity: .28; background-size: 120px 120px, 310px 310px; animation-duration: 28s; animation-direction: reverse; }
.gold-dust:after { opacity: .18; filter: blur(1px); background-size: 90px 90px, 210px 210px; animation-duration: 16s; }

.npc-shadow {
    position: absolute;
    bottom: 14%;
    width: 42px;
    height: 140px;
    z-index: -1;
    border-radius: 46% 46% 16% 16%;
    background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.58));
    filter: blur(1px);
    opacity: 0;
    animation: npcCross 14s ease-in-out infinite;
}

.npc-a { left: -8%; animation-delay: 1.2s; }
.npc-b { right: -10%; height: 120px; width: 36px; animation-name: npcCrossReverse; animation-delay: 7s; }

.hero-loader {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 30px;
    transform: translateY(-1.5vh);
}

.crest {
    position: relative;
    /* ✅ CS-NEW-1: capped by vmin (not just vw) so a short viewport (landscape
       phone) can't blow the crest up to fill the screen height-wise - see the
       max-height landscape query below for the further-reduced short cap. */
    width: min(33vw, 52vmin, 330px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
}

.progress-orbit {
    position: absolute;
    inset: 0;
    filter: drop-shadow(0 0 20px rgba(215,170,82,.22));
    animation: orbitFloat 6s ease-in-out infinite;
}

.orbit-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.orbit-track { fill: none; stroke: rgba(246,221,150,.10); stroke-width: 1.5; stroke-dasharray: 2 10; }
.orbit-progress {
    fill: none;
    stroke: var(--gold-soft);
    stroke-width: 3.2;
    stroke-linecap: round;
    stroke-dasharray: 590;
    stroke-dashoffset: calc(590 - (590 * var(--progress) / 100));
    transition: stroke-dashoffset .45s cubic-bezier(.22,.61,.36,1);
    filter: drop-shadow(0 0 10px rgba(246,221,150,.65));
}

.orbit-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold-soft);
    box-shadow: 0 0 18px var(--gold-soft);
    left: 50%;
    top: 50%;
    transform-origin: 0 0;
}

.dot-one { animation: dotOrbit 5.2s linear infinite; }
.dot-two { width: 4px; height: 4px; animation: dotOrbit 8s linear infinite reverse; opacity: .65; }

.metal-disc {
    position: absolute;
    width: 72%;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 42% 32%, rgba(255,236,184,.18), rgba(255,207,107,.05) 31%, rgba(0,0,0,.44) 63%, rgba(0,0,0,.78)),
        conic-gradient(from 180deg, transparent, rgba(246,221,150,.23), transparent, rgba(135,81,22,.25), transparent);
    border: 1px solid rgba(246,221,150,.20);
    box-shadow: inset 0 0 60px rgba(0,0,0,.74), 0 34px 70px rgba(0,0,0,.55);
    backdrop-filter: blur(7px);
}

.logo-shell {
    position: relative;
    width: 62%;
    min-width: 190px;
    padding: 26px 25px;
    border-radius: 26px;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
}

.logo {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 18px rgba(190,255,121,.25)) drop-shadow(0 12px 18px rgba(0,0,0,.65));
}

.specular-sweep {
    position: absolute;
    top: -40%;
    bottom: -40%;
    left: -75%;
    width: 46%;
    transform: rotate(18deg);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.20), rgba(246,221,150,.34), transparent);
    animation: sweep 3.8s cubic-bezier(.2,.75,.24,1) infinite;
}

.copy-block {
    text-align: center;
    letter-spacing: .02em;
    transform: translateY(-12px);
}

.loading-message {
    margin: 0;
    font-size: clamp(20px, 2.4vw, 34px);
    font-weight: 500;
    text-shadow: 0 8px 24px rgba(0,0,0,.8);
}

.subcopy {
    margin: 8px 0 0;
    color: rgba(255,241,207,.58);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .42em;
}

/* CS-306: the calm 18+ line under the loading copy (same muted ink as .subcopy, smaller, sentence case). */
.adults-note {
    margin: 14px 0 0;
    color: rgba(255,241,207,.5);
    font-size: 11px;
    letter-spacing: .08em;
}

.minimal-hud {
    position: absolute;
    right: 34px;
    bottom: 28px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 15px;
    border: 1px solid rgba(246,221,150,.13);
    border-radius: 999px;
    background: rgba(0,0,0,.28);
    backdrop-filter: blur(10px);
    color: rgba(255,241,207,.75);
    letter-spacing: .16em;
    font-size: 11px;
    box-shadow: 0 14px 48px rgba(0,0,0,.45);
}

/* ✅ min-width grew from 38px and letter-spacing was reset to normal so the
   "12.3 / 68.1 MB · ~14s" readout (js/main.js UpdateLoadingReadout) doesn't get
   stretched by the HUD's wide .16em tracking or clipped against the divider —
   a bare "0%" still fits the same slot fine at this width. */
.percent { font-size: 13px; color: var(--gold-soft); min-width: 150px; text-align: right; letter-spacing: normal; white-space: nowrap; }
.divider { width: 1px; height: 14px; background: rgba(246,221,150,.22); }

@keyframes slowPush { from { transform: scale(1.035) translate3d(-.5%,0,0); } to { transform: scale(1.095) translate3d(.5%,-1%,0); } }
@keyframes breathe { 0%,100% { opacity: .22; } 50% { opacity: .43; } }
@keyframes floorPulse { 0%,100% { opacity: .48; transform: scaleX(.95); } 50% { opacity: .78; transform: scaleX(1.05); } }
@keyframes dustMove { to { background-position: 10% -180%, 70% -130%; } }
@keyframes npcCross { 0%,14% { transform: translateX(0) scale(.85); opacity: 0; } 25% { opacity: .32; } 55% { opacity: .22; } 75%,100% { transform: translateX(118vw) scale(1.08); opacity: 0; } }
@keyframes npcCrossReverse { 0%,20% { transform: translateX(0) scale(.8); opacity: 0; } 31% { opacity: .25; } 55% { opacity: .18; } 78%,100% { transform: translateX(-118vw) scale(1.05); opacity: 0; } }
@keyframes orbitFloat { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.012); } }
@keyframes dotOrbit { from { transform: rotate(0deg) translateX(47%); } to { transform: rotate(360deg) translateX(47%); } }
@keyframes sweep { 0% { left: -80%; opacity: 0; } 12% { opacity: 1; } 42%,100% { left: 130%; opacity: 0; } }

@media (max-width: 760px) {
    .crest { width: min(60vw, 280px); }
    .logo-shell { min-width: 165px; padding: 20px; }
    .subcopy { letter-spacing: .22em; }
    .minimal-hud { right: 18px; bottom: 18px; }
}

/* ✅ CS-NEW-1: the max-width rule above never matches a landscape phone
   (e.g. 844x390 - width is well over 760px), so without this the crest
   stays min(33vw,52vmin,330px) ≈ 278px against a 390px-tall viewport and
   the .metal-disc (72% of the crest) fills the screen. This targets short
   viewports by height/orientation instead, and shrinks/repositions the
   whole loader stack so the crest, copy and HUD all stay on-screen and
   legible at a ~390px height. */
@media (max-height: 520px) and (orientation: landscape) {
    .crest { width: min(40vmin, 210px); }
    .hero-loader { gap: 12px; transform: none; }
    .logo-shell { min-width: 0; padding: 12px; }
    .loading-message { font-size: clamp(15px, 3.4vh, 20px); }
    .subcopy { font-size: 10px; letter-spacing: .22em; }
    .adults-note { margin-top: 6px; font-size: 10px; }
    .copy-block { transform: none; }
    .minimal-hud { right: 12px; bottom: 10px; padding: 8px 12px; }
    .percent { min-width: 130px; }
}

/* ✅ CS-NEW-1: backdrop-filter over an animating layer re-blurs every frame,
   which stalls the very animation this screen is meant to show on the low-
   powered/coarse-pointer (touch) GPUs it runs on most. Drop it here and trim
   the volumetric light's blur instead of leaving mobile stuck re-computing a
   backdrop blur 60x a second. */
@media (pointer: coarse) {
    .metal-disc {
        backdrop-filter: none;
        background:
            radial-gradient(circle at 42% 32%, rgba(255,236,184,.18), rgba(255,207,107,.05) 31%, rgba(0,0,0,.44) 63%, rgba(0,0,0,.58)),
            conic-gradient(from 180deg, transparent, rgba(246,221,150,.23), transparent, rgba(135,81,22,.25), transparent);
    }

    .minimal-hud { backdrop-filter: none; }
    .volumetric-light { filter: blur(12px); }
}

@media (prefers-reduced-motion: reduce) {
    #loading-screen *, #loading-screen *:before, #loading-screen *:after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
    }

    /* The rule above kills the swell's transition but not the transform itself, which
       would leave the logo snapping to 1.5x in a single frame - the one thing reduced
       motion is asking us not to do. Drop the swell; the screen still holds and fades. */
    #loading-screen.finishing .crest {
        transform: none !important;
    }
}

#iframe-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 11;

    opacity: 0;
    pointer-events: none;
}

#rotate-message {
    display: none;
    position: fixed;
    inset: 0;
    background: #111;
    color: #fff;
    font-size: 32px;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
}

#rotate-icon {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
}

@media (orientation: portrait) {
    #rotate-message {
        display: flex;
    }

    #unity-container {
        display: none;
    }
}

/* ✅ iOS home screen toast */
#ios-toast {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 14px;
    padding: 12px 40px 12px 16px;
    border-radius: 10px;
    z-index: 9999;
    max-width: 90%;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#ios-toast.visible {
    display: block;
}

#ios-toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
}

/* ✅ CS-256 iOS reload-loop guard. Fixed above everything (loading screen z-index:1,
   leave-confirm 30, our own buttons 20) since it can replace the boot sequence entirely -
   toggled by js/main.js via the "visible" class, same pattern as #ios-toast/#leave-confirm.
   Palette matches #leave-confirm-panel (gold-on-charcoal) rather than introducing a new one. */
#reload-guard {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;

    align-items: center;
    justify-content: center;

    background: rgba(2, 4, 9, 0.86);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

#reload-guard.visible {
    display: flex;
}

#reload-guard-panel {
    width: min(86vw, 420px);
    padding: 30px 28px 26px;
    border: 1px solid rgba(246, 221, 150, 0.22);
    border-radius: 14px;
    background: rgba(10, 17, 28, 0.98);
    color: #fff;
    text-align: center;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}

#reload-guard-panel h2 {
    margin: 0 0 10px;
    font-size: clamp(19px, 3.2vw, 24px);
    color: var(--gold-soft);
    letter-spacing: 0.02em;
}

#reload-guard-panel p {
    margin: 0 0 14px;
    font-size: clamp(14px, 2.2vw, 16px);
    line-height: 1.45;
    color: rgba(226, 232, 240, 0.86);
}

/* The low-memory hint: visually distinct (smaller, warm tint) from the main
   explanation above it, so it reads as a tip rather than a repeat of the same line. */
#reload-guard-hint {
    margin-bottom: 22px;
    font-size: 12.5px;
    color: rgba(255, 200, 140, 0.78);
}

#reload-guard-retry {
    min-height: 52px;
    width: 100%;
    padding: 0 22px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    font-size: clamp(14px, 2.1vw, 16px);
    font-weight: 600;
    color: #050403;
    background: var(--gold-soft);
    cursor: pointer;
}

#reload-guard-retry:active {
    transform: translateY(1px);
}

#reload-guard-retry:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.9);
    outline-offset: 2px;
}
