/* ════════════════════════════════════════════════
   DESIGN TOKENS
   ════════════════════════════════════════════════ */

:root {
    --color-bg:           #0c0d18;
    --color-panel:        #13152a;
    --color-panel-grad:   linear-gradient(135deg, #10122a 0%, #161830 100%);
    --color-border:       #2e2f5a;
    --color-border-light: #4a4a80;
    --color-accent:       #7d85b4;
    --color-accent-dim:   #2d2f60;
    --color-text:         #c8cce8;
    --color-text-dim:     #5a5a8a;
    --color-danger:  #ff4466;
    --color-success: #66ffaa;
    --color-amber:   #ffaa44;

    /* Violet-blue palette matching minesweeper */
    --steel-bg:        #10122a;
    --steel-panel:     #161830;
    --steel-border:    #30305a;
    --steel-highlight: rgba(125, 133, 180, 0.10);

    --font-ui: 'Averia Libre', sans-serif;
    --font-display: 'Averia Libre', sans-serif;
    --font-landing: 'Averia Libre', sans-serif;

    --bevel: inset 1px 1px 0 rgba(138, 156, 181, 0.1),
        inset -1px -1px 0 rgba(0, 0, 0, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.6);

    --bevel-inset: inset 1px 1px 4px rgba(0, 0, 0, 0.6),
        inset -1px -1px 0 rgba(138, 156, 181, 0.06);

    --glow-accent: 0 0 12px rgba(125, 133, 180, 0.25);

    /* ── Viewport-scaled layout tokens (reference: 2560×1600) ──
       Heights scale with vh (ref = 1600px), widths with vw (ref = 2560px).
       min() caps the value so it never exceeds the original design size.     */
    --h-header:   min(126px, 7.875vh);      /* 126/1600 */
    --h-footer:   min(259px, 16.1875vh);    /* 259/1600 */
    --h-worldnav: min(92px,  5.75vh);       /* 92/1600  */
    --w-divider:  min(64px,  2.5vw);        /* 64/2560  */
    --w-charbtn:  min(78px,  3.046875vw);   /* 78/2560  */
    --w-worldbtn: min(152px, 5.9375vw);     /* 152/2560 */
}


/* ════════════════════════════════════════════════
   BASE RESET
   ════════════════════════════════════════════════ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: var(--color-bg);
    font-family: 'Averia Libre', sans-serif;
    font-weight: 400;
    letter-spacing: -0.06em;
    color: var(--color-text);
}

canvas {
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    color: inherit;
    /* Subtle white-leaning glow — 50% toned down */
    filter: drop-shadow(0 0 8px rgba(235, 240, 255, 0.45))
            drop-shadow(0 0 14px rgba(200, 215, 255, 0.25));
    transition: filter 0.2s ease;
}
button img {
    filter: drop-shadow(0 0 7px rgba(235, 240, 255, 0.42))
            drop-shadow(0 0 14px rgba(200, 215, 255, 0.22));
}
button:hover {
    filter: drop-shadow(0 0 12px rgba(245, 248, 255, 0.7))
            drop-shadow(0 0 20px rgba(215, 225, 255, 0.4));
}
button:hover img {
    filter: drop-shadow(0 0 11px rgba(245, 248, 255, 0.65))
            drop-shadow(0 0 18px rgba(215, 225, 255, 0.35));
}


/* ════════════════════════════════════════════════
   LANDING PAGE
   ════════════════════════════════════════════════ */

#landing-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #000;
    z-index: 100;
    cursor: default;
}

#landing-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 0;
    pointer-events: none;
}

#landing-vignette {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(0, 5, 15, 0.6) 100%
    );
}

#landing-ui {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#enter-button-img {
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    pointer-events: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: enterGlowPulse 1.8s ease-in-out infinite;
    /* Always visible — never block the user behind a video that may fail to load */
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    transition: opacity 0.6s ease, transform 0.6s ease;
}
body.landing-video-ready #enter-button-img {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

#enter-btn-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 320px;
    max-height: 120px;
    object-fit: contain;
    pointer-events: none;
}

@keyframes enterGlowPulse {
    0%   {
        filter: drop-shadow(0 0 4px rgba(255,255,255,0.3))
                drop-shadow(0 0 8px rgba(255,255,255,0.1));
    }
    50%  {
        filter: drop-shadow(0 0 12px rgba(255,255,255,0.9))
                drop-shadow(0 0 24px rgba(255,255,255,0.5))
                drop-shadow(0 0 40px rgba(255,255,255,0.3));
    }
    100% {
        filter: drop-shadow(0 0 4px rgba(255,255,255,0.3))
                drop-shadow(0 0 8px rgba(255,255,255,0.1));
    }
}

#enter-button-img:hover {
    animation: enterGlowPulseHover 0.6s ease-in-out infinite;
}

@keyframes enterGlowPulseHover {
    0%   {
        filter: drop-shadow(0 0 16px rgba(255,255,255,1))
                drop-shadow(0 0 32px rgba(255,255,255,0.7));
    }
    50%  {
        filter: drop-shadow(0 0 24px rgba(255,255,255,1))
                drop-shadow(0 0 48px rgba(255,255,255,0.9))
                drop-shadow(0 0 64px rgba(255,255,255,0.5));
    }
    100% {
        filter: drop-shadow(0 0 16px rgba(255,255,255,1))
                drop-shadow(0 0 32px rgba(255,255,255,0.7));
    }
}

/* ════════════════════════════════════════════════
   INTRO WELCOME OVERLAY
   ════════════════════════════════════════════════ */

#intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#intro-blur-bg {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(14px) brightness(0.7);
    -webkit-backdrop-filter: blur(14px) brightness(0.7);
    background: rgba(0, 4, 18, 0.45);
    z-index: 0;
}

#intro-godrays {
    position: absolute;
    /* extend past edges so rotation doesn't show corners */
    inset: -60%;
    width: 220%;
    height: 220%;
    background: repeating-conic-gradient(
        rgba(190, 215, 255, 0.045) 0deg,
        transparent 6deg,
        transparent 20deg,
        rgba(190, 215, 255, 0.028) 26deg,
        transparent 32deg,
        transparent 46deg,
        rgba(190, 215, 255, 0.02) 52deg,
        transparent 58deg
    );
    filter: blur(6px);
    animation: raysRotate 40s linear infinite;
    z-index: 1;
    pointer-events: none;
}

@keyframes raysRotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

#intro-center-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 55% at 50% 50%,
        rgba(160, 200, 255, 0.18) 0%,
        rgba(80,  130, 255, 0.08) 35%,
        transparent 70%
    );
    z-index: 2;
    pointer-events: none;
}

#intro-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
    /* Keep content fully on-screen and leave room for loading bar + enter btn */
    max-width: 100vw;
    max-height: 100vh;
    padding: 24px;
    box-sizing: border-box;
}

#intro-welcome-img {
    display: block;
    /* Preserve the PNG's natural aspect ratio and ensure it's never cropped.
       Width is capped to the design max (1428px @ 1920x1080) and to the
       viewport; height is capped to leave ~30% of the viewport for the
       loading bar + enter button underneath. `height:auto`+`width:auto`
       with max-* bounds makes the browser fit both while preserving AR. */
    width: auto;
    height: auto;
    max-width: min(1428px, 92vw);
    max-height: 70vh;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(180, 210, 255, 0.55))
            drop-shadow(0 0 64px rgba(140, 180, 255, 0.25));
}
/* welcomem.png and intro-mobile-text are mobile-only — never shown on desktop.
   The `.intro-mobile-only { display:none }` rule below is what hides them; we
   intentionally do NOT give #intro-welcome-img-mobile any base display rule
   here, because an ID selector would beat the class and leak it onto desktop. */

/* Mobile-only intro text shown above the welcomem.png image */
#intro-mobile-text {
    color: #ffffff;
    font-family: 'Averia Libre', serif;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    max-width: 92vw;
    margin: 0 auto;
    padding: 0 4px;
    text-shadow: 0 0 8px rgba(140, 180, 255, 0.55),
                 0 0 16px rgba(80, 130, 255, 0.35);
}
#intro-mobile-text p { margin: 0 0 10px 0; }
#intro-mobile-text p:last-child { margin-bottom: 0; }

/* Default visibility: desktop image visible, mobile assets hidden */
.intro-mobile-only  { display: none; }
.intro-desktop-only { display: block; }

/* Tight screens (short Macs, small laptops): shrink gap & give image more room */
@media (max-height: 820px) {
    #intro-content { gap: 24px; padding: 16px; }
    #intro-welcome-img { max-height: 62vh; }
}
@media (max-height: 640px) {
    #intro-content { gap: 16px; padding: 10px; }
    #intro-welcome-img { max-height: 56vh; }
}
/* Narrow screens */
@media (max-width: 640px) {
    #intro-welcome-img { max-width: 96vw; }
}

/* Mobile: welcomem.png IS the entire screen — no blur/godrays/glow behind it.
   Layout (top→bottom): image fullscreen → text overlaid in upper half →
   loading bar + enter button stacked BELOW the text in the lower half. */
@media (max-width: 768px) {
    .intro-desktop-only { display: none !important; }
    .intro-mobile-only  { display: block !important; }

    /* Kill the desktop overlay layers so only the image shows */
    #intro-blur-bg,
    #intro-godrays,
    #intro-center-glow {
        display: none !important;
    }
    #intro-overlay {
        background: #000 !important;
    }

    /* welcomem.png fully visible within the safe viewport area (never cropped
       by Safari's top address bar or bottom toolbar). `object-fit: contain`
       keeps the whole image on-screen; `100dvh` + safe-area padding respects
       the browser chrome. */
    #intro-welcome-img-mobile {
        position: fixed !important;
        top: env(safe-area-inset-top, 0) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: env(safe-area-inset-bottom, 0) !important;
        width: 100vw !important;
        height: auto !important;
        max-width: 100vw !important;
        max-height: calc(100dvh
            - env(safe-area-inset-top, 0)
            - env(safe-area-inset-bottom, 0)) !important;
        object-fit: contain !important;
        object-position: center center !important;
        z-index: 1 !important;
        filter: none !important;
        margin: 0 !important;
        padding: 0 !important;
        pointer-events: none;
    }

    /* The intro flex column controls vertical stacking of text + bar + button. */
    #intro-content {
        position: relative;
        z-index: 3;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        padding: 0;
        gap: 0;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
    }

    #intro-mobile-text {
        /* `position: relative` + z-index puts the text ABOVE the image,
           which is also a child of #intro-content (z-index: 1). Without an
           explicit z-index, the text is in-flow content (z=auto) and the
           positioned image paints over it. */
        position: relative;
        z-index: 5;
        transform: none;
        margin-top: 14vh;          /* upper portion of screen */
        margin-bottom: 22px;
        width: 96vw;
        max-width: 96vw;
        padding: 0 8px;
        box-sizing: border-box;
        font-size: 14px;
        line-height: 1.4;
        text-align: center;
        color: #ffffff;
        text-shadow: 0 0 6px rgba(0,0,0,0.6),
                     0 0 14px rgba(0,0,0,0.4),
                     0 0 10px rgba(140, 180, 255, 0.35);
    }
    #intro-mobile-text p { margin: 0 0 8px 0; }
    #intro-mobile-text p:last-child { margin-bottom: 0; }

    /* Loading bar + enter button stacked BELOW the text */
    #intro-loading-bar-wrap {
        position: relative;
        z-index: 5;
        margin: 6px auto 14px auto;
    }
    #intro-enter-btn {
        position: relative;
        z-index: 5;
        margin-top: 4px;
    }

    /* Enter button 20% smaller than desktop (169 * 0.8, 64 * 0.8) */
    #intro-enter-btn img {
        max-width: 135px;
        max-height: 51px;
    }

    /* Mobile hint shown directly under the ENTER button */
    #intro-mobile-bigscreen-hint {
        position: relative;
        z-index: 5;
        margin-top: 10px;
        padding: 0 18px;
        max-width: 92vw;
        font-family: 'Averia Libre', serif;
        font-size: 15px;
        line-height: 1.35;
        font-style: italic;
        text-align: center;
        color: #cfd9ff;
        text-shadow:
            0 0 4px rgba(0, 0, 0, 0.7),
            0 0 10px rgba(140, 180, 255, 0.35);
        opacity: 0.92;
    }
}

/* Hide the hint on desktop (mobile-only class already hides it but make
   it explicit so an ID wouldn't accidentally leak it onto desktop). */
#intro-mobile-bigscreen-hint {
    display: none;
}
@media (max-width: 768px) {
    #intro-mobile-bigscreen-hint {
        display: block;
    }
}

/* Loading bar shown while preloading worlds */
#intro-loading-bar-wrap {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 16px auto;
}

#intro-loading-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #3355ff, #88ccff);
    border-radius: 2px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(51, 85, 255, 0.6);
}

#intro-enter-btn {
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: enterGlowPulse 1.8s ease-in-out infinite;
}

#intro-enter-btn img {
    display: block;
    width: auto;
    height: auto;
    max-width: 169px;   /* 154 * 1.10 */
    max-height: 64px;   /* 58  * 1.10 */
    object-fit: contain;
    pointer-events: none;
}

#intro-enter-btn:hover {
    animation: enterGlowPulseHover 0.6s ease-in-out infinite;
}

/* ════════════════════════════════════════════════
   UI SHELL — CSS GRID
   ════════════════════════════════════════════════ */

#ui-shell {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 10;
    width: 100vw;
    height: 100vh;
    pointer-events: none;

    grid-template-areas:
        "header  header  header"
        "char    divider canvas"
        "char    divider worlds"
        "footer  footer  footer";
    grid-template-columns: 29.75% var(--w-divider) 1fr;
    grid-template-rows: var(--h-header) 1fr auto var(--h-footer);
}

#ui-shell.visible {
    display: grid;
}

@media (min-width: 768px) {
    #ui-shell::after {
        content: '';
        position: absolute;
        inset: 0;
        z-index: 9999;
        pointer-events: none;
        background: repeating-linear-gradient(to bottom,
                transparent 0px,
                transparent 2px,
                rgba(0, 0, 0, 0.08) 2px,
                rgba(0, 0, 0, 0.08) 4px);
        animation: scanlineScroll 10s linear infinite;
    }
}

@media (max-width: 768px) {
    #vertical-divider {
        display: none;
    }
    /* Mobile layout: the full definition lives in the MOBILE block near the
       bottom of this file (around line ~1765). Keep this block minimal so it
       doesn't fight the main one. */
}

@media (max-width: 480px) {
    /* Mobile keeps only the world-tracker panel (handled in 768px block).
       Don't blanket-hide nth-child here since mobile already hides
       sound-bar, img-panel-1, img-panel-3 by id. */
    .image-panel {
        flex: 1;
    }
}

@keyframes scanlineScroll {
    to {
        background-position: 0 100px;
    }
}

/* ════════════════════════════════════════════════
   HUD PANELS — HEADER & FOOTER
   ════════════════════════════════════════════════ */

/* #hud-footer is defined further down (single source at ~line 1405). */

#hud-header {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: var(--h-header);
    background: linear-gradient(180deg, #161830 0%, #10122a 100%);
    overflow: hidden;
    flex-shrink: 0;
    pointer-events: auto;
    grid-area: header;
    border-bottom: 2px solid #2d2d4a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

/* ── Header Sections (3-section layout) ── */
.header-section {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-right: 1px solid #2d2d4a;
    box-sizing: border-box;
    overflow: hidden;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.04) 0%,
            transparent 50%,
            rgba(0, 0, 0, 0.2) 100%);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.06),
        inset -1px -1px 0 rgba(0, 0, 0, 0.4);
}

.header-section:last-child {
    border-right: none;
}

#header-logo {
    width: calc(29.75% + var(--w-divider));
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

#header-logo-inner {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Imagen A1 ocupa todo el panel */
#header-logo-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Botones encima de A1 — sectores 2 y 3 de 3 */
#header-logo-buttons {
    position: absolute;
    top: 0;
    right: 0;
    width: 66.66%;
    height: 100%;
    display: flex;
    flex-direction: row;
    z-index: 2;
}

.header-logo-btn-slot {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.header-logo-btn {
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 150ms, transform 150ms;
    pointer-events: auto;
}

.header-logo-btn:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.header-logo-btn:active {
    transform: scale(0.97);
}

.header-logo-btn img {
    width: 126.5%;   /* 115% × 1.10 ≈ 10% wider */
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

/* Shift A1button1 more to the right */
#logo-btn-slot-1 {
    padding-left: 35px;
}

#header-map {
    flex: 66;
    padding: 4px 8px;
}

#header-credits {
    flex: 34;
    transition: box-shadow 0.3s ease;
}
/* When glowing, lift the panel above its siblings so the shadow isn't buried */
#hud-header.credits-glowing {
    overflow: visible;   /* let the glow bleed past the header edge */
}
#hud-header.credits-glowing #header-credits {
    z-index: 10;         /* above sibling header sections */
    overflow: visible;   /* let box-shadow escape the element clip */
}
/* Pulsing electric-blue glow — runs forever while .world-enter-glow is active */
@keyframes headerCreditsPulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(0, 0, 255, 0.7),
                    0 0 10px 3px rgba(0, 0, 255, 0.6),
                    inset 0 0 8px rgba(0, 0, 255, 0.15);
    }
    50% {
        box-shadow: 0 0 0 2px #3333ff,
                    0 0 18px 6px rgba(50, 50, 255, 0.95),
                    0 0 32px 10px rgba(0, 0, 200, 0.5),
                    inset 0 0 16px rgba(0, 0, 255, 0.2);
    }
}
#header-credits.world-enter-glow {
    animation: headerCreditsPulse 2.4s ease-in-out infinite;
}

.header-section-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Panel H2: World Info — Console Blue ── */

/* Icon and title are hidden — only the desc text is shown */
.world-info-icon {
    display: none !important;
}

.world-info-title {
    display: none !important;
}

#footer-top-right {
    background: #001eff;
    padding: 0 20px;
    gap: 0;
    border-left: 3px solid #3355ff;
    box-shadow: inset 0 0 30px rgba(0, 30, 255, 0.5);
}

.world-info-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    gap: 0;
}

/* Wrapper applies shared scaleX so cursor stays right after text */
.world-info-desc-wrap {
    display: inline-block;
    transform: scaleX(0.62) scaleY(1.6);
    transform-origin: left center;
    white-space: nowrap;
}

.world-info-desc {
    font-family: 'Averia Libre', sans-serif;
    font-size: clamp(12px, 2.8vh, 30px);
    font-weight: 200;
    color: #ffffff;
    letter-spacing: -0.05em;
    line-height: 1;
    white-space: nowrap;
    /* Black outline — 30% thinner */
    -webkit-text-stroke: 0.4px #000;
    text-shadow:
        -0.7px -0.7px 0 #000,
         0.7px -0.7px 0 #000,
        -0.7px  0.7px 0 #000,
         0.7px  0.7px 0 #000,
         0 0 6px #ffffff,
         0 0 14px rgba(0, 80, 255, 0.9),
         0 0 28px rgba(0, 30, 255, 0.5);
}

/* Spanish translation tooltip — appears on hover of the desc panel */
#footer-top-right {
    position: relative;
}
/* Spanish hover-tooltip removed (no longer rendered). */
.world-info-desc-es {
    display: none !important;
}

/* Square terminal cursor — inline after text inside same scaled wrapper */
#world-text-cursor {
    font-family: monospace;
    font-size: clamp(12px, 2.8vh, 30px);
    line-height: 1;
    color: #ffffff;
    display: inline;
    text-shadow:
        0 0 6px #ffffff,
        0 0 14px rgba(0, 80, 255, 0.9),
        0 0 28px rgba(0, 30, 255, 0.5);
    animation: blinkCaret 0.7s step-end infinite;
    margin-left: 2px;
}

@keyframes blinkCaret {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── World Tracker Panel (car-stereo playlist) ── */
#world-tracker-panel {
    background: #04050d;
    overflow: hidden;
    cursor: default;
}

#world-track-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Top 1-slot header line */
    padding-top: 0;
}

#world-track-list {
    width: 100%;
    transition: transform 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.track-item {
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-family: 'Averia Libre', monospace;
    font-size: 18px;
    font-weight: 300;
    letter-spacing: -0.5px;
    color: rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s, background 0.3s;
    -webkit-text-stroke: 0.5px #000;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.track-item.active {
    color: #ffffff;
    font-weight: 600;
    background: rgba(0, 30, 255, 0.18);
    border-left: 2px solid #001eff;
    letter-spacing: -0.5px;
}

.track-item.active::before {
    content: '▶';
    margin-right: 6px;
    font-size: 10px;
    color: #001eff;
    text-shadow: 0 0 6px #001eff;
    flex-shrink: 0;
}

/* ── Relief Texture (Panels H3, H4) ── */
.hud-relief-pattern {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 3px,
            rgba(255, 255, 255, 0.015) 3px,
            rgba(255, 255, 255, 0.015) 4px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 3px,
            rgba(255, 255, 255, 0.015) 3px,
            rgba(255, 255, 255, 0.015) 4px);
    pointer-events: none;
}

.hud-panel-label {
    position: relative;
    z-index: 1;
    font-family: 'Averia Libre', sans-serif;
    font-size: 10px;
    letter-spacing: -0.5px;
    color: #5a7a94;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* ── Minimap Panel ── */
#minimap-panel {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-image: radial-gradient(
        circle, rgba(125,133,180,0.08) 1px, transparent 1px
    );
    background-size: 8px 8px;
}

/* ════════════════════════════════════════════════
   CHARACTER PANEL
   ════════════════════════════════════════════════ */

#character-panel {
    grid-area: char;
    display: grid;
    grid-template-columns: var(--w-charbtn) 1fr;
    gap: 6px;
    padding: 8px;
    background-image: url('assets/tex/B1.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-right: 1px solid var(--color-border);
    box-shadow: var(--bevel);
    pointer-events: auto;
    overflow: hidden;
}

#texture-buttons {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    align-items: center;
    width: var(--w-charbtn);
    height: 100%;
    gap: 0;
    padding: 4px 0;
    background-image: url('assets/tex/B1.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ── Texture buttons — PNG image swap ── */
.texture-btn {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: none;
    background-color: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 120ms ease;
}

.texture-btn:hover {
    transform: scale(1.06);
}

.texture-btn:active {
    transform: scale(0.97);
}

/* Both images overlap — positioned absolute inside the button */
.texture-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 150ms ease;
}

/* Default: show normal, hide hover */
.texture-btn .btn-normal { opacity: 1; }
.texture-btn .btn-hover  { opacity: 0; }

/* Hover: swap */
.texture-btn:hover .btn-normal { opacity: 0; }
.texture-btn:hover .btn-hover  { opacity: 1; }

/* Active: swap (same as hover) */
.texture-btn.active .btn-normal { opacity: 0; }
.texture-btn.active .btn-hover  { opacity: 1; }

/* Hover while active: keep hover image */
.texture-btn.active:hover .btn-normal { opacity: 0; }
.texture-btn.active:hover .btn-hover  { opacity: 1; }

#character-display {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-anim {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    display: block;
    mix-blend-mode: screen;
}


/* ════════════════════════════════════════════════
   VERTICAL DIVIDER
   ════════════════════════════════════════════════ */
#vertical-divider {
    grid-area: divider;
    width: var(--w-divider);
    height: 100%;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    border-right: 1px solid rgba(125, 133, 180, 0.15);
    border-left:  1px solid rgba(0, 0, 0, 0.4);
    z-index: 1;
    background-image: url('assets/tex/B3.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ════════════════════════════════════════════════
   CANVAS AREA
   ════════════════════════════════════════════════ */

#canvas-area {
    grid-area: canvas;
    position: relative;
    overflow: hidden;
    background: #000;
    /* Prevent the browser from intercepting touch gestures (scroll/pinch/zoom)
       so touchmove fires for our rotate-by-finger handler on mobile. */
    touch-action: none;
}
#canvas-area canvas {
    touch-action: none;
}

/* World 00 — world01bw on the right side (85% height, vertically centered). */
#world-00-overlay-right {
    position: absolute;
    top: 50%;
    right: 0;
    left: auto;
    height: 85%;
    transform: translateY(-50%);
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#world-00-overlay-right.visible {
    opacity: 1;
}

#egg-bw-img-2 {
    display: block;
    height: 100%;
    width: auto;
    margin-left: auto;   /* pushes image to the right edge */
    filter: brightness(0.9) contrast(1.1);
    mix-blend-mode: screen;
}

/* World 03 — charBW standing at bottom, centered on divider right edge */
#world-03-overlay {
    position: fixed;
    bottom: -50px;
    z-index: 150;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
    transform: translateX(-50%);
}

#world-03-overlay.visible {
    opacity: 1;
}

#char-bw-img {
    display: block;
    height: min(56vh, 525px);
    width: auto;
    filter: brightness(0.92) contrast(1.05);
    mix-blend-mode: screen;
}

#carousel-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#carousel-container canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

#room-name-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 800;
    text-align: center;
    pointer-events: none;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    text-shadow: 0 0 20px currentColor;
    white-space: nowrap;
}

#room-name-display.visible {
    opacity: 1;
}

/* Animated World Number */
#world-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 120px;
    color: var(--color-accent);
    font-weight: 800;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    text-shadow: 0 0 40px var(--color-accent);
}

/* ════════════════════════════════════════════════
   WORLD NAV
   ════════════════════════════════════════════════ */

#world-nav-wrap {
    grid-area: worlds;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

/* Thin "Memorypicker" title bar — dark navy, same as text bar */
#memorypicker-title {
    width: 100%;
    height: 15px;
    line-height: 15px;
    padding: 0 20px;
    background: #000a3a;
    border-left: 3px solid #1a2a80;
    box-shadow: inset 0 0 12px rgba(0, 15, 80, 0.8);
    font-family: 'Averia Libre', sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: -0.5px;
    color: #ffffff;
    text-transform: none;
    white-space: nowrap;
    overflow: hidden;
    -webkit-text-stroke: 0.4px #000;
    text-shadow:
        -0.7px -0.7px 0 #000,
         0.7px -0.7px 0 #000,
        -0.7px  0.7px 0 #000,
         0.7px  0.7px 0 #000,
         0 0 6px #ffffff,
         0 0 14px rgba(0, 80, 255, 0.9),
         0 0 28px rgba(0, 30, 255, 0.5);
}

#world-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    padding: 4px 4px;
    background-image: url('assets/tex/buttonsWBG.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    border-top: 1px solid var(--color-border);
    pointer-events: auto;
    gap: 2px;
    min-height: var(--h-worldnav);
}

.world-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--w-worldbtn);
    height: calc(100% - 8px);
    padding: 0;
    border-radius: 2px;
    background: transparent;
    border: none;
    transition: all 0.2s ease-out;
    overflow: hidden;
}

.world-btn-img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    pointer-events: none;
}

.world-btn:hover {
    filter: brightness(1.1);
}

.world-btn.active,
.texture-btn.active {
    background: transparent;
    border-radius: 6px;
    box-shadow: 0 0 0 2px #0000ff,
                0 0 8px 2px rgba(0, 0, 255, 0.8),
                0 0 14px 4px rgba(0, 0, 220, 0.4);
    animation: worldBtnActivePulse 2.4s ease-in-out infinite;
}
@keyframes worldBtnActivePulse {
    0%, 100% {
        box-shadow: 0 0 0 2px #0000ff,
                    0 0 8px 2px rgba(0, 0, 255, 0.8),
                    0 0 14px 4px rgba(0, 0, 220, 0.4);
    }
    50% {
        box-shadow: 0 0 0 2px #3333ff,
                    0 0 12px 3px rgba(50, 50, 255, 1),
                    0 0 20px 6px rgba(0, 0, 200, 0.55);
    }
}

.world-btn.loading .world-icon {
    display: none;
}

.world-btn.loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-accent-dim);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.world-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.world-label {
    font-size: 9px;
    font-family: var(--font-ui);
    letter-spacing: -0.5px;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 72px;
}

/* ════════════════════════════════════════════════
   FOOTER HUD (RPG Image Panels)
   ════════════════════════════════════════════════ */

#hud-footer {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #0a0c14;
    border-top: 2px solid #2d2d4a;
    grid-area: footer;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 2;
    pointer-events: auto;
}

/* Footer top row: spectrogram + world info */
#footer-top-row {
    display: flex;
    flex-direction: row;
    height: 35%;
    width: 100%;
    border-bottom: 1px solid #2d2d4a;
    box-sizing: border-box;
}

#footer-top-left {
    width: calc(29.75% + var(--w-divider));
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    border-right: 1px solid #2d2d4a;
    background: linear-gradient(135deg, #10122a 0%, #161830 100%);
}

#footer-top-right {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 20px;
    /* Console-blue is applied earlier at line ~746 — keep transparent here
       so it shows through, instead of a dark gradient that would defeat it. */
    background: transparent;
    min-width: 0;
}

/* Footer bottom row: minesweepers + panels */
#footer-bottom-row {
    display: flex;
    flex-direction: row;
    height: 65%;
    width: 100%;
    gap: 3px;
    padding: 3px;
    box-sizing: border-box;
}

.image-panel {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0d0f1a;
    cursor: pointer;
    transition: transform 150ms ease, filter 150ms ease;
}

.image-panel:hover {
    transform: scaleY(1.03);
    filter: brightness(1.15);
    z-index: 2;
}
/* Side decoration panels are not clickable — no hover movement */
#img-panel-1:hover,
#img-panel-3:hover {
    transform: none;
    filter: none;
    cursor: default;
}
#img-panel-1,
#img-panel-3 {
    cursor: default;
}

.panel-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    position: relative;
    z-index: 1;
}

.panel-border-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow:
        inset 2px 2px 0 rgba(125, 133, 180, 0.15),
        inset -2px -2px 0 rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(125, 133, 180, 0.12);
    z-index: 2;
}

.image-panel.active {
    filter: brightness(1.2);
}

.image-panel.active .panel-border-overlay {
    box-shadow:
        inset 0 0 0 2px #7d85b4,
        inset 2px 2px 0 rgba(125, 133, 180, 0.3),
        inset -2px -2px 0 rgba(0, 0, 0, 0.5);
}

.image-panel::before {
    content: attr(id);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Averia Libre', sans-serif;
    font-size: 10px;
    color: rgba(125, 133, 180, 0.2);
    letter-spacing: -0.5px;
    pointer-events: none;
    z-index: 0;
}

/* .world-btn.active / keyframes / .world-icon / .world-label — single source of
   truth lives at lines ~1341-1399 above. Previous duplicate removed. */


/* ════════════════════════════════════════════════
   MOBILE TEXTURE FAB + DRAWER
   ════════════════════════════════════════════════ */

#texture-fab {
    display: none;
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-panel);
    border: 2px solid var(--color-border);
    box-shadow: var(--bevel), 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 100;
    pointer-events: auto;
    align-items: center;
    justify-content: center;
}

.fab-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent);
    border: 2px solid var(--color-border-light);
}

#texture-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
    pointer-events: none;
    opacity: 0;
    transition: opacity 300ms ease;
}

#texture-drawer-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

#texture-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 200px;
    height: 100vh;
    background: var(--color-panel-grad);
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.6);
    z-index: 99;
    padding: 20px 12px;
    transform: translateX(100%);
    transition: transform 300ms ease-out;
    pointer-events: auto;
}

#texture-drawer.open {
    transform: translateX(0);
}
.drawer-title {
    font-family: var(--font-display);
    font-size: 12px;
    color: var(--color-accent);
    letter-spacing: -0.5px;
    margin-bottom: 16px;
    text-align: center;
}

.drawer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    justify-items: center;
}

.drawer-grid .texture-btn {
    width: 56px;
    height: 56px;
}



/* ════════════════════════════════════════════════
   WORLD LOADER OVERLAY
   ════════════════════════════════════════════════ */

#world-loader {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(5, 5, 16, 0.92);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    pointer-events: auto;
}

.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-accent-dim);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    font-family: var(--font-display);
    font-size: 14px;
    color: var(--color-accent);
    letter-spacing: -0.5px;
    text-shadow: 0 0 10px rgba(125, 133, 180, 0.4);
    animation: loaderPulse 1.5s ease-in-out infinite;
}

.loader-bar-track {
    width: 180px;
    height: 3px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}

.loader-bar-fill {
    width: 40%;
    height: 100%;
    background: var(--color-accent);
    border-radius: 2px;
    animation: loaderBar 1.2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--color-accent);
}

@keyframes loaderPulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

@keyframes loaderBar {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(350%);
    }
}


/* ════════════════════════════════════════════════
   PLACEHOLDER WORLD OVERLAY
   ════════════════════════════════════════════════ */

.placeholder-overlay {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    pointer-events: none;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.6) 100%);
}

.placeholder-icon {
    color: var(--color-accent-dim);
    opacity: 0.5;
    animation: placeholderSpin 8s linear infinite;
}

@keyframes placeholderSpin {
    to {
        transform: rotate(360deg);
    }
}

.placeholder-title {
    font-family: var(--font-display);
    font-size: 18px;
    color: var(--color-text);
    letter-spacing: -0.5px;
    text-shadow: 0 0 10px rgba(200, 223, 240, 0.3);
}

.placeholder-message {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--color-accent);
    letter-spacing: -0.5px;
    text-shadow: 0 0 16px rgba(125, 133, 180, 0.5);
    animation: placeholderPulse 2s ease-in-out infinite;
}

.placeholder-sub {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--color-text-dim);
    letter-spacing: -0.5px;
}

@keyframes placeholderPulse {

    0%,
    100% {
        opacity: 0.5;
        text-shadow: 0 0 10px rgba(125, 133, 180, 0.3);
    }

    50% {
        opacity: 1;
        text-shadow: 0 0 24px rgba(125, 133, 180, 0.7);
    }
}


/* ════════════════════════════════════════════════
   RESPONSIVE — TABLET (≤ 1024px)
   ════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    #ui-shell.visible {
        grid-template-columns: 20% 80%;
    }

    #hud-header {
        height: 80px;
    }

    #hud-footer {
        height: 70px;
    }

    .world-info-desc {
        display: none;
    }

    .world-label {
        display: none;
    }

    .world-btn {
        width: 56px;
        height: 56px;
        padding: 6px;
    }

    .world-icon {
        width: 24px;
        height: 24px;
    }

    #character-display {
        min-height: 80px;
    }

    .texture-btn {
        width: 50px;
        height: 50px;
    }

    #character-panel {
        grid-template-columns: 60px 1fr;
    }
}


/* ════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 768px)
   ════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* ─── MOBILE GRID ────────────────────────────────────────────────
       Layout (Safari-safe — respects top/bottom browser chrome):

         ┌────────────────┬──────┐
         │  header (map)  │      │
         ├────────────────┤  9-  │
         │  name strip    │ btn  │
         ├────────────────┤ ver- │
         │                │ tic- │
         │    canvas      │ al   │
         │                │ col- │
         │                │ umn  │
         ├────────────────┤      │
         │ footer:        │      │
         │  desc          │      │
         │  spectrogram   │      │
         └────────────────┴──────┘
    */
    #ui-shell.visible {
        /* Header spans the full width; memory column starts below it. */
        grid-template-areas:
            "header header"
            "name   memory"
            "canvas memory"
            "footer memory";
        grid-template-columns: 1fr 46px;
        grid-template-rows:
            calc(54px + env(safe-area-inset-top, 0))   /* header + notch */
            auto                                        /* world-name strip */
            1fr                                         /* canvas fills rest */
            calc(140px + env(safe-area-inset-bottom, 0)); /* desc + spectrogram */
    }

    /* ─── HEADER ─── */
    #hud-header {
        height: auto;
        padding-top: env(safe-area-inset-top, 0);
        box-sizing: border-box;
    }
    #header-logo,
    #header-credits {
        display: none !important;
    }
    #hud-header {
        grid-template-columns: 1fr;
    }
    #header-map {
        flex: 1 1 100%;
        width: 100%;
    }

    /* Hide character panel + texture FAB/drawer entirely on mobile */
    #character-panel,
    #texture-fab,
    #texture-drawer,
    #texture-drawer-backdrop {
        display: none !important;
    }

    /* ─── WORLD NAME STRIP (between header and canvas) ───
       JS relocates #world-tracker-panel into this grid area on mobile. */
    #world-tracker-panel {
        grid-area: name;
        position: relative !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        min-height: 24px !important;
        padding: 0 !important;
        background: #0a0c14 !important;
        border: none !important;
        border-top: 1px solid #2d2d4a !important;
        border-bottom: 1px solid #2d2d4a !important;
        box-shadow: none !important;
        overflow: visible !important;
    }
    /* The viewport is desktop-only `position:absolute`; on mobile it must be
       in flow so the strip auto-sizes to the visible track item. */
    #world-tracker-panel #world-track-viewport {
        position: static !important;
        inset: auto !important;
        overflow: visible !important;
        height: auto !important;
        display: block !important;
    }
    #world-tracker-panel #world-track-list {
        transform: none !important;
        height: auto !important;
        padding: 0 !important;
        display: block !important;
    }
    #world-tracker-panel #world-track-list .track-item {
        display: none !important;
    }
    #world-tracker-panel #world-track-list .track-item.active {
        display: flex !important;
        justify-content: center;
        align-items: center;
        height: auto !important;
        line-height: 1.2;
        font-size: 14px;
        padding: 4px 6px;
        letter-spacing: -0.3px;
        background: transparent !important;
        color: #e8eaff;
    }
    #world-tracker-panel #world-track-list .track-item.active::before {
        font-size: 9px;
        margin-right: 4px;
    }

    /* ─── RIGHT-SIDE VERTICAL MEMORY BAR ─── */
    #world-nav-wrap {
        grid-area: memory;
        width: 46px;
        height: 100%;
        /* Stronger bottom padding so the 9th button isn't covered by Safari's
           bottom toolbar (and the top has room for the notch). */
        padding-top: calc(env(safe-area-inset-top, 0) + 4px);
        padding-bottom: calc(env(safe-area-inset-bottom, 24px) + 36px);
        box-sizing: border-box;
        background: #0a0c14;
        border-left: 1px solid #2d2d4a;
        overflow: visible;
    }
    #memorypicker-title {
        display: none;      /* hide the horizontal title on mobile */
    }
    #world-nav {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        gap: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        background: none;    /* rotated bg handled via ::before below */
        isolation: isolate;
        box-sizing: border-box;
    }
    /* Rotate the horizontal background image 90° so it fills the vertical bar. */
    #world-nav::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 1200px;
        height: 120px;
        background: url('assets/tex/buttonsWBG.png') center/100% 100% no-repeat;
        transform: translate(-50%, -50%) rotate(90deg);
        transform-origin: center;
        z-index: -1;
        opacity: 0.9;
        pointer-events: none;
    }
    /* Rectangular buttons (taller than wide). Each takes 1/9 of the bar's
       vertical space via flex:1, capped so they don't blow out on tall
       devices. Icon rotated 90° with object-fit:contain so the full art
       is visible (no chopped width). */
    .world-btn {
        width: 42px !important;
        max-width: 42px !important;
        height: auto !important;
        max-height: 121px !important;
        min-height: 56px !important;
        padding: 0 !important;
        flex: 1 1 0 !important;
        border-radius: 4px;
        overflow: hidden;
    }
    .world-btn-img,
    .world-btn img {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: contain;
        display: block;
        /* +30% bigger icon via uniform scale on top of the 90° rotation */
        transform: rotate(90deg) scale(1.3);
        transform-origin: center;
    }
    .world-icon {
        width: 100%;
        height: auto;
        max-width: 28px;
        max-height: 28px;
    }
    .world-label {
        display: none;
    }

    /* ─── FOOTER: world description (top) + spectrogram (bottom) ─── */
    #hud-footer {
        height: auto;
        /* With 100svh viewport-lock the Safari toolbar no longer overlaps,
           so we only reserve the home-indicator safe area. */
        padding: 0 0 env(safe-area-inset-bottom, 0) 0;
        gap: 0;
        flex-direction: column;
        overflow: hidden;
    }
    /* Stack footer rows vertically: top-row has the desc, bottom-row collapses */
    #footer-top-row {
        order: 1;
        display: flex;
        flex-direction: column-reverse;  /* desc (right child) on top, spectrogram (left child) below */
        width: 100%;
        height: 100%;
        flex: 1 1 auto;
        min-height: 0;
        border-bottom: none;
    }
    #footer-bottom-row {
        display: none !important;       /* hide old bottom-row (moved tracker away) */
    }
    /* Spectrogram cell: bottom half of footer */
    #footer-top-left {
        width: 100% !important;
        height: 60px;
        flex: 0 0 60px !important;
        border-right: none !important;
        border-top: 1px solid #2d2d4a;
        background: #0a0c14;
    }
    /* World description cell: top half of footer — sized to content so the
       blue panel hugs the text instead of leaving empty space below. */
    #footer-top-right {
        display: flex !important;
        flex: 0 0 auto !important;
        width: 100% !important;
        min-height: 0 !important;
        gap: 0;
        padding: 4px 12px 4px 12px !important;
        background: #001eff !important;    /* console-blue */
        box-shadow: inset 0 0 20px rgba(0, 30, 255, 0.45);
        box-sizing: border-box;
        overflow: hidden;
        align-items: flex-start !important;
        justify-content: flex-start !important;
    }
    #footer-top-right .world-info-text {
        padding-top: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
    /* Spectrogram absorbs the remaining vertical space */
    #footer-top-left {
        flex: 1 1 auto !important;
        min-height: 60px !important;
    }
    #footer-top-right .world-info-icon {
        display: none !important;   /* hide icon on mobile to save horizontal room */
    }
    #footer-top-right .world-info-text {
        width: 100% !important;
        height: auto !important;
        gap: 0 !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        overflow: visible !important;
        display: block !important;
    }
    #footer-top-right .world-info-title {
        display: none !important; /* title is shown in the strip under the map */
    }
    /* Reset the desktop scale-transform so text renders at its real size. */
    #footer-top-right .world-info-desc-wrap {
        display: block !important;
        transform: none !important;
        white-space: normal !important;
    }
    #footer-top-right .world-info-desc {
        display: inline !important;
        font-size: 13px !important;
        line-height: 1.25 !important;
        font-weight: 300 !important;
        color: #ffffff !important;
        white-space: normal !important;
        letter-spacing: 0 !important;
        -webkit-text-stroke: 0 !important;
        text-shadow: 0 0 4px rgba(0, 0, 0, 0.7) !important;
    }
    #footer-top-right #world-text-cursor {
        display: inline !important;
        color: #ffffff !important;
        font-size: 13px !important;
    }
    /* Spanish tooltip hover — hide on touch devices; it relies on hover */
    .world-info-desc-es {
        display: none !important;
    }
}

/* ════════════════════════════════════════════════
   CUSTOM CURSOR
   ════════════════════════════════════════════════ */

#custom-cursor {
    width: 56px;
    height: 56px;
    background: url('assets/tex/pointer.png') no-repeat center center;
    background-size: contain;
    border: none;
    border-radius: 0;
    position: fixed;
    pointer-events: none;
    /* MUST BE HERE TO PREVENT BLOCKING CLICKS */
    z-index: 99999;
    transform: translate(-50%, -50%);
    transition: width 150ms, height 150ms, filter 180ms;
    filter: drop-shadow(0 0 3px rgba(180, 200, 255, 0.3));
}

@media (pointer: fine) {
    /* Hide the OS/browser cursor everywhere — !important overrides the
       cursor:pointer rules on buttons/links so the native arrow stops
       showing alongside the custom cursor. */
    *, *::before, *::after,
    html, body,
    button, a, input, textarea, select, label {
        cursor: none !important;
    }

    /* Mini glow cuando el cursor está sobre un elemento clickeable */
    #custom-cursor.hover {
        width: 72px;
        height: 72px;
        filter:
            drop-shadow(0 0 6px rgba(180, 210, 255, 0.95))
            drop-shadow(0 0 14px rgba(120, 170, 255, 0.7))
            drop-shadow(0 0 22px rgba(90, 140, 255, 0.45));
    }

    #custom-cursor.flash {
        filter:
            drop-shadow(0 0 10px rgba(255, 255, 255, 1))
            drop-shadow(0 0 18px rgba(200, 230, 255, 0.9));
        transition: none;
    }
}

@media (pointer: coarse) {
    #custom-cursor {
        display: none !important;
    }
}

/* ════════════════════════════════════════════════
   SPECTROGRAM WATERFALL
   ════════════════════════════════════════════════ */

#spectrogram-container {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.spectrogram-label {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-family: 'Averia Libre', sans-serif;
    font-size: 8px;
    letter-spacing: -0.5px;
    color: rgba(0, 100, 160, 0.5);
    z-index: 2;
    pointer-events: none;
    text-transform: uppercase;
}
#spectrogram-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* ════════════════════════════════════════════════
   FLOATING TEXT OVERLAYS 
   ════════════════════════════════════════════════ */

#text-overlay-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.floating-text {
    position: fixed;
    mix-blend-mode: screen;
    pointer-events: none;
    opacity: 0;
    max-width: 55%;
    height: auto;
    --s: 1;           /* inline override carries per-spawn scale */
    --rot: 0deg;      /* inline override carries per-spawn rotation */
    animation: textAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: opacity 7s ease-out;
    transform-origin: center center;
}

@keyframes textAppear {
    0%   { opacity: 0; transform: rotate(var(--rot)) scale(calc(var(--s) * 0.85)) translateY(8px); }
    100% { opacity: 1; transform: rotate(var(--rot)) scale(var(--s))             translateY(0); }
}

.floating-text.fading {
    opacity: 0 !important;
    transition: opacity 7s ease-out;
}

/* ══════════════════════════════════════════
   SOUND BAR — layered music controls
══════════════════════════════════════════ */

/* Sound bar takes same width as spectrogram (footer-top-left) */
#sound-bar {
    flex: 0 0 calc(29.75% + var(--w-divider)) !important;
    cursor: default;
}
#sound-bar:hover {
    transform: none;
    filter: none;
}

#sound-bar-controls {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    gap: 10px;
}

/* ── Beat indicator bars (vertical stack, half height) — pinned left ── */
#beat-indicators {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: var(--w-charbtn);
    height: 60%;
    flex-shrink: 0;
}

.beat-bar {
    flex: 1;
    background: #000000;
    border: 1.5px solid #ffffff;
    border-radius: 2px;
    box-shadow:
        0 0 4px rgba(255, 255, 255, 0.9),
        0 0 10px rgba(255, 255, 255, 0.5);
    transition: background 0.08s, box-shadow 0.08s, border-color 0.08s;
}

.beat-bar.active {
    background: #0000ff;
    border-color: #ffffff;
    box-shadow:
        0 0 6px rgba(255, 255, 255, 0.9),
        0 0 14px rgba(255, 255, 255, 0.6),
        0 0 10px rgba(0, 0, 255, 0.9),
        0 0 22px rgba(0, 0, 220, 0.55),
        inset 0 0 6px rgba(80, 160, 255, 0.6);
}

/* ── Layer toggle buttons (15% larger than left-panel btns) — centered in panel ── */
#layer-toggles {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
}

.layer-toggle-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    width: calc(var(--w-charbtn) * 1.15);
    height: calc(var(--w-charbtn) * 1.15);
    flex-shrink: 0;
}

.layer-toggle-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Show ON image by default, hide OFF */
.layer-toggle-btn .layer-btn-off { display: none; }
.layer-toggle-btn .layer-btn-on  { display: block; }

/* When muted: show OFF, hide ON */
.layer-toggle-btn[data-on="false"] .layer-btn-off { display: block; }
.layer-toggle-btn[data-on="false"] .layer-btn-on  { display: none; }

.layer-toggle-btn:hover {
    filter: brightness(1.25);
}

/* ── Volume slider (vertical) — white glowy treatment matching beat bars ── */
#volume-slider-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    height: 60%;
    align-self: center;
    flex-shrink: 0;
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    writing-mode: vertical-lr;
    direction: rtl;
    width: 8px;
    height: 100%;
    /* Active portion (from bottom up) = blue. Inactive (above fill) = black.
       White border + glow is on the element itself. */
    background: linear-gradient(to top, #0000ff 0%, #0000ff var(--vol-fill, 70%), #000000 var(--vol-fill, 70%), #000000 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    border: 1.5px solid #ffffff;
    box-shadow:
        0 0 4px rgba(255, 255, 255, 0.9),
        0 0 10px rgba(255, 255, 255, 0.5),
        0 0 8px rgba(0, 0, 255, 0.4);
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 10px;
    background: #ffffff;
    border-radius: 2px;
    cursor: pointer;
    border: 1px solid #ffffff;
    box-shadow:
        0 0 6px rgba(255, 255, 255, 1),
        0 0 14px rgba(255, 255, 255, 0.85),
        0 0 22px rgba(255, 255, 255, 0.5);
}

#volume-slider::-moz-range-thumb {
    width: 18px;
    height: 10px;
    background: #ffffff;
    border-radius: 2px;
    border: 1px solid #ffffff;
    cursor: pointer;
    box-shadow:
        0 0 6px rgba(255, 255, 255, 1),
        0 0 14px rgba(255, 255, 255, 0.85),
        0 0 22px rgba(255, 255, 255, 0.5);
}

/* ── Layer button tooltip (same style as world ES hover) ── */
#layer-btn-tooltip {
    position: fixed;
    padding: 6px 12px;
    font-family: 'Averia Libre', sans-serif;
    font-size: clamp(12px, 1.8vh, 17px);
    font-weight: 400;
    color: #ffffff;
    background: rgba(0, 10, 40, 0.88);
    border: 1px solid rgba(120, 160, 255, 0.45);
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.01em;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 9999;
    text-shadow: 0 0 6px rgba(0, 80, 255, 0.5);
    box-shadow: 0 0 18px rgba(0, 80, 255, 0.35);
}
#layer-btn-tooltip.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

#parallax-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#pmap-bg {
  position: absolute;
  width: 380%;
  height: 380%;
  top: 0;
  left: 0;
  background-image: url('assets/map2.png?v=3');
  background-size: cover;
  background-repeat: repeat;
  opacity: 0.4;
  will-change: transform;
  transition: transform 2.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

#pmap-fg {
  position: absolute;
  width: 380%;
  height: 380%;
  top: 0;
  left: 0;
  background-image: url('assets/map1.png?v=3');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  will-change: transform;
  transition: transform 1.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.pmap-node {
  transition: r 300ms, fill 300ms;
}

@keyframes nodeHeartbeat {
  0%   { filter: drop-shadow(0 0 2px #ffffff) 
                 drop-shadow(0 0 4px #ffffff); }
  40%  { filter: drop-shadow(0 0 8px #ffffff) 
                 drop-shadow(0 0 16px rgba(255,255,255,0.8)) 
                 drop-shadow(0 0 24px #ffffff); }
  60%  { filter: drop-shadow(0 0 8px #ffffff) 
                 drop-shadow(0 0 16px rgba(255,255,255,0.8)) 
                 drop-shadow(0 0 24px #ffffff); }
  100% { filter: drop-shadow(0 0 2px #ffffff) 
                 drop-shadow(0 0 4px #ffffff); }
}

.pmap-node-active {
  animation: nodeHeartbeat 1.4s ease-in-out infinite;
}

@keyframes pathTrace {
  0%   { opacity: 0; stroke-dashoffset: 40; }
  25%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: 0; }
}

.pmap-trajectory {
  animation: pathTrace 1.5s ease forwards;
}

/* ════════════════════════════════════════════════
   TUTORIAL MODE (triggered by A1button1)
   ════════════════════════════════════════════════ */
#tutorial-dim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
body.tutorial-mode #tutorial-dim {
    opacity: 1;
    pointer-events: auto;
}
/* Individual button clones placed above the dim layer so only BUTTONS stay
   bright while their containing panels remain dimmed along with the rest. */
.tutorial-button-clone {
    position: fixed;
    z-index: 9993;
    pointer-events: none;
    box-shadow: 0 0 14px rgba(168, 190, 255, 0.7),
                0 0 28px rgba(136, 153, 204, 0.4);
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#tutorial-close {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 10px rgba(190, 215, 255, 1))
            drop-shadow(0 0 22px rgba(168, 190, 255, 0.7));
    transition: filter 0.2s ease, transform 0.2s ease;
}
#tutorial-close img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
body.tutorial-mode #tutorial-close {
    display: flex;
}
#tutorial-close:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 16px rgba(220, 235, 255, 1))
            drop-shadow(0 0 32px rgba(190, 215, 255, 0.95));
}

.tutorial-label {
    position: fixed;
    z-index: 9995;
    display: none;
    pointer-events: none;
    /* Default sizing matches the previous textual label box (~240px wide) */
    width: 240px;
    max-width: 92vw;
}
.tutorial-label img {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(190, 215, 255, 0.95))
            drop-shadow(0 0 22px rgba(168, 190, 255, 0.6));
}
body.tutorial-mode .tutorial-label {
    display: block;
}

/* ════════════════════════════════════════════════
   CREDITS OVERLAY (triggered by A1button2) — same
   blurry+godrays look as the welcome intro overlay.
   ════════════════════════════════════════════════ */
#credits-overlay {
    position: fixed;
    inset: 0;
    z-index: 9997;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
body.credits-open #credits-overlay {
    display: flex;
}
#credits-blur-bg {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(14px) brightness(0.7);
    -webkit-backdrop-filter: blur(14px) brightness(0.7);
    background: rgba(0, 4, 18, 0.45);
    z-index: 0;
}
#credits-godrays {
    position: absolute;
    inset: -60%;
    width: 220%;
    height: 220%;
    background: repeating-conic-gradient(
        rgba(190, 215, 255, 0.045) 0deg,
        transparent 6deg,
        transparent 20deg,
        rgba(190, 215, 255, 0.028) 26deg,
        transparent 32deg,
        transparent 46deg,
        rgba(190, 215, 255, 0.02) 52deg,
        transparent 58deg
    );
    filter: blur(6px);
    animation: raysRotate 40s linear infinite;
    z-index: 1;
    pointer-events: none;
}
#credits-center-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse 60% 55% at 50% 50%,
        rgba(160, 200, 255, 0.18) 0%,
        rgba(80,  130, 255, 0.08) 35%,
        transparent 70%
    );
    z-index: 2;
    pointer-events: none;
}
#credits-content {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100vw;
    max-height: 100vh;
    padding: 24px;
    box-sizing: border-box;
}
#credits-img {
    display: block;
    width: auto;
    height: auto;
    max-width: min(1428px, 92vw);
    max-height: 80vh;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(180, 210, 255, 0.55))
            drop-shadow(0 0 64px rgba(140, 180, 255, 0.25));
}
#credits-close {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 10px rgba(190, 215, 255, 1))
            drop-shadow(0 0 22px rgba(168, 190, 255, 0.7));
    transition: filter 0.2s ease, transform 0.2s ease;
}
#credits-close img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
body.credits-open #credits-close {
    display: flex;
}
#credits-close:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 16px rgba(220, 235, 255, 1))
            drop-shadow(0 0 32px rgba(190, 215, 255, 0.95));
}
@media (max-height: 820px) {
    #credits-content { padding: 16px; }
    #credits-img { max-height: 74vh; }
}
@media (max-height: 640px) {
    #credits-content { padding: 10px; }
    #credits-img { max-height: 70vh; }
}

/* ════════════════════════════════════════════════
   MOBILE-ONLY OVERRIDES (misc world/intro tweaks)
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Landing ENTER button 20% smaller than desktop (320*0.8, 120*0.8) */
    #enter-btn-img {
        max-width: 256px !important;
        max-height: 96px !important;
    }

    /* Welcome screen intro text: 18px and text block 15% narrower */
    #intro-mobile-text {
        font-size: 18px !important;
        line-height: 1.45 !important;
        width: 81.6vw !important;
        max-width: 81.6vw !important;
    }

    /* Hide world01bw.png overlay on mobile for world 01 Embryo */
    #world-00-overlay-right,
    #world-00-overlay-right.visible,
    #egg-bw-img-2 {
        display: none !important;
    }

    /* World 06 Super_Me_Era charBW overlay: shift right and 30% smaller */
    #world-03-overlay {
        transform: translateX(-20%) !important;
    }
    #char-bw-img {
        height: min(39.2vh, 367px) !important;
    }

    /* ─── Hide mobile instruction image on desktop (id selector beats class) ─── */
}

/* Desktop: keep mobile-only widgets hidden everywhere */
#mobile-world-instruction-text,
#mobile-skin-toggle {
    display: none;
}

/* ════════════════════════════════════════════════
   MOBILE: viewport lock + swipe lock + instruction overlay
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Lock the entire page so:
       (a) iOS Safari can't scroll the layout vertically,
       (b) horizontal swipe-to-rotate inside the canvas doesn't drag the page,
       (c) overscroll bounce is disabled. */
    html, body {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        /* 100svh = small viewport (Safari toolbar visible) so the layout
           fits without being clipped by the bottom toolbar. */
        height: 100svh !important;
        max-height: 100svh !important;
        overflow: hidden !important;
        overscroll-behavior: none !important;
        touch-action: none !important;
    }
    #ui-shell.visible {
        height: 100svh !important;
        max-height: 100svh !important;
        overflow: hidden !important;
        touch-action: none !important;
    }

    /* Mobile instruction text — sits ABOVE the typewriter description so
       it stays anchored while the desc types itself out below. Persists
       while the world is active. Uppercase, centered, strong glow. */
    #mobile-world-instruction-text {
        display: block !important;
        width: 100% !important;
        margin: 0 0 4px 0 !important;
        padding: 0 4px !important;
        box-sizing: border-box !important;
        font-family: 'Averia Libre', sans-serif !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        line-height: 1.15 !important;
        letter-spacing: 0.5px !important;
        text-align: center !important;
        color: #ffffff !important;
        text-transform: uppercase;
        text-shadow:
            0 0 6px rgba(255, 255, 255, 0.85),
            0 0 14px rgba(160, 200, 255, 0.65),
            0 0 24px rgba(120, 180, 255, 0.45),
            0 0 4px rgba(0, 0, 0, 0.6);
    }
    #mobile-world-instruction-text:empty {
        display: none !important;
    }

    /* ─── Mobile skin-mode toggle button (always visible, top-left of canvas) ─── */
    #mobile-skin-toggle {
        display: block !important;
        position: fixed !important;
        /* Sits at the bottom of the viewport, over the spectrogram strip. */
        top: auto !important;
        bottom: calc(env(safe-area-inset-bottom, 0) + 12px) !important;
        /* Sit clear of the skin column so it doesn't cover the skin buttons
           when the panel is open. */
        left: 62px !important;
        width: 44px !important;
        height: 44px !important;
        padding: 3px !important;
        margin: 0 !important;
        background: rgba(10, 12, 20, 0.85) !important;
        border: 1px solid #88ccff !important;
        border-radius: 6px !important;
        cursor: pointer;
        z-index: 99999 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent;
        box-shadow: 0 0 8px rgba(120, 180, 255, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    #mobile-skin-toggle img {
        display: block;
        width: 100% !important;
        height: 100% !important;
        object-fit: contain;
        pointer-events: none;
    }
    /* Active state when skin mode is on */
    body.mobile-skin-mode #mobile-skin-toggle {
        background: rgba(0, 30, 255, 0.55) !important;
        border-color: #88ccff !important;
        box-shadow: 0 0 12px rgba(120, 180, 255, 0.6);
    }

    /* ─── SKIN MODE: replace memory bar + canvas + footer with character panel ─── */
    body.mobile-skin-mode #world-nav-wrap,
    body.mobile-skin-mode #canvas-area,
    body.mobile-skin-mode #world-tracker-panel,
    body.mobile-skin-mode #hud-footer {
        display: none !important;
    }
    /* Show the character panel as a full-area overlay covering canvas+footer.
       Desktop hides #character-panel via display:none — override here. */
    body.mobile-skin-mode #character-panel {
        display: flex !important;
        flex-direction: row !important;
        position: fixed !important;
        top: calc(54px + env(safe-area-inset-top, 0)) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: env(safe-area-inset-bottom, 0) !important;
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #0a0c14 !important;
        z-index: 240 !important;
        gap: 0 !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        border: none !important;
        box-shadow: none !important;
    }
    /* Skin colour buttons — vertical strip on the left, same proportions
       as the world memory buttons. */
    body.mobile-skin-mode #texture-buttons {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 0 !important;
        /* Column slightly wider than the button so the icons get a small
           horizontal margin on each side. */
        width: 52px !important;
        max-width: 52px !important;
        height: 100% !important;
        padding: 4px 0 !important;
        background: #0a0c14 !important;
        border-right: 1px solid #2d2d4a !important;
        box-sizing: border-box !important;
    }
    body.mobile-skin-mode .texture-btn {
        display: block !important;
        width: 38px !important;
        max-width: 38px !important;
        height: auto !important;
        min-height: 50px !important;
        max-height: 109px !important;
        flex: 1 1 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: none !important;
        border-radius: 4px;
        overflow: hidden;
    }
    body.mobile-skin-mode .texture-btn img {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: contain !important;
        transform: rotate(90deg) scale(1.3);
        transform-origin: center;
    }
    body.mobile-skin-mode .texture-btn .btn-hover { display: none !important; }
    body.mobile-skin-mode .texture-btn.active .btn-normal { display: none !important; }
    body.mobile-skin-mode .texture-btn.active .btn-hover  { display: block !important; }
    /* Character display fills the remaining space to the right of the buttons */
    body.mobile-skin-mode #character-display {
        display: flex !important;
        flex: 1 1 auto !important;
        align-items: center !important;
        justify-content: center !important;
        background: #050810 !important;
        overflow: hidden;
    }
    body.mobile-skin-mode #character-webp {
        max-width: 100% !important;
        max-height: 100% !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain !important;
        opacity: 1 !important;
    }
}
