/* ===================================================================
   SwiftRPG — Terminal Chronicle Map Client
   =================================================================== */

input:focus, textarea:focus, select:focus, button:focus { outline: none; }

/* === Welcome-style buttons (.btn / .btn-secondary) === */
.btn {
    display: inline-block;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 10px 28px;
    background: transparent;
    color: var(--amber);
    border: 1px solid var(--amber-dim);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
}
.btn:hover {
    background: var(--amber);
    color: var(--void);
    box-shadow: 0 0 20px rgba(212, 160, 23, 0.2);
    border-bottom: 1px solid var(--amber-dim);
}
.btn-secondary {
    color: var(--smoke);
    border-color: var(--ash);
}
.btn-secondary:hover {
    background: var(--ash);
    color: var(--bone);
    box-shadow: none;
}

/* === Auth overlay (shown to unauthenticated users) === */
.auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(10, 10, 12, 0.78);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: auto;
}
.auth-overlay-inner {
    position: relative;
    text-align: center;
    padding: 28px 36px;
    background: var(--void);
    border: 1px solid var(--amber-dim);
    border-radius: 4px;
    box-shadow: 0 0 40px rgba(212, 160, 23, 0.15);
    max-width: 420px;
}
.auth-overlay-close {
    position: absolute;
    top: 6px;
    right: 10px;
    background: transparent;
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: var(--font-ui);
    font-size: 1.1rem;
    line-height: 1;
    width: 26px;
    height: 26px;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.auth-overlay-close:hover,
.auth-overlay-close:focus {
    background: var(--amber);
    color: var(--void);
    box-shadow: 0 0 10px rgba(212, 160, 23, 0.45);
    outline: none;
}
.auth-overlay-hint {
    margin: 14px 0 0;
    font-size: 0.72rem;
    color: var(--smoke);
}
.auth-overlay-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--amber);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    text-decoration: underline dotted;
    text-underline-offset: 3px;
    cursor: pointer;
}
.auth-overlay-link:hover,
.auth-overlay-link:focus {
    color: var(--amber-glow);
    outline: none;
}
.auth-reopen-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 90;
    background: rgba(10, 10, 12, 0.82);
    border: 1px solid var(--amber-dim);
    color: var(--amber);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.auth-reopen-btn:hover,
.auth-reopen-btn:focus {
    background: var(--amber);
    color: var(--void);
    box-shadow: 0 0 12px rgba(212, 160, 23, 0.45);
    outline: none;
}
.auth-overlay-title {
    font-family: 'MedievalSharp', serif;
    color: var(--amber);
    font-size: 1.8rem;
    margin: 0 0 8px;
    letter-spacing: 0.08em;
}
.auth-overlay-subtitle {
    color: var(--smoke);
    font-size: 0.82rem;
    margin: 0 0 20px;
}
.auth-overlay .hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

:root {
    --amber: #D4A017;
    --amber-dim: #8B6914;
    --amber-glow: #F5C842;
    --emerald: #2D6A4F;
    --emerald-dim: #1B4332;
    --parchment: #F5E6C8;
    --parchment-dim: #C4A882;
    --void: #0A0A0C;
    --charcoal: #141418;
    --slate: #1E1E24;
    --ash: #2A2A32;
    --smoke: #C4C4D0;
    --bone: #E2DED6;
    --font-ui: 'IBM Plex Mono', monospace;
    --font-display: 'MedievalSharp', cursive;
}

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

html { font-size: 16px; }
html, body { height: 100%; overflow: hidden; }

@media (min-width: 1440px) { html { font-size: 18px; } }
@media (min-width: 1920px) { html { font-size: 20px; } }
@media (min-width: 2560px) { html { font-size: 22px; } }

body {
    font-family: var(--font-ui);
    font-weight: 400;
    font-size: 13px;
    background: var(--void);
    color: var(--bone);
    line-height: 1.5;
}

/* Scanlines */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.06) 2px,
        rgba(0, 0, 0, 0.06) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

a { color: var(--amber); text-decoration: none; }
a:hover { color: var(--amber-glow); }

.dim { color: var(--smoke); }

/* === CHROME LAYOUT === */
.map-chrome {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid var(--ash);
    background: var(--charcoal);
    flex-shrink: 0;
}

.map-logo {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--amber);
    text-shadow: 0 0 16px rgba(212, 160, 23, 0.25);
}

.map-nav {
    display: flex;
    gap: 16px;
}

.map-nav a {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--smoke);
    transition: color 0.2s;
}

.map-nav a:hover { color: var(--amber); }

.nav-toggle {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--smoke);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-toggle input { accent-color: var(--amber); cursor: pointer; }

.nav-hamburger {
    display: none;
    background: none;
    border: 1px solid var(--ash);
    color: var(--smoke);
    font-size: 1.2rem;
    padding: 2px 8px;
    cursor: pointer;
    border-radius: 3px;
    line-height: 1;
}

.nav-hamburger:hover {
    color: var(--amber);
    border-color: var(--amber);
}

@media (max-width: 600px) {
    .nav-hamburger { display: block; }

    .map-nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        background: var(--charcoal);
        border: 1px solid var(--ash);
        border-top: none;
        flex-direction: column;
        padding: 8px 16px;
        gap: 10px;
        z-index: 50;
        min-width: 140px;
    }

    .map-nav.nav-open {
        display: flex;
    }

    .map-header {
        position: relative;
    }
}

/* === TOPBAR (location metadata) === */
.map-topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 6px 12px;
    background: var(--charcoal);
    border-bottom: 1px solid var(--ash);
    flex-shrink: 0;
}

.topbar-stat {
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}

.topbar-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--smoke);
}

.topbar-value {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--amber);
}

.topbar-divider {
    width: 1px;
    align-self: stretch;
    background: var(--ash);
    margin: 0 4px;
}

/* === MAP + SIDEBAR === */
.map-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.map-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    position: relative;
}

.map-overlay {
    position: absolute;
    z-index: 90;
    background: rgba(20, 20, 24, 0.85);
    border: 1px solid var(--ash);
    border-radius: 6px;
    cursor: grab;
    -webkit-user-select: none;
    user-select: none;
}

.map-overlay:active { cursor: grabbing; }

.overlay-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--smoke);
    font-size: 0.85rem;
    line-height: 1;
    padding: 4px 6px;
    cursor: grab;
    user-select: none;
    flex: 0 0 auto;
}

.overlay-drag-handle:active {
    cursor: grabbing;
}

.map-overlay:hover .overlay-drag-handle {
    color: var(--amber);
}

#compass-overlay {
    bottom: calc(var(--log-bar-height, 160px) + 12px);
    right: 12px;
    padding: 4px;
}

#player-lookup-overlay {
    top: 12px;
    right: 12px;
    padding: 4px;
}

#player-lookup {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    color: var(--bone);
    background: var(--ash);
    border: 1px solid var(--smoke);
    border-radius: 3px;
    padding: 4px 6px;
    cursor: pointer;
    min-width: 120px;
}

#player-lookup:focus {
    outline: none;
    border-color: var(--amber);
}

#player-lookup option {
    background: var(--obsidian);
    color: var(--bone);
}

#hp-overlay {
    bottom: calc(var(--log-bar-height, 160px) + 12px);
    left: 12px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#hp-bar-track {
    width: 60px;
    height: 8px;
    background: var(--ash);
    border-radius: 4px;
    overflow: hidden;
}

#hp-bar-fill {
    height: 100%;
    background: #4a7;
    border-radius: 4px;
    transition: width 0.3s;
    width: 100%;
}

#hp-text {
    font-size: 0.65rem;
    color: var(--bone);
    white-space: nowrap;
}

.btn-eat {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.62rem;
    padding: 2px 8px;
    border: 1px solid #4a7;
    background: transparent;
    color: #4a7;
    cursor: pointer;
    border-radius: 2px;
    -webkit-user-select: none;
    user-select: none;
}

.btn-eat:hover {
    color: #6c9;
    border-color: #6c9;
}

.btn-eat:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Context menu */
.ctx-menu {
    display: none;
    position: fixed;
    z-index: 200;
    background: var(--charcoal);
    border: 1px solid var(--ash);
    border-radius: 4px;
    padding: 4px 0;
    min-width: 140px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.ctx-menu.open { display: block; }

.ctx-menu-item {
    display: block;
    width: 100%;
    padding: 6px 14px;
    border: none;
    background: none;
    color: var(--bone);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.ctx-menu-item:hover {
    background: rgba(212, 160, 23, 0.1);
    color: var(--amber);
}

.ctx-menu-divider {
    height: 1px;
    background: var(--ash);
    margin: 4px 0;
}

.has-ctx-menu { cursor: context-menu; -webkit-user-select: none; user-select: none; }

#game-container {
    flex: 1;
    background: var(--void);
    position: relative;
    min-height: 0;
}

#game-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* === STABLE PANE (left sidebar) === */
.stable-body .stable-row {
    border-bottom: 1px solid var(--ash);
    padding: 6px 2px;
    font-size: 0.68rem;
    color: var(--bone);
}

.stable-body .stable-row:last-child {
    border-bottom: none;
}

.stable-body .stable-row b {
    color: var(--amber);
    font-weight: 600;
}

/* === SIDEBAR === */
.map-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--charcoal);
    border-left: 1px solid var(--ash);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.map-sidebar-left {
    order: -1;
    border-left: none;
    border-right: 1px solid var(--ash);
    display: none;
}

@media (min-width: 1200px) {
    .map-sidebar-left { display: flex; }
    .map-sidebar-right { }
}

@media (min-width: 769px) and (max-width: 1199px) {
    .map-sidebar-left { display: none; }
}

.sidebar-section {
    border-bottom: 1px solid var(--ash);
}

.sidebar-heading {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--smoke);
    padding: 10px 14px 6px;
}
.sidebar-heading::after {
    content: ' ▾';
    font-size: 0.55rem;
    opacity: 0.5;
}
.sidebar-heading.collapsed::after {
    content: ' ▸';
}

.sidebar-group-heading {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--amber-dim);
    padding: 12px 14px 4px;
    border-top: 1px solid var(--ash);
    margin-top: 4px;
}

/* Action buttons */
.action-btn {
    display: block;
    width: 100%;
    padding: 7px 10px;
    margin-bottom: 4px;
    font-family: var(--font-ui);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--amber);
    background: rgba(212, 160, 23, 0.06);
    -webkit-user-select: none;
    user-select: none;
    border: 1px solid var(--amber-dim);
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.action-btn:hover {
    background: rgba(212, 160, 23, 0.15);
    box-shadow: 0 0 8px rgba(212, 160, 23, 0.2);
}

.action-btn:active:not(:disabled) {
    color: #fff;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.action-btn:disabled {
    color: var(--smoke);
    border-color: var(--ash);
    background: transparent;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Bespoke split for the Scry utility spell: main button + narrow (auto)
   companion that reuses the last-chosen direction. Keeps the parchment
   styling of a regular .action-btn but lays them side-by-side. */
.spell-split {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}
.spell-split .action-btn {
    margin-bottom: 0;
}
.spell-split .action-btn:first-child {
    flex: 1 1 auto;
}
.spell-split .action-btn.scry-auto {
    flex: 0 0 auto;
    width: auto;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
}

/* Home shelter block (player stats sidebar) */
.home-shelter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px 8px;
    font-size: 0.7rem;
    color: var(--bone);
}
.home-shelter .home-label {
    color: var(--smoke);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.6rem;
}
.home-shelter #home-name {
    flex: 1 1 auto;
    color: var(--amber);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.home-shelter #home-change {
    font-family: var(--font-ui);
    font-size: 0.6rem;
    padding: 2px 8px;
    color: var(--amber);
    background: rgba(212, 160, 23, 0.06);
    border: 1px solid var(--amber-dim);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.home-shelter #home-change:hover {
    background: rgba(212, 160, 23, 0.15);
}

/* Floating panes (Favorites, Autocast) — detachable sidebar sections */
.sidebar-group-heading.pane-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.pane-heading .pane-title {
    flex: 1;
    min-width: 0;
}
.pane-heading .pane-controls {
    display: inline-flex;
    gap: 2px;
    flex-shrink: 0;
}
.pane-btn {
    background: transparent;
    border: none;
    color: var(--smoke);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 4px;
    line-height: 1;
}
.pane-btn:hover {
    color: var(--amber);
}
.map-overlay.floating-pane {
    padding: 4px;
    min-width: 180px;
    max-width: 280px;
}
.map-overlay.floating-pane .sidebar-group-heading {
    border-top: none;
    margin-top: 0;
    padding: 6px 10px 4px;
}
.map-overlay.floating-pane .sidebar-body {
    padding: 0 8px 6px;
}

/* Favorites: icon-only action buttons laid out in a wrapping row */
.favorites-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
/* Drag-to-reorder affordances for favorite buttons */
.favorites-row .fav-draggable {
    cursor: pointer;
}
.favorites-row .fav-dragging {
    opacity: 0.4;
    cursor: grabbing;
}
/* Vertical drop-indicator line shown on the hovered sibling */
.favorites-row .fav-drop-before {
    box-shadow: -2px 0 0 0 var(--parchment, #e8d9a6);
}
.favorites-row .fav-drop-after {
    box-shadow: 2px 0 0 0 var(--parchment, #e8d9a6);
}
.action-btn.action-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    font-size: 1.1rem;
    line-height: 1;
    text-align: center;
}
/* Building list */
.building-entry {
    font-size: 0.78rem;
    color: var(--parchment);
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.building-entry .building-name {
    flex: 1;
}

.building-entry .btn-enter,
.btn-leave {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    padding: 1px 8px;
    border: 1px solid var(--ash);
    background: transparent;
    color: var(--smoke);
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.15s, border-color 0.15s;
}

.building-entry .btn-enter:hover,
.btn-leave:hover {
    color: var(--parchment);
    border-color: var(--parchment);
}

.btn-leave {
    font-size: 0.72rem;
    padding: 2px 10px;
    margin-top: 4px;
    display: inline-block;
}

/* NPC list */
.npc-entry {
    font-size: 0.78rem;
    color: var(--bone);
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px 6px;
    flex-wrap: wrap;
}

.npc-entry .npc-info {
    flex: 1;
    min-width: 0;
    /* Prevent mobile text-selection / copy callout from firing during the
       long-press gear-tooltip gesture, which was dismissing the tooltip. */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.npc-entry .npc-name {
    color: var(--parchment);
    cursor: help;
}

.npc-entry .npc-occupation {
    font-size: 0.68rem;
    color: var(--smoke);
}

.npc-entry .npc-subtitle {
    font-size: 0.62rem;
    color: var(--smoke);
    margin-left: 4px;
}

.npc-entry .btn-talk {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    padding: 1px 8px;
    border: 1px solid var(--ash);
    background: transparent;
    color: var(--smoke);
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.npc-entry .btn-talk:hover {
    color: var(--parchment);
    border-color: var(--parchment);
}

/* Collapsible headings */
.sidebar-heading-toggle {
    cursor: pointer;
    user-select: none;
}

.sidebar-heading-toggle .toggle-arrow {
    font-size: 0.7em;
    transition: transform 0.2s;
    display: inline-block;
}

.sidebar-heading-toggle.collapsed .toggle-arrow {
    transform: rotate(-90deg);
}

/* Scrollable panels */
.panel-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 60px;
    max-height: 400px;
}

.panel-resize-handle {
    height: 5px;
    cursor: ns-resize;
    background: var(--ash);
    border-radius: 0 0 3px 3px;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.panel-resize-handle:hover,
.panel-resize-handle.dragging {
    opacity: 0.8;
    background: var(--amber);
}

/* Quest list */
.quest-entry {
    font-size: 0.78rem;
    color: var(--parchment);
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.quest-entry .quest-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quest-entry .btn-quest-accept {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    padding: 1px 8px;
    border: 1px solid var(--ash);
    background: transparent;
    color: var(--amber);
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.quest-entry .btn-quest-accept:hover {
    color: var(--amber-glow);
    border-color: var(--amber);
}

.quest-entry-clickable {
    cursor: pointer;
    transition: color 0.15s;
}

.quest-entry-clickable:hover .quest-name {
    color: var(--amber);
}

.quest-status {
    font-size: 0.68rem;
    flex-shrink: 0;
}

.quest-status-in_progress {
    color: var(--amber);
}

.quest-status-completed {
    color: #4a7;
}

.no-actions {
    font-size: 0.72rem;
    color: var(--smoke);
    font-style: italic;
}

.sidebar-body {
    padding: 0 14px 12px;
}

/* Tile stats */
.tile-stat {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
}

.tile-label {
    font-size: 0.78rem;
    color: var(--smoke);
}

.tile-value {
    font-size: 0.78rem;
    color: var(--bone);
    font-weight: 500;
}

/* Resources */
.res-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.res-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--amber);
    background: rgba(212, 160, 23, 0.08);
    border: 1px solid rgba(212, 160, 23, 0.15);
    border-radius: 2px;
}

.res-label {
    font-size: 0.78rem;
    color: var(--smoke);
    flex: 1;
}

.res-val {
    font-size: 0.78rem;
    color: var(--bone);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* Compass */
.exit-compass {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 3px 0;
}

.exit-mid, .exit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.exit-center {
    color: var(--ash);
    font-size: 0.7rem;
    width: 28px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-cooldown .exit-dir {
    opacity: 0.3;
    pointer-events: none;
    cursor: not-allowed;
}

.compass-cooldown .exit-center {
    color: var(--smoke);
    font-size: 0.58rem;
}

.exit-dir {
    width: 28px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--bone);
    background: var(--ash);
    border: 1px solid var(--smoke);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.exit-dir:hover {
    color: var(--amber-glow);
    border-color: var(--amber);
    background: rgba(212, 160, 23, 0.12);
    box-shadow: 0 0 8px rgba(212, 160, 23, 0.2);
}

.exit-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-zoom {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bone);
    background: var(--ash);
    border: 1px solid var(--smoke);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    font-family: inherit;
}

.btn-zoom:hover {
    color: var(--amber-glow);
    border-color: var(--amber);
    background: rgba(212, 160, 23, 0.12);
    box-shadow: 0 0 8px rgba(212, 160, 23, 0.2);
}

.exit-dir:active {
    background: rgba(212, 160, 23, 0.2);
}

.exit-dir.available {
    color: var(--amber-glow);
    border-color: var(--amber);
    background: rgba(212, 160, 23, 0.08);
}

.exit-dir.unavailable {
    color: var(--ash);
    border-color: var(--slate);
    background: var(--charcoal);
    cursor: not-allowed;
    opacity: 0.4;
}

/* === LOG BAR === */
.map-log-bar {
    padding: 0;
    background: var(--charcoal);
    border-top: 1px solid var(--ash);
    flex-shrink: 0;
    height: 160px;
    min-height: 100px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    z-index: 45;
}

.log-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    cursor: ns-resize;
    z-index: 10;
}

.log-resize-handle:hover,
.log-resize-handle.dragging {
    background: rgba(212, 160, 23, 0.3);
}

.map-log-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--smoke);
    padding: 6px 16px 4px;
    flex-shrink: 0;
}

.log-tab {
    font-family: var(--font-ui);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 4px 12px;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--smoke);
    cursor: pointer;
    border-radius: 3px 3px 0 0;
    transition: color 0.15s, border-color 0.15s;
}

.log-tab:hover { color: var(--parchment); }
.log-tab.active { color: var(--amber); border-color: var(--ash); background: var(--charcoal); }
.log-tab.unseen { color: #5CB85C; }


#chat-messages {
    flex: 1;
    overflow-y: auto;
}

#chat-messages { scrollbar-width: thin; scrollbar-color: var(--ash) transparent; display: flex; flex-direction: column; }
#chat-messages div:first-child { margin-top: auto; }
#chat-messages::-webkit-scrollbar { width: 4px; height: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--ash); border-radius: 2px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-nicklist { scrollbar-width: thin; scrollbar-color: var(--ash) transparent; }
#chat-nicklist::-webkit-scrollbar { width: 4px; }
#chat-nicklist::-webkit-scrollbar-thumb { background: var(--ash); border-radius: 2px; }
#chat-nicklist::-webkit-scrollbar-track { background: transparent; }
#chat-messages .chat-msg { padding: 1px 0; padding-left: 54px; text-indent: -54px; white-space: pre-wrap; }
#chat-messages .chat-nick { font-weight: 600; }
#chat-messages .chat-ts { color: var(--ash); font-size: 0.6rem; margin-right: 4px; }
#chat-messages .chat-history { opacity: 0.65; font-style: italic; }
#chat-messages .chat-ts.chat-history { color: var(--smoke); }
#chat-nicklist { cursor: default; }

#chat-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    padding-bottom: 2px;
}

#chat-input-bar {
    flex-shrink: 0;
}

.btn-clear-log {
    background: none;
    border: none;
    color: var(--smoke);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.6;
    -webkit-user-select: none;
    user-select: none;
}
.btn-clear-log:hover { opacity: 1; color: var(--amber); }

.map-log {
    font-size: 0.72rem;
    line-height: 1.5;
    overflow-y: auto;
    padding: 0 16px 6px;
    flex: 1;
    min-height: 0;
}

.log-entry {
    padding: 1px 0;
    animation: logFade 0.3s ease;
}

@keyframes logFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.log-entry .log-ts { color: var(--smoke); font-variant-numeric: tabular-nums; }
.log-entry .log-action { color: var(--amber); }
.log-entry .log-xp { color: #5CB85C; }
.log-entry .log-error { color: #D9534F; }
.log-entry .log-levelup { color: #9B59B6; font-weight: 600; }

/* === FOOTER === */
.map-footer {
    padding: 6px 16px;
    border-top: 1px solid var(--ash);
    background: var(--charcoal);
    text-align: center;
    font-size: 0.68rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-reset-ui {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    color: var(--smoke);
    background: transparent;
    border: 1px solid var(--smoke);
    border-radius: 3px;
    padding: 1px 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.btn-reset-ui:hover {
    color: var(--amber);
    border-color: var(--amber);
}

.health-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-ok {
    background: #4a7;
    box-shadow: 0 0 4px #4a7;
}

.health-down {
    background: #c44;
    box-shadow: 0 0 4px #c44;
}

.health-unknown {
    background: var(--smoke);
}

.health-dot.stale-server {
    background: #ff2b2b !important;
    box-shadow: 0 0 6px #ff2b2b, 0 0 12px #ff2b2b;
    animation: stale-pulse 1.2s ease-in-out infinite;
}

@keyframes stale-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.stale-server-warning {
    color: #ff2b2b;
    font-weight: 600;
    font-size: 0.85rem;
    margin-left: 8px;
    letter-spacing: 0.02em;
}

/* === BIOME COLORS (for map tiles) === */
.biome-deep_ocean { background: #0B1D3A; }
.biome-ocean { background: #14385E; }
.biome-sand { background: #8B7D52; }
.biome-tundra { background: #6B7B7B; }
.biome-desert { background: #9B8A5A; }
.biome-grassland { background: #3D5A3D; }
.biome-forest { background: #2B4A2B; }
.biome-rainforest { background: #1A3A2A; }
.biome-mountain { background: #5A5A5A; }
.biome-snow { background: #8A8A90; }
.biome-swamp { background: #2A3A2A; }
.biome-savanna { background: #6B6A3A; }
.biome-plains { background: #4A6A3A; }
.biome-taiga { background: #2A4A3A; }
.biome-hills { background: #4A5A4A; }
.biome-jungle { background: #1A3020; }
.biome-volcanic { background: #4A2A1A; }
.biome-river { background: #1A4A6A; }
.biome-lake { background: #183858; }
.biome-cliff { background: #6A6050; }
.biome-fog { background: var(--ash); }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ash); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--amber-dim); }

/* === ARENA === */
.arena-btn-alert { animation: arena-flash 1s ease-in-out infinite; }
@keyframes arena-flash {
    0%, 100% { color: var(--amber); }
    50% { color: #ff4444; }
}
.arena-btn-challenge { animation: arena-challenge-flash 1.5s ease-in-out infinite; }
@keyframes arena-challenge-flash {
    0%, 100% { color: var(--amber); }
    50% { color: #ffdd00; }
}
.arena-section { background: var(--charcoal); border: 1px solid var(--ash); border-radius: 4px; padding: 12px; margin-bottom: 16px; }
.arena-title { font-size: 0.85rem; color: var(--amber); margin-bottom: 8px; font-weight: 600; }
.arena-tier-btn { display: inline-block; margin: 2px; padding: 4px 10px; border: 1px solid var(--ash); background: transparent; color: var(--bone); cursor: pointer; font-family: inherit; font-size: 0.65rem; border-radius: 3px; }
.arena-tier-btn:hover { border-color: var(--amber); color: var(--amber); }
.arena-combatant { display: inline-block; width: 46%; vertical-align: top; padding: 10px; border: 1px solid var(--ash); border-radius: 4px; margin: 4px; height: 110px; overflow-y: auto; }
.arena-hp-bar { height: 10px; background: var(--smoke); border-radius: 2px; overflow: hidden; margin: 4px 0; }
.arena-hp-bar-fill { height: 100%; background: #5cb85c; transition: width 0.3s; border-radius: 2px; }
.arena-status { display: inline-block; padding: 2px 6px; margin: 2px; background: var(--ash); border-radius: 2px; font-size: 0.58rem; }
.arena-log { max-height: 180px; overflow-y: auto; font-size: 0.62rem; background: var(--obsidian); padding: 8px; font-family: 'IBM Plex Mono', monospace; border: 1px solid var(--ash); border-radius: 3px; }
.arena-action-btn { padding: 6px 14px; border: 1px solid var(--amber); background: transparent; color: var(--amber); cursor: pointer; font-family: inherit; font-size: 0.68rem; margin: 4px; border-radius: 3px; }
.arena-action-btn:hover { background: rgba(212,160,23,0.1); }
.arena-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.arena-input { font-family: inherit; font-size: 0.68rem; background: var(--charcoal); color: var(--bone); border: 1px solid var(--ash); border-radius: 3px; padding: 3px 6px; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    html, body { overflow: auto; }
    .map-chrome { height: auto; min-height: 100vh; min-height: 100dvh; }
    .map-topbar { gap: 3px 10px; padding: 4px 8px; }
    .topbar-stat { gap: 3px; }
    .topbar-label { font-size: 0.58rem; }
    .topbar-value { font-size: 0.72rem; }
    .topbar-divider { display: none; }
    .map-layout { display: flex; flex-wrap: wrap; }
    .map-main { min-height: 50vh; height: 50vh; width: 100%; flex-basis: 100%; }
    .map-sidebar {
        width: 50%;
        overflow-y: visible;
        max-height: none;
        padding-bottom: 60px;
        -webkit-overflow-scrolling: touch;
        border-left: none;
        border-right: none;
    }
    .map-sidebar-left {
        display: flex !important;
        order: 1;
        border-right: 1px solid var(--ash);
    }
    .map-sidebar-right {
        order: 2;
    }
    .sidebar-section { border-bottom: 1px solid var(--ash); }
}

/* Hide map overlays that would otherwise clutter the Colosseum/Arena view */
body.arena-open #compass-overlay,
body.arena-open #player-lookup-overlay {
    display: none;
}

/* --- Equippable-item stat tooltip (Equipment > Inventory) --- */
.item-tooltip {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    min-width: 150px;
    max-width: 260px;
    padding: 7px 10px 8px 10px;
    background: linear-gradient(180deg, #2a241a 0%, #1d1812 100%);
    color: var(--bone);
    border: 1px solid var(--amber-dim);
    border-radius: 4px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
    font-size: 0.7rem;
    line-height: 1.25;
    font-family: inherit;
}
.item-tooltip-title {
    color: var(--amber);
    font-weight: 600;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--amber-dim);
    padding-bottom: 3px;
    margin-bottom: 4px;
    text-transform: capitalize;
}
.item-tooltip-slot {
    color: var(--parchment-dim);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}
.item-tooltip-stats {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1px 10px;
    margin: 4px 0;
}
.item-tooltip-stats > div {
    display: contents;
}
.item-tooltip-stat-label {
    color: var(--smoke);
}
.item-tooltip-stat-val {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.item-tooltip-stat-cmp {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.58rem;
    min-width: 2.4em;
    align-self: center;
}
.item-tooltip-cmp-note {
    margin-top: 2px;
    color: var(--smoke);
    font-size: 0.56rem;
    font-style: italic;
    text-align: right;
}
.item-tooltip-dur {
    color: var(--parchment-dim);
    font-size: 0.64rem;
    margin-top: 4px;
}
.item-tooltip-effects {
    list-style: disc;
    padding-left: 14px;
    margin: 5px 0 0 0;
    color: var(--amber-glow);
    font-size: 0.64rem;
}
.item-tooltip-effects li {
    margin: 1px 0;
}
.item-tooltip-effects-label {
    margin-top: 5px;
    font-size: 0.6rem;
    color: var(--smoke);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.item-tooltip-effects-label + .item-tooltip-effects {
    margin-top: 1px;
}
.item-tooltip-effects-none {
    font-size: 0.62rem;
    color: var(--smoke);
    font-style: italic;
    padding-left: 2px;
}
