/* =========================================================
   ROOT
   ========================================================= */

:root {
    --bg-dark: #090a0c;
    --panel-dark: #121316;
    --panel-light: #1b1c20;

    --border-dark: #3c3025;
    --border-light: #80613c;

    --ember: #e27628;
    --ember-light: #ffad45;

    --gold: #e7bd5b;
    --text: #e7e0d4;
    --muted: #918a80;

    --hp: #a92222;
    --hp-light: #dc3434;

    --xp: #b66a22;
    --xp-light: #ef9a35;
}


* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;

    background: #08090a;

    color: var(--text);

    font-family:
        "Segoe UI",
        Arial,
        sans-serif;
}


button,
input {
    font: inherit;
}


button {
    color: var(--text);

    background:
        linear-gradient(
            #292521,
            #171513
        );

    border:
        1px solid
        #6d5437;

    border-radius: 3px;

    padding: 9px 14px;

    cursor: pointer;

    transition:
        border-color 0.15s,
        background 0.15s,
        box-shadow 0.15s;
}


button:hover {
    border-color:
        var(--ember);

    box-shadow:
        0 0 8px
        rgba(
            226,
            118,
            40,
            0.3
        );
}


button:disabled {
    opacity: 0.35;

    cursor: default;
}


input {
    width: 100%;

    padding: 11px;

    margin-bottom: 10px;

    color: white;

    background: #0c0d0f;

    border:
        1px solid #45392c;

    border-radius: 3px;

    outline: none;
}


input:focus {
    border-color:
        var(--ember);
}


.hidden {
    display: none !important;
}


/* =========================================================
   LOGIN / CHARACTER SCREENS
   ========================================================= */

.screen {
    position: fixed;

    inset: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    background:
        radial-gradient(
            circle at center,
            #241711,
            #08090a 65%
        );
}


.panel {
    width: 380px;

    padding: 28px;

    background:
        linear-gradient(
            145deg,
            rgba(30, 27, 24, 0.98),
            rgba(10, 11, 13, 0.98)
        );

    border:
        1px solid
        var(--border-light);

    box-shadow:
        0 0 0 3px #080808,
        0 0 0 4px #49351f,
        0 18px 50px rgba(0, 0, 0, 0.8);
}


.login-panel {
    text-align: center;
}


.game-logo {
    font-size: 38px;

    font-weight: 900;

    letter-spacing: 5px;

    color:
        var(--ember-light);

    text-shadow:
        0 0 15px
        rgba(
            226,
            118,
            40,
            0.6
        );
}


.game-subtitle {
    margin-top: -3px;
    margin-bottom: 25px;

    font-size: 11px;

    letter-spacing: 8px;

    color: #817365;
}


.panel h2 {
    font-size: 16px;

    letter-spacing: 2px;

    color: #c3b7a6;
}


.button-row {
    display: flex;

    gap: 10px;
}


.button-row button {
    flex: 1;
}


.message {
    min-height: 22px;

    margin-top: 12px;

    color: #ffbd63;

    text-align: center;
}


.connection-status {
    margin-top: 10px;

    color: #777;

    font-size: 11px;
}


.character-panel {
    width: 460px;
}


#character-list {
    display: flex;

    flex-direction: column;

    gap: 8px;

    max-height: 300px;

    overflow-y: auto;

    margin-top: 16px;
}


.character-entry {
    display: flex;

    align-items: center;

    gap: 10px;

    padding: 11px;

    background: #161719;

    border:
        1px solid #3c352d;
}


.character-info {
    flex: 1;
}


.character-name {
    color: #f1e4cf;

    font-weight: bold;
}


.character-details {
    margin-top: 4px;

    color: #8e867d;

    font-size: 11px;
}


.divider {
    height: 1px;

    margin: 22px 0;

    background:
        linear-gradient(
            90deg,
            transparent,
            #785433,
            transparent
        );
}


.section-title {
    margin-bottom: 10px;

    color:
        var(--gold);

    font-size: 11px;

    letter-spacing: 2px;
}


/* =========================================================
   GAME
   ========================================================= */

#game-screen {
    position: fixed;

    inset: 0;

    overflow: hidden;
}


#game {
    display: block;

    width: 100%;
    height: 100%;

    background: #20252b;
}


/* =========================================================
   PLAYER HUD
   ========================================================= */

.player-hud {
    position: fixed;

    left: 18px;
    top: 18px;

    width: 355px;

    padding:
        10px 13px 9px;

    pointer-events: none;

    background:
        linear-gradient(
            110deg,
            rgba(13, 14, 16, 0.96),
            rgba(32, 26, 21, 0.93)
        );

    border:
        1px solid
        #715134;

    box-shadow:
        0 0 0 2px
        rgba(0, 0, 0, 0.85),
        0 5px 18px
        rgba(0, 0, 0, 0.6);

    clip-path:
        polygon(
            0 0,
            calc(100% - 13px) 0,
            100% 13px,
            100% 100%,
            13px 100%,
            0 calc(100% - 13px)
        );
}


.hud-top {
    display: flex;

    gap: 10px;

    align-items: center;
}


.portrait-frame {
    width: 65px;
    height: 65px;

    flex-shrink: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    background:
        linear-gradient(
            135deg,
            #725133,
            #271c13
        );

    border:
        1px solid
        #aa7845;

    transform:
        rotate(45deg);

    box-shadow:
        inset 0 0 12px black;
}


.portrait-inner {
    width: 48px;
    height: 48px;

    display: flex;

    align-items: center;
    justify-content: center;

    background:
        radial-gradient(
            circle,
            #37251a,
            #0c0c0d
        );

    color:
        var(--ember-light);

    font-size: 27px;

    transform:
        rotate(-45deg);
}


.hud-character {
    flex: 1;
}


.hud-name-row {
    display: flex;

    justify-content:
        space-between;

    align-items: center;

    margin-bottom: 5px;
}


#hud-name {
    overflow: hidden;

    color: #f3e6d3;

    font-size: 15px;

    font-weight: 700;

    text-overflow: ellipsis;

    white-space: nowrap;
}


.hud-level {
    color:
        var(--gold);

    font-size: 11px;

    font-weight: bold;
}


/* =========================================================
   STAT BARS
   ========================================================= */

.stat-bar {
    position: relative;

    height: 17px;

    margin-bottom: 5px;

    overflow: hidden;

    background: #080809;

    border:
        1px solid #40362d;

    box-shadow:
        inset 0 0 5px black;
}


.stat-fill {
    height: 100%;

    width: 0%;

    transition:
        width 0.18s ease-out;
}


.hp-bar .stat-fill {
    background:
        linear-gradient(
            90deg,
            #641313,
            var(--hp),
            var(--hp-light)
        );

    box-shadow:
        inset 0 1px
        rgba(255, 255, 255, 0.15);
}


.xp-bar {
    height: 11px;
}


.xp-bar .stat-fill {
    background:
        linear-gradient(
            90deg,
            #713b13,
            var(--xp),
            var(--xp-light)
        );
}


.stat-text {
    position: absolute;

    inset: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    color: white;

    font-size: 10px;

    font-weight: 700;

    text-shadow:
        1px 1px 2px black;
}


.stat-text.small {
    font-size: 8px;
}


/* =========================================================
   HUD STATS
   ========================================================= */

.hud-stats {
    display: grid;

    grid-template-columns:
        1fr 1fr 1fr;

    margin-top: 7px;

    border-top:
        1px solid #342a21;

    padding-top: 7px;
}


.hud-stat {
    text-align: center;

    color: #c9c0b4;

    font-size: 12px;
}


.hud-stat + .hud-stat {
    border-left:
        1px solid #352c24;
}


.hud-icon {
    margin-right: 4px;

    color: #bbb;
}


.coin-icon {
    margin-right: 4px;

    color:
        var(--gold);
}


.hud-stat.gold {
    color:
        var(--gold);
}


/* =========================================================
   INTERACTION PROMPT
   ========================================================= */

.interaction-prompt {
    position: fixed;

    left: 50%;
    bottom: 115px;

    transform:
        translateX(-50%);

    display: flex;

    align-items: center;

    gap: 10px;

    padding:
        8px 14px;

    pointer-events: none;

    background:
        rgba(
            8,
            9,
            10,
            0.92
        );

    border:
        1px solid
        #705236;

    box-shadow:
        0 5px 20px
        rgba(0, 0, 0, 0.6);
}


.key-box {
    width: 35px;
    height: 35px;

    display: flex;

    align-items: center;
    justify-content: center;

    color:
        var(--ember-light);

    font-weight: bold;

    background: #181410;

    border:
        1px solid
        #a36b39;

    box-shadow:
        inset 0 0 8px black;
}


.interaction-action {
    color: #8d8277;

    font-size: 8px;

    letter-spacing: 2px;
}


#interaction-name {
    color: white;

    font-size: 12px;

    font-weight: 600;
}


/* =========================================================
   ACTION BAR
   ========================================================= */

.action-bar {
    position: fixed;

    left: 50%;
    bottom: 20px;

    transform:
        translateX(-50%);

    display: flex;

    gap: 4px;

    padding: 6px;

    background:
        linear-gradient(
            #181715,
            #090a0b
        );

    border:
        1px solid
        #65482e;

    box-shadow:
        0 0 0 2px
        rgba(0, 0, 0, 0.85),
        0 5px 20px
        rgba(0, 0, 0, 0.7);
}


.action-slot {
    position: relative;

    width: 51px;
    height: 51px;

    display: flex;

    align-items: center;
    justify-content: center;

    background:
        radial-gradient(
            circle,
            #25221e,
            #0e0f10
        );

    border:
        1px solid
        #554432;

    box-shadow:
        inset 0 0 8px
        rgba(0, 0, 0, 0.8);
}


.inventory-action {
    cursor: pointer;
}


.inventory-action:hover {
    border-color:
        var(--ember);
}


.action-key {
    position: absolute;

    right: 3px;
    top: 2px;

    color: #93887a;

    font-size: 9px;
}


.action-icon {
    color: #ddd;

    font-size: 23px;
}


.sword-icon {
    color: #c8c8c8;
}


.potion-icon {
    color: #d74444;
}


/* =========================================================
   GAME WINDOWS
   ========================================================= */

.game-window {
    position: fixed;

    left: 50%;
    top: 50%;

    transform:
        translate(-50%, -50%);

    padding: 16px;

    background:
        linear-gradient(
            145deg,
            rgba(27, 25, 22, 0.985),
            rgba(8, 9, 11, 0.99)
        );

    border:
        1px solid
        #775536;

    box-shadow:
        0 0 0 2px #080808,
        0 0 0 3px #38291d,
        0 15px 50px
        rgba(0, 0, 0, 0.9);

    z-index: 50;
}


.window-header {
    display: flex;

    align-items: center;

    justify-content:
        space-between;

    padding-bottom: 10px;

    margin-bottom: 12px;

    border-bottom:
        1px solid #443426;
}


.window-title {
    color:
        var(--ember-light);

    font-size: 18px;

    font-weight: 800;

    letter-spacing: 2px;
}


.window-subtitle {
    margin-top: 2px;

    color: #81766b;

    font-size: 9px;

    letter-spacing: 2px;
}


.window-close {
    width: 34px;
    height: 34px;

    padding: 0;

    color: #c9a57e;

    font-size: 22px;
}


.window-help {
    margin-top: 10px;

    color: #756e67;

    font-size: 10px;

    text-align: center;
}


/* =========================================================
   INVENTORY
   ========================================================= */

.inventory-window {
    width: 520px;
}


.character-stats {
    padding: 7px;

    margin-bottom: 10px;

    color: #c5b8a7;

    background: #101113;

    border:
        1px solid #382f28;

    font-size: 11px;

    text-align: center;
}


.equipment-area {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 9px;

    margin-bottom: 13px;
}


.equipment-slot {
    position: relative;

    min-height: 120px;

    padding: 10px;

    text-align: center;

    background:
        radial-gradient(
            circle at top,
            #24201b,
            #101113
        );

    border:
        1px solid #493c30;
}


.equipment-symbol {
    color: #a99072;

    font-size: 24px;
}


.equipment-label {
    margin-top: 3px;

    color: #766d64;

    font-size: 9px;

    letter-spacing: 2px;
}


.equipment-name {
    min-height: 18px;

    margin-top: 5px;

    color:
        var(--gold);

    font-size: 12px;

    font-weight: bold;
}


.equipment-stats {
    min-height: 16px;

    color: #9b9288;

    font-size: 10px;
}


.small-button {
    margin-top: 5px;

    padding: 4px 8px;

    font-size: 9px;
}


.inventory-section-label {
    margin-bottom: 6px;

    color: #81766a;

    font-size: 9px;

    letter-spacing: 2px;
}


.inventory-grid {
    display: grid;

    grid-template-columns:
        repeat(5, 1fr);

    gap: 6px;
}


.inventory-slot {
    position: relative;

    height: 66px;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 5px;

    color: #cfc6ba;

    font-size: 10px;

    text-align: center;

    cursor: pointer;

    user-select: none;

    background:
        radial-gradient(
            circle,
            #24211d,
            #0e0f10
        );

    border:
        1px solid #44392e;

    box-shadow:
        inset 0 0 7px
        rgba(0, 0, 0, 0.8);
}


.inventory-slot:hover {
    border-color:
        #a36d3b;

    background:
        radial-gradient(
            circle,
            #33281e,
            #111214
        );
}


.inventory-slot.empty {
    color: #3e3d3b;

    cursor: default;
}


.inventory-slot.equipped {
    border:
        1px solid
        var(--gold);

    box-shadow:
        inset 0 0 10px
        rgba(218, 166, 72, 0.2),
        0 0 6px
        rgba(218, 166, 72, 0.2);
}


.inventory-quantity {
    position: absolute;

    right: 4px;
    bottom: 3px;

    padding: 1px 3px;

    color: white;

    background:
        rgba(0, 0, 0, 0.85);

    font-size: 9px;
}


.inventory-message,
.shop-message {
    min-height: 19px;

    margin-top: 9px;

    color: #ffb75d;

    font-size: 11px;

    text-align: center;
}


/* =========================================================
   CONTEXT MENU
   ========================================================= */

.item-menu {
    position: fixed;

    z-index: 100;

    min-width: 135px;

    padding: 5px;

    background: #101113;

    border:
        1px solid #775536;

    box-shadow:
        0 8px 20px
        rgba(0, 0, 0, 0.8);
}


.item-menu button {
    display: block;

    width: 100%;

    margin: 2px 0;

    padding: 7px;

    text-align: left;
}


/* =========================================================
   TOOLTIP
   ========================================================= */

.item-tooltip {
    position: fixed;

    z-index: 120;

    max-width: 230px;

    padding: 9px;

    pointer-events: none;

    color: #ddd;

    background:
        rgba(8, 9, 10, 0.98);

    border:
        1px solid #80603d;

    box-shadow:
        0 5px 15px
        rgba(0, 0, 0, 0.8);

    font-size: 11px;
}


.tooltip-name {
    color:
        var(--gold);

    font-weight: bold;
}


.tooltip-type {
    margin-top: 2px;

    color: #716b65;

    font-size: 9px;

    text-transform: uppercase;
}


.tooltip-stat {
    margin-top: 5px;

    color: #cfc7bd;
}


/* =========================================================
   SHOP
   ========================================================= */

.shop-window {
    width: 450px;
}


.shop-gold {
    padding: 8px;

    margin-bottom: 10px;

    color:
        var(--gold);

    background: #101113;

    border:
        1px solid #44372b;

    text-align: center;

    font-weight: bold;
}


.shop-items {
    max-height: 340px;

    overflow-y: auto;
}


.shop-item {
    display: grid;

    grid-template-columns:
        1fr 75px 70px;

    gap: 8px;

    align-items: center;

    margin-bottom: 6px;

    padding: 10px;

    background:
        linear-gradient(
            90deg,
            #151617,
            #1d1916
        );

    border:
        1px solid #40362d;
}


.shop-item:hover {
    border-color:
        #755437;
}


.shop-item-name {
    color: #eadbc6;

    font-weight: bold;
}


.shop-item-description {
    margin-top: 3px;

    color: #827970;

    font-size: 10px;
}


.shop-item-price {
    color:
        var(--gold);

    font-size: 12px;

    text-align: right;
}


.shop-buy {
    padding: 6px;

    font-size: 10px;
}


/* =========================================================
   CONTROLS / STATUS
   ========================================================= */

#game-info {
    position: fixed;

    left: 15px;
    bottom: 15px;

    padding: 8px 10px;

    pointer-events: none;

    color: #756f68;

    background:
        rgba(5, 6, 7, 0.7);

    border:
        1px solid #2e2b27;

    font-size: 9px;
}


.status {
    position: fixed;

    right: 12px;
    bottom: 10px;

    color: #65615d;

    font-size: 9px;

    pointer-events: none;
}


/* =========================================================
   SMALL SCREENS
   ========================================================= */

@media (max-width: 650px) {

    .player-hud {
        width: 310px;

        transform:
            scale(0.9);

        transform-origin:
            top left;
    }


    .inventory-window,
    .shop-window {
        width:
            calc(100% - 20px);
    }


    .action-slot {
        width: 43px;
        height: 43px;
    }


    .panel {
        width:
            calc(100% - 30px);
    }
}


/* =========================================================
   CHAT
   ========================================================= */

.chat-box {
    position: fixed;
    left: 15px;
    bottom: 82px;
    z-index: 38;
    width: min(390px, calc(100% - 30px));
    pointer-events: auto;
}

.chat-messages {
    height: 150px;
    overflow-y: auto;
    padding: 9px 10px;
    background: rgba(5, 6, 7, 0.78);
    border: 1px solid #3c3025;
    border-bottom: 0;
    font-size: 12px;
    line-height: 1.35;
    scrollbar-width: thin;
}

.chat-message {
    margin: 0 0 4px;
    overflow-wrap: anywhere;
    color: #d5cec3;
}

.chat-name {
    color: var(--ember-light);
    font-weight: 700;
}

.chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 5px;
    padding: 5px;
    background: rgba(8, 9, 10, 0.94);
    border: 1px solid #65482e;
}

.chat-form input {
    min-width: 0;
    margin: 0;
    padding: 8px 9px;
}

.chat-form button {
    min-width: 58px;
    padding: 7px 9px;
    font-size: 10px;
}


.chat-mobile-header,
.mobile-chat-toggle {
    display: none;
}

@media (hover: none), (pointer: coarse) {
    .chat-box {
        display: none;
        left: 8px;
        bottom: 154px;
        width: min(280px, calc(100% - 16px));
        z-index: 70;
    }

    .chat-box.mobile-open {
        display: block;
    }

    .chat-mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 30px;
        padding-left: 9px;
        color: var(--ember-light);
        background: rgba(8, 9, 10, 0.96);
        border: 1px solid #65482e;
        border-bottom: 0;
        font-size: 10px;
        font-weight: 800;
        letter-spacing: 1px;
    }

    .chat-mobile-header button {
        width: 34px;
        height: 29px;
        padding: 0;
        border: 0;
        border-left: 1px solid #65482e;
        font-size: 20px;
    }

    .mobile-chat-toggle {
        display: block;
        position: fixed;
        left: 10px;
        bottom: 154px;
        z-index: 69;
        min-width: 58px;
        min-height: 42px;
        padding: 8px 10px;
        font-size: 10px;
        font-weight: 800;
        letter-spacing: 1px;
        touch-action: manipulation;
    }

    .mobile-chat-toggle.chat-is-open {
        display: none;
    }

    .chat-messages {
        height: 68px;
        padding: 6px 8px;
        font-size: 10px;
        line-height: 1.25;
    }

    .chat-message {
        margin-bottom: 2px;
    }

    .chat-form {
        gap: 3px;
        padding: 4px;
    }

    .chat-form input {
        min-height: 38px;
        padding: 6px 7px;
        font-size: 16px;
    }

    .chat-form button {
        min-width: 48px;
        min-height: 38px;
        padding: 5px 7px;
        font-size: 9px;
    }
}

/* =========================================================
   MOBILE TOUCH CONTROLS
   ========================================================= */

.mobile-controls {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 18px;
    z-index: 35;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.touch-stick {
    position: absolute;
    left: 22px;
    bottom: 0;
    width: 132px;
    height: 132px;
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
    background: rgba(10, 10, 12, 0.55);
    border: 2px solid rgba(226, 118, 40, 0.55);
    box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.75);
}

.touch-stick::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 58px;
    height: 58px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(255, 173, 69, 0.18);
}

.touch-stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 58px;
    height: 58px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(226, 118, 40, 0.88), rgba(73, 47, 29, 0.92));
    border: 2px solid rgba(255, 173, 69, 0.9);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.7);
    pointer-events: none;
}

.mobile-actions {
    position: absolute;
    right: 22px;
    bottom: 0;
    width: 190px;
    height: 145px;
    pointer-events: none;
}

.mobile-actions button {
    position: absolute;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
    font-weight: 800;
    letter-spacing: 1px;
}

.mobile-attack-button {
    right: 0;
    bottom: 0;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    padding: 0;
    color: #fff1df;
    background: radial-gradient(circle, #8b3e1d, #32160e);
    border: 2px solid var(--ember-light);
}

.mobile-small-button {
    width: 64px;
    height: 54px;
    padding: 0;
    border-radius: 12px;
    font-size: 11px;
}

#mobile-interact {
    right: 98px;
    bottom: 10px;
}

#mobile-inventory {
    right: 72px;
    bottom: 75px;
}

@media (hover: none), (pointer: coarse) {
    .mobile-controls {
        display: block;
    }

    #game-info,
    .action-bar {
        display: none;
    }

    .interaction-prompt {
        bottom: 170px;
    }
}

@media (hover: none) and (pointer: coarse) and (max-width: 650px) {
    .player-hud {
        left: 8px;
        top: 8px;
        width: 300px;
        transform: scale(0.78);
        transform-origin: top left;
    }

    .touch-stick {
        left: 14px;
        width: 118px;
        height: 118px;
    }

    .mobile-actions {
        right: 14px;
        transform: scale(0.9);
        transform-origin: bottom right;
    }

    .inventory-window,
    .shop-window {
        max-height: calc(100% - 20px);
        overflow-y: auto;
    }
}

/* ============================================================
   SHOP + INVENTORY TRADING LAYOUT
   ============================================================ */

body.shop-open #inventory-window {
    left: calc(50% - 460px);
    right: auto;
    transform: none;
}

body.shop-open #shop-window {
    left: calc(50% + 20px);
    right: auto;
    transform: none;
}


/* ============================================================
   DESKTOP RESOLUTION SCALING
   Reference layout: 1920 x 1080
   ============================================================ */

/*
   The canvas remains full-screen. The desktop HUD uses one shared
   scale value so its proportions remain consistent across common
   desktop/laptop resolutions.

   Touch/mobile controls keep the dedicated mobile rules below.
*/

:root {
    --desktop-ui-scale: 1;
}

@media (hover: hover) and (pointer: fine) and
       ((max-width: 1700px) or (max-height: 950px)) {
    :root {
        --desktop-ui-scale: 0.88;
    }
}

@media (hover: hover) and (pointer: fine) and
       ((max-width: 1450px) or (max-height: 820px)) {
    :root {
        --desktop-ui-scale: 0.76;
    }
}

@media (hover: hover) and (pointer: fine) and
       ((max-width: 1200px) or (max-height: 700px)) {
    :root {
        --desktop-ui-scale: 0.66;
    }
}

@media (hover: hover) and (pointer: fine) and
       (min-width: 2400px) and (min-height: 1300px) {
    :root {
        --desktop-ui-scale: 1.15;
    }
}

/* Top-left anchored UI */
@media (hover: hover) and (pointer: fine) {
    .player-hud {
        transform: scale(var(--desktop-ui-scale));
        transform-origin: top left;
    }

    /* Bottom-left anchored UI */
    #game-info,
    .chat-box {
        transform: scale(var(--desktop-ui-scale));
        transform-origin: bottom left;
    }

    /* Bottom-right anchored UI */
    .status {
        transform: scale(var(--desktop-ui-scale));
        transform-origin: bottom right;
    }

    /*
       Centered bottom UI already uses translateX(-50%).
       Keep that translation and add the common scale.
    */
    .action-bar {
        transform:
            translateX(-50%)
            scale(var(--desktop-ui-scale));
        transform-origin: bottom center;
    }

    .interaction-prompt {
        transform:
            translateX(-50%)
            scale(var(--desktop-ui-scale));
        transform-origin: bottom center;
    }

    /*
       Normal centered windows keep their existing centering and
       receive the same scale.
    */
    .game-window {
        transform:
            translate(-50%, -50%)
            scale(var(--desktop-ui-scale));
        transform-origin: center;
    }

    /*
       Trading windows are positioned side-by-side by the existing
       shop-open rules. They intentionally use no translate, so only
       apply the shared scale while the shop is open.
    */
    body.shop-open #inventory-window,
    body.shop-open #shop-window {
        transform: scale(var(--desktop-ui-scale));
        transform-origin: top left;
    }

    /*
       Context menus/tooltips use viewport coordinates generated by
       JavaScript. Scaling their contents keeps visual sizing
       consistent without changing their coordinate system.
    */
    .item-menu,
    .item-tooltip {
        transform: scale(var(--desktop-ui-scale));
        transform-origin: top left;
    }
}

/*
   Prevent large windows from disappearing below a short desktop
   viewport. Content scrolls inside the window when necessary.
*/
@media (hover: hover) and (pointer: fine) and (max-height: 800px) {
    .inventory-window,
    .shop-window {
        max-height: calc(100vh - 30px);
        overflow-y: auto;
    }
}

/*
   Touch/mobile uses the existing purpose-built mobile sizing.
   Do not inherit desktop scaling.
*/
@media (hover: none), (pointer: coarse) {
    :root {
        --desktop-ui-scale: 1;
    }
}
