/* Sidehaven game interface. Shared website styles stay on their existing surface. */
body.game.modern-hud {
    --ink: #f3e6c9;
    --muted: #a7bec5;
    --line: #34525b;
    --accent: #79c7cf;
    --gold: #f3c576;
    --hud-base: #07141c;
    --hud-raised: #142f3c;
    --hud-hover: #1c4150;
    --dock-height: 88px;
    font-family: "Segoe UI", Arial, sans-serif;
}

body.game.modern-hud #hud-leftRail,
body.game.modern-hud #hud-rightRail,
body.game.modern-hud #hud-profile,
body.game.modern-hud #hud-buildTools {
    display: none !important;
}

.modern-hud button,
.modern-hud .button {
    color: var(--ink);
    background: #132c38;
    border-color: var(--line);
    border-radius: 7px;
}

.modern-hud button:hover:enabled,
.modern-hud .button:hover,
.modern-hud summary:hover {
    border-color: var(--accent);
    background: var(--hud-hover);
}

.modern-hud button:focus-visible,
.modern-hud summary:focus-visible,
.modern-hud a:focus-visible,
.modern-hud input:focus-visible,
.modern-hud select:focus-visible,
.modern-hud textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modern-hud button.primary {
    color: #10232e;
    background: var(--gold);
    border-color: var(--gold);
    font-weight: 650;
}

.modern-hud button.primary:hover:enabled {
    color: #10232e;
    background: #ffdda0;
    border-color: #ffdda0;
}

.modern-hud button.selected,
.modern-hud button[aria-pressed="true"],
.modern-hud button[aria-current="page"] {
    border-color: #70979e;
    background: #204452;
}

.modern-hud button:disabled {
    opacity: .57;
    cursor: default;
}

.modern-hud .panel {
    color: var(--ink);
    background: rgb(9 28 38 / var(--menu-opacity, .96));
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 14px 32px #0007;
    overflow: hidden;
}

.modern-hud .titlebar {
    min-height: 36px;
    padding: 6px 12px;
    background: rgb(20 47 60 / var(--menu-opacity, .96));
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.modern-hud .titlebar button {
    min-height: 26px;
    min-width: 28px;
}

body.game.modern-hud .floating-window {
    max-width: calc(100vw - 16px);
    min-width: min(280px, calc(100vw - 16px));
    max-height: max(0px, calc(100dvh - var(--dock-height) - 16px));
    min-height: min(180px, max(0px, calc(100dvh - var(--dock-height) - 16px)));
}

.modern-hud .floating-window .window-content {
    padding: 14px;
    overflow: auto;
    overscroll-behavior: contain;
}

.modern-hud .card,
.modern-hud .list-item {
    background: var(--hud-raised);
    border-color: var(--line);
    border-radius: 7px;
}

.modern-hud input,
.modern-hud textarea,
.modern-hud select {
    color: var(--ink);
    background: #071820;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.modern-hud .chat-panel {
    max-width: calc(100vw - 16px);
    max-height: max(0px, calc(100dvh - var(--dock-height) - 16px));
    background: rgb(9 28 38 / var(--chat-opacity, .94));
}

.modern-hud .chat-panel .titlebar {
    height: 32px;
    min-height: 32px;
    padding: 4px 9px;
    font-size: 13px;
    background: rgb(20 47 60 / var(--chat-opacity, .94));
}

.modern-hud .chat-panel .titlebar button {
    min-height: 22px;
}

.modern-hud .chat-content {
    height: calc(100% - 32px);
}

.modern-hud .chat-tabs {
    flex-wrap: wrap;
}

#sidehaven-dock {
    position: fixed;
    inset: auto 0 0;
    z-index: 60;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: clamp(190px, 18vw, 250px) minmax(0, 1fr) 42px;
    align-items: stretch;
    gap: 8px;
    padding: 8px max(10px, env(safe-area-inset-right, 0px))
        max(8px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
    color: var(--ink, #f3e6c9);
    background: rgb(7 20 28 / .98);
    border-top: 1px solid #5d756e;
    box-shadow: 0 -4px 24px #0007;
    pointer-events: auto;
}

#sidehaven-dock[hidden],
#sidehaven-dock [hidden],
#sidehaven-world[hidden],
#hud-pause[hidden] {
    display: none !important;
}

#sidehaven-dock .dock-profile {
    display: flex;
    gap: 9px;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 67px;
    padding: 7px 8px;
    text-align: left;
    background: #102834;
}

.dock-avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 44px;
    overflow: hidden;
    background: #1c4150;
    border: 1px solid #426371;
    border-radius: 7px;
}

.dock-avatar .avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 0;
    border-radius: 0;
}

.dock-avatar .icon {
    width: 25px;
    height: 25px;
}

.dock-identity {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    flex: 1;
    gap: 4px;
    min-width: 0;
}

.dock-name,
.dock-level {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.15;
}

.dock-name { font-size: 14px; }
.dock-level { font-size: 11px; color: var(--muted); }

.dock-wallet {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 10px;
    align-items: center;
    font-size: 11px;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dock-wallet span { display: flex; gap: 3px; align-items: center; }
.dock-wallet .icon { width: 12px; height: 12px; flex: none; }
.dock-wallet .gold { color: var(--gold); }

.dock-xp {
    display: block;
    height: 3px;
    background: #3b5561;
    border-radius: 3px;
    overflow: hidden;
}

.dock-xp i {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
}

.dock-nav {
    display: flex;
    gap: 5px;
    align-items: stretch;
    min-width: 0;
    padding: 3px;
    overflow-x: auto;
    scrollbar-color: #597c86 #132b35;
    scrollbar-width: thin;
    overscroll-behavior-x: contain;
}

#sidehaven-dock .dock-nav button {
    display: flex;
    flex: 1 0 61px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    min-width: 61px;
    min-height: 58px;
    padding: 5px 3px;
    font-size: 11px;
    line-height: 1.14;
    text-align: center;
    white-space: normal;
}

.dock-nav button .icon,
.dock-nav .dock-symbol {
    flex: none;
    width: 21px;
    height: 21px;
}

.dock-nav .dock-symbol {
    color: var(--gold);
    font-size: 19px;
    line-height: 21px;
}

#sidehaven-dock .dock-nav button[aria-pressed="true"],
#sidehaven-dock .dock-nav button[aria-current="page"] {
    color: #fff2d9;
    border-color: var(--gold);
    box-shadow: inset 0 -2px var(--gold);
}

.dock-picked {
    grid-column: 2 / -1;
    min-width: 0;
    margin: 0 3px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dock-options {
    position: relative;
    align-self: center;
    min-width: 0;
}

#sidehaven-dock .dock-options summary {
    display: grid;
    place-items: center;
    width: 42px;
    min-height: 42px;
    padding: 0;
    list-style: none;
    cursor: pointer;
    background: #132c38;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.dock-options summary::-webkit-details-marker { display: none; }

.dock-options-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    display: grid;
    gap: 5px;
    width: min(208px, calc(100vw - 20px));
    max-height: max(0px, calc(100dvh - var(--dock-height) - 20px));
    padding: 8px;
    overflow: auto;
    background: var(--hud-base);
    border: 1px solid var(--line);
    border-radius: 9px;
    box-shadow: 0 10px 25px #0009;
}

.dock-options-menu button {
    min-height: 34px;
    padding: 5px 10px;
    text-align: left;
}

#sidehaven-world {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    z-index: 5;
    max-width: min(55vw, 360px);
    padding: 7px 10px;
    overflow: hidden;
    color: var(--ink);
    background: rgb(7 20 28 / .86);
    border: 1px solid #5c7680;
    border-radius: 6px;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.modern-hud .controller-focus {
    outline: 2px solid var(--gold) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 4px var(--hud-base) !important;
}

#hud-pause {
    position: fixed;
    inset: 0;
    z-index: 130;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
        max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    pointer-events: auto;
}

#hud-pause .pause-backdrop {
    position: absolute;
    inset: 0;
    background: rgb(2 12 18 / .76);
    pointer-events: none;
}

#hud-pause .pause-card {
    position: relative;
    box-sizing: border-box;
    width: min(100%, 420px);
    max-height: 100%;
    min-height: 0;
    padding: clamp(16px, 4vw, 28px);
    overflow: auto;
    color: var(--ink);
    background: #102834;
    border: 1px solid #55747d;
    border-top: 2px solid var(--gold);
    border-radius: 11px;
    box-shadow: 0 20px 48px #000a;
    overscroll-behavior: contain;
}

#hud-pause .pause-heading {
    margin: 0;
    color: var(--ink);
    font-size: clamp(22px, 4vw, 28px);
    line-height: 1.15;
    font-weight: 650;
}

#hud-pause .pause-description,
#hud-pause .pause-status {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

#hud-pause .pause-status:empty { display: none; }

#hud-pause .pause-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-top: 18px;
    padding: 3px;
}

#hud-pause .pause-actions button {
    width: 100%;
    min-height: 44px;
    padding: 7px 12px;
    text-align: left;
    font-size: 14px;
}

#sidehaven-hud-pointer {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 240;
    pointer-events: none;
    width: 0;
    height: 0;
}
#sidehaven-hud-pointer::before,
#sidehaven-hud-pointer::after {
    content: "";
    position: absolute;
    background: #fff;
    box-shadow: 0 0 0 1px #0a121a;
}
#sidehaven-hud-pointer::before { left: -7px; top: -1px; width: 14px; height: 2px; }
#sidehaven-hud-pointer::after { left: -1px; top: -7px; width: 2px; height: 14px; }
.modern-hud .controller-pointer-hover {
    outline: 2px solid var(--accent, #d9ad66);
    outline-offset: 1px;
}

#sidehaven-keyboard {
    position: fixed;
    z-index: 200;
    left: 50%;
    bottom: calc(var(--dock-height) + 8px);
    transform: translateX(-50%);
    width: min(800px, calc(100vw - 20px));
    max-height: max(0px, calc(100dvh - var(--dock-height) - 16px));
    padding: 12px;
    overflow: auto;
    background: #0c202b;
    border: 1px solid var(--gold);
    border-radius: 10px;
    box-shadow: 0 12px 30px #000a;
    pointer-events: auto;
}

#sidehaven-keyboard header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

#sidehaven-keyboard input { margin-bottom: 8px; font-size: 16px; }
.keyboard-row { display: flex; gap: 5px; justify-content: center; margin: 0 0 5px; }
.keyboard-row button { flex: 1; min-width: 0; min-height: 37px; padding: 4px; }
.keyboard-row button.wide { flex: 2; }
.keyboard-help { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 960px) {
    #sidehaven-dock {
        grid-template-columns: minmax(0, 1fr) 42px;
        gap: 5px;
    }

    #sidehaven-dock .dock-profile { grid-area: 1 / 1; min-height: 44px; padding: 4px 8px; }
    #sidehaven-dock .dock-options { grid-area: 1 / 2; }
    #sidehaven-dock .dock-nav { grid-area: 2 / 1 / 3 / -1; }
    .dock-picked { grid-column: 1 / -1; }
    .dock-avatar { width: 30px; height: 34px; }
    .dock-avatar .icon { width: 22px; height: 22px; }

    .dock-identity {
        grid-template-columns: minmax(0, max-content) minmax(0, 1fr) minmax(0, max-content);
        gap: 4px 10px;
        align-items: center;
    }

    .dock-wallet { grid-column: 3; grid-row: 1; justify-content: flex-end; }
    .dock-xp { grid-column: 1 / -1; grid-row: 2; }
    .dock-name { max-width: min(28vw, 180px); }

    #sidehaven-dock .dock-nav button {
        min-height: 51px;
        padding: 4px 3px;
    }
}

@media (max-width: 520px) {
    .dock-identity {
        grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
        gap: 3px 7px;
    }

    .dock-name { max-width: none; font-size: 12px; }
    .dock-level { grid-column: 1; grid-row: 2; font-size: 10px; }
    .dock-wallet { grid-column: 2; grid-row: 1 / 3; gap: 3px 6px; font-size: 10px; }
    .dock-xp { grid-column: 1 / -1; grid-row: 3; }
    #sidehaven-world { max-width: 77vw; font-size: 12px; }
    .keyboard-row { gap: 3px; }
    .keyboard-row button { min-height: 34px; padding: 3px 1px; font-size: 12px; }
    .modern-hud .floating-window .window-content { padding: 10px; }
}

@media (max-height: 410px) {
    #sidehaven-dock { padding-top: 4px; }
    #sidehaven-dock .dock-nav button { min-height: 42px; gap: 2px; }
    #sidehaven-dock .dock-profile { min-height: 42px; }
    #hud-pause .pause-card { padding: 14px; }
    #hud-pause .pause-actions { margin-top: 8px; }
}

body.game .settings-display-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 18px;
}
body.game .settings-display-grid section {
    padding: 12px;
    border: 1px solid var(--border, #394851);
    border-radius: 6px;
}
body.game .settings-display-grid input[type=checkbox] {
    width: auto;
    flex: none;
}

body.game.game-paused #app { z-index: 61; }

.feature-tips{border:1px solid #c4a66a;background:#202f38;padding:12px;margin:0 0 14px;border-radius:5px;color:#f3ebd8;line-height:1.45}.feature-tips ol{padding-left:20px;margin:8px 0 0}.feature-tips li+li{margin-top:6px}.feature-tips button{flex-shrink:0}.build-tools .feature-tips{max-width:450px;margin:8px 0 0;font-size:12px}
