/*
 * ZOO CURATOR V76 — DRAG + COMPATIBILITY HOVER FIXES
 * Known-good GitHub baseline. Future builds must descend from this version.
 */

:root {
    --zoo-zoom: 1;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    background: #e7e4dc;
}

body {
    user-select: none;
}


/* ============================================================
   LOADING
   ============================================================ */

#bootScreen {
    position: fixed;
    inset: 0;

    z-index: 10000;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background: #e7e4dc;
}

#bootScreen.hidden {
    display: none;
}

#bootTitle {
    margin-bottom: 22px;

    font-size: 38px;
    font-weight: 700;
}

#bootStatus {
    font-size: 22px;
    font-weight: 700;
}

#bootDetail {
    margin-top: 10px;

    font-size: 15px;
    opacity: 0.65;
}


/* ============================================================
   ERROR
   ============================================================ */

#fatalError {
    display: none;

    position: fixed;
    inset: 0;

    z-index: 11000;

    padding: 40px;

    background: #f4eeee;
    color: #8b1e1e;

    font-family: monospace;
    white-space: pre-wrap;
}

#fatalError.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}


/* ============================================================
   GAME
   ============================================================ */

#gameApp {
    position: fixed;
    inset: 0;

    visibility: hidden;
}

#gameApp.visible {
    visibility: visible;
}


/* ============================================================
   HEADER
   ============================================================ */

#actionMenu {
    position: fixed;

    left: 0;
    right: 0;
    top: 0;

    height: 220px;

    z-index: 5000;

    background: #f4f1e9;

    border-bottom:
        2px solid #bcb7aa;

    box-shadow:
        0 3px 10px
        rgba(0, 0, 0, 0.12);
}


/* ============================================================
   ZOO NAME
   ============================================================ */

#playerZooName {
    position: absolute;

    left: 50%;
    top: 4px;

    transform:
        translateX(-50%);

    width: 640px;

    min-height: 40px;

    font-size: 28px;
    font-weight: 700;

    line-height: 34px;

    text-align: center;
}


/* ============================================================
   ZOO NAME EDITOR
   ============================================================ */

.zoo-name-editor {
    display: flex;

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

    gap: 7px;

    width: 100%;
}

.zoo-name-text {
    display: block;

    max-width: 480px;

    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.zoo-name-edit-button {
    width: 28px;
    height: 28px;

    flex: 0 0 auto;

    display: flex;

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

    padding: 0;

    border:
        1px solid
        rgba(73, 69, 59, 0.45);

    border-radius: 6px;

    background: #ebe8df;

    color: #403d36;

    font-size: 19px;
    font-weight: 700;

    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 2px 4px
        rgba(0, 0, 0, 0.12);
}

.zoo-name-edit-button:hover {
    background: #fff;
}

.zoo-name-edit-button.editing {
    background: #ffe887;

    box-shadow:
        0 0 8px
        rgba(255, 210, 30, 0.65);
}

.zoo-name-input {
    width: 390px;
    height: 31px;

    padding: 2px 8px;

    border:
        2px solid #9b8b48;

    border-radius: 6px;

    background: #fff;

    font: inherit;
    font-size: 21px;
    font-weight: 700;

    text-align: center;

    outline: none;
}


/* ============================================================
   HEADER LEFT
   ============================================================ */

#headerLeft {
    position: absolute;

    left: 18px;
    top: 18px;
}

.header-small {
    padding: 6px 10px;

    border:
        1px solid #bbb6aa;

    border-radius: 6px;

    background: #ebe8df;

    font-size: 14px;
}


/* ============================================================
   HEADER ACTIONS
   ============================================================ */

#headerActions {
    position: absolute;

    left: 50%;
    top: 45px;

    transform:
        translateX(-50%);
}

.exchange-controls {
    display: flex;

    align-items: center;

    gap: 11px;
}


/* ============================================================
   ACTION CARDS
   ============================================================ */

.action-card,
.action-slot,
.exchange-result,
.trade-offer {
    width: 100px;
    height: 144px;

    flex: 0 0 auto;

    border-radius: 8px;
}

.action-card {
    padding: 0;

    overflow: hidden;

    border:
        2px solid
        rgba(73, 69, 59, 0.65);

    background: #fff;

    box-shadow:
        0 3px 8px
        rgba(0, 0, 0, 0.20);
}

.draw-card {
    cursor: pointer;
}

.draw-card img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: fill;
}


/* ============================================================
   EXCHANGE
   ============================================================ */

.action-slot,
.exchange-result {
    position: relative;

    overflow: visible;

    border:
        2px solid
        rgba(73, 69, 59, 0.55);

    background: #99968f;

    opacity: 0.45;

    box-shadow:
        inset 0 0 10px
        rgba(0, 0, 0, 0.14);
}

.action-slot.exchange-ready {
    background: #fff;

    opacity: 1;

    box-shadow:
        0 3px 8px
        rgba(0, 0, 0, 0.20);
}


/* ============================================================
   UPGRADE RESULT GLOW
   ============================================================ */

.exchange-result.result-ready {
    background: #fff;

    opacity: 1;

    cursor: pointer;

    border:
        2px solid
        rgba(73, 69, 59, 0.65);

    box-shadow:
        0 0 0 4px
        rgba(255, 211, 35, 0.95),

        0 0 18px 8px
        rgba(255, 211, 35, 0.78),

        0 4px 10px
        rgba(0, 0, 0, 0.25);

    animation:
        upgradeGlowPulse
        1.35s
        ease-in-out
        infinite
        alternate;
}

@keyframes upgradeGlowPulse {

    from {
        box-shadow:
            0 0 0 3px
            rgba(255, 211, 35, 0.85),

            0 0 12px 5px
            rgba(255, 211, 35, 0.60),

            0 4px 10px
            rgba(0, 0, 0, 0.25);
    }

    to {
        box-shadow:
            0 0 0 5px
            rgba(255, 220, 60, 1),

            0 0 23px 10px
            rgba(255, 211, 35, 0.90),

            0 4px 10px
            rgba(0, 0, 0, 0.25);
    }

}

.exchange-card,
.result-card {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: fill;

    border:
        2px solid
        rgba(73, 69, 59, 0.65);

    border-radius: 7px;

    background: #fff;
}

.exchange-card {
    cursor: grab;

    /* Override the normal 135 x 194.4 animal-card dimensions. */
    width: 100px !important;
    height: 144px !important;
    transform: none !important;
}

.exchange-card:active,
.result-card:active {
    cursor: grabbing;
}

.result-card {
    cursor: grab;
}


/* ============================================================
   TRADE OFFERS
   ============================================================ */

.trade-offer {
    display: flex;

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

    border:
        2px solid
        rgba(73, 69, 59, 0.55);

    background: #ddd9d0;

    color: #6e6a62;

    font-size: 11px;
    font-weight: 700;

    text-align: center;

    box-shadow:
        0 3px 8px
        rgba(0, 0, 0, 0.12);
}


/* ============================================================
   OPPONENTS
   ============================================================ */

#opponentZoos {
    position: absolute;
    right: 18px;
    top: 8px;
    width: 255px;
}

.opponent-title {
    margin-bottom: 5px;

    font-size: 13px;
    font-weight: 700;

    text-align: right;

    opacity: 0.6;
}

.opponent-name {
    margin-bottom: 5px;

    padding: 6px 11px;

    border:
        1px solid #bbb6aa;

    border-radius: 5px;

    background: #ebe8df;

    font-size: 15px;
    font-weight: 700;

    text-align: right;
}


/* ============================================================
   ZOO BOARD
   ============================================================ */

#zooBoard {
    position: fixed;

    left: 0;
    right: 0;

    top: 220px;
    bottom: 0;

    overflow: auto;

    z-index: 100;

    background: #e7e4dc;

    cursor: grab;

    touch-action: none;
}

#zooBoard.panning {
    cursor: grabbing;
}

#zooCanvas {
    position: relative;

    width: 6000px;
    height: 5000px;

    /* Zoom the complete zoo coordinate system as one world. */
    zoom: var(--zoo-zoom);
}


/* ============================================================
   ENCLOSURES
   ============================================================ */

.enclosure {
    position: absolute;

    width: 350px;
    height: 466.6667px;

    cursor: grab;

    touch-action: none;
}

.enclosure.dragging-enclosure {
    cursor: grabbing;

    z-index: 500;
}

.enclosure-image {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    object-fit: fill;

    pointer-events: none;

    border:
        2px solid
        rgba(73, 69, 59, 0.55);

    border-radius: 10px;

    box-shadow:
        0 4px 11px
        rgba(0, 0, 0, 0.16);
}


/* ============================================================
   NEW ENCLOSURE GLOW
   ============================================================ */

.enclosure.new-enclosure
.enclosure-image {
    box-shadow:
        0 0 0 5px
        rgba(255, 211, 35, 0.95),

        0 0 24px 12px
        rgba(255, 211, 35, 0.78),

        0 4px 11px
        rgba(0, 0, 0, 0.20);

    animation:
        newEnclosurePulse
        1.4s
        ease-in-out
        infinite
        alternate;
}

@keyframes newEnclosurePulse {

    from {
        box-shadow:
            0 0 0 4px
            rgba(255, 211, 35, 0.82),

            0 0 15px 7px
            rgba(255, 211, 35, 0.60),

            0 4px 11px
            rgba(0, 0, 0, 0.20);
    }

    to {
        box-shadow:
            0 0 0 6px
            rgba(255, 220, 60, 1),

            0 0 28px 14px
            rgba(255, 211, 35, 0.88),

            0 4px 11px
            rgba(0, 0, 0, 0.20);
    }

}


/* ============================================================
   ENCLOSURE SPOTS
   ============================================================ */

/*
    Keep this geometry unchanged.

    This is the enclosure layout that was correctly aligned.
*/

.slot {
    position: absolute;
    width: 50%;
    height: 50%;
    z-index: 20;
    pointer-events: auto;
}

.slot[data-slot-index="0"] { left: 0; top: 0; }
.slot[data-slot-index="1"] { left: 50%; top: 0; }
.slot[data-slot-index="2"] { left: 0; top: 50%; }
.slot[data-slot-index="3"] { left: 50%; top: 50%; }
.slot.empty-slot { cursor: default; }


/* ============================================================
   ANIMAL CARDS
   ============================================================ */

.animal-card {
    display: block;

    width: 135px;
    height: 194.4px;

    object-fit: fill;

    border:
        2px solid
        rgba(73, 69, 59, 0.68);

    border-radius: 8px;

    background: #fff;

    box-shadow:
        0 3px 8px
        rgba(0, 0, 0, 0.22);

    cursor: grab;

    touch-action: none;
}

.animal-card:active {
    cursor: grabbing;
}


/*
    Enclosure receives the zoo zoom.

    Animal must NOT get another scale transform.
*/

.enclosure-animal {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 135px;
    height: 194.4px;
    transform: translate(-50%, -50%);
}


/* ============================================================
   EXCHANGE ELIGIBILITY
   ============================================================ */

.animal-card.exchange-eligible {
    box-shadow:
        0 0 0 4px
        rgba(255, 211, 35, 0.95),

        0 0 15px 7px
        rgba(255, 211, 35, 0.72),

        0 3px 8px
        rgba(0, 0, 0, 0.22);
}

/* During an animal drag: hold the pre-drag eligibility glow for 1 second,
   then fade it away over 1 second. */
.animal-card.exchange-drag-glow {
    animation: exchangeDragGlowAway 2s linear forwards !important;
}

@keyframes exchangeDragGlowAway {
    0%, 50% {
        box-shadow:
            0 0 0 4px rgba(255, 211, 35, 0.95),
            0 0 15px 7px rgba(255, 211, 35, 0.72),
            0 3px 8px rgba(0, 0, 0, 0.22);
    }
    100% {
        box-shadow:
            0 0 0 0 rgba(255, 211, 35, 0),
            0 0 0 0 rgba(255, 211, 35, 0),
            0 3px 8px rgba(0, 0, 0, 0.22);
    }
}

/* When the animal is placed/restored, eligible glows return over 1 second. */
.animal-card.exchange-eligible.exchange-glow-return {
    animation: exchangeGlowReturn 1s ease forwards !important;
}

@keyframes exchangeGlowReturn {
    from {
        box-shadow:
            0 0 0 0 rgba(255, 211, 35, 0),
            0 0 0 0 rgba(255, 211, 35, 0),
            0 3px 8px rgba(0, 0, 0, 0.22);
    }
    to {
        box-shadow:
            0 0 0 4px rgba(255, 211, 35, 0.95),
            0 0 15px 7px rgba(255, 211, 35, 0.72),
            0 3px 8px rgba(0, 0, 0, 0.22);
    }
}


/* ============================================================
   HAND
   ============================================================ */

#hand {
    position: fixed;

    left: 50%;
    bottom: 15px;

    transform:
        translateX(-50%);

    z-index: 6000;

    display: flex;

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

    gap: 12px;

    pointer-events: none;
}

#hand .animal-card {
    position: relative;

    left: auto;
    top: auto;

    width: 270px;
    height: 388.8px;

    transform: none;

    flex: 0 0 auto;

    pointer-events: auto;

    border-radius: 11px;

    box-shadow:
        0 5px 14px
        rgba(0, 0, 0, 0.26);
}


/* ============================================================
   HOVER PREVIEW
   ============================================================ */

#hoverPreview {
    position: fixed;
    left: 18px;
    bottom: 18px;
    width: 405px;
    height: 583.2px;
    z-index: 7000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform-origin: left bottom;
    transition: width 0.16s ease, height 0.16s ease, opacity 1s ease, visibility 0s linear 1s;
}

#hoverPreview.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: width 0.16s ease, height 0.16s ease, opacity 0.10s ease, visibility 0s;
}

#hoverPreviewImage {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    border: 2px solid rgba(73, 69, 59, 0.72);
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(0,0,0,0.32);
}

#hoverPreviewImage {
    transition: transform 0.42s ease, opacity 0.22s ease;
    backface-visibility: hidden;
}

#hoverPreviewWiki {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 18px;
    border: 2px solid rgba(73,69,59,.72);
    border-radius: 11px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.45);
    box-shadow: 0 8px 22px rgba(0,0,0,.32);
    opacity: 0;
    transform: rotateY(180deg);
    backface-visibility: hidden;
    transition: transform 0.42s ease, opacity 0.22s ease;
    pointer-events: none;
}

#hoverPreview.wiki-open #hoverPreviewImage {
    opacity: 0;
    transform: rotateY(180deg);
}

#hoverPreview.wiki-open #hoverPreviewWiki {
    opacity: 1;
    transform: rotateY(0deg);
    pointer-events: auto;
}

.wiki-preview-toolbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,.45);
}

#wikiPreviewTitle {
    font-size: 20px;
    line-height: 1.15;
}

#wikiPreviewLink {
    flex: 0 0 auto;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0,0,0,.55);
}

#wikiPreviewStatus {
    margin: 9px 0 7px;
    font-size: 10px;
    font-weight: 800;
    opacity: .9;
}

#wikiPreviewText {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 10px 12px;
    border-radius: 7px;
    background: rgba(255,255,255,.90);
    color: #242424;
    text-shadow: none;
    white-space: pre-wrap;
    user-select: text;
    font-size: 12px;
    line-height: 1.45;
}

#hoverPreview.super-zoom #wikiPreviewTitle { font-size: 28px; }
#hoverPreview.super-zoom #wikiPreviewStatus { font-size: 12px; }
#hoverPreview.super-zoom #wikiPreviewText { font-size: 15px; line-height: 1.5; }

#hoverPreview.super-zoom {
    width: min(810px, calc(100vw - 36px));
    height: min(1166.4px, calc(100vh - 36px));
}

#hoverPreview.super-zoom #hoverPreviewImage { object-fit: contain; }


/* ============================================================
   DRAGGED ANIMAL
   ============================================================ */

.dragging-animal {
    position: fixed;

    z-index: 20000;

    object-fit: fill;

    pointer-events: none;

    border:
        2px solid
        rgba(73, 69, 59, 0.72);

    border-radius: 8px;

    background: #fff;

    box-shadow:
        0 6px 16px
        rgba(0, 0, 0, 0.30);
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1150px) {

    #opponentZoos {
        display: none;
    }

    #headerActions {
        transform:
            translateX(-50%)
            scale(0.85);

        transform-origin:
            top center;
    }

}

/* PROGRESSION TRACKER */
#progressTracker { position: absolute; left: 245px; top: 4px; z-index: 5100; width: 405px; font-size: 9px; }
.progress-table { display:grid; grid-template-columns: 115px repeat(5,54px); gap:2px; }
.progress-heading { display:flex; align-items:center; justify-content:center; height:18px; border-radius:3px; background:#deddd5; font-size:9px; font-weight:800; }
.progress-category-heading { justify-content:flex-start; padding-left:6px; }
.progress-category { display:flex; align-items:center; height:17px; padding:1px 6px; border-radius:3px; color:#fff; font-size:9px; font-weight:800; white-space:nowrap; text-shadow:0 1px 2px rgba(0,0,0,.55); }
.progress-check-cell { display:flex; align-items:center; justify-content:center; height:17px; border-radius:3px; background:rgba(255,255,255,.5); }
.progress-checkbox { display:flex; width:13px; height:13px; align-items:center; justify-content:center; border:1px solid #716f68; border-radius:2px; background:rgba(255,255,255,.9); color:#285c2d; font-size:11px; font-weight:900; }
.progress-checkbox.checked { color:transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.level2-milestone { margin-top:3px; padding:3px 6px; border:1px solid rgba(65,71,60,.25); border-radius:4px; background:rgba(255,255,255,.72); font-size:9px; }


/* ============================================================
   ANIMAL INFORMATION TABS / ZOOTIERLISTE
   ============================================================ */
.animal-info-tabs {
    display:flex;
    gap:6px;
    margin-bottom:10px;
}
.animal-info-tab {
    flex:1 1 0;
    padding:7px 8px;
    border:1px solid rgba(255,255,255,.55);
    border-radius:6px;
    background:rgba(255,255,255,.16);
    color:#fff;
    font-size:11px;
    font-weight:800;
    cursor:pointer;
    text-shadow:0 1px 2px rgba(0,0,0,.45);
}
.animal-info-tab.active { background:rgba(255,255,255,.38); }
#ztlPreviewPane { display:flex; flex:1 1 auto; min-height:0; flex-direction:column; }
#ztlPreviewPane[hidden] { display:none; }
#ztlPreviewStatus { margin:9px 0 7px; font-size:10px; font-weight:800; opacity:.9; }
#ztlPreviewText {
    flex:1 1 auto;
    min-height:0;
    overflow:auto;
    padding:10px 12px;
    border-radius:7px;
    background:rgba(255,255,255,.90);
    color:#242424;
    text-shadow:none;
    user-select:text;
    font-size:12px;
    line-height:1.4;
}
#ztlPreviewLink { flex:0 0 auto; color:#fff; font-size:11px; font-weight:800; text-shadow:0 1px 2px rgba(0,0,0,.55); }
.ztl-total { margin-bottom:10px; padding:9px; border-radius:6px; background:rgba(0,0,0,.07); }
.ztl-total span { display:block; margin-top:3px; font-size:10px; opacity:.72; }
.ztl-record { display:grid; gap:2px; padding:8px 4px; border-top:1px solid rgba(0,0,0,.13); color:#242424; text-decoration:none; }
.ztl-record:hover { background:rgba(0,0,0,.05); }
.ztl-record em { font-size:11px; }
.ztl-record span { font-size:10px; opacity:.76; }
#hoverPreview.super-zoom #ztlPreviewText { font-size:15px; line-height:1.5; }
#hoverPreview.super-zoom #ztlPreviewStatus { font-size:12px; }
#hoverPreview.super-zoom .animal-info-tab { font-size:13px; }

/* ============================================================
   GAME OPTIONS
   ============================================================ */
.game-options-button {
    display:block;
    margin-top:8px;
    padding:6px 10px;
    border:1px solid #aaa69b;
    border-radius:6px;
    background:#fff;
    font-weight:700;
    cursor:pointer;
}
.game-options-button:hover { background:#f7f3e8; }
.game-options-overlay {
    display:none;
    position:fixed;
    inset:0;
    z-index:30000;
    align-items:center;
    justify-content:center;
    background:rgba(30,28,24,.48);
}
.game-options-overlay.visible { display:flex; }
.game-options-modal {
    width:min(520px,calc(100vw - 40px));
    max-height:calc(100vh - 50px);
    overflow:auto;
    padding:22px;
    border:2px solid #aaa69b;
    border-radius:12px;
    background:#f4f1e9;
    box-shadow:0 14px 45px rgba(0,0,0,.3);
}
.game-options-modal h2 { margin:0 0 8px; }
.category-option-list { display:grid; grid-template-columns:1fr 1fr; gap:7px 12px; margin:18px 0; }
.category-option { display:flex; align-items:center; gap:8px; padding:7px; border-radius:6px; background:rgba(255,255,255,.65); cursor:pointer; }
.category-option-colour { width:16px; height:16px; border-radius:3px; border:1px solid rgba(0,0,0,.25); }
.options-warning { padding:10px; border-radius:6px; background:#fff0bd; font-size:13px; font-weight:700; }
.options-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }
.options-actions button { padding:8px 12px; cursor:pointer; }

/* ============================================================
   OPPONENT TRADING
   ============================================================ */
.trade-offer { cursor:default; }
.trade-offer.trade-filled { opacity:1; background:#fff; padding:0; overflow:visible; }
.trade-offer > span { pointer-events:none; }
.trade-card {
    width:100px !important;
    height:144px !important;
    transform:none !important;
    border-radius:7px !important;
}
.incoming-trade-card { cursor:grab; }
.opponent-name.wants-trade {
    cursor:pointer;
    box-shadow:0 0 0 2px rgba(255,211,35,.75),0 0 10px 4px rgba(255,211,35,.48);
}
.opponent-name.selected-trade {
    background:#ffe477;
    border-color:#b99a1f;
    box-shadow:0 0 0 3px rgba(255,211,35,.9),0 0 15px 6px rgba(255,211,35,.6);
}


/* ============================================================
   V18 — OPPONENT TRADE AREA / EXPANDING OPPONENT LIST
   ============================================================ */
.opponent-trade-area {
    /* Same vertical action row as Draw/Exchange. JavaScript positions this
       pair in the free horizontal space between the right-most Exchange card
       and the opponent-zoo names. The element itself lives directly under
       <body>, outside transformed #headerActions. */
    position:fixed;
    /* Exact left/top are calculated from the live Exchange and opponent
       rectangles in JavaScript. */
    left:auto;
    right:auto;
    top:45px;
    z-index:6500;
    display:flex;
    visibility:visible;
    opacity:1;
    pointer-events:auto;
    gap:10px;
    align-items:flex-start;
}
.opponent-trade-area .trade-offer {
    width:100px;
    height:144px;
    flex:0 0 100px;
    display:flex;
    visibility:visible;
    pointer-events:auto;
}
#opponentZoos .opponent-name {
    min-height:27px;
    margin-bottom:4px;
}


/* ============================================================
   V21 — AUTONOMOUS OPPONENT OFFERS
   ============================================================ */
.decline-opponent-offer {
    position:absolute;
    top:150px;
    left:110px;
    width:100px;
    min-height:27px;
    padding:4px 6px;
    border:1px solid #9d2d2d;
    border-radius:5px;
    background:#fff4f4;
    font-size:10px;
    font-weight:700;
    cursor:pointer;
}
.decline-opponent-offer:hover { background:#ffe2e2; }


/* ============================================================
   V26 — LARGE HEADER-FITTING TRADE CARDS
   ============================================================ */
.opponent-trade-area {
    gap: var(--trade-card-gap, 12px) !important;
}
.opponent-trade-area .trade-offer {
    width: var(--trade-card-width, 100px) !important;
    height: var(--trade-card-height, 144px) !important;
    flex: 0 0 var(--trade-card-width, 100px) !important;
}
.opponent-trade-area .trade-card {
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important;
}
.opponent-trade-area .decline-opponent-offer {
    left: calc(var(--trade-card-width, 100px) + var(--trade-card-gap, 12px));
    top: calc(var(--trade-card-height, 144px) + 6px);
    width: var(--trade-card-width, 100px);
}


/* ============================================================
   V27 — OPPONENT TRADE VALIDATION + PREFERENCE BARS
   ============================================================ */
.trade-offer.trade-locked .incoming-trade-card {
    cursor: not-allowed !important;
    filter: grayscale(0.55) brightness(0.82);
    opacity: 0.72;
}
.opponent-name {
    position: relative;
    padding-bottom: 8px !important;
}
.opponent-preference-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    display: flex;
    overflow: hidden;
    border-radius: 0 0 4px 4px;
    pointer-events: none;
}
.opponent-preference-segment {
    flex: 1 1 33.333%;
    height: 100%;
}


/* ===== v28: progression highlighting / independent reward milestones ===== */
.progression-highlight {
    animation: progressionTrackerGlow 2s ease-out forwards !important;
}
@keyframes progressionTrackerGlow {
    0%, 50% {
        filter: drop-shadow(0 0 5px #ffe36a) drop-shadow(0 0 12px #ffd21f);
    }
    100% {
        filter: drop-shadow(0 0 0 rgba(255,210,31,0));
    }
}
.progress-checkbox.checked { cursor: pointer; }
.progress-checkbox.checked.pinned {
    outline: 2px solid #ffd21f;
    outline-offset: 2px;
    box-shadow: 0 0 8px #ffd21f, inset 0 0 0 1px rgba(255,255,255,.35);
}
.progression-milestones {
    display:flex;
    flex-wrap:wrap;
    gap:5px 12px;
    align-items:center;
}
.progress-level-rewards { display:inline-flex; align-items:center; gap:4px; white-space:nowrap; }
.reward-tick {
    min-width:18px; height:18px; padding:0 3px;
    display:inline-flex; align-items:center; justify-content:center;
    border:1px solid #777; border-radius:3px; background:#f4f2ec;
    font-size:10px; font-weight:800;
}
.reward-tick.earned { background:#ffe36a; border-color:#b18a00; }

#exchange1, #exchange2, #result { position:relative; }
#exchange1::before, #exchange2::before, #result::before {
    content: attr(data-box-label);
    position:absolute;
    left:50%;
    top:-17px;
    transform:translateX(-50%);
    font-size:10px;
    line-height:1;
    font-weight:900;
    letter-spacing:.7px;
    color:#4f4c45;
    white-space:nowrap;
    pointer-events:none;
}


/* ===== v29: action-box spacing and configurable game options ===== */
/* Room for the EXCHANGE / UPGRADE captions introduced in v28. */
#drawCard,
#exchange1,
#exchange2,
#result {
    transform: translateY(15px);
}

/* Do not show the milestone counters below the progression tracker. */
.progression-milestones {
    display: none !important;
}

.advanced-game-rules {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,.16);
    display: grid;
    gap: 9px;
}
.advanced-options-title {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .8px;
}
.advanced-game-rules label {
    display: grid;
    grid-template-columns: 1fr 105px;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 700;
}
.advanced-game-rules input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}
.advanced-options-note {
    font-size: 10px;
    opacity: .68;
}
/* ============================================================
   V32 — PHONE ACTION HUD
   Keep the zoo world unchanged; only reorganise the fixed header.
   ============================================================ */
@media (max-width: 700px) {
    #actionMenu {
        height: 300px;
        overflow: visible;
    }

    #playerZooName {
        left: 54px;
        right: 8px;
        top: 6px;
        width: auto;
        min-height: 32px;
        transform: none;
        font-size: 18px;
        line-height: 26px;
        text-align: left;
    }
    .zoo-name-editor { justify-content: flex-start; }
    .zoo-name-text { max-width: calc(100vw - 105px); }
    .zoo-name-input { width: min(230px, calc(100vw - 120px)); font-size: 16px; }
    .zoo-name-edit-button { width: 30px; height: 30px; }

    #headerLeft { left: 6px; top: 6px; }
    .header-small { padding: 5px 7px; font-size: 11px; }

    #progressTracker { display: none !important; }

    #headerActions {
        left: 50%;
        top: 48px;
        width: auto;
        transform: translateX(-50%) !important;
    }
    .exchange-controls { gap: 7px; }

    /* The two trade boxes are moved to their own row by JS already; hide the
       original placeholders from the action flex if they momentarily exist. */
    #headerActions #outgoingOffer,
    #headerActions #ingoingOffer { display: none !important; }

    .action-card,
    .action-slot,
    .exchange-result {
        width: 64px;
        height: 92.16px;
        border-radius: 6px;
    }
    .exchange-card,
    .result-card {
        width: 64px !important;
        height: 92.16px !important;
    }
    #drawCard,
    #exchange1,
    #exchange2,
    #result { transform: translateY(12px); }
    #exchange1::before,
    #exchange2::before,
    #result::before { top: -14px; font-size: 8px; }

    /* Dedicated second action row: outgoing/incoming trading. */
    .opponent-trade-area {
        position: fixed !important;
        left: 50% !important;
        right: auto !important;
        top: 165px !important;
        transform: translateX(-50%);
        width: auto;
        height: 92px;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        gap: 8px !important;
        z-index: 6500;
    }
    .opponent-trade-area .trade-offer {
        width: 64px !important;
        height: 92.16px !important;
        flex: 0 0 64px !important;
        font-size: 8px;
        border-radius: 6px;
    }
    .opponent-trade-area .trade-card {
        width: 100% !important;
        height: 100% !important;
    }
    .opponent-trade-area .decline-opponent-offer {
        left: 72px !important;
        top: 96px !important;
        width: 64px !important;
        min-height: 22px;
        padding: 2px 3px;
        font-size: 8px;
    }

    /* Opponents become a compact horizontal strip at the bottom of the HUD. */
    #opponentZoos {
        display: flex !important;
        position: absolute;
        left: 6px;
        right: 6px;
        top: 264px;
        width: auto;
        gap: 4px;
        align-items: stretch;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .opponent-title { display: none; }
    #opponentZoos .opponent-name {
        flex: 0 0 auto;
        min-width: 92px;
        min-height: 27px;
        margin: 0;
        padding: 5px 7px 8px !important;
        font-size: 10px;
        text-align: center;
        white-space: nowrap;
    }

    #zooBoard { top: 300px; }

    /* Hand remains usable without covering most of a phone screen. */
    #hand { bottom: 8px; }
    #hand .animal-card { width: 150px; height: 216px; }

    /* Desktop hover panel is too large for phones; keep its information card
       inside the available screen if touch interaction opens it. */
    #hoverPreview {
        left: 8px;
        bottom: 8px;
        width: min(270px, calc(100vw - 16px));
        height: min(388.8px, calc(100% - 16px));
    }
    #hoverPreview.super-zoom {
        width: calc(100vw - 16px);
        height: min(560px, calc(100% - 16px));
    }
}

@media (max-width: 700px) and (orientation: landscape) {
    #actionMenu { height: 190px; }
    #headerActions { top: 43px; left: 35%; }
    .opponent-trade-area { top: 55px !important; left: 72% !important; }
    #opponentZoos { top: 157px; }
    #zooBoard { top: 190px; }
}

/* ============================================================
   V33 — OPTIONS/TURN ORDER + MOBILE TAP PREVIEW
   ============================================================ */

/* Game Options sits above the turn counter on desktop and mobile. */
#headerLeft {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

#headerLeft .game-options-button {
    margin-top: 0;
    order: 1;
}

#headerLeft #turnOrder {
    order: 2;
}

@media (max-width: 700px) {
    /* Keep the two left-header controls narrow so they do not run into the
       zoo name or other phone-HUD text. */
    #headerLeft {
        left: 5px;
        top: 5px;
        width: 58px;
        gap: 4px;
        align-items: stretch;
    }

    #headerLeft .game-options-button {
        width: 58px;
        min-width: 0;
        margin: 0;
        padding: 4px 3px;
        font-size: 9px;
        line-height: 1.05;
        white-space: normal;
    }

    #headerLeft #turnOrder {
        width: 58px;
        min-width: 0;
        padding: 4px 3px;
        font-size: 9px;
        line-height: 1.05;
        text-align: center;
        white-space: normal;
    }

    /* Leave a little more room for the narrow two-button column. */
    #playerZooName {
        left: 70px;
    }

    /* On phones a tap on a zoo animal opens this existing desktop preview.
       Keep the same 1000:1440 card ratio while sizing it for a phone. */
    #hoverPreview {
        left: 8px;
        bottom: 8px;
        width: min(210px, 52vw);
        height: auto;
        aspect-ratio: 1000 / 1440;
        max-height: calc(100% - 16px);
        transform-origin: left bottom;
    }

    #hoverPreview.super-zoom {
        width: min(300px, calc(100vw - 16px));
        height: auto;
        aspect-ratio: 1000 / 1440;
        max-height: calc(100% - 16px);
    }
}


/* ============================================================
   V35 — MOBILE TOP BAR + SMOOTH TOUCH ZOOM SUPPORT
   ============================================================ */
.advanced-game-rules select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    padding: 6px 7px;
}

@media (max-width: 700px) {
    /* One compact top line: Turn left, zoo name centred, Options right. */
    #headerLeft {
        position: absolute;
        left: 0;
        right: 0;
        top: 5px;
        width: 100%;
        height: 30px;
        display: block;
        pointer-events: none;
        z-index: 7200;
    }

    #headerLeft #turnOrder {
        position: absolute;
        left: 5px;
        top: 0;
        width: 48px;
        min-width: 48px;
        box-sizing: border-box;
        padding: 4px 2px;
        font-size: 8px;
        line-height: 1.05;
        text-align: center;
        white-space: nowrap;
        pointer-events: auto;
    }

    #headerLeft .game-options-button {
        position: absolute;
        right: 5px;
        top: 0;
        width: 48px;
        min-width: 48px;
        box-sizing: border-box;
        margin: 0;
        padding: 4px 2px;
        font-size: 8px;
        line-height: 1.05;
        white-space: normal;
        pointer-events: auto;
    }

    #playerZooName {
        left: 50%;
        right: auto;
        top: 5px;
        width: calc(100vw - 116px);
        min-height: 28px;
        transform: translateX(-50%);
        font-size: 16px;
        line-height: 24px;
        text-align: center;
        z-index: 7100;
    }
    #playerZooName .zoo-name-editor { justify-content: center; }
    #playerZooName .zoo-name-text { max-width: calc(100vw - 150px); }
    #playerZooName .zoo-name-input { width: min(190px, calc(100vw - 155px)); }

    /* We implement the gesture ourselves; stop browser page gestures from
       competing with zoo panning/pinch zoom. */
    #zooBoard { touch-action: none; }
}

/* ============================================================
   V39 — MOBILE PREVIEW / PINCH / BOTTOM TRADE HUD
   ============================================================ */

@media (max-width: 700px) {
    /*
       Phone preview state machine:
       1. card tap = normal bottom-left preview
       2. preview tap = larger card
       3. another tap = Wikipedia/info back
       Desktop hover behaviour is unchanged.
    */
    #hoverPreview {
        left: 8px !important;
        right: auto !important;
        bottom: 8px !important;
        top: auto !important;
        width: min(190px, 46vw) !important;
        height: auto !important;
        aspect-ratio: 1000 / 1440;
        transform-origin: left bottom !important;
    }

    #hoverPreview.super-zoom {
        width: min(300px, calc(100vw - 16px)) !important;
        height: auto !important;
        aspect-ratio: 1000 / 1440;
    }

    /*
       The browser must never convert a one-finger drag into page zoom.
       JavaScript only changes state.zoom while exactly TWO touch pointers
       are registered. A single finger is reserved for dragging/panning.
    */
    #zooBoard,
    #zooCanvas,
    .enclosure,
    .animal-card {
        touch-action: none !important;
    }

    /*
       Trade controls live at the bottom on phones, entirely outside the top
       action header. Cards stay at the source 1000:1440 ratio and use only
       the space they need.
    */
    #opponentTradeArea {
        position: fixed !important;
        left: 50% !important;
        right: auto !important;
        top: auto !important;
        bottom: 62px !important;
        transform: translateX(-50%) !important;
        width: auto !important;
        max-width: calc(100vw - 16px) !important;
        min-height: 78px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: flex-end !important;
        gap: 10px !important;
        z-index: 7600 !important;
        opacity: 1 !important;
        transition: opacity .35s ease !important;
        --trade-card-width: 54px !important;
        --trade-card-height: 77.76px !important;
        --trade-card-gap: 10px !important;
    }

    #opponentTradeArea.trade-hud-idle {
        opacity: .30 !important;
    }

    #opponentTradeArea .trade-offer {
        width: 54px !important;
        height: 77.76px !important;
        flex: 0 0 54px !important;
    }

    #opponentTradeArea .trade-card {
        width: 54px !important;
        height: 77.76px !important;
    }

    /*
       In Real Zoo mode only offering zoos are displayed. With the hard
       three-zoo offer cap, these form one clean row beneath the cards.
    */
    #opponentZoos {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: 5px !important;
        width: auto !important;
        height: 50px !important;
        max-height: 50px !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: flex-start !important;
        gap: 5px !important;
        overflow: hidden !important;
        z-index: 7550 !important;
        opacity: 1 !important;
        transition: opacity .35s ease !important;
        pointer-events: auto !important;
    }

    #opponentZoos.trade-hud-idle {
        opacity: .30 !important;
    }

    #opponentZoos .opponent-name {
        box-sizing: border-box !important;
        flex: 1 1 0 !important;
        width: auto !important;
        max-width: calc((100vw - 26px) / 3) !important;
        min-width: 0 !important;
        min-height: 42px !important;
        max-height: 46px !important;
        margin: 0 !important;
        padding: 4px 3px 8px !important;
        overflow: hidden !important;
        font-size: 8px !important;
        line-height: 1.05 !important;
        text-align: center !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }

    /* Do not reserve the old mobile top-header space for trading. */
    #headerActions #outgoingOffer,
    #headerActions #ingoingOffer {
        display: none !important;
    }
}


/* ============================================================
   V40 — TRADE-ELIGIBLE BLUE CARD GLOW
   ============================================================ */
.animal-card.trade-eligible-glow {
    filter:
        drop-shadow(0 0 4px rgba(65, 170, 255, .98))
        drop-shadow(0 0 9px rgba(65, 170, 255, .88))
        drop-shadow(0 0 15px rgba(65, 170, 255, .65)) !important;
}

@media (max-width: 700px) {
    .animal-card.trade-eligible-glow {
        filter:
            drop-shadow(0 0 4px rgba(65, 170, 255, 1))
            drop-shadow(0 0 10px rgba(65, 170, 255, .95))
            drop-shadow(0 0 16px rgba(65, 170, 255, .72)) !important;
    }
}

/* ============================================================
   V44 — BLUE TRADE GLOW FADE
   ============================================================ */
.animal-card.trade-eligible-glow {
    transition: filter 1s ease-out;
}

.animal-card.trade-eligible-glow.trade-eligible-glow-fading {
    filter:
        drop-shadow(0 0 0 rgba(65, 170, 255, 0))
        drop-shadow(0 0 0 rgba(65, 170, 255, 0))
        drop-shadow(0 0 0 rgba(65, 170, 255, 0)) !important;
}


/* ============================================================
   V45 — SAVE / LOAD + TURN HISTORY
   ============================================================ */

#headerLeft {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
}

/* Save/Load is the new top control. Options and turn counter sit beneath it. */
#headerLeft .save-load-button {
    order: 1;
}
#headerLeft .game-options-button {
    order: 2;
}
#headerLeft #turnOrder {
    order: 3;
}

.save-load-button {
    border: 1px solid rgba(70, 58, 39, 0.45);
    background: #fffdf6;
    color: #30291f;
    border-radius: 7px;
    padding: 7px 11px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 2px 7px rgba(0,0,0,0.12);
}
.save-load-button:hover {
    background: #f7f3e8;
}

.save-load-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: rgba(18, 17, 14, 0.62);
}
.save-load-overlay.visible {
    display: flex;
}
.save-load-modal {
    width: min(760px, 94vw);
    max-height: min(760px, 88vh);
    overflow: auto;
    background: #fffdf7;
    color: #29241d;
    border: 2px solid rgba(75, 62, 42, 0.45);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 70px rgba(0,0,0,0.38);
}
.save-load-modal h2 {
    margin: 0 0 6px;
}
.save-load-modal > p {
    margin: 0 0 16px;
    opacity: 0.76;
}
.save-slot-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.save-empty {
    padding: 28px 14px;
    text-align: center;
    border: 1px dashed rgba(60,50,35,0.35);
    border-radius: 8px;
    opacity: 0.7;
}
.save-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border: 1px solid rgba(70,58,39,0.25);
    border-radius: 9px;
    background: rgba(255,255,255,0.7);
}
.save-slot-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.save-slot-info strong {
    font-size: 16px;
}
.save-slot-zoo {
    font-weight: 700;
}
.save-slot-meta {
    font-size: 12px;
    opacity: 0.68;
}
.save-slot-actions,
.save-load-footer,
.turn-history-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}
.save-slot-actions button,
.save-load-footer button,
.turn-history-actions button {
    border: 1px solid rgba(70,58,39,0.35);
    border-radius: 6px;
    background: #fff;
    padding: 7px 10px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.save-slot-actions button:hover,
.save-load-footer button:hover,
.turn-history-actions button:hover {
    background: #f3eee2;
}
.save-load-footer {
    justify-content: flex-end;
    margin-top: 16px;
}

.turn-history-trigger {
    cursor: pointer;
    user-select: none;
}
.turn-history-trigger:hover {
    text-decoration: underline;
}
.turn-history-panel {
    position: fixed;
    z-index: 11500;
    left: 18px;
    top: 138px;
    width: min(390px, calc(100vw - 36px));
    display: none;
    padding: 14px;
    border: 2px solid rgba(68,58,42,0.42);
    border-radius: 10px;
    background: rgba(255,253,247,0.97);
    color: #29241d;
    box-shadow: 0 12px 35px rgba(0,0,0,0.28);
}
.turn-history-panel.visible {
    display: block;
}
.turn-history-title {
    font-weight: 900;
    font-size: 17px;
}
.turn-history-label {
    margin-top: 4px;
    font-weight: 800;
}
#turnHistorySlider {
    width: 100%;
    margin: 14px 0 12px;
}
.turn-history-note {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.35;
    opacity: 0.72;
}

/* Historical turns are museum mode: board pan/zoom remains active, but
   animals/enclosures cannot be dragged and gameplay controls cannot mutate. */
body.history-viewing #headerActions,
body.history-viewing #hand,
body.history-viewing #exchangeControls,
body.history-viewing #opponentTradeArea,
body.history-viewing #gameOptionsButton,
body.history-viewing #saveLoadButton {
    pointer-events: none !important;
    opacity: 0.42;
}
/* Animal cards deliberately KEEP pointer events in history mode so their
   normal preview / zoom / flip-to-info functionality remains available.
   Enclosures stay locked. */
body.history-viewing #zooCanvas .enclosure {
    pointer-events: none !important;
}
body.history-viewing #turnOrder {
    pointer-events: auto !important;
    opacity: 1 !important;
}

@media (max-width: 700px) {
    #headerLeft {
        gap: 4px;
    }
    #headerLeft .save-load-button,
    #headerLeft .game-options-button {
        font-size: 10px;
        padding: 5px 7px;
    }
    .save-slot {
        align-items: stretch;
        flex-direction: column;
    }
    .save-slot-actions button {
        flex: 1 1 auto;
    }
    .turn-history-panel {
        left: 10px;
        top: 110px;
        width: calc(100vw - 20px);
    }
}

/* ============================================================
   V47 — NO YELLOW UPGRADE GLOW IN TURN-HISTORY VIEW
   ============================================================ */

/* Historical snapshots are inspection-only. Upgrade-ready/selected yellow
   effects belong exclusively to the live turn. */
body.history-viewing #zooCanvas .animal-card {
    filter: none !important;
    box-shadow: none !important;
}

/* ============================================================
   V48 — NO BLUE TRADE GLOW IN TURN-HISTORY VIEW
   ============================================================ */
body.history-viewing #zooCanvas .animal-card.trade-eligible-glow,
body.history-viewing #zooCanvas .animal-card.trade-eligible-glow-fading {
    filter: none !important;
    box-shadow: none !important;
}

/* ============================================================
   V49 — LOCK ENCLOSURES IN TURN-HISTORY VIEW
   ============================================================ */
body.history-viewing #zooCanvas .enclosure,
body.history-viewing #zooCanvas .enclosure * {
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-drag: none !important;
}



/* ============================================================
   V50 — HISTORICAL ANIMAL PREVIEW / ZOOM RESTORED
   ============================================================ */
body.history-viewing #zooCanvas .animal-card {
    pointer-events: auto !important;
    cursor: zoom-in;
}
