:root {
    --brand: linear-gradient(135deg, #1d4ed8 0%, #1e3a8a  100%);
    --pure-bg: #ffffff;
    --bg-title: #F2F0EF;
    --blue: #5297ff;
    --blue-alt: #5269ff;
    --blue-deep: #5999ff;
    --blue-muted: #5269ff;
    --unit-font: #70bfef;
    --cyan: #11c2f7;
    --pink: #ffc6c3;
    --content-blue: #455163;
    --bg: #F5F3F0;
    --bg-soft: rgb(253, 253, 253);
    --bg-panel: rgb(250, 250, 250);
    --bg-panel-alt: rgb(254, 254, 254);
    --bg-footer: rgb(40, 40, 40);
    --color-picker: black;
    --border-light: rgb(240, 240, 240);
    --border-dotted: rgb(180, 180, 180);
    --cm-text: #5297ff;
    --text: #5297ff;
    --text-muted: #5297ff;
    --text-placeholder: rgb(100, 100, 100);
    --text-on-accent: white;
    --popup: brightness(0) invert(1);
    --shadow-blur: 100px;
    --color-bar: rgb(233, 234, 236);
}

[data-theme="dark"] {
    --brand: linear-gradient(135deg, #B3C5FF 0%, #70A1FF 100%);
    --pure-bg: #000000;
    --blue: #6699ff;
    --color-picker: white;
    --blue-alt: #7a94ff;
    --blue-deep: #6f9fff;
    --blue-muted: #7a94ff;
    --unit-font: #3d87cb;
    --cyan: #33cbff;
    --pink: #ff9a95;
    --content-blue: #bcd7ff;
    --bg: #1A1A1A;
    --bg-soft: #1b1b1b;
    --bg-panel: #1a1a1a;
    --bg-panel-alt: #171717;
    --bg-footer: #0a0a0a;
    --bg-title: #1B1C1E;
    --border-light: rgb(50, 50, 50);
    --border-dotted: rgb(110, 110, 110);
    --cm-text: #8db1ef;
    --text: #5297ff;
    --text-muted: #5297ff;
    --text-placeholder: rgb(160, 160, 160);
    --text-on-accent: white;
    --popup: brightness(0);
    --color-bar: rgb(57, 57, 57);
}

[data-theme="dark"] .animal-box {
    background: rgb(58, 58, 58)
}
   /* ==========================================================================
   LIQUID GLASS — "ADDED!" POPUP
   ========================================================================== */
.added-popup {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999999999;
    
    /* Glass Background */
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    
    /* Glass Highlights & Borders */
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1), 
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
        
    padding: 10px 20px;
    border-radius: 30px;
    
    /* Flexbox for text and icon */
    display: flex;
    align-items: center;
    gap: 8px;
    
    color: var(--text-strong);
    font-family: "Elms Sans", sans-serif;
    font-weight: 900;
    font-size: 15px;
    pointer-events: none;
    
    /* Animation */
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}



.added-popup .popup-icon {
    height: 20px;
    width: auto;
    margin: 0;
    padding: 0;
    opacity: 1;
    display: block;
}

/* Dark Mode Overrides */
[data-theme="dark"] .added-popup {
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5), 
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.activePop {
    animation: popupAni 0.3s ease-in-out forwards;
}
.unactivePop {
    animation: fadeInPopup 0.5s ease-in-out  forwards;
}
@keyframes fadeInPopup {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
@keyframes popupAni {
    from {
        transform: translate(-50%, -30px) ;
        opacity: 0;
    }
    to {
        transform: translateX(-50%);
        opacity: 1;
    }
}
.popup-icon {
    filter: var(--popup);
    height: 20px; 
    width: 20px;
    margin-left: 10px;
} 
body {
    touch-action: manipulation;
    background: var(--bg);
    font-family: "Elms Sans", sans-serif !important;
    color: var(--content-blue);
    transition: background 0.3s ease, color 0.3s ease;
    overflow-x: hidden !important;
    padding-top: 0px;
}
img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}
button {
    cursor: pointer !important;
}

input, textarea, select {
    font-size: 16px !important;
}
.title {
    text-align: center;
    font-size: 30px;
    font-weight: bolder;
}
#body-web {
    width: 100%;
    margin: 0 auto;
    margin-top: 10%;
    overflow-y: scroll;
    overflow-x: hidden;
}

a {
    color: var(--cyan);
    font-size: 1.1em;
}
.personbox {
    animation: personBox 0.2s ease-in-out forwards;
    touch-action: none;
}
@keyframes personBox{
    from {
      opacity: 0.3;
      transform: translateY(30px) scale(0.8);
    }
    to {
      opacity: 1;
      transform: translateY(0px) scale(1);
    }
}
/* ==========================================================================
   MODE TOGGLE
   ========================================================================== */
#mode {
    width: 80%;
    border: 1px solid var(--blue);
    height: 30px;
    display: flex;
    flex-direction: row;
    gap: 0;
    padding: 0;
}
.darkmode, .lightmode{
    flex: 1;
    border: none;
    background: var(--bg);
    color: var(--blue);
    height: 100%;
}
.darkmodeA, .lightmodeA {
    color: var(--text-on-accent) !important;
    background: var(--blue) !important;
}
/* ==========================================================================
   TITLE BAR
   ========================================================================== */
   /*
#title-bar {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 50px;
    z-index: calc(99999999 * 99999999);
    background: var(--bg-title);
    border-bottom: 1px solid var(--border-light);
    padding: 0 10px;
    padding-right: 10px !important;
    gap: 5px;
    backdrop-filter: blur(var(--shadow-blur));
    overflow: hidden;
}
*/

/* ==========================================================================
TITLE BAR — LIQUID GLASS (Tinted with var(--bg-title))
========================================================================== */
#title-bar {
 display: flex;
 flex-direction: row;
 flex-wrap: nowrap;
 align-items: center;
 position: fixed;
 top: 0;
 left: 0;
 right: 0;
 width: 100%;
 height: 50px;
 z-index: 100000; 
 
 /* 1. The base color is your requested var(--bg-title), made 75% opaque */
 background: var(--bg-title); /* Fallback for older browsers */
 background: color-mix(in srgb, var(--bg-title) 75%, transparent);
 
 /* 2. The Glass Blur - blurs whatever content scrolls underneath */
 backdrop-filter: blur(12px) saturate(180%);
 -webkit-backdrop-filter: blur(12px) saturate(180%);
 
 /* 3. The Glass Highlights & Shadows */
 border-bottom: 1px solid rgba(255, 255, 255, 0.5);
 box-shadow: 
     0 4px 30px rgba(0, 0, 0, 0.05),        /* Drop shadow */
     inset 0 1px 0 rgba(255, 255, 255, 0.8); /* Top edge light reflection */
 
 padding: 0 10px;
 padding-right: 10px !important;
 gap: 5px;
 transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
[data-theme="dark"] #title-bar {
    background: linear-gradient(
        135deg, 
        rgba(30, 30, 30, 0.75) 0%, 
        rgba(15, 15, 15, 0.35) 100%
    );
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 4px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15); /* Top edge reflection */
}

@scope (#title-bar) {
    > div:first-child {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 90%;
      aspect-ratio: 1/1;
    }
    img {
      height: 55px;
      margin: auto 0;
      opacity: 0.8;
      z-index: -100;
    }
    p {
      flex: 0.7;
    }
    .logo {
      height: 40px;
      opacity: 0.8;
      border: none !important;
    }
    button {
      font-size: 8px;
      padding: 5px 7px;
      border-radius: 1px;
      border: 1px solid var(--cyan);
      font-family: "Elms Sans", sans-serif;
      font-weight: 800;
    }
}
/* ==========================================================================
   HEIGHT TRACKER BUTTON — icon only
   --------------------------------------------------------------------------
   The button renders only photos/htracker-icon.png (which ships blue).
   · heightTracker.html: the icon keeps its original blue (active).
   · Any other page: JS adds .is-inactive, and the icon is recoloured so it
     reads as an inactive control — black in the light theme, white in the
     dark theme.
   ========================================================================== */
#title-bar .heighttracker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    line-height: 1;
    flex: 0 0 auto;
    transition: background 0.15s ease, transform 0.08s ease;
}
#title-bar .heighttracker-btn:hover {
    background: rgba(82, 151, 255, 0.14);
}
#title-bar .heighttracker-btn:active {
    transform: scale(0.94);
}
[data-theme="dark"] #title-bar .heighttracker-btn:hover {
    background: rgba(255, 255, 255, 0.10);
}

#title-bar .heighttracker-btn img.htracker-icon {
    display: block;
    height: 20px !important;
    width: auto !important;
    max-width: 140px;
    margin: 0 !important;
    opacity: 1 !important;
    z-index: auto !important;
    border: none !important;
    pointer-events: none;
    transition: filter 0.2s ease;
}

#title-bar .heighttracker-btn.is-inactive img.htracker-icon {
    filter: grayscale(100%);
}
[data-theme="dark"] #title-bar .heighttracker-btn.is-inactive img.htracker-icon {
    filter:grayscale(100%);
}
/* ==========================================================================
   HEIGHT CALCULATOR BUTTON — icon only
   --------------------------------------------------------------------------
   The button renders only photos/hcal.png (which ships blue).
   · heightCal.html: the icon keeps its original blue (active).
   · Any other page: JS adds .is-inactive, and the icon is recoloured so it
     reads as an inactive control — black in the light theme, white in the
     dark theme.
   brightness(0) turns any artwork black; adding invert(1) turns it white,
   so a single PNG covers both themes without a second asset.
   ========================================================================== */

#title-bar .heightcal-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    padding: 0 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    line-height: 1;
    flex: 0 0 auto;
    transition: background 0.15s ease, transform 0.08s ease;
}
#title-bar .heightcal-btn:hover {
    background: rgba(82, 151, 255, 0.14);
}
#title-bar .heightcal-btn:active {
    transform: scale(0.94);
}
[data-theme="dark"] #title-bar .heightcal-btn:hover {
    background: rgba(255, 255, 255, 0.10);
}

/* Override the scoped `img { height: 55px; opacity: .8; z-index: -100 }`
   rule so the icon renders at its intended size. */
#title-bar .heightcal-btn img.hcal-icon {
    display: block;
    height: 20px !important;
    width: auto !important;
    max-width: 140px;
    margin: 0 !important;
    opacity: 1 !important;
    z-index: auto !important;
    border: none !important;
    pointer-events: none;
    transition: filter 0.2s ease;
}

/* Inactive — light theme: black icon */
#title-bar .heightcal-btn.is-inactive img.hcal-icon {
    filter: grayscale(100%);
}
/* Inactive — dark theme: white icon */
[data-theme="dark"] #title-bar .heightcal-btn.is-inactive img.hcal-icon {
    filter: grayscale(100%);
}
/* ==========================================================================
   HOME BUTTON — icon only
   --------------------------------------------------------------------------
   The button renders only photos/home-icon.png (which ships blue).
   · Main page (index.html): the icon keeps its original blue.
   · Any other page: JS adds .is-inactive, and the icon is recoloured so it
     reads as an inactive control — black in the light theme, white in the
     dark theme.
   brightness(0) turns any artwork black; adding invert(1) turns it white,
   so a single PNG covers both themes without a second asset.
   ========================================================================== */
#title-bar .home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    min-width: 34px;
    padding: 0 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s ease, transform 0.08s ease;
}
#title-bar .home-btn:hover {
    background: rgba(82, 151, 255, 0.14);
}
#title-bar .home-btn:active {
    transform: scale(0.94);
}
[data-theme="dark"] #title-bar .home-btn:hover {
    background: rgba(255, 255, 255, 0.10);
}

#title-bar .math-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    min-width: 34px;
    padding: 0 6px;
    background: transparent;
    border: none;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s ease, transform 0.08s ease;
}
#title-bar .math-btn:hover {
    background: rgba(82, 151, 255, 0.14);
}
#title-bar .math-btn:active {
    transform: scale(0.94);
}
[data-theme="dark"] #title-bar .math-btn:hover {
    background: rgba(255, 255, 255, 0.10);
}
#title-bar .math-btn img.math-icon {
    display: block;
    height: 22px !important;
    width: auto !important;
    margin: 0 !important;
    opacity: 1 !important;
    z-index: auto !important;
    border: none !important;
    pointer-events: none;
    transition: filter 0.2s ease;
}
/* The scoped `img { height: 55px; opacity: .8; z-index: -100 }` rule in
   #title-bar would otherwise stretch and hide the icon — override it. */
#title-bar .home-btn img.home-icon {
    display: block;
    height: 22px !important;
    width: auto !important;
    margin: 0 !important;
    opacity: 1 !important;
    z-index: auto !important;
    border: none !important;
    pointer-events: none;
    transition: filter 0.2s ease;
}

/* Inactive — light theme: black icon */
#title-bar .home-btn.is-inactive img.home-icon {
    filter: brightness(0);
}
/* Inactive — dark theme: white icon */
[data-theme="dark"] #title-bar .home-btn.is-inactive img.home-icon {
    filter: brightness(0) invert(1);
}
#vers {
    display: flex;
    position: absolute;
    right: 30px;
    bottom: -2px;
    height: 10px;
    width: 70px;
    div {
      font-size: 6px;
      width: 100%;
      text-align: right;
      font-weight: 900;
      opacity: 0.5;
    }
}
/* ==========================================================================
   HAMBURGER MENU
   ========================================================================== */
.ham-menu {
    height: 50% !important;
    aspect-ratio: 1/1 !important;
    margin: auto;
    border: none;
    display: flex;
    position: relative;
    z-index: 10000000000;
    cursor: pointer;
}
.active1 {
    animation: stick1 0.2s ease-in-out forwards;
    transform-origin: left;
}
.active2 {
    animation: stick2 0.2s ease-in-out forwards;
    transform-origin: left;
}
.active3 {
    animation: stick3 0.2s ease-in-out forwards;
}
@keyframes stick3 {
    from { transform: scale(1); opacity: 1; }
    to   { transform: scale(0.3, 0.5); opacity: 0; }
}
@keyframes stick1 {
    from { transform: translateY(-15%) rotate(0deg); }
    to   { transform: translateY(-15%) rotate(38deg); }
}
@keyframes stick2 {
    from { transform: translateY(-85%) rotate(0deg); }
    to   { transform: translateY(-85%) rotate(-38deg); }
}
@scope (.ham-menu) {
    div { transition: 0.2s ease-in-out; border-radius: 5px; }
    > div:first-child {
      position: absolute; top: 15%; transform: translateY(-25%);
      height: 10%; width: 100%; background: var(--blue);
    }
    > div:nth-child(2) {
      position: absolute; top: 50%; transform: translateY(-50%);
      height: 10%; width: 100%; background: var(--blue);
    }
    > div:nth-child(3) {
      position: absolute; height: 10%; width: 100%;
      background: var(--blue); top: 85%; transform: translateY(-75%);
    }
}

/* ==========================================================================
   MENU PANEL
   ========================================================================== */
/*
.menu-display {
    position: fixed;
    z-index: 1000000;
    top: 50px;
    right: -55vw;
    height: calc(100vh - 50px);
    width: 70%;
    backdrop-filter: blur(var(--shadow-blur));
    border-left: 1px solid var(--border-light);
    display: none;
    flex-direction: column;
    background: var(--bg);
    opacity: 0.8;
    padding-left: 0;
}
*/

/* ==========================================================================
   MENU PANEL — LIQUID GLASS
   ========================================================================== */
.menu-display {
    position: fixed;
    z-index: 1000000;
    top: 50px;
    right: -55vw;
    height: calc(100vh - 50px);
    width: 70%;
    padding-bottom: 100px;
    overflow-y: scroll;
    
    /* 1. The Glass Background */
    background: var(--bg); /* Fallback */
    background: color-mix(in srgb, var(--bg) 80%, transparent);
    
    /* 2. The Blur Effect */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    /* 3. Highlights & Shadows (Left edge is the "edge" of the glass) */
    border-left: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        -4px 0 30px rgba(0, 0, 0, 0.05),
        inset 1px 0 0 rgba(255, 255, 255, 0.9);
        
    display: none;
    flex-direction: column;
    padding-left: 0;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Dark Mode Glass */
[data-theme="dark"] .menu-display {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 
        -4px 0 30px rgba(0, 0, 0, 0.3),
        inset 1px 0 0 rgba(255, 255, 255, 0.12);
}

.activemenu   { animation: swipeMenu   0.2s ease-in-out forwards; }
.unactivemenu { animation: unswipeMenu 0.2s ease-in-out forwards; }
@scope (.menu-display) {
    h4 {
      text-align: center;
      border-bottom: 3px solid var(--blue-muted);
      padding-bottom: 10px;
      margin-top: 0;
    }
    > div:nth-child(2),
    > div:nth-child(3),
    > div:nth-child(4) {
      display: flex;
      flex-direction: row !important;
      padding: 0 0 15px 8px;
      align-items: center;
      gap: 5px;
      margin-bottom: 10px;
      border-bottom: 1px solid var(--blue-muted);
      margin-left: 1%;
      height: 50px;
    }
    > div:nth-child(5),
    > div:nth-child(6) {
      display: flex;
      width: 100%;
      flex-direction: column;
      gap: 10px;
      justify-content: center !important;
      margin: 0 auto;
      border-bottom: 1px solid var(--blue-muted);
      padding: 0 0 20px 0;
      div { text-align: center; font-weight: 500; }
      button {
        width: 90%;
        height: 35px;
        border-radius: 2px;
        background: rgb(79, 158, 255);
        color: var(--bg);
        border: none;
        font-weight: 1000;
        margin: 0 auto;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 10px;
        p {
            text-align: center;
        }
      }
    }
}
.icon-tool {
    height: 25px;
    width: 25px;
}
.icon-tools {
    height: 25px;
    filter: brightness(10%) invert(1);
}
[data-theme="dark"] .icon-tools {
    filter: brightness(20%);
}
@scope (.div1) {
    > div {
      display: flex;
      flex-direction: row;
      align-items: center;
      gap: 0;
      color: var(--text) !important;
      button {
        background: var(--bg);
        border: 1px solid var(--blue);
        color: var(--blue);
        height: 23px;
        border-radius: 5px;
        margin: 0 3px;
      }
      div {
        width: 10vw;
        background: var(--bg);
        color: var(--text);
        border: none;
        display: grid;
        text-align: center;
      }
    }
    p { color: var(--text) !important; font-weight: bolder !important; }
    .p { color: var(--text) !important; font-weight: bolder !important; }
}
@keyframes swipeMenu {
    from { right: -55vw; }
    to   { right: 0vw; }
}
@keyframes unswipeMenu {
    from { right: 0vw; }
    to   { right: -55vw; }
}

/* ==========================================================================
   HEIGHT DISPLAY
   ========================================================================== */
.top-ad-wrapper {
    width: 100%;
    max-width: 468px;
    height: 60px;
    margin: 10px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    clear: both;
}
.native-ad-container {
    max-width: 100%;
    max-height: 100px;
    overflow: hidden;
    margin: 0px auto;
    margin-bottom: 10px;
    padding: 10px;
    box-sizing: border-box;
}
.native-ad-container > div {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    gap: 0px !important;
}
.native-ad-container img {
    max-height: 80px !important;
    object-fit: cover !important;
    border-radius: 6px;
}
.native-ad-container a,
.native-ad-container span,
.native-ad-container div {
    font-size: 12px !important;
    line-height: 1.2 !important;
}
.ad { overflow-x: hidden; }
.clickHere {
    width: min(90%, 360px);
    height: auto;
    margin: 20px auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #ffffff;
    font-family: inherit;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.clickHere:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}
.clickHere:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

#height-display {
    width: 100%;
    height: 420px;
    transform: scale(0.985, 0.965);
    background-color: var(--bg);
    border: 1px solid var(--border-light);
    margin: 0 auto;
    margin-top: 0px;
    margin-bottom: -5px;
    position: relative !important;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}
.brand {
    width: 100%;
    height: 20px;
    position: absolute;
    text-align: center;
    color: var(--brand);
    font-size: 13px;
    font-weight: 1000 !important;
    opacity: 0.4;
    letter-spacing: 1px;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-color: var(--pure-bg);
    background-image: var(--brand);
    z-index: 10000000000;
}
#display-person {
    width: 92%;
    height: 420px;
    position: absolute;
    right: 0;
    overflow-x: auto !important;      /* was: scroll — no bar when not needed */
    overflow-y: hidden;
    z-index: 100;
    display: flex;
    justify-content: safe center;
    align-items: flex-end;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;

    /* NEW: gives the first and last figures' labels real breathing room
       inside the scroll container so they can't be clipped by the
       container's own left / right boundary. */
    padding-left: 28px;
    padding-right: 28px;
    box-sizing: border-box;
    scroll-padding-left: 28px;
    scroll-padding-right: 28px;
    gap: var(--figure-gap, 10px);
}
#display-person > .personbox {
    margin: 0 !important;
    flex-shrink: 0 !important;
}
/* ==========================================================================
   LINEUP ORDER — inline delete button + drag-to-reorder
   ========================================================================== */

/* Widen the trailing column so three buttons fit in a row. */
.adjust-display .figure-display > div {
    grid-template-columns: 20px 1fr 76px !important;
}

/* figurePosition (3rd child) becomes a horizontal row: up, down, delete. */
.adjust-display .figure-display > div > div:nth-child(3) {
    display: flex !important;
    flex-direction: row !important;
    gap: 3px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    padding: 0 2px 0 0 !important;
    z-index: 10000 !important;
}

.adjust-display .figure-display > div > div:nth-child(3) .move-up,
.adjust-display .figure-display > div > div:nth-child(3) .move-down,
.adjust-display .figure-display > div > div:nth-child(3) .del-figure {
    padding: 0 !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    flex: 0 0 20px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border: 1px solid var(--blue);
    border-radius: 2px;
    background-color: var(--bg);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 78% 78%;
    cursor: pointer;
}

.adjust-display .figure-display > div > div:nth-child(3) .move-up   { background-image: url('photos/moveUp.png'); }
.adjust-display .figure-display > div > div:nth-child(3) .move-down { background-image: url('photos/moveDown.png'); }
.adjust-display .figure-display > div > div:nth-child(3) .del-figure {
    background-image: url('photos/delbtn.png');
}

/* Dragging state — follow the finger, block browser scroll/select. */
.adjust-display .figure-display > div.dragging {
    touch-action: none !important;
    user-select: none;
    -webkit-user-select: none;
    cursor: grabbing;
    opacity: 0.95;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    z-index: 500;
    position: relative;
}

.newperson { 
    flex-shrink: 0; 
    transition: none !important;
    
    /* Use optimize-contrast for sharp edges, not pixelated */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ==========================================================================
   FIGURE ZOOM + REMOVE ANIMATIONS
   ========================================================================== */

/* personInfo pop/refit animation. The existing transform-origin and
   will-change rules stay; this just smooths the scale change. */
#display-person .personbox > div {
    transition: transform 0.2s ease-out;
}

/* Figure removal — canvas figure drops down and fades. */
@keyframes personBoxOut {
    from { opacity: 1; transform: translateY(0)    scale(1);    }
    to   { opacity: 0; transform: translateY(20px) scale(0.85); }
}
.personbox.removing {
    animation: personBoxOut 0.2s ease-in forwards !important;
    pointer-events: none !important;
}

/* Paired lineup-order row shrinks in place. */
@keyframes figureOut {
    from { opacity: 1; transform: scale(1);    }
    to   { opacity: 0; transform: scale(0.9);  }
}
.adjust-display .figure-display > div.removing {
    animation: figureOut 0.2s ease-in forwards !important;
    pointer-events: none !important;
}

#display-person .personbox > div {
    transform-origin: center bottom;
    will-change: transform;
}

#height-info {
    width: 95%;
    margin: 0 auto;
}
#lineup-scrollbar {
    display: block;
    width: 70%;
    margin: 6px auto 4px auto;
    accent-color: var(--blue);
    cursor: pointer;
}
#lineup-scrollbar:disabled {
    opacity: 0.5;
    cursor: default;
}
.youSure {
    display: none;
    z-index: 999999999999999;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    border: 2.5px solid var(--blue-muted);
    border-radius: 10px;
    width: 75%;
    height: 240px;
    p:first-child {
      text-align: center;
      font-size: 1.3em;
      font-weight: 700;
      border-bottom: 1px solid var(--blue-muted);
      padding-bottom: 10px;
    }
    p:nth-child(2) {
      text-align: center;
      font-weight: 500;
      padding: 0 10px;
    }
    > div {
      display: flex;
      height: 40px;
      width: calc(100% - 40px);
      margin: 10px auto;
      gap: 20px;
      padding: 0 20px 0 20px;
      button { flex: 1; height: 100%; }
      button:first-child {
        background: var(--bg);
        color: var(--blue);
        border: 1px solid var(--blue-muted);
        border-radius: 5px;
      }
      button:nth-child(2) {
        color: var(--bg);
        background: var(--blue);
        border: 1px solid var(--blue);
        border-radius: 5px;
      }
    }
}
@keyframes shareAnimation {
    from { 
        transform: translate(-50%, -60%); 
        border-radius: 50%; opacity: 0.4; 
    }
    to   { 
        transform: translate(-50%, -50%); 
        border-radius: 10px; opacity: 1; 
    }
}
.share-animation {
    animation: shareAnimation 0.25s ease-in-out forwards;
    transform-origin: center;
}
.share-modal {
    display: none;
    z-index: 999999999999999;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    border: 2.5px solid var(--blue-muted);
    border-radius: 10px;
    width: 85%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: 16px;
    p:first-of-type {
      text-align: center;
      font-size: 1.3em;
      font-weight: 700;
      border-bottom: 1px solid var(--blue-muted);
      padding: 14px 0 10px 0;
    }
    p.share-sub {
      text-align: center;
      font-weight: 500;
      font-size: 0.85em;
      padding: 8px 16px 0 16px;
      color: var(--blue-muted);
    }
    p.share-warn {
      text-align: center;
      font-weight: 600;
      font-size: 0.8em;
      padding: 6px 16px 0 16px;
      color: var(--blue);
    }
    p.share-warn:empty { display: none; }
}
.share-preview {
    width: calc(100% - 32px);
    height: 150px;
    margin: 12px auto 0 auto;
    border: 1.5px solid var(--blue-muted);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    background: var(--bg);
}
.share-preview-inner {
    position: absolute;
    left: 0; bottom: 0;
    transform-origin: bottom left;
    pointer-events: none;
}
.share-link-row {
    display: flex;
    width: calc(100% - 32px);
    height: 38px;
    margin: 14px auto 0 auto;
    gap: 6px;
}
.share-link-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 8px;
    background: var(--bg);
    color: var(--content-blue);
    border: 1px solid var(--blue-muted);
    border-radius: 5px;
    font-size: 0.8em;
}
.share-copy-btn {
    width: 60px;
    height: 100%;
    background: var(--blue);
    color: var(--bg);
    border: 1px solid var(--blue);
    border-radius: 5px;
    font-weight: 700;
    cursor: pointer;
}
.share-native-btn {
    display: block;
    width: calc(100% - 32px);
    height: 38px;
    margin: 10px auto 0 auto;
    background: var(--bg);
    color: var(--blue);
    border: 1px solid var(--blue-muted);
    border-radius: 5px;
    font-weight: 700;
    cursor: pointer;
}
.nav-options {
    width: 99vw;
    height: 60px;
    overflow: hidden;
    margin: 0 auto;
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    column-gap: 5px;
    border: 1px solid var(--blue) !important;
    border-radius: 30px;
    background: var(--bg);
    font-family: "Elms Sans", sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}
.male-opt, .female-opt, .cel-opt, .obj-opt, .img-opt, .mals-opt, .coun-opt {
    flex: 1;
    background-color: var(--bg);
    border: none;
    color: var(--blue) !important;
    font-size: 8px;
    border-radius: 25.2px;
    animation: unactiveOption 0.5s ease-in-out;
    cursor: pointer;
    font-family: "Elms Sans", sans-serif;
    font-weight: 700;
}
.ob {
    flex: 1;
    background-color: var(--bg);
    border: none;
    color: var(--blue);
    border-radius: 25.2px;
    animation: unactiveOption 0.5s ease-in-out;
    cursor: pointer;
    font-family: "Elms Sans", sans-serif;
    p { margin-top: 5px; }
    img { max-width: 100%; height: auto; object-fit: contain; }
}
.female-opt-active,
.male-opt-active,
.cel-opt-active,
.obj-opt-active,
.mals-opt-active,
.img-opt-active, 
.coun-opt-active{
    background: linear-gradient(var(--cyan) 0%, var(--blue) 100%) !important;
    color: var(--text-on-accent) !important;
    border: none;
    flex: 2.7;
    font-size: 10px;
    border-radius: 6px !important;
    animation: activeOption 0.5s ease-in-out;
    cursor: pointer;
    font-family: "Elms Sans", sans-serif;
    font-weight: 1000;
}
@keyframes activeOption {
    0%   { background-color: var(--bg); transform: scale(0.4, 0.2); color: var(--blue); font-size: 8px; }
    30%  { background-color: var(--blue); color: var(--text-on-accent); }
    70%  { flex: 3.1; transform: scaleY(0.85); }
    100% { background-color: var(--blue); flex: 2.7; color: var(--text-on-accent); font-size: 10px; }
}
@keyframes unactiveOption {
    0%   { flex: 2.7; color: var(--text-on-accent); font-size: 10px; }
    30%  { background-color: var(--bg); color: var(--blue); }
    100% { background-color: var(--bg); flex: 1; color: var(--blue); font-size: 8px; }
}

/* ==========================================================================
   UNIT OPTION
   ========================================================================== */
#unit-option {
    width: 100%;
    height: 60px;
    display: flex;
    padding: 0px;
    align-items: center;
}
#unit-option2 {
    margin-left: 3px !important;
    margin-right: auto;
    margin-bottom: -14px;
    width: 35%;
    height: 30px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    opacity: 0.78;
    gap: 0 !important;
    border: 1.5px solid var(--blue);
    border-radius: 5px;
    overflow: hidden;
}
@scope (#unit-option2) {
    div:first-child {
        font-size: 0.3em;
        text-align: center;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        font-weight: 500;
        height: 40%;
        color: var(--bg);
        background: var(--blue);
        border-bottom: 1px solid var(--bg);
    }
    div:nth-child(2) {
        height: 60% !important;
        width: 100%;
        display: flex;
        button { 
            flex: 1 !important; 
            border: none !important; 
            font-size: 0.67em;
            font-weight: 700; 
        }
    }
}
@scope (#unit-option) {
    div { border: 1px solid var(--blue); display: flex; width: 100%; height: 30px; }
    button { flex: 1; border: 1px solid var(--blue); height: 30px; }
    p { color: var(--text) !important; font-weight: bolder !important; }
}
version {
    position: absolute;
    bottom: 0;
    left: 0;
    color: var(--text);
    font-weight: bolder;
    text-align: center;
    border-top: 1px solid var(--border-dotted);
}
.mbtn, .ubtn { background: var(--bg); color: var(--blue); }
.mbtn-active, .ubtn-active { background: var(--blue); color: var(--text-on-accent); }
#metric-hBox { display: block; }
#us-hBox { display: none; }

/* ==========================================================================
   OPTION DISPLAY (CLEAN FORM)
   ========================================================================== */
#option-display {
    width: 95%;
    margin: 20px auto;
    padding: 24px 15px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-sizing: border-box;
    font-family: "Elms Sans", sans-serif;
    display: flex;
    flex-direction: column;
    gap: 0px !important;
}

#option-display label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--content-blue);
    margin-bottom: 0px;
    padding-left: 2px;
}
#option-display > * {
    margin-bottom: 0 !important;
}
#option-display input[type="text"],
#option-display input[type="number"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    box-sizing: border-box;
    margin-bottom: 18px;
    transition: border-color 0.2s ease;
}

#option-display input:focus {
    outline: none;
    border-color: var(--blue);
}

/* Gender Toggle */
#gender-option {
    display: flex;
    width: 100%;
    height: 48px;
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 18px;
    background: var(--bg);
}

#gender-option > div {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    color: var(--content-blue);
    background: transparent;
    transition: 0.2s ease;
}

#gender-option > div.male-option-ac,
#gender-option > div.female-option-ac {
    background: rgba(82, 151, 255, 0.1);
    color: var(--blue);
    box-shadow: inset 0 -3px 0 var(--blue);
}

/* Buttons */
#option-display .create-btn {
    width: 100%;
    height: 54px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 27px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 10px;
    font-family: inherit;
}

#option-display .change-avatar {
    width: 100%;
    background: transparent;
    color: var(--blue);
    border: none;
    font-size: 14px;
    font-weight: 600;
    padding: 14px;
    cursor: pointer;
    margin-top: 8px;
    font-family: "Elms Sans", sans-serif !important;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    > div {
        display: inline-flex;
        margin-left: 9px;
        font-size: 1.5em;
        transform: rotate(90deg) scale(1.05, 1.56);
        justify-content: center;
        align-items: center;
        font-weight: 300;
        transform-origin: center;
        transition: transform 0.2s ease-in-out !important;
    }
}
.a-arrow-una {
    transform: rotate(-90deg) scale(1.05, 1.56);
    animation: arrowSpin 0.25s ease-in-out forwards;
}
.a-arrow-a {
    transform: rotate(90deg) scale(1.05, 1.56);
    animation: arrowSpin 0.25s ease-in-out reverse forwards;
}
@keyframes arrowSpin {
    0%   { transform: rotate(-90deg) scale(1.05, 1.56); }
    100%  { transform: rotate(90deg) scale(1.05, 1.56); }
}


.color-options {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
}

.color-options .color,
.color-options .custom-color,
.color-options .more-bn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}
.custom-color {
    border-radius: 8px !important;
    padding: 0 !important;
}
#gender-option {
    height: 40px;
    width: 80%;
    margin: 0 auto;
    margin-top: 8px;
    display: flex;
    flex-direction: row;
    border: 1px solid var(--blue);
    overflow: hidden;
    border-radius: 7px;
    gap: 0;
    > div {
      flex: 1;
      border: none;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: bolder;
    }
}
.male-option,.female-option { color: var(--blue); background: var(--bg); }
.male-option-ac { background: var(--blue); color: var(--bg); }
.female-option-ac { background: var(--pink); color: var(--bg); }
#ruler { position: absolute; width: 100%; bottom: 0; }
@scope (#ruler) {
    .cm::after {
        content: "";
        width: 95%;
        height: 1px;
        background: var(--border-dotted);
        opacity: 0.8;
        margin-right: 0;
      }
    .cm-hide::after { content: none; }
    .cm-show::after { content: ""; }
    div {
      font-size: 7px;
      position: absolute !important;
      bottom: 0;
      left: 0;
      right: 0;
      display: block;
      padding-right: 0px;
      width: 100%;
      z-index: 8;
      font-family: "Elms Sans", sans-serif;
      font-weight: 700;
      opacity: 1;
      color: var(--cm-text) !important;
      display: flex;
      flex-direction: row !important;
      font-size: 0.45em;
    }
    .cm0   { height: 20px; border-top: none; border-bottom: 1px solid green; display: flex; align-items: end;}
    .cm10  { height: 20px; }
    .cm20  { height: 40px; }
    .cm30  { height: 60px; }
    .cm40  { height: 80px; }
    .cm50  { height: 100px; }
    .cm60  { height: 120px; }
    .cm70  { height: 140px; }
    .cm80  { height: 160px; }
    .cm90  { height: 180px; }
    .cm100 { height: 200px; }
    .cm110 { height: 220px; }
    .cm120 { height: 240px; }
    .cm130 { height: 260px; }
    .cm140 { height: 280px; }
    .cm150 { height: 300px; }
    .cm160 { height: 320px; }
    .cm170 { height: 340px; }
    .cm180 { height: 360px; }
    .cm190 { height: 380px; }
    .cm200 { height: 400px; }
    .cmText { height: 420px; 
        font-size: 0.58em; font-weight: bolder !important; color: lightblue; border: none !important}
}

.cel-btn { background: var(--blue); color: var(--bg); }
.anime-btn,.unreal-btn { background: var(--bg); color: var(--blue); }
#image-upload { color: var(--bg); background: var(--blue); }
#cel-display,#anim-display,#unreal-display {
    overflow-x: hidden;
    overflow-y: scroll;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 10000;
    height: 320px;
    width: 100%;
    padding-bottom: 20px;
}
.cel-box,.celeb {
    height: 40px !important;
    flex-shrink: 0 !important;
    width: 90%;
    padding: 10px 0 10px 20px;
    padding-right: 0 !important;
    display: flex;
    align-items: center;
    background: var(--bg);
    color: var(--blue);
    border: 1px solid var(--blue);
    border-radius: 5px;
    font-weight: 800;
    cursor: pointer;
}
#celBox {
    width: 95%;
    height: 260px;
    overflow-y: scroll;
    overflow-x: hidden;
    z-index: 20;
    background-color: var(--bg);
    display: grid;
    grid-template-columns: 1fr;
    position: absolute;
    bottom: 8px;
    left: 5px;
    right: 5px;
    z-index: 21;
    border: none !important;
}

.img-option {
    display: flex;
    position: absolute !important;
    top: 10px !important;
    left: 50%;
    transform: translate(-50%);
    height: 40px;
    width: 90%;
    border: 1px solid var(--blue);
    border-radius: 10px;
    overflow: hidden;
    button { flex: 1; border: none;; height: 100%; }
}
.ai-generator-box {
    display: none;
    flex-direction: column;
    padding-top: 45px;
    gap: 7px;
    input {
      background: var(--bg);
      width: 90%;
      height: 35px;
      border: 1px solid var(--blue);
      border-radius: 10px;
      color: var(--blue);
    }
    textarea {
      background: var(--bg);
      width: 90%;
      height: 65px;
      border: 1px solid var(--blue);
      border-radius: 10px;
      color: var(--blue);
    }
    button {
      width: 50%;
      height: 40px;
      border: 1px solid var(--blue);
      border-radius: 10px;
      color: var(--blue);
      background: var(--bg);
      margin: 0 auto;
    }
}
#upload-option {
    padding-top: 45px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    input {
      width: 90%;
      background: var(--bg);
      height: 35px;
      border: 1px solid var(--blue);
      border-radius: 10px;
      color: var(--blue);
    }
    button {
      width: 40%;
      height: 40px;
      color: var(--blue);
      background: var(--bg);
      border: 1px solid var(--blue);
      border-radius: 8px;
      margin: 0 auto;
    }
}
.upload-btn,.create-imgBtn { background: var(--bg); color: var(--blue); }
.upload-btnA,.create-imgBtnA { background: var(--blue); color: var(--bg); }
.statue-btn, .building-btn, .astro-btn,.object-btn {
    color: var(--blue);
    background: var(--bg);
    border: 1px solid var(--blue);
}
.Sbtn, .Bbtn, .Abtn,.Obtn {
    background: var(--blue) !important;
    color: var(--text-on-accent) !important;
    border: none !important;
}
#statue { display: flex; position: relative; }
.boxblabla {
    display: flex;
    input:first-child { flex: 1; }
    input:nth-child(2) { flex: 2; }
}
#building,#obD { display: none; flex-direction: column; }
@scope (#building) {
    input {
      margin-top: 0 !important;
      height: 30px;
      width: 90%;
      border: 1px solid var(--blue);
      border-radius: 15px;
      background: var(--bg);
      color: var(--text);
    }
    input::placeholder { padding-left: 10px; color: var(--text-placeholder); }
    button {
      display: block;
      padding: 10px 20px;
      border: 1px solid var(--blue-muted);
      background-color: var(--bg);
      color: var(--cyan);
      margin: 0 auto;
      margin-top: 10px;
      margin-bottom: 10px;
      transition: 0.5s ease-in-out;
      cursor: pointer;
      border-radius: 10px;
      font-family: "Elms Sans", sans-serif;
    }
    button:active { transform: scale(1.2); border-radius: 20px; border: 2px solid var(--blue); font-weight: bold; }
    section {
      width: 75%;
      height: 400px;
      flex-shrink: 0;
      padding: 10% 5%;
      margin: 0 auto;
      min-height: 400px;
      border: 2px solid blue;
      border-radius: 10px;
      overflow-x: hidden;
      overflow-y: scroll;
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      grid-gap: 10px;
      div {
        aspect-ratio: 1/1;
        border: 1px solid blue;
        border-radius: 15px;
        display: flex;
        justify-content: center;
        align-items: center;
        img { height: auto; width: 50%; aspect-ratio: 1/1; }
      }
    }
}
#universe { display: none; position: relative; }

/* ==========================================================================
   ANIMAL DISPLAY
   ========================================================================== */
#animal-display {
    position: static;
    margin: 0 auto;
    margin-top: 20px;
    top: 0;
    width: 92%;
    height: 400px;
    overflow-y: scroll;
    z-index: 20;
    background-color: var(--bg);
    border: 2px solid var(--blue-muted);
    border-radius: 30px;
    display: none;
    grid-template-columns: calc(1fr - 15%);
    transition: 0.5s;
    padding: 10px;
}

/* ==========================================================================
   SEARCH BAR / CUSTOM CELEBRITY SEARCH
   ========================================================================== */
.search-bar {
    position: sticky;
    top: 2px;
    width: 95%;
    height: 35px;
    display: flex;
    gap: 3px;
    border: none !important;
    margin-bottom: 20px;
    z-index: 15;
    padding: 0 !important;
    backdrop-filter: blur(30000px);
    background: var(--bg) !important;
}
#cel-custom {
    width: 90%;
    position: sticky;
    top: 0;
    left: 5px;
    right: 5px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 30px 10px;
    row-gap: 10px;
    border: none;
    justify-content: center;
    padding: 0 !important;
    background: color-mix(in srgb, var(--bg) 20%, transparent);
    z-index: 100000000000000;
    backdrop-filter: blur(1000px);
    div { border: none; }
    div:first-child {
      display: flex;
      gap: 5px;
      input {
        flex: 3;
        border: 1px solid var(--blue);
        border-radius: 10px;
        background: var(--bg);
        color: var(--text);
      }
      button {
        flex: 1;
        background: var(--blue);
        color: var(--text-on-accent);
        border-radius: 10px;
        height: 30px;
      }
    }
    div:nth-child(2) { opacity: 1; div { opacity: 1; } }
}
@scope (.search-bar) {
    input {
      flex: 3;
      border: 1px solid var(--blue-deep);
      border-radius: 10px;
      background: transparent;
      color: var(--text);
    }
    input::placeholder {
      color: var(--blue-deep);
      opacity: 0.5;
      font-size: 16px;
      padding-left: 5px;
    }
    button {
      flex: 1;
      border: 1px solid var(--blue-deep);
      border-radius: 10px;
      background-color: var(--blue-deep);
      height: 100%;
      color: var(--text-on-accent);
    }
}
.pre { color: #AE8625 !important; }


/* ==========================================================================
   ZOOM CONTROLS
   ========================================================================== */
.adjust {
    height: 30px;
    display: flex;
    flex-direction: row;
    width: 80%;
    justify-content: center;
    margin: 0 auto;
    gap: 20px;
    font-family: "Elms Sans", sans-serif;
}
.share-btn {
    background: var(--blue) !important;
    color: var(--bg) !important;
    border: 1px solid var(--blue-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 7px 12px;
    font-weight: 800;
    height: 93%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}
.more-bn {
    width: 35px;
    height: 35px;
    transition: 0.3s ease-in-out;
    background-image: url('photos/morecolor.png');
    background-size: contain;
    background-repeat: no-repeat;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}

.zoomIn-btn, .zoomOut-btn,.adjust-btn,.custom-btn,.x-btn,.clear-btn {
    width: 30px;
    height: 30px;
    background-image: url('photos/zoomOut.png');
    background-size: contain;
    background-repeat: no-repeat;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}
.clear-btn { background-image: url('photos/ClearAll.png'); }
.zoomOut-btn { background-image: url('photos/zoomIn.png'); }
.custom-btn { background-image: url('photos/custom.png'); border: none; }
.adjust-btn { background-image: url('photos/pen.png'); width: 27px; height: 27px; }
.x-btn {
    height: 20px;
    width: 20px;
    background-image: url('photos/Xbutton.png');
    position: absolute;
    top: 20px;
    right: 20px;
}
.customize {
    position: relative;
    min-height: 480px;      /* was: height: 480px; */
    width: calc(90vw - 40px);
    margin: 0 auto;
    display: none;
    flex-direction: column;
    justify-content: center;
    border: 2px solid var(--blue-muted);
    border-radius: 20px;
    margin-top: 10px;
    padding: 0 20px 20px 20px;
}
@scope (.customize) {
    h3 {
      text-align: center;
      font-weight: 1000;
      border-bottom: 2px dashed var(--blue-muted);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0 0 20px 0;
    }
    p { font-weight: 700; padding-left: 20px; }
    > div {
      display: flex;
      flex-direction: column;
      > div {
        display: flex;
        flex-direction: row;
        height: 60px;
        width: 87%;
        margin: 0 auto;
        gap: 3px;
        input:nth-child(2) {
          height: 20px !important;
          width: 50%;
          color: var(--blue);
          background: var(--bg);
          border: 1px solid var(--blue-muted);
        }
        button { height: 30px !important; width: 50px; background: var(--blue); color: var(--bg); border: none; }
        div {
          flex: 1;
          text-align: center;
          border: 1px solid var(--blue-muted);
          display: grid;
          align-items: center;
        }
      }
    }
}
.adjust-display {
    display: none;
    width: calc(90% - 20px);
    height: 300px;
    margin: 0 auto;
    padding: 0 10px;
    margin-top: 10px;
    flex-direction: column;
    background: var(--bg);
    color: var(--blue);
    border: 3px solid var(--blue);
    border-radius: 10px;
    position: relative;
}
.lines-option { background: var(--blue); color: var(--bg); }
.active-adjust { animation: openingAdjust 0.4s ease-in-out forwards; }
.unactive-adjust { animation: openingAdjust 0.4s ease-in-out reverse forwards; }
@scope (.adjust-display) {
    > div:first-child { top: 10px !important; }
    > div:nth-child(2) {
      font-weight: bolder;
      text-align: center;
      border-bottom: 1px solid var(--blue);
      padding: 10px 20px;
      margin-bottom: 10px;
    }
    > div:nth-child(3) {
      display: flex;
      flex-direction: column;
      gap: 5px;
      overflow-x: hidden;
      overflow-y: scroll;
      flex-wrap: nowrap;
      > div {
        height: 45px !important;
        width: calc(100% - 20px);
        border: 1px solid;
        border-radius: 5px;
        display: grid;
        grid-template-columns: 20px 1fr 40px;
        grid-gap: 10px;
        align-items: center;
        div:first-child { width: 20px; text-align: center; font-weight: bolder; }
        div:nth-child(3) { z-index: 10000; }
      }
    }
}
.del-figure,.move-up,.move-down {
    overflow: hidden;
    height: 20px;
    width: 20px;
    background-image: url('photos/delbtn.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
    margin-right: 0px;
    z-index: 50;
}
.move-up {
    background-image: url('photos/moveUp.png');
    height: 20px;
    width: 20px;
    border: 1px solid var(--blue);
    border-radius: 1px;
    padding: 0 10px;
    z-index: 100;
}
.move-down {
    background-image: url('photos/moveDown.png');
    height: 20px;
    width: 20px;
    border: 1px solid var(--blue);
    border-radius: 1px;
    padding: 0 10px;
    z-index: 100;
}
.editable-detail {
    cursor: pointer;
    border-bottom: 1px dashed currentColor;
}
.editable-detail input {
    font-family: inherit;
    border: 1px solid var(--blue);
    border-radius: 2px;
    background: transparent;
    color: inherit;
    padding: 0 2px;
}
@keyframes openingAdjust {
    from { transform: translateY(-70px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
@scope (.adjust) {
    button {
      color: var(--blue);
      background: var(--bg);
      border: 1px solid var(--blue);
      padding: 5px 7px;
      border-radius: 15px;
      font-family: "Elms Sans", sans-serif;
    }
}
.clear-btn {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}

/* ==========================================================================
   CONTENT SECTIONS
   ========================================================================== */
h2 { color: var(--blue) !important; }
.about-tool-section,
.how-to-use-section,
.faq-section {
    width: 95%;
    margin: 0 auto;
    margin-top: 150px;
    font-size: 18px;
    font-family: "Elms Sans", sans-serif;
}
@scope (.about-tool-section) {
    h2, h3 { color: var(--blue); }
    p, li  { color: var(--text-muted); }
}
@scope (.how-to-use-section) {
    h2 { color: var(--blue); }
    strong, p { color: var(--text-muted); }
    strong { padding-left: 5%; }
    p { padding-left: 10%; }
}
@scope (.faq-section) {
    h2 { color: var(--blue); }
    h3, p { color: var(--text-muted); }
    h3 { padding-left: 5%; }
    p { padding-left: 10%; }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
#footer-section {
    display: flex;
    width: 100vw;
    height: 80px;
    align-items: center;
    background: var(--bg-footer);
    margin-left: calc(-50vw + 50%) !important;
}
@scope (#footer-section) {
    div {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      text-align: center;
      color: white !important;
      text-decoration: underline;
    }
    a { color: white; }
}

/* ==========================================================================
   AVATAR GRIDS
   ========================================================================== */
#male-avatar {
    display: none;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    grid-gap: 10px;
    overflow-y: scroll !important;
    overflow-x: hidden;
    height: 300px;
    padding: 10px;
    border-top: 3px solid #5297ff;
}

#female-avatar {
    display: none;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    grid-gap: 10px;
    overflow-y: scroll !important;
    overflow-x: hidden;
    height: 300px;
    padding: 10px;
    border-top: 3px solid #5297ff;
}
#object-dis {
    width: 100%;
    display: grid;
    grid-gap: 7px;
    grid-template-columns: 1fr 1fr 1fr;
    > div {
      height: 120px;
      display: flex;
      flex-direction: column !important;
      img { width: 100%; height: 80%; }
      p { height: 10%; font-size: 0.6em; font-weight: 700; text-align: center; padding: 0; margin: 0; }
    }
}
@scope (#male-avatar) {
    div.avm {
      aspect-ratio: 1/2;
      border: none;
      border-radius: 10px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    img { height: 80px; opacity: 0.75; }
}

@scope (#female-avatar) {
    div.avf {
      aspect-ratio: 1/2;
      border: none;
      border-radius: 10px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    img { height: 80px; opacity: 0.75; }
}
#male-avatar > div.avm,
#female-avatar > div.avf {
    background: rgb(243, 243, 243) !important;
}
[data-theme="dark"] #male-avatar > div.avm,
[data-theme="dark"] #female-avatar > div.avf {
    background: rgb(125, 125, 125) !important;
}

/* Infinite Scroll Loaders */
#male-avatar .infinite-loader,
#female-avatar .infinite-loader,
#male-avatar .infinite-sentinel,
#female-avatar .infinite-sentinel,
#cel-display .infinite-loader,
#anim-display .infinite-loader,
#unreal-display .infinite-loader {
    grid-column: 1 / -1;
    width: 100%;
}

.more-colors {
  display: none;
  grid-template-columns: repeat(5, 1fr);
  place-items: center; /* Centers the circles perfectly in their cells */
  gap: 12px; /* Better spacing */
  margin: 15px auto 0 auto;
  width: 90%;
  padding: 15px;
  border: none;
  border-radius: 22px;
  background: rgb(240, 240, 240); /* Gives the box a cleaner look */
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.05); /* Subtle inner depth */
  box-sizing: border-box;
}
[data-theme="dark"] .more-colors {
    background: rgb(48, 48, 48) !important;
}
.more-colors div {
  height: 34px; /* Slightly larger for easier tapping */
  width: 34px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2); /* Makes the colors pop */
}

.color-options .custom-color-apply {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--blue);
    background: var(--blue);
    color: #fff;
    font-family: "Elms Sans", sans-serif;
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  }
  .color-options .custom-color-apply:hover  { transform: scale(1.08); }
  .color-options .custom-color-apply:active { transform: scale(0.95); }
  .color-options .custom-color-apply.applied {
    background: #22c55e;
    border-color: #22c55e;
  }
  [data-theme="dark"] .color-options .custom-color-apply {
    color: var(--bg);
  }

/* Hover and Active effects */
.more-colors div:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.more-colors div:active {
  transform: scale(0.95);
}
.color-options {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap !important;
    gap: 5px;
    margin: 0 auto !important;
    width: 90%;
    height: 30px;
    margin-top: 10px;
    height: 30px;
    width: auto;
    background: var(--color-bar);
    padding: 3.5px 9px;
    border-radius: 10px;
    div {
      height: 26px !important;
      width: 26px !important;
      border: 2px solid var(--color-picker);
      border-radius: 50%;
      cursor: pointer;
    }
    input[type="color"] {
      height: 30px;
      width: 30px;
      border-radius: 50%;
      cursor: pointer;
      -webkit-appearance: none;
      appearance: none;
      border: none;
      padding: 0;
      background: none;
      overflow: hidden;
      flex-shrink: 0;
    }
    input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
    input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
    input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }
}
.color-bar {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    justify-content: center;
    padding: 5px !important;
    width: auto;
    height: auto;
    div:first-child { 
        display: flex; 
        flex-direction: row; 
    }
}
.red, .cred     { background: red; }
.blue, .cblue   { background: blue; }
.yellow, .cyellow { background: yellow; }
.green, .cgreen { background: green; }
.pink, .cpink   { background: pink; }
.brown, .cbrown { background: brown; }
.black, .cblack { background: black; }
.orange { background: orange; }
.purple { background: purple; }
.aqua   { background: aqua; }
.teal, .cteal       { background: teal; }
.lime, .clime       { background: lime; }
.indigo, .cindigo   { background: indigo; }
.violet, .cviolet   { background: violet; }
.crimson, .ccrimson { background: crimson; }
.gold, .cgold       { background: gold; }
.silver, .csilver   { background: silver; }
.coral, .ccoral     { background: coral; }
.navy, .cnavy       { background: navy; }
.grey, .cgrey       { background: grey; }
.custom-color { border-radius: 15px !important; }

/* ==========================================================================
   CELEBRITY EXPANDED PICKER
   ========================================================================== */
.cel-box.expanded-celeb {
    height: auto !important;
    min-height: 40px !important;
    flex-shrink: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 10px !important;
    gap: 6px;
    cursor: default;
}
.celeb-expand-header {
    font-size: 1.05em;
    font-weight: 900;
    color: var(--blue);
    border-bottom: 1px dashed var(--blue-muted);
    padding-bottom: 4px;
}
.celeb-expand-info {
    font-size: 0.85em;
    color: var(--blue);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.celeb-expand-info .celeb-sep { opacity: 0.5; }
.celeb-expand-label {
    font-size: 0.75em;
    font-weight: 800;
    color: var(--blue);
    margin-top: 2px;
}
.celeb-expand-avatars {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-height: 140px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid var(--blue-muted);
    border-radius: 5px;
    background: var(--bg);
}
.celeb-expand-avatars img {
    width: 100%;
    height: 64px;
    object-fit: contain;
    border: 1px solid var(--blue-muted);
    border-radius: 4px;
    padding: 2px;
    box-sizing: border-box;
    cursor: pointer;
    background: var(--bg);
}
.celeb-expand-avatars img.sel { border: 3px solid var(--cyan); }
.celeb-expand-colors {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--blue-muted);
    border-radius: 5px;
    background: var(--bg);
}
.celeb-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-sizing: border-box;
}
.celeb-swatch.sel { border-color: var(--cyan); }
.celeb-custom-color {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
    flex-shrink: 0;
    margin-left: 6px;
}
.celeb-custom-color::-webkit-color-swatch-wrapper { padding: 0; }
.celeb-custom-color::-webkit-color-swatch { border: none; border-radius: 50%; }
.celeb-custom-color::-moz-color-swatch { border: none; border-radius: 50%; }
.celeb-custom-color.sel { box-shadow: 0 0 0 2px var(--cyan); }
.celeb-add-plus-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 10px;
    margin-top: 8px;
    background: var(--blue);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    font-family: "Elms Sans", sans-serif;
    font-size: 0.95em;
    font-weight: 900;
    letter-spacing: 0.5px;
    cursor: pointer;
}
.celeb-add-plus-btn:hover { filter: brightness(1.1); }
.celeb-add-plus-btn .plus-sign { font-size: 1.4em; line-height: 1; font-weight: 900; }
.celeb-cancel-link {
    display: block;
    text-align: center;
    font-size: 0.75em;
    color: var(--blue-muted);
    text-decoration: underline;
    cursor: pointer;
    padding: 4px 0 0 0;
    background: none;
    border: none;
    width: 100%;
    font-family: "Elms Sans", sans-serif;
}

#main-toggle {
    margin-top: 40px;
    display: flex;
    flex-direction: row-reverse;
}

/* ==========================================================================
   VIEW TOGGLE (2D / 3D)
   ========================================================================== */
#view-toggle-bar {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-right: 5px;
    margin-left: auto;
    width: 30%;
    max-width: 260px;
}
.view-mode-btn {
    flex: 1;
    padding: 7px 12px;
    border: 1px solid var(--blue);
    background: var(--bg);
    color: var(--blue);
    border-radius: 6px;
    font-family: "Elms Sans", sans-serif;
    font-weight: 900;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}
.view-mode-btn.view-mode-active {
    background: var(--blue);
    color: var(--bg);
}

/* ==========================================================================
   3D HEIGHT DISPLAY
   ========================================================================== */
#height-display-3d * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}
#height-display-3d {
    position: relative;
    width: 100%;
    height: 480px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    margin: 0 auto;
    margin-top: 0px;
    overflow: hidden;
    display: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
}
#height-display-3d .brand {
    z-index: 5000;
    pointer-events: none;
}
#three-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}
#three-container:active { cursor: grabbing; }
#three-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    touch-action: none;
}

/* --------------------------------------------------------------------------
   Controls overlay (camera + action buttons)
   -------------------------------------------------------------------------- */
#three-controls {
    position: absolute;
    top: 50px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
    width: 118px;
}
.ctrl-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.ctrl-label {
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 2px;
    opacity: 0.85;
}
.ctrl-btn {
    padding: 6px 8px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 5px;
    font-family: "Elms Sans", sans-serif;
    font-weight: 800;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.08s ease;
}
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-btn.active { background: #ff5a5a; }
#reset-3d-view {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

#pov-figure-select {
    position: absolute;
    top: 8px;
    left: 50px !important;
    z-index: 10;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--blue);
    background: var(--bg);
    color: var(--blue);
    font-family: "Elms Sans", sans-serif;
    font-weight: 700;
    font-size: 12px;
    max-width: 160px;
    display: none;
}
.dpad-up,.dpad-down,.dpad-left,.dpad-right {
    background-image: url('photos/fig-up.png');
    background-size: contain;
    background-repeat: no-repeat;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    touch-action: manipulation;
}
.dpad-down { background-image: url('photos/fig-down.png'); }
.dpad-left { background-image: url('photos/fig-left.png'); }
.dpad-right { background-image: url('photos/fig-right.png'); }
/* ==========================================================================
   IN-GAME CONTROLS HINT (shown only while in 1st-person mode)
   ========================================================================== */
#controls-hint {
    position: absolute;
    top: 60px;
    left: 8px;
    z-index: 10;
    display: none;
    flex-direction: column;
    gap: 3px;
    padding: 0;
    min-width: 118px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: none;
}
#controls-hint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 6px 5px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: #cdd9ff;
    font-family: "Elms Sans", sans-serif;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1px;
}
#controls-hint-toggle {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    font-family: inherit;
    font-weight: 900;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
#controls-hint-toggle:hover  { background: rgba(255, 255, 255, 0.25); }
#controls-hint-toggle:active { transform: scale(0.9); }
#controls-hint-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 9px 7px 9px;
}
#controls-hint.collapsed #controls-hint-body { display: none; }
#controls-hint.collapsed #controls-hint-header { border-bottom: none; }
#controls-hint.collapsed { min-width: 0; }
#controls-hint.collapsed #controls-hint-header span { display: none; }
.ctrl-hint {
    color: #eef3ff;
    font-family: "Elms Sans", sans-serif;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ctrl-hint kbd {
    display: inline-block;
    min-width: 16px;
    padding: 1px 5px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-bottom-width: 2px;
    border-radius: 3px;
    color: #fff;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 9px;
    font-weight: 800;
    text-align: center;
    line-height: 1.2;
}
#eye-hud { color: #ffe47a; font-weight: 900; }

/* ==========================================================================
   3D SETTINGS, JUMP BUTTON, D-PAD POSITION VARIABLES
   ========================================================================== */
#height-display-3d {
    --joy-size: 110px;
    --joy-left: 16px;
    --joy-bottom: 16px;
    --joy-right: 16px;
}

/* ---- Settings gear button (top-left) ---- */
#three-settings-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 12;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
#three-settings-btn:hover { filter: brightness(1.1); }
#three-settings-btn:active { transform: scale(0.95); }

/* ---- Settings panel (drops below the gear) ---- */
/* ==========================================================================
   SETTINGS PANEL — always scrollable, on every device
   --------------------------------------------------------------------------
   Two caps, whichever is smaller wins:
     · calc(100% - 60px)  → never taller than the 3D wrapper
     · calc(100dvh - 100px) → never taller than the visible screen

   touch-action: pan-y re-enables finger scrolling inside the panel even
   though the wrapper has touch-action: none (Pointer Events spec intersects
   touch-action down the tree, so this is required on touch devices).
   ========================================================================== */
   #three-settings-panel {
    position: absolute;
    top: 48px;
    left: 8px;
    z-index: 13;
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);

    max-height: calc(100% - 60px);
    max-height: min(calc(100% - 60px), calc(100vh  - 100px));
    max-height: min(calc(100% - 60px), calc(100dvh - 100px));
    max-width: calc(100% - 20px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.55) rgba(0, 0, 0, 0.25);
}

#three-settings-panel::-webkit-scrollbar { width: 8px; }
#three-settings-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}
#three-settings-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
}
#three-settings-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.75);
}
.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #eef3ff;
    font-family: "Elms Sans", sans-serif;
    font-size: 11px;
    font-weight: 700;
}
.setting-row {
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  }
.setting-row label { flex: 0 0 78px; }
.setting-row input[type="range"] { flex: 1; accent-color: var(--blue); min-width: 0; }
.setting-row span {
    flex: 0 0 34px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

/* ---- Jump button — pinned above the D-pad's horizontal level on the right ---- */
#jump-btn {
    position: absolute;
    right: var(--joy-right) !important;
    bottom: calc(var(--joy-bottom) + var(--joy-size) + 12px) !important;
    z-index: 11;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: rgba(82, 151, 255, 0.85);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.7);
    font-family: "Elms Sans", sans-serif;
    font-weight: 900;
    font-size: 10px;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
#jump-btn:active {
    transform: scale(0.92);
    background: rgba(82, 151, 255, 1);
}

/* ==========================================================================
   3D LOADING OVERLAY
   ========================================================================== */
#three-loading {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-family: "Elms Sans", sans-serif;
    pointer-events: auto;
}
#three-loading.active { display: flex; }
.three-loading-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.22);
    border-top-color: #5297ff;
    animation: threeSpin 0.8s linear infinite;
}
@keyframes threeSpin { to { transform: rotate(360deg); } }
.three-loading-text {
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   3D ROTATE (LANDSCAPE) BUTTON
   ========================================================================== */
#three-rotate-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 12;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    transition: background 0.15s ease, transform 0.08s ease;
}
#three-rotate-btn img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
    display: block;
}
#three-rotate-btn:hover  { filter: brightness(1.1); }
#three-rotate-btn:active { transform: scale(0.95); }
#three-rotate-btn.active { background: #ff5a5a; }

/* --------------------------------------------------------------------------
   Landscape fallback for browsers without an orientation lock
   -------------------------------------------------------------------------- */
#height-display-3d.rotated-3d {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vh !important;
    height: 100vw !important;
    width: 100dvh !important;
    height: 100dvw !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: hidden;
    transform: rotate(90deg) translateY(-100%);
    transform-origin: top left;
    z-index: 2147483000;
}
@media (orientation: landscape) {
    #height-display-3d.rotated-3d {
      transform: none !important;
      width: 100vw !important;
      height: 100vh !important;
      width: 100dvw !important;
      height: 100dvh !important;
    }
}
body.rotate-3d-active {
    overflow: hidden !important;
    overscroll-behavior: none;
}

/* ==========================================================================
   MOBILE LANDSCAPE — tighten D-pad, JUMP, controls, and the display
   ========================================================================== */
@media (orientation: landscape) and (max-height: 520px) {
    #height-display-3d,
    #height-display {
      height: min(480px, 82vh);
    }

    #height-display-3d {
      --joy-size: 86px;
      --joy-left: 10px;
      --joy-right: 10px;
      --joy-bottom: 10px;
    }

    #jump-btn {
      width: 52px;
      height: 52px;
      font-size: 9px;
      letter-spacing: 0;
    }

    #three-controls {
      width: 96px;
      gap: 4px;
      top: 6px;
      right: 6px;
    }
    .ctrl-btn { padding: 5px 6px; font-size: 10px; }
    .ctrl-label { font-size: 8px; }
    #three-settings-btn { top: 6px; left: 6px; width: 30px; height: 30px; }
    #pov-figure-select {
      left: 44px;
      top: 6px;
      max-width: 130px;
      font-size: 11px;
    }
    #controls-hint {
      top: 46px;
      left: 6px;
      max-height: 60vh;
      overflow-y: auto;
    }
    .ctrl-hint { font-size: 9px; }
    .ctrl-hint kbd { font-size: 8px; padding: 0 4px; }

    #three-settings-panel {
        /* In landscape the container itself is much shorter; anchor the
           panel's height to the container, not the viewport, so it never
           spills off the bottom of the 3D view. */
        max-height: calc(100% - 50px);
        min-width: 200px;
        top: 42px;
        left: 6px;
        /* overflow / touch-action / scrollbar styling are inherited from the
           base rule above — no need to repeat them. */
      }
    }

/* ==========================================================================
   MOBILE D-PAD (replaces the move joystick)
   ========================================================================== */
   #dpad {
    /* Visible by default so it always appears on touch devices, even if
       JS hasn't run yet. A media query below hides it on desktop. */
    display: grid;
    position: absolute;
    bottom: var(--joy-bottom);
    left: var(--joy-left);
    width: var(--joy-size);
    height: var(--joy-size);
    z-index: 10;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 3px;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  
  /* Hide on desktop (devices with a real mouse and hover). Modern, reliable
     way to distinguish desktop from touch — far more robust than JS UA
     sniffing. */
  @media (hover: hover) and (pointer: fine) {
    #dpad { display: none; }
  }
.dpad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(82, 151, 255, 0.28);
    border: 2px solid rgba(82, 151, 255, 0.65);
    border-radius: 8px;
    color: #ffffff;
    font-family: "Elms Sans", sans-serif;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    transition: background 0.08s ease, transform 0.06s ease;
}
.dpad-btn.active,
.dpad-btn:active {
    background: rgba(82, 151, 255, 0.9);
    border-color: #ffffff;
    transform: scale(0.94);
}
.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }
/* =====================================================================
   BLOCK TOOLS (3D view)
   ===================================================================== */
#block-crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  z-index: 9;
  pointer-events: none;
  display: none;
}
#block-crosshair::before,
#block-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
#block-crosshair::before { left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; }
#block-crosshair::after  { top: 50%; left: 0; right: 0; height: 2px; margin-top: -1px; }

#mine-progress {
  position: absolute;
  top: calc(50% + 26px); left: 50%;
  transform: translateX(-50%);
  width: 130px; height: 8px;
  z-index: 9;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: none;
  overflow: hidden;
  pointer-events: none;
}
#mine-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #6fb0ff, #ff5a5a);
  transition: width 0.05s linear;
}

/* =====================================================================
   JUMP + HIT BUTTONS — bottom-right stack
   Jump sits at the very bottom-right; Hit floats directly above it.
   Both follow the --joy-right / --joy-bottom settings so they move
   with the joystick sliders.
   ===================================================================== */
#jump-btn {
    left: auto !important;
    right: var(--joy-right) !important;
    bottom: var(--joy-bottom) !important;
    top: auto !important;
}

#hit-btn {
    position: absolute;
    left: auto !important;
    right: var(--joy-right) !important;
    bottom: calc(var(--joy-bottom) + 74px) !important;
    z-index: 11;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 90, 90, 0.85);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.75);
    font-family: "Elms Sans", sans-serif;
    font-weight: 900;
    font-size: 10px;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 0;
    transition: transform 0.08s ease, background 0.15s ease;
}
#hit-btn:active,
#hit-btn.active {
    transform: scale(0.92);
    background: rgba(255, 90, 90, 1);
}
@media (orientation: landscape) and (max-height: 520px) {
    #hit-btn {
        width: 56px; height: 56px;
        font-size: 9px;
        bottom: calc(var(--joy-bottom) + 62px) !important;
    }
    
}

/* =====================================================================
   "ADD PERSON" overlay button
   ===================================================================== */
.add-person-btn {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    padding: 12px 26px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-family: "Elms Sans", sans-serif;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}
.add-person-btn:hover {
    filter: brightness(1.1);
    transform: translate(-50%, -50%) scale(1.05);
}
.add-person-btn:active {
    transform: translate(-50%, -50%) scale(0.95);
}
.add-person-btn.hidden { display: none; }
/* ==========================================================================
   HIDE "ADD PERSON" WHENEVER ANY FIGURE EXISTS
   --------------------------------------------------------------------------
   Belt-and-braces: the class-based hiding below is still the primary path,
   but this selector is specificity (1,3,0) and uses :has() so it wins over
   ANY later display rule — including rules a user stylesheet or a
   third-party script might add. It also covers the case where the JS
   observer misses an update.
   ========================================================================== */
.main-layout:has(#display-person > .personbox) .add-person-btn {
  display: none !important;
}
#height-display-3d .add-person-btn { z-index: 20; }

#hand-btn {
    position: absolute;
    bottom: 22px;
    left: calc(50% + 76px);
    z-index: 11;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #eef3ff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}
#hand-btn:active { transform: scale(0.94); }
#hand-btn.active {
    background: var(--blue);
    color: #fff;
    border-color: #fff;
}

/* Toolbar — reposition on touch so it doesn't collide with the D-pad */
#block-toolbar {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 11;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
@media (hover: none) and (pointer: coarse) {
    #block-toolbar {
        bottom: calc(var(--joy-bottom) + var(--joy-size) + 8px);
    }
}
/* =====================================================================
   TOOLBAR BUTTONS — image icons
   ===================================================================== */
.tool-btn img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    pointer-events: none;
    display: block;
}
/* The hand button is now just another tool button */
#hand-btn {
    width: 56px;
    height: 54px;
}

/* =====================================================================
   JUMP + HIT — image buttons
   ===================================================================== */
#jump-btn img,
#hit-btn img {
    width: 62%;
    height: 62%;
    object-fit: contain;
    pointer-events: none;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
#hit-btn span { display: none; }   /* icon-only */
#jump-btn span { display: none; }  /* icon-only */

@media (orientation: landscape) and (max-height: 520px) {
    .tool-btn img { width: 20px; height: 20px; }
    #jump-btn img,
    #hit-btn img { width: 58%; height: 58%; }
}
/* =====================================================================
   FINAL FIXES — D-pad icons, tool states, mobile layout
   ===================================================================== */

/* ---- D-PAD ICONS -------------------------------------------------- 
   The earlier `.dpad-btn { background: ... }` used the shorthand, which
   silently resets background-image — that's why the arrows never
   appeared. Switch to background-color so the icon URLs declared on
   .dpad-up / .dpad-down / .dpad-left / .dpad-right survive. */
.dpad-btn {
    background-color: rgba(82, 151, 255, 0.28) !important;
}
.dpad-btn.active,
.dpad-btn:active {
    background-color: rgba(82, 151, 255, 0.95) !important;
}
.dpad-up,
.dpad-down,
.dpad-left,
.dpad-right {
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 62% 62% !important;
}

/* ---- TOOL BUTTONS — icon only ------------------------------------ */
.tool-btn {
    width: 52px;
    height: 52px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.08s ease;
}
.tool-btn img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    pointer-events: none;
    display: block;
}
.tool-btn:active { transform: scale(0.94); }

/* Active tool — the DIV goes dark so you can see what's in your hand */
.tool-btn.active {
    background: rgba(0, 0, 0, 0.88);
    border-color: var(--blue);
    box-shadow: inset 0 0 0 2px var(--blue),
                0 0 10px rgba(82, 151, 255, 0.55);
}
.tool-btn.active img {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.9))
            brightness(1.15);
}

/* ---- JUMP + HIT — icon only, matched size ------------------------ */
#jump-btn,
#hit-btn {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#jump-btn img,
#hit-btn img {
    width: 62%;
    height: 62%;
    object-fit: contain;
    pointer-events: none;
    display: block;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
#jump-btn span,
#hit-btn span { display: none !important; }

/* =====================================================================
   MOBILE LAYOUT — everything gets a defined home, nothing overlaps
   Covers both touch devices and narrow browser windows.
   ===================================================================== */
@media (hover: none) and (pointer: coarse), (max-width: 640px) {
    /* --- Toolbar: horizontal strip above the D-pad, centred --- */
    #block-toolbar {
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        bottom: calc(var(--joy-bottom) + var(--joy-size) + 18px) !important;
        padding: 5px 7px;
        gap: 8px;
        border-radius: 12px;
    }
    .tool-btn {
        width: 46px;
        height: 46px;
    }
    .tool-btn img { width: 26px; height: 26px; }

    /* --- JUMP bottom-right; HIT stacks cleanly above it --- */
    #jump-btn {
        width: 56px !important;
        height: 56px !important;
        left: auto !important;
        right: var(--joy-right) !important;
        bottom: var(--joy-bottom) !important;
        top: auto !important;
    }
    #hit-btn {
        width: 56px !important;
        height: 56px !important;
        left: auto !important;
        right: var(--joy-right) !important;
        bottom: calc(var(--joy-bottom) + 68px) !important;
    }
    #jump-btn img,
    #hit-btn img { width: 58%; height: 58%; }

    /* --- Compact camera controls --- */
    #three-controls {
        width: 96px;
        top: 6px;
        right: 6px;
        gap: 4px;
    }
    .ctrl-btn { padding: 5px 6px; font-size: 10px; }
    .ctrl-label { font-size: 8px; }

    /* --- Compact settings + rotate --- */
    #three-settings-btn,
    #three-rotate-btn {
        width: 30px;
        height: 30px;
        top: 6px;
    }
    #three-settings-btn { left: 6px; }
    #three-rotate-btn { right: 6px; }

    /* --- POV dropdown narrower so it doesn't run into the rotate btn --- */
    #pov-figure-select {
        left: 42px !important;
        top: 6px;
        max-width: 130px;
        font-size: 11px;
    }

    /* --- Controls hint leaves room for the toolbar --- */
    #controls-hint {
        top: 46px;
        left: 6px;
        max-height: 55vh;
        overflow-y: auto;
    }
    .ctrl-hint { font-size: 9px; }
    .ctrl-hint kbd { font-size: 8px; padding: 0 4px; }

    /* --- Settings panel doesn't run off the bottom --- */
    #three-settings-panel {
        top: 42px;
        left: 6px;
        max-height: 70vh;
        overflow-y: auto;
        min-width: 200px;
    }
}

/* Extra squeeze for short landscape phone screens */
@media (orientation: landscape) and (max-height: 520px) {
    #height-display-3d {
        --joy-size: 84px;
        --joy-bottom: 8px;
        --joy-right: 8px;
    }
    #block-toolbar {
        bottom: calc(var(--joy-bottom) + var(--joy-size) + 10px) !important;
        padding: 4px 6px;
        gap: 6px;
    }
    .tool-btn { width: 40px; height: 40px; }
    .tool-btn img { width: 22px; height: 22px; }
    #jump-btn,
    #hit-btn { width: 48px !important; height: 48px !important; }
    #hit-btn {
        bottom: calc(var(--joy-bottom) + 58px) !important;
    }
}
/* =====================================================================
   TOOLBAR — icon-only, centered at bottom of 3D view
   ===================================================================== */

/* Safety net: kill any stray text inside icon buttons, now or later */
#block-toolbar .tool-btn span,
#hand-btn span,
#jump-btn span,
#hit-btn span {
    display: none !important;
}

#block-toolbar {
    position: absolute !important;
    left: 50% !important;
    right: auto !important;
    top: auto !important;
    bottom: 12px !important;
    transform: translateX(-50%) !important;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 11;
}

.tool-btn {
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0 !important;    /* belt-and-braces: any text renders at 0px */
    line-height: 0 !important;
    transition: background 0.15s ease, border-color 0.15s ease,
                box-shadow 0.15s ease, transform 0.08s ease;
}
.tool-btn img {
    width: 26px !important;
    height: 26px !important;
    object-fit: contain;
    pointer-events: none;
    display: block;
}
.tool-btn:active { transform: scale(0.94); }

/* Active tool — container goes dark so you can see what's equipped */
.tool-btn.active {
    background: rgba(0, 0, 0, 0.88) !important;
    border-color: var(--blue) !important;
    box-shadow: inset 0 0 0 2px var(--blue),
                0 0 10px rgba(82, 151, 255, 0.55) !important;
}
.tool-btn.active img {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.9)) brightness(1.15);
}

/* =====================================================================
   MOBILE — keep the toolbar centered at bottom, slightly smaller
   ===================================================================== */
@media (hover: none) and (pointer: coarse), (max-width: 640px) {
    #block-toolbar {
        bottom: 10px !important;
        padding: 4px 6px;
        gap: 5px;
    }
    .tool-btn {
        width: 38px !important;
        height: 38px !important;
    }
    .tool-btn img {
        width: 22px !important;
        height: 22px !important;
    }

    /* Lift JUMP + HIT above the toolbar so they never sit on top of it */
    #jump-btn {
        width: 52px !important;
        height: 52px !important;
        bottom: calc(var(--joy-bottom)) !important;
        right: var(--joy-right) !important;
    }
    #hit-btn {
        width: 52px !important;
        height: 52px !important;
        bottom: calc(var(--joy-bottom) + 62px) !important;
        right: var(--joy-right) !important;
    }
}

/* Very short landscape screens */
@media (orientation: landscape) and (max-height: 520px) {
    #block-toolbar {
        bottom: 6px !important;
        padding: 3px 5px;
        gap: 4px;
    }
    .tool-btn { width: 34px !important; height: 34px !important; }
    .tool-btn img { width: 20px !important; height: 20px !important; }
}
/* =====================================================================
   MOBILE TOUCH HARDENING FOR THE 3D VIEW
   =====================================================================
   Two mobile-only annoyances show up in the 3D view:

     1. Fast repeated taps on JUMP / HIT / D-pad register as a
        double-tap on some browsers and zoom the WHOLE PAGE — toolbar
        included. The existing `touch-action: none` on the canvas
        doesn't catch taps that land on the overlay buttons.

     2. Long-press or a drag that starts on text inside the 3D view
        pops the native Copy / Look Up / Translate callout, because
        iOS still treats the underlying layout as selectable text
        even when it's visually behind the canvas.

   These rules eliminate both: nothing inside #height-display-3d can
   be text-selected, highlighted, or trigger a callout, and the native
   tap-highlight square is suppressed.
   ===================================================================== */
#height-display-3d,
#height-display-3d * {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Belt-and-braces: also suppress the tap highlight on the containers
   that wrap the 3D view. A quick drag that leaves the canvas and
   re-enters would otherwise flash the grey iOS highlight square on
   these. Selection itself is NOT disabled here — only the visual
   flash — so users can still copy text from the share modal etc. */
#body-web,
#height-info,
#option-display,
#celebrities-display,
#object-display
#animal-display,
.img-display,
.view-mode-btn,
.view-mode-btn * {
    -webkit-tap-highlight-color: transparent !important;
}

/* Make the 3D wrapper itself unflickable: no rubber-band, no browser
   pan, no browser zoom. Every gesture in here is handled by the
   in-canvas pointermove listener. */
#height-display-3d {
    touch-action: none;
    overscroll-behavior: contain;
}

/* =====================================================================
   GLOBAL 3D-MODE SELECTION LOCK
   =====================================================================
   While 3D mode is active, the whole document becomes unselectable.
   This is necessary because in the rotated/fullscreen 3D layout the
   canvas is a fixed-position overlay — the page text it visually
   covers is still there in the layout, and iOS will select it if a
   drag crosses over it. Targeting the subtree alone was not enough;
   this class is applied to <html> by View3D.activate() and removed by
   View3D.deactivate().

   Inputs and textareas are explicitly opted back in so the share link,
   the rename editor, and the AI prompt field keep working normally.
   ===================================================================== */
html.view-3d-active,
html.view-3d-active body,
html.view-3d-active body *:not(input):not(textarea) {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

/* Re-enable selection on real text-entry fields so the share link
   can still be long-pressed and copied. */
html.view-3d-active input,
html.view-3d-active textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* The 3D wrapper should never scroll the page underneath it. */
html.view-3d-active,
html.view-3d-active body {
    overscroll-behavior: none;
}
/* ==========================================================================
   JUMP / HIT — settings-controlled size and position
   --------------------------------------------------------------------------
   The old --joy-* variables used by these two buttons are gone; they now
   read their own CSS variables. Parent-selector specificity plus
   !important makes these win over every older rule and every mobile
   media query, so the settings panel is the single source of truth.
   ========================================================================== */
#height-display-3d {
  --jump-size: 62px;
  --jump-right: 16px;
  --jump-bottom: 16px;
  --hit-size: 68px;
  --hit-right: 16px;
  --hit-bottom: 90px;
}

#height-display-3d #jump-btn {
  left: auto !important;
  top: auto !important;
  right: var(--jump-right) !important;
  bottom: var(--jump-bottom) !important;
  width: var(--jump-size) !important;
  height: var(--jump-size) !important;
}

#height-display-3d #hit-btn {
  left: auto !important;
  top: auto !important;
  right: var(--hit-right) !important;
  bottom: var(--hit-bottom) !important;
  width: var(--hit-size) !important;
  height: var(--hit-size) !important;
}

/* Section header inside the settings panel */
.setting-group-label {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font-family: "Elms Sans", sans-serif;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    opacity: 1;
  }
/* ==========================================================================
   D-PAD and NAVIGATION BAR — settings-controlled size + position
   --------------------------------------------------------------------------
   Both elements now read their dimensions from CSS variables that the
   settings panel writes. Using two-level IDs (or !important on child
   rules that don't have IDs) makes these win over every older rule and
   every mobile media query.
   ========================================================================== */
#height-display-3d #dpad {
  left:   var(--dpad-left,   16px) !important;
  bottom: var(--dpad-bottom, 16px) !important;
  right:  auto !important;
  top:    auto !important;
  width:  var(--dpad-size, 110px) !important;
  height: var(--dpad-size, 110px) !important;
}

/* Nav bar. The scale factor multiplies the base sizes defined in the
   original CSS so 1.00× looks exactly like it does now. */
#height-display-3d #three-controls {
  top:   var(--nav-top,   50px) !important;
  right: var(--nav-right,  8px) !important;
  left:  auto !important;
  bottom: auto !important;
  width: calc(118px * var(--nav-scale, 1)) !important;
  gap:   calc(6px * var(--nav-scale, 1)) !important;
}
#height-display-3d #three-controls .ctrl-btn {
  font-size: calc(11px * var(--nav-scale, 1)) !important;
  padding: calc(6px * var(--nav-scale, 1)) calc(8px * var(--nav-scale, 1)) !important;
}
#height-display-3d #three-controls .ctrl-label {
  font-size: calc(9px * var(--nav-scale, 1)) !important;
  margin-bottom: calc(2px * var(--nav-scale, 1)) !important;
}
#height-display-3d #three-controls .ctrl-group {
  padding: calc(6px * var(--nav-scale, 1)) !important;
  gap: calc(4px * var(--nav-scale, 1)) !important;
  border-radius: calc(8px * var(--nav-scale, 1)) !important;
}



/* WebKit / Blink scrollbar styling — visible enough to hint "scroll me"
   without stealing attention from the sliders themselves. */
#three-settings-panel::-webkit-scrollbar {
  width: 6px;
}
#three-settings-panel::-webkit-scrollbar-track {
  background: transparent;
}
#three-settings-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.30);
  border-radius: 3px;
}
#three-settings-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.50);
}

/* ==========================================================================
   TOOL BAR (block / pickaxe / hand) — settings-controlled size + position
   --------------------------------------------------------------------------
   The toolbar is centred with `left: 50%; transform: translateX(-50%)` in
   the base CSS. The X slider is an *offset from that centre*, so 0 means
   "keep it dead centre" and negative/positive values nudge it left or
   right. Y is the offset from the bottom edge of the 3D wrapper.
   Two-ID specificity plus !important beats every older rule and every
   mobile media query.
   ========================================================================== */
#height-display-3d {
  --toolbar-size: 44px;
  --toolbar-x: 0px;
  --toolbar-y: 12px;
}

#height-display-3d #block-toolbar {
  position: absolute !important;
  left: calc(50% + var(--toolbar-x, 0px)) !important;
  right: auto !important;
  top: auto !important;
  bottom: var(--toolbar-y, 12px) !important;
  transform: translateX(-50%) !important;
  z-index: 11 !important;
}

#height-display-3d #block-toolbar .tool-btn {
  width:  var(--toolbar-size, 44px) !important;
  height: var(--toolbar-size, 44px) !important;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

#height-display-3d #block-toolbar .tool-btn img {
  width:  calc(var(--toolbar-size, 44px) * 0.6) !important;
  height: calc(var(--toolbar-size, 44px) * 0.6) !important;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

/* ==========================================================================
   NAV OPTIONS — CLEAN PERFORMANT TABS
   ========================================================================== */
.nav-options {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 58px;
    padding: 0px;
    gap: 1px;
    margin: 10px auto;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-panel);
    box-sizing: border-box;
}

.nav-options > button {
    flex: 1;
    border: none;
    border-radius: 3px;
    background: var(--bg);
    color: var(--blue);
    font-family: "Elms Sans", sans-serif;
    font-weight: 700;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0 4px;
    line-height: 1.2;
}

/* Remove the old keyframe animations entirely to stop layout thrashing */
.nav-options > button.male-opt-active,
.nav-options > button.female-opt-active,
.nav-options > button.coun-opt-active,
.nav-options > button.mals-opt-active,
.nav-options > button.obj-opt-active,
.nav-options > button.img-opt-active {
    background: var(--blue);
    color: var(--bg);
    flex: 1; /* Stops the layout from stretching active buttons */
}
/* ==========================================================================
   CUSTOM BACKGROUND COLOR ROW
   ========================================================================== */
.bg-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px auto 0;
  width: 87%;
}
.bg-custom-row .bg-custom-input {
  width: 46px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--blue-muted);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
}
.bg-custom-row .bg-custom-input::-webkit-color-swatch-wrapper { padding: 2px; }
.bg-custom-row .bg-custom-input::-webkit-color-swatch { border: none; border-radius: 4px; }
.bg-custom-row .bg-custom-input::-moz-color-swatch { border: none; border-radius: 4px; }

.bg-custom-row .bg-apply-btn,
.bg-custom-row .bg-reset-btn {
  flex: 1;
  height: 32px;
  border: 1px solid var(--blue-muted);
  border-radius: 6px;
  font-family: "Elms Sans", sans-serif;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  background: var(--blue);
  color: var(--bg);
}
.bg-custom-row .bg-reset-btn {
  background: var(--bg);
  color: var(--blue);
}

/* ==========================================================================
   WIDE-SCREEN TWO-COLUMN LAYOUT
   --------------------------------------------------------------------------
   On laptops, iPads in landscape, and any viewport 900px or wider, the
   canvas moves to the left and the category strip + form panel move to the
   right, side by side. On phones and small tablets in portrait the layout
   collapses back to the original single-column stacking — the wrappers
   become transparent block elements, so nothing else changes.
   ========================================================================== */

.main-layout,
.layout-left,
.layout-right {
  /* Narrow-screen default: transparent wrappers, original flow preserved. */
  display: block;
}

/* ==========================================================================
   TWO-COLUMN LAYOUT — TIERED BREAKPOINTS
   --------------------------------------------------------------------------
     < 700px  : single column (phone portrait, small phone landscape)
     700–1023 : two column, right = 320px  (iPad portrait, small tablets)
     ≥ 1024px : two column, right = 420px  (iPad landscape, laptops, desktops)
   ========================================================================== */

.main-layout,
.layout-left,
.layout-right {
  display: block;
}

/* ---------- Tablet tier ---------- */
@media (min-width: 700px) {
  .main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    column-gap: 14px;
    align-items: start;
    width: 97%;
    max-width: 1440px;
    margin: 0 auto;
  }

  .layout-left,
  .layout-right {
    display: block;
    min-width: 0;
    align-self: start;
  }

  .layout-left > #height-display,
  .layout-left > #height-display-3d {
    width: 100%;
  }

  .layout-left > nav.adjust { width: 88%; }

  .layout-right > .customize,
  .layout-right > .adjust-display {
    width: calc(100% - 4px);
    margin-left: auto;
    margin-right: auto;
  }

  .layout-right > #height-info         { width: 100%; }
  .layout-right > #option-display      { width: 100%; }
  .layout-right > #celebrities-display { width: 100%; }
  .layout-right > #object-display      { width: 100% !important; }
  .layout-right > .img-display         { width: 100% !important; }
  .layout-right > #animal-display      { width: 100% !important; }

  .layout-right > #object-display,
  .layout-right > .img-display,
  .layout-right > #animal-display {
    margin-top: 12px !important;
    margin-bottom: 0 !important;
    box-sizing: border-box;
  }

  .layout-right .nav-options {
    height: 54px;
    padding: 3px 4px;
    gap: 3px;
  }
  .layout-right .nav-options > button {
    font-size: 7px;
  }
  .layout-right .nav-options > .male-opt-active,
  .layout-right .nav-options > .female-opt-active,
  .layout-right .nav-options > .obj-opt-active,
  .layout-right .nav-options > .mals-opt-active,
  .layout-right .nav-options > .img-opt-active {
    font-size: 8.5px;
  }

  .layout-right #celebrities-display > div:first-child,
  .layout-right .img-option {
    width: 96%;
  }
  .layout-right #celebrities-display > div:first-child button,
  .layout-right .img-option button {
    font-size: 10px;
    padding: 0 4px;
  }
}

/* ---------- Laptop / desktop tier ---------- */
@media (min-width: 1024px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) 420px;
    column-gap: 18px;
    width: 96%;
  }

  .layout-right .nav-options {
    height: 60px;
    padding: 4px 5px;
    gap: 5px;
  }
  .layout-right .nav-options > button {
    font-size: 8px;
  }
  .layout-right .nav-options > .male-opt-active,
  .layout-right .nav-options > .female-opt-active,
  .layout-right .nav-options > .obj-opt-active,
  .layout-right .nav-options > .mals-opt-active,
  .layout-right .nav-options > .img-opt-active, 
  .layout-right .nav-options > .coun-opt-active{
    font-size: 10px;
  }
}

/* ---------- Narrow-screen reset (below 700px) ---------- */
@media (max-width: 699px) {
  .layout-right > #object-display,
  .layout-right > .img-display,
  .layout-right > #animal-display {
    width: 90% !important;
    margin-top: 20px !important;
  }
}
/* ==========================================================================
   RIGHT-COLUMN PANELS — unified sizing
   --------------------------------------------------------------------------
   The three relocated panels (entity, custom image, animal) each had their
   own width and margin rules written for a full-page column. Normalise
   them so they visually match the option-display / celebrities-display
   panels sitting above them.
   ========================================================================== */

#object-display,
.img-display,
#animal-display {
  box-sizing: border-box;
  width: 90% !important;
  max-width: none !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* ==========================================================================
   DARK MODE — AVATAR BACKDROPS
   --------------------------------------------------------------------------
   The avatar silhouettes are dark-on-transparent PNGs, so they vanish
   against dark backgrounds in dark mode. The white backdrop must go on
   whichever element actually IS the tile — putting it on the <img> in the
   "Add Person" grids just produced a small white rectangle floating inside
   the grey tile, which is exactly the artifact we're fixing here.
   ========================================================================== */

/* Celebrity picker: the <img> itself is the tile. */
[data-theme="dark"] .celeb-expand-avatars img {
    background: #ffffff;
}

/* "Add Person" / "Change Avatar" grids: the tile is the parent div.
   Its background is set to 'gray' inline by main.js in dark mode, so we
   need !important to override the inline style. */
[data-theme="dark"] #male-avatar > div,
[data-theme="dark"] #female-avatar > div {
    background: gray !important;
}

/* ==========================================================================
   STICK THE LABEL TO THE FIGURE
   --------------------------------------------------------------------------
   .personbox is a column flex container holding the label (personInfo) on
   top and the figure image (.newperson) directly below. Nothing sits between
   them in the DOM, but several small things can still produce a visible
   strip of empty canvas:
     · a default flex 'gap' on .personbox
     · the label's own padding-bottom (3px from CreatePerson's '3px 5px')
     · extra leading below the label's last text line from line-height
     · subpixel rounding when the image's fractional height is rounded to
       physical pixels
   Zero all of those out, and overlap the image by 1px to absorb any
   remaining rounding seam.
   ========================================================================== */
#display-person .personbox {
    gap: 0 !important;
    row-gap: 0 !important;
}
#display-person .personbox > div {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    line-height: 1.1 !important;
}
#display-person .personbox > .newperson {
    margin-top: -1px !important;
    padding-top: 0 !important;
    border-top: 0 !important;
    display: block !important;
}

/* ==========================================================================
   ARTICLES LIST — cards under the main content section
   ========================================================================== */
.articles-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 60px;
    padding: 20px;
}
.article-card {
    display: block;
    padding: 22px 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    color: var(--blue);
    font-family: "Elms Sans", sans-serif;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease,
                transform 0.15s ease;
}
.article-card:hover {
    background: rgba(82, 151, 255, 0.10);
    border-color: var(--blue);
    transform: translateY(-2px);
    text-decoration: none;
}
[data-theme="light"] .article-card {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .article-card:hover {
    background: rgba(82, 151, 255, 0.10);
}
@media (max-width: 600px) {
    .article-card { font-size: 16px; padding: 18px 20px; }
}

/* ==========================================================================
   BACKGROUND IMAGE LAYER + OPACITY CONTROLS
   ========================================================================== */

/* The image layer sits behind every other child of #height-display.
   It is invisible (display:none) until an image is loaded. */
#height-display .bg-image-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    display: none;
    opacity: 1;
    transition: opacity 0.15s ease;
}
#height-display .bg-image-layer.active {
    display: block;
}

/* Row layouts inside the Customize panel — these override the generic
   @scope (.customize) > div > div rules via higher specificity + !important. */
.customize .bg-image-row,
.customize .bg-opacity-row,
.customize .ruler-opacity-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    height: 44px !important;
    width: 87% !important;
    margin: 0 auto !important;
    gap: 8px !important;
}

/* File input */
.customize .bg-image-input {
    flex: 1 !important;
    height: 32px !important;
    width: auto !important;
    min-width: 0 !important;
    border: 1px solid var(--blue-muted) !important;
    border-radius: 6px !important;
    background: var(--bg) !important;
    color: var(--blue) !important;
    font-size: 11px !important;
    font-family: "Elms Sans", sans-serif !important;
    box-sizing: border-box !important;
    padding: 2px 6px !important;
    cursor: pointer !important;
}
.customize .bg-image-input::file-selector-button {
    background: var(--blue);
    color: var(--bg);
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    margin-right: 8px;
    cursor: pointer;
    font-family: "Elms Sans", sans-serif;
    font-weight: 800;
    font-size: 11px;
}

/* Clear button */
.customize .bg-image-clear {
    flex: 0 0 auto !important;
    height: 32px !important;
    width: auto !important;
    padding: 0 12px !important;
    background: var(--bg) !important;
    color: var(--blue) !important;
    border: 1px solid var(--blue-muted) !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    font-family: "Elms Sans", sans-serif !important;
    cursor: pointer !important;
}

/* Slider labels */
.customize .bg-opacity-row label,
.customize .ruler-opacity-row label {
    flex: 0 0 auto !important;
    padding-left: 0 !important;
    font-size: 12px !important;
    color: var(--blue) !important;
    margin-bottom: 0 !important;
    white-space: nowrap;
}

/* Range inputs */
.customize .bg-opacity-range,
.customize .ruler-opacity-range {
    flex: 1 !important;
    height: 24px !important;
    width: auto !important;
    min-width: 0 !important;
    border: none !important;
    background: transparent !important;
    accent-color: var(--blue) !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Percentage read-outs */
.customize .bg-opacity-value,
.customize .ruler-opacity-value {
    flex: 0 0 44px !important;
    text-align: right !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    color: var(--blue) !important;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   COUNTRY PANEL
   ========================================================================== */
#country-display {
  margin: 0 auto;
  margin-top: 20px;
  width: 90%;
  height: 400px;
  z-index: 20;
  background-color: var(--bg);
  border: 2px solid var(--blue-muted);
  border-radius: 30px;
  display: none;
  flex-direction: column;
  padding: 10px;
  transition: 0.5s;
  overflow: hidden;
}
#country-display > div:first-child {
  display: flex;
  column-gap: 5px;
  width: 100%;
  height: 40px;
  margin-bottom: 10px;
}
#country-display > div:first-child button {
  flex: 1;
  color: var(--blue);
  background: var(--bg);
  border: 1px solid var(--blue);
  border-radius: 5px;
  cursor: pointer;
  font-family: "Elms Sans", sans-serif;
  font-weight: 800;
  font-size: 11px;
}
#country-display > div:first-child button.country-sub-active {
  background: var(--blue);
  color: var(--bg);
}
#countryBox {
  width: 100%;
  flex: 1;
  overflow: hidden;
}
#countryBox > div {
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.country-box {
  border: 1px solid var(--blue);
  color: var(--blue);
  background: var(--bg);
  z-index: 10;
  padding: 7px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Elms Sans", sans-serif;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.country-box:hover {
  background: color-mix(in srgb, var(--blue) 10%, var(--bg));
}
.country-box .country-flag {
  font-size: 18px;
  line-height: 1;
}
.country-box .country-name {
  flex: 1;
  text-align: left;
}
.country-box .country-height {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  opacity: 0.85;
}

/* ==========================================================================
   COUNTRY SUMMARY PANEL
   ========================================================================== */
#country-summary {
  width: 95%;
  margin: 10px auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  display: none;
  font-family: "Elms Sans", sans-serif;
  color: var(--blue);
  overflow: hidden;
}
#country-summary.visible { display: block; }

.country-summary-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
}
.country-summary-head .chev {
  margin-left: auto;
  transition: transform 0.2s ease;
  font-size: 12px;
  opacity: 0.65;
}
#country-summary.open .country-summary-head .chev {
  transform: rotate(180deg);
}
.country-summary-body {
  display: none;
  padding: 0 14px 12px 14px;
  border-top: 1px dashed var(--border-light);
  padding-top: 10px;
  font-size: 12.5px;
  line-height: 1.55;
}
#country-summary.open .country-summary-body { display: block; }
.country-summary-body p { margin: 0 0 8px 0; }
.country-summary-body p:last-child { margin-bottom: 0; }
.country-summary-body b { font-weight: 800; }
.country-summary-source {
  font-size: 10px !important;
  opacity: 0.6;
  margin-top: 6px !important;
}

.country-figure-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    margin-bottom: 10px;
    padding: 0 6px;
    border: 1px solid var(--blue-muted);
    border-radius: 8px;
    background: var(--bg-panel);
    font-family: "Elms Sans", sans-serif;
    font-size: 12px;
    color: var(--blue);
    flex-shrink: 0;
  }
  .country-figure-picker button {
    width: 28px;
    height: 26px;
    flex: 0 0 28px;
    background: var(--bg);
    color: var(--blue);
    border: 1px solid var(--blue-muted);
    border-radius: 6px;
    font-family: inherit;
    font-weight: 800;
    font-size: 11px;
    cursor: pointer;
    line-height: 1;
  }
  .country-figure-picker button:disabled {
    opacity: 0.35;
    cursor: default;
  }
  .country-fig-label {
    flex: 1;
    text-align: center;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .country-fig-label b { font-weight: 800; }
  .country-fig-label .auto-tag {
    opacity: 0.55;
    font-weight: 500;
  }
  .country-summary-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    margin-bottom: 10px;
    padding: 0 10px;
    border: 1px solid var(--blue-muted);
    border-radius: 8px;
    background: var(--bg-panel);
    font-family: "Elms Sans", sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
  }
  .country-summary-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
  }
  .country-summary-toggle-track {
    position: relative;
    width: 34px;
    height: 18px;
    flex: 0 0 34px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--blue) 20%, var(--bg));
    border: 1px solid var(--blue-muted);
    transition: background 0.15s ease, border-color 0.15s ease;
  }
  .country-summary-toggle-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--blue);
    transition: transform 0.15s ease, background 0.15s ease;
  }
  .country-summary-toggle-input:checked + .country-summary-toggle-track {
    background: var(--blue);
    border-color: var(--blue);
  }
  .country-summary-toggle-input:checked + .country-summary-toggle-track::after {
    transform: translateX(16px);
    background: var(--bg);
  }
  .country-summary-toggle-text { flex: 1; }

.cel-box,
.animal-box,
.obj-box,
.country-box {
    content-visibility: auto;
    contain-intrinsic-size: auto 40px;
}
/* Add at the end of style.css */
#universe-grid .obj-box {
    content-visibility: visible !important;
}
/* The currently-expanded celebrity picker is interactive; don't let the
   browser skip rendering it even if it happens to sit just below the fold. */
.cel-box.expanded-celeb {
    content-visibility: visible;
}

.customize .gap-size-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    height: 44px !important;
    width: 87% !important;
    margin: 0 auto !important;
    gap: 8px !important;
}
.customize .gap-size-row label {
    flex: 0 0 auto !important;
    padding-left: 0 !important;
    font-size: 12px !important;
    color: var(--blue) !important;
    margin-bottom: 0 !important;
    white-space: nowrap;
}
.customize .figure-gap-range {
    flex: 1 !important;
    height: 24px !important;
    width: auto !important;
    min-width: 0 !important;
    border: none !important;
    background: transparent !important;
    accent-color: var(--blue) !important;
    margin: 0 !important;
    padding: 0 !important;
}
.customize .figure-gap-value {
    flex: 0 0 44px !important;
    text-align: right !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    color: var(--blue) !important;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   LIQUID GLASS — MODALS & POPUPS
   ========================================================================== */

/* Both the Share Modal and the Clear (You Sure) panel */
.youSure,
.share-modal {
    /* Glass Background */
    background: var(--bg) !important;
    background: color-mix(in srgb, var(--bg) 75%, transparent) !important;
    
    /* Blur & Saturation */
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    
    /* Bevel Highlights & Shadows */
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.15), 
        inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
        
    border-radius: 16px !important;
}

/* Dark Mode Overrides for the Modals */
[data-theme="dark"] .youSure,
[data-theme="dark"] .share-modal {
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5), 
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
}

/* ── "Added!" Toast Notification ─────────────────────────────────── */
.glass-toast {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 9999999999;
    
    /* Glass Background */
    background: color-mix(in srgb, var(--bg) 75%, transparent);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1), 
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
        
    padding: 12px 24px;
    border-radius: 30px;
    color: var(--text-strong);
    font-family: "Elms Sans", sans-serif;
    font-weight: 800;
    font-size: 14px;
    pointer-events: none;
    
    /* Animation */
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

[data-theme="dark"] .glass-toast {
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5), 
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

#celebrities-display,
#animal-display,
#object-display,
.img-display,
#country-display,
.adjust-display,
.customize,
.share-modal,
.youSure {
    content-visibility: auto;
    contain-intrinsic-size: auto 400px;
    overflow-y: scroll !important;
}

/* ==========================================================================
   PERFORMANCE OVERRIDES — appended to fix the main frame-drop causes
   ========================================================================== */

/* --- FIX 1: height transition = 20 reflows per zoom click × 13 frames ------
   The figure resizing is instant in the JS; a CSS height transition forces
   the whole column flex to re-layout every animation frame. Removing it
   makes zoom snap immediately (which is also snappier UX). */
.newperson {
    transition: none !important;
}

/* --- FIX 2: backdrop-filter cleanup ---------------------------------------
   · blur(30000px) is a no-op visually (the .search-bar already has an
     opaque background), but the browser still pays to set up the pass.
   · .nav-options sits over the page background which is a solid colour —
     blurring it produces the same solid colour. Zero visual benefit.
   · .added-popup is a small toast; it doesn't need blur.
   · The others keep a *much* cheaper 10px blur, no saturate(). */
.search-bar {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.nav-options {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.added-popup {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
#title-bar {
    /* saturate() is an extra pass on top of blur(); keep blur only */
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}
.menu-display {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}
.youSure,
.share-modal {
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

/* --- FIX 3: will-change on every figure label ----------------------------
   Having will-change: transform on 20+ labels forces 20+ compositor
   layers permanently. The browser promotes automatically when a transition
   actually starts, so we don't need it declared up front. */
#display-person .personbox > div {
    will-change: auto !important;
}

/* ==========================================================================
   UNIFIED PANEL STYLES
   ========================================================================== */

#celebrities-display,
#animal-display,
#object-display,
#country-display,
.img-display {
    width: 95%;
    margin: 20px auto;
    padding: 20px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-sizing: border-box;
    display: none; /* Controlled by JS */
    flex-direction: column;
    overflow: hidden;
}

/* Tabs inside panels (Celebrities, Entities, Countries) */
#celebrities-display > div:first-child,
#object-display > div:first-child,
#country-display > div:first-child {
    display: flex;
    width: 100%;
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--bg);
}

#celebrities-display > div:first-child button,
#object-display > div:first-child button,
#country-display > div:first-child button {
    flex: 1;
    padding: 12px 8px;
    border: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    background: transparent;
    cursor: pointer;
}

#celebrities-display > div:first-child button.cel-btn,
#object-display > div:first-child button.Sbtn,
#object-display > div:first-child button.Obtn,
#object-display > div:first-child button.Abtn,
#country-display > div:first-child button.country-sub-active {
    background: var(--blue);
    color: var(--bg);
}

/* Search Bars */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    position: relative;
}

.search-bar input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.search-bar button {
    padding: 12px 20px;
    border: none;
    background: var(--blue);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

/* List Items */
.cel-box, .country-box, .animal-box, .obj-box {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 8px;
    background: var(--bg);
    color: var(--content-blue);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    box-sizing: border-box;
    transition: background 0.15s ease;
}
.cel-box:hover, .country-box:hover, .animal-box:hover, .obj-box:hover {
    background: rgba(82, 151, 255, 0.05);
}

/* ==========================================================================
   FINAL CLEAN LAYOUT & PERFORMANCE FIXES
   ========================================================================== */

/* 1. KILL ALL CATEGORY BUTTON ANIMATIONS */
.nav-options > button {
    animation: none !important;
    transform: none !important;
    flex: 1 !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

/* 2. UNIFIED PANEL CONTAINER SETUP */
#object-display,
#animal-display,
#celebrities-display,
#country-display,
.img-display {
    display: none; /* JS will set to flex or block */
    flex-direction: column;
    height: 520px; /* Fixed height to constrain scrolling */
    max-height: calc(100vh - 120px);
    overflow: hidden !important;
    padding: 16px;
    box-sizing: border-box;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 95%;
    margin: 20px auto;
    position: relative; 
}

/* Force flex layout when JS makes them visible */
#object-display[style*="display: flex"],
#object-display[style*="display: grid"],
#animal-display[style*="display: flex"],
#animal-display[style*="display: grid"],
#celebrities-display[style*="display: flex"],
#country-display[style*="display: flex"],
#country-display[style*="display: grid"],
.img-display[style*="display: flex"] {
    display: flex !important;
}

/* 3. ENTITY PANEL (Stop tabs from stacking) */
#objBox {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Crucial for nested scrolling */
    width: 100%;
}

#statue, #universe, #obD {
    flex-direction: column;
    gap: 8px;
    height: 100%;
    overflow-y: auto !important;
    padding-right: 6px;
    box-sizing: border-box;
    /* Do NOT force display: flex here. JS handles showing/hiding! */
}

/* Object 3-column grid */
#object-dis {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding-bottom: 20px;
    width: 100%;
}
#object-dis .obj-box {
    flex-direction: column;
    justify-content: center;
    height: 110px;
    padding: 8px;
    margin-bottom: 0;
}
#object-dis .obj-box img {
    height: 60px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 4px;
}
#object-dis .obj-box p {
    font-size: 11px;
    margin: 0;
    line-height: 1.1;
    text-align: center;
}

/* 4. CELEBRITIES PANEL */
#celebrities-display > div:nth-child(2) {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    width: 100%;
}
#celebrities-display > div:nth-child(2) > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    height: 100%;
    width: 100%;
}

/* Hide unused lists so they don't take up flex space */
#anim-display, #unreal-display {
    display: none !important;
}

#cel-display {
    flex: 1;
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: auto !important;
    padding-right: 6px;
    box-sizing: border-box;
}

/* 5. CUSTOM IMAGE PANEL */
.img-option {
    display: flex;
    position: static !important; 
    transform: none !important;
    top: auto !important;
    left: auto !important;
    height: 40px;
    width: 100%;
    margin-bottom: 20px;
    border: none !important;
    gap: 8px;
    flex-shrink: 0;
}
.img-option button {
    flex: 1;
    border-radius: 8px;
    font-weight: 700;
}

/* The wrapper holding both forms needs to scroll properly */
.img-display > div:nth-child(2) {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Remove the forced display: flex so JS can hide/show them */
#upload-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 0 !important;
    overflow-y: auto !important;
}

.ai-generator-box {
    flex: 1;
    flex-direction: column;
    gap: 12px;
    padding-top: 0 !important;
    overflow-y: auto !important;
    /* We do NOT put display here. The JS will set display: flex when needed. */
}

/* 6. ANIMAL PANEL */
#animal-display {
    overflow-y: auto !important;
    display: none; /* JS toggles grid */
}
#animal-display[style*="display: grid"],
#animal-display[style*="display: flex"] {
    display: grid !important;
    grid-template-columns: 1fr;
}

/* 7. COUNTRY PANEL */
#countryBox {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
#countryBox > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
#country-list {
    flex: 1;
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 8. STICKY SEARCH BARS */
#statue .search-bar,
#universe .search-bar,
#obD .search-bar,
#animal-display .search-bar,
#celebrities-display .search-bar,
#country-display .search-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-panel);
    margin-bottom: 12px;
    padding: 8px 0;
    border: none !important;
    flex-shrink: 0;
    width: 100%;
    height: 40px;
}

/* 9. LIST ITEMS */
.obj-box, .animal-box, .cel-box, .country-box {
    flex-shrink: 0;
    width: 100% !important;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    color: var(--content-blue);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 8px;
}

.obj-box:hover, .animal-box:hover, .cel-box:hover, .country-box:hover {
    background: rgba(82, 151, 255, 0.08);
}

/* 10. TABS */
#celebrities-display > div:first-child,
#object-display > div:first-child,
#country-display > div:first-child {
    display: flex;
    width: 100%;
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--bg);
    flex-shrink: 0;
}

#celebrities-display > div:first-child button,
#object-display > div:first-child button,
#country-display > div:first-child button {
    flex: 1;
    padding: 12px 8px;
    border: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    background: transparent;
    cursor: pointer;
}

#celebrities-display > div:first-child button.cel-btn,
#object-display > div:first-child button.Sbtn,
#object-display > div:first-child button.Obtn,
#object-display > div:first-child button.Abtn,
#country-display > div:first-child button.country-sub-active {
    background: var(--blue);
    color: var(--bg);
}

/* ==========================================================================
   AUTO AVATARS TOGGLE (Customize panel)
   ========================================================================== */
.customize > div > .auto-avatar-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    height: auto !important;
    min-height: 48px !important;
    width: 87% !important;
    margin: 0 auto !important;
    gap: 0 !important;
}

.auto-avatar-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--blue-muted);
    border-radius: 8px;
    background: var(--bg);
    font-family: "Elms Sans", sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.auto-avatar-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.auto-avatar-track {
    position: relative;
    width: 34px;
    height: 18px;
    flex: 0 0 34px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--blue) 20%, var(--bg));
    border: 1px solid var(--blue-muted);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.auto-avatar-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--blue);
    transition: transform 0.15s ease, background 0.15s ease;
}
.auto-avatar-input:checked + .auto-avatar-track {
    background: var(--blue);
    border-color: var(--blue);
}
.auto-avatar-input:checked + .auto-avatar-track::after {
    transform: translateX(16px);
    background: var(--bg);
}

.auto-avatar-text {
    flex: 1;
    line-height: 1.25;
}

/* ==========================================================================
   COLOR SWATCHES — accommodate the added yellow / purple presets
   ========================================================================== */
.color-options {
    flex-wrap: wrap !important;
    height: auto !important;
    min-height: 30px;
    row-gap: 4px;
    justify-content: center;
}

/* ==========================================================================
   SOCIAL MEDIA BAR
   ========================================================================== */
.social-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    max-width: 1000px;
    margin: 60px auto 40px;
    padding: 0 20px;
    box-sizing: border-box;
}

.social-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--bg-panel);
    color: var(--content-blue);
    text-decoration: none;
    font-family: "Elms Sans", sans-serif;
    transition: transform 0.15s ease,
                box-shadow 0.15s ease,
                border-color 0.15s ease;
    overflow: hidden;
}

.social-btn:hover {
    transform: translateY(-3px);
    border-color: var(--blue);
    box-shadow: 0 8px 22px rgba(82, 151, 255, 0.18);
    text-decoration: none;
}

.social-btn:active {
    transform: translateY(-1px) scale(0.99);
}

.social-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.social-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* Brand colours */
.social-tiktok .social-icon {
    background: #000000;
}
.social-facebook .social-icon {
    background: #1877f2;
}
.social-twitter .social-icon {
    background: #000000;
}
.social-instagram .social-icon {
    background: linear-gradient(
        45deg,
        #f09433 0%,
        #e6683c 25%,
        #dc2743 50%,
        #cc2366 75%,
        #bc1888 100%
    );
}

.social-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.social-name {
    font-weight: 900;
    font-size: 14px;
    color: var(--blue);
}

.social-user {
    font-size: 12px;
    color: var(--content-blue);
    opacity: 0.75;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dark-theme icon borders so black TikTok / Twitter tiles stay visible */
[data-theme="dark"] .social-tiktok .social-icon,
[data-theme="dark"] .social-twitter .social-icon {
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Responsive */
@media (max-width: 700px) {
    .social-nav {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin: 40px auto 30px;
    }
    .social-btn {
        padding: 12px 12px;
        gap: 10px;
    }
    .social-icon {
        width: 34px;
        height: 34px;
    }
    .social-icon svg {
        width: 18px;
        height: 18px;
    }
    .social-name { font-size: 12.5px; }
    .social-user { font-size: 11px; }
}

@media (max-width: 380px) {
    .social-nav {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   FREE POSITIONING — toggle in Customize panel + drag behaviour
   ========================================================================== */
.customize > div > .free-pos-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    height: auto !important;
    min-height: 48px !important;
    width: 87% !important;
    margin: 0 auto !important;
    gap: 0 !important;
}

.free-pos-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--blue-muted);
    border-radius: 8px;
    background: var(--bg);
    font-family: "Elms Sans", sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.free-pos-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.free-pos-track {
    position: relative;
    width: 34px;
    height: 18px;
    flex: 0 0 34px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--blue) 20%, var(--bg));
    border: 1px solid var(--blue-muted);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.free-pos-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--blue);
    transition: transform 0.15s ease, background 0.15s ease;
}
.free-pos-input:checked + .free-pos-track {
    background: var(--blue);
    border-color: var(--blue);
}
.free-pos-input:checked + .free-pos-track::after {
    transform: translateX(16px);
    background: var(--bg);
}

.free-pos-text {
    flex: 1;
    line-height: 1.25;
}

/* Draggable figures inside the canvas */
#display-person.free-pos-active > .personbox {
    cursor: grab;
}
#display-person.free-pos-active > .personbox.dragging {
    cursor: grabbing;
    opacity: 0.96;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}
.newperson { 
    flex-shrink: 0; 
    transition: none !important;
    /* Prevents the browser from applying its soft bilinear filter on top
       of an already-soft alpha edge from the background-removal pass. */
    image-rendering: -webkit-optimize-contrast;
}

#male-avatar img,
#female-avatar img,
.celeb-expand-avatars img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* ==========================================================================
   CUSTOM COLOR PICKER — 2D Board
   ========================================================================== */
.color-options .custom-color-widget {
  display: inline-block !important;
  position: relative;
  height: 32px !important;
  width: 32px  !important;
  flex-shrink: 0;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.color-options .custom-color {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  height: 100% !important;
  border-radius: 50% !important;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
  box-sizing: border-box;
}

.color-options .custom-color-preview {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #5297ff;
  pointer-events: none;
  border: 1px solid rgba(0,0,0,0.1);
}

/* ----- The Panel ----- */
.color-options .custom-color-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: auto;
  width: 57vw;
  max-width: calc(100vw - 40px);
  padding: 12px;
  background: var(--bg);
  border: 2px solid var(--blue-muted);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  z-index: 9999;
  box-sizing: border-box;
  flex-direction: column;
  gap: 12px;
  font-family: "Elms Sans", sans-serif;
}
.color-options .custom-color-panel.active {
  display: flex;
}

.cc-panel-header {
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--blue);
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-dotted);
}

/* ----- 2D Color Board ----- */
.cc-board {
  position: relative;
  display: block;
  width: 100%;
  height: 140px;
  border-radius: 8px;
  overflow: hidden;
  /* The background color is set dynamically in JS to the current Hue.
     These gradients create the white (left) and black (bottom) overlays. */
  background-image: 
    linear-gradient(to top, #000, transparent), 
    linear-gradient(to right, #fff, transparent);
  cursor: crosshair;
  touch-action: none;
}

.cc-board-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5), inset 0 0 2px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
  left: 0;
  top: 0;
}

/* ----- Hue Slider ----- */
.cc-slider-row {
  display: flex;
  align-items: center;
  width: 100%;
}
.cc-slider-row input[type="range"].cc-hue-slider {
  width: 100%;
  height: 12px;
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  margin: 0;
  background: linear-gradient(to right, 
    #ff0000 0%, #ffff00 17%, #00ff00 33%, 
    #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
  cursor: pointer;
}
.cc-slider-row input[type="range"].cc-hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #444;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  cursor: pointer;
}
.cc-slider-row input[type="range"].cc-hue-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #444;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
  cursor: pointer;
}

/* ----- Preview & Hex Input ----- */
.cc-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cc-preview-large {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--border-dotted);
  background: #5297ff;
}
#option-display .cc-hex {
  flex: 1 !important;
  width: auto !important;
  min-width: 0;
  height: 36px !important;
  padding: 0 8px !important;
  margin-bottom: 0 !important;
  border: 1px solid var(--border-dotted) !important;
  border-radius: 6px !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  font-family: ui-monospace, Menlo, monospace !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-align: center;
  text-transform: uppercase;
  box-sizing: border-box;
}

/* ----- Actions ----- */
.cc-panel-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-dotted);
}
.cc-panel-actions button {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  font-family: "Elms Sans", sans-serif;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--blue-muted);
}
.cc-cancel-btn {
  background: var(--bg);
  color: var(--blue);
}
.cc-apply-btn {
  background: var(--blue);
  color: var(--bg);
  border-color: var(--blue);
}
.cc-apply-btn:active,
.cc-cancel-btn:active {
  transform: scale(0.97);
}

/* ==========================================================================
   ANIMAL PANEL — 3-column card grid + Living / Prehistoric tabs
   ========================================================================== */
#animal-display {
    display: none;
    flex-direction: column;
    height: 520px;
    max-height: calc(100vh - 120px);
    overflow: hidden !important;
    padding: 16px;
    box-sizing: border-box;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    width: 95%;
    margin: 20px auto;
    position: relative;
}
#animal-display[style*="display: flex"],
#animal-display[style*="display: grid"] {
    display: flex !important;
}
#animal-templates,
#universe-templates {
    display: none !important;
}

.animal-tabs {
    display: flex;
    width: 100%;
    border: 1px solid var(--border-dotted);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--bg);
    flex-shrink: 0;
}
.animal-tab-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    font-size: 11px;
    font-weight: 600;
    color: var(--blue);
    background: transparent;
    cursor: pointer;
    font-family: "Elms Sans", sans-serif;
    transition: background 0.15s ease, color 0.15s ease;
}
.animal-tab-btn.animal-tab-active {
    background: var(--blue);
    color: var(--bg);
}

#animal-display .search-bar {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 12px;
    height: 40px;
    padding: 0;
}

#animal-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding-bottom: 20px;
    align-content: start;
}

#animal-grid .animal-box,
#universe-grid .obj-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 110px;
    padding: 8px;
    margin-bottom: 0;
    width: 100% !important;
    box-sizing: border-box;
}
#animal-grid .animal-box img,
#universe-grid .obj-box img {
    height: 60px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 4px;
    display: block;
}
#animal-grid .animal-box p,
#universe-grid .obj-box p {
    font-size: 11px;
    margin: 0;
    line-height: 1.1;
    text-align: center;
}

/* ==========================================================================
   UNIVERSE (Astronomical Object) — 3-column card grid inside #objBox
   ========================================================================== */
#universe {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden !important;
    gap: 0 !important;
}
#universe[style*="display: flex"] {
    display: flex !important;
}
#universe .search-bar {
    position: relative;
    flex-shrink: 0;
    margin-bottom: 12px;
    height: 40px;
    padding: 0;
}
#universe-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding-bottom: 20px;
    align-content: start;
}