/* Enhanced Persistent Header - MorrHollow Style */

/* Import panel-specific styles */
@import url('./panels/wallet-panel.css?v=morrhollow2024');

:root {
    --header-height: 48px;
    --header-bg: linear-gradient(180deg, rgba(30, 41, 59, 0.95) 0%, rgba(51, 65, 85, 0.98) 100%);
    --header-border: rgba(212, 175, 55, 0.4);
    --panel-bg: rgba(26, 26, 46, 0.98);
    --accent-primary: #93C5FD;
    --accent-gold: rgba(186, 166, 116, 0.7);
    --accent-success: #40FF40;
    --accent-danger: #FF4040;
    --text-primary: #ffffff;
    --text-secondary: rgba(186, 166, 116, 0.8);
    --glow-blue: rgba(147, 197, 253, 0.3);
    --mobile-breakpoint: 900px;
    --tablet-breakpoint: 1400px;
}

/* Ensure body has padding for fixed header */
body {
    padding-top: var(--header-height);
}

/* Main Header - Enhanced with MorrHollow style */
.persistent-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10000;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    font-family: 'RemiliaMincho', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, serif;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 30px rgba(147, 197, 253, 0.1);
    overflow: hidden; /* CRITICAL: Prevent any overflow */
    min-height: 48px;
    max-height: 48px; /* Hard constraint */
}

/* Header Sections */
.header-section {
    display: flex;
    align-items: center;
    gap: 6px; /* Reduced from 8px to save space */
    flex-wrap: nowrap; /* Prevent wrapping */
    height: 100%; /* Take full header height */
    max-height: 48px; /* Hard constraint */
}

.header-left {
    flex: 0 0 auto;
    padding-left: 12px;
    height: 100%;
}

.header-center {
    flex: 1 1 auto;
    justify-content: center;
    gap: 4px;
    height: 100%;
}

.header-right {
    flex: 0 1 auto;
    padding-right: 8px; /* Reduced padding */
    max-width: 60%; /* Increased slightly for flexibility */
    overflow: visible;
    gap: 3px; /* Tighter gap */
    flex-wrap: nowrap; /* Never wrap */
    min-width: 0; /* Allow shrinking below content size */
    height: 100%; /* Take full header height */
}

/* Logo - Enhanced with gold accent */
.logo-full {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1px;
    margin-left: 8px;
    text-shadow: 
        0px 1px 2px rgba(0, 0, 0, 0.8),
        0 0 10px var(--accent-primary);
    font-family: 'RemiliaMincho', serif;
}

.logo-compact {
    display: none;
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-gold);
    margin-left: 8px;
    text-shadow: 
        0px 1px 2px rgba(0, 0, 0, 0.8),
        0 0 10px var(--accent-primary);
}

/* Hamburger Menu */
.menu-hamburger {
    background: linear-gradient(135deg, 
        rgba(30, 41, 59, 0.3) 0%,
        rgba(51, 65, 85, 0.4) 100%);
    border: 1px solid rgba(147, 197, 253, 0.2);
    color: var(--text-secondary);
    font-size: 24px;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.menu-hamburger:hover {
    background: rgba(147, 197, 253, 0.1);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--glow-blue);
}

/* Header Buttons - Enhanced with game UI style */
.header-btn {
    background: linear-gradient(135deg,
        rgba(30, 41, 59, 0.3) 0%,
        rgba(51, 65, 85, 0.4) 100%);
    border: 1px solid rgba(147, 197, 253, 0.2);
    color: var(--text-secondary);
    padding: 4px 8px; /* Further reduced */
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    font-size: 12px; /* Further reduced */
    font-weight: 500;
    position: relative;
    overflow: hidden;
    font-family: 'RemiliaMincho', serif;
    white-space: nowrap;
    flex-shrink: 1; /* Allow shrinking if needed */
    max-height: 36px; /* CRITICAL: Stay within header bounds */
    height: 36px; /* Fixed height */
    line-height: 1; /* Compact line height */
}

.header-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(147, 197, 253, 0.2), 
        transparent);
    transition: left 0.5s ease;
}

.header-btn:hover {
    background: linear-gradient(135deg, 
        rgba(30, 41, 59, 0.5) 0%,
        rgba(51, 65, 85, 0.6) 100%);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 
        0 0 10px var(--glow-blue),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.header-btn:hover::before {
    left: 100%;
}

.header-btn.active {
    background: linear-gradient(135deg, 
        rgba(147, 197, 253, 0.15) 0%,
        rgba(147, 197, 253, 0.25) 100%);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 
        0 0 15px var(--glow-blue),
        inset 0 0 10px rgba(147, 197, 253, 0.1);
    text-shadow: 0 0 5px var(--accent-primary);
}

.header-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 8px;
    right: 8px;
    height: 2px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--accent-primary), 
        transparent);
    animation: glow-pulse 1.5s ease-in-out infinite;
}

.btn-icon {
    font-size: 16px; /* Smaller icons */
    line-height: 1;
    filter: drop-shadow(0 0 3px currentColor);
    flex-shrink: 0; /* Icons don't shrink */
}

.btn-text {
    white-space: nowrap;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Allow text to shrink */
}

.icon-only {
    padding: 4px 6px; /* Further reduced */
    min-width: 30px; /* Smaller minimum */
    width: 36px; /* Fixed width for consistency */
    justify-content: center; /* Center the icon */
}

.icon-only .btn-text {
    display: none;
}

/* Wallet display compact mode */
.wallet-display {
    max-width: 130px; /* More aggressive limit */
    min-width: 80px; /* Minimum for readability */
}

.wallet-display .btn-text {
    max-width: 70px; /* Tighter constraint */
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px; /* Smaller text for SHARD amount */
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   UNIFIED HOLLOWCORE STATUS DISPLAY - Inspired by Hollowcore Hub V2
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.hollowcore-status-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px;
    background: linear-gradient(135deg,
        rgba(30, 41, 59, 0.3) 0%,
        rgba(51, 65, 85, 0.4) 100%);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 6px;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.hollowcore-status-display:hover {
    background: linear-gradient(135deg,
        rgba(30, 41, 59, 0.5) 0%,
        rgba(51, 65, 85, 0.6) 100%);
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow:
        inset 0 0 20px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(212, 175, 55, 0.2);
}

/* Companion Selector Button */
.companion-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    border-right: 1px solid rgba(212, 175, 55, 0.2);
    padding-right: 12px;
    margin-right: 4px;
    transition: all 0.2s ease;
    max-width: 180px;
}

.companion-selector-btn:hover {
    transform: translateX(-2px);
}

.companion-selector-btn:hover .dropdown-arrow-icon {
    color: rgba(212, 175, 55, 1);
    transform: translateY(1px);
}

/* Companion Avatar Section */
.companion-avatar-section {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    flex: 1;
    min-width: 0;
}

.companion-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(212, 175, 55, 0.4);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.companion-selector-btn:hover .companion-avatar-img {
    border-color: rgba(212, 175, 55, 0.7);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.companion-icon-fallback {
    font-size: 24px;
    filter: drop-shadow(0 0 6px rgba(147, 197, 253, 0.5));
    flex-shrink: 0;
}

.companion-name-display {
    color: rgba(212, 175, 55, 1);
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.3), 0 1px 2px rgba(0, 0, 0, 0.8);
    font-family: 'RemiliaMincho', serif;
    flex: 1;
    min-width: 0;
}

.dropdown-arrow-icon {
    font-size: 10px;
    color: rgba(186, 166, 116, 0.7);
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

/* Resources Section */
.resources-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    height: 100%; /* Match parent height */
}

.resource-display {
    display: flex;
    align-items: center;
    justify-content: center; /* Center content */
    gap: 5px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: 30px; /* Fixed height for consistent alignment */
    min-height: 30px; /* Ensure minimum height */
}

.resource-display:hover {
    transform: translateY(-1px);
}

.resource-icon {
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resource-value {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    line-height: 1;
    display: flex;
    align-items: center;
}

/* Battery Resource - Scoped to persistent header to prevent conflicts */
.persistent-header .battery-display,
.hollowcore-status-display .battery-display {
    border-color: rgba(147, 197, 253, 0.3);
    color: #93C5FD;
    margin: 0 !important; /* Prevent external overrides */
    margin-top: 0 !important; /* Specifically prevent margin-top */
}

.persistent-header .battery-display:hover,
.hollowcore-status-display .battery-display:hover {
    background: rgba(147, 197, 253, 0.08);
    border-color: rgba(147, 197, 253, 0.5);
    box-shadow: 0 0 10px rgba(147, 197, 253, 0.2);
}

.persistent-header .battery-display .resource-icon,
.hollowcore-status-display .battery-display .resource-icon {
    filter: drop-shadow(0 0 4px rgba(147, 197, 253, 0.5));
}

/* Shard Resource - Clickable - Scoped to persistent header */
.persistent-header .shard-display,
.hollowcore-status-display .shard-display {
    border-color: rgba(212, 175, 55, 0.3);
    color: rgba(212, 175, 55, 1);
    cursor: pointer;
    margin: 0 !important; /* Prevent external overrides */
}

.persistent-header .shard-display:hover,
.hollowcore-status-display .shard-display:hover {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
    transform: translateY(-2px);
}

.persistent-header .shard-display .resource-icon,
.hollowcore-status-display .shard-display .resource-icon {
    filter: drop-shadow(0 0 4px rgba(212, 175, 55, 0.6));
}

/* Balance Display - Enhanced with gold glow */
.balance-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, 
        rgba(186, 166, 116, 0.1) 0%,
        rgba(212, 175, 55, 0.15) 100%);
    border: 1px solid var(--header-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.balance-display:hover {
    background: linear-gradient(135deg, 
        rgba(186, 166, 116, 0.15) 0%,
        rgba(212, 175, 55, 0.2) 100%);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
}

.balance-icon {
    font-size: 16px;
    filter: drop-shadow(0 0 3px rgba(212, 175, 55, 0.6));
}

.balance-amount {
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 14px;
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.4);
    font-family: 'RemiliaMincho', monospace;
}

/* Notification Badge - Enhanced with pulse */
.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: linear-gradient(135deg, 
        var(--accent-danger), 
        rgba(255, 64, 64, 0.8));
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 10px var(--accent-danger);
    animation: notification-pulse 2s ease-in-out infinite;
}

/* Panel Container */
.panel-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 9999;
    pointer-events: none;
}

/* Panels - Enhanced with game UI style */
.panel {
    position: absolute;
    top: 0;
    background: linear-gradient(180deg, 
        rgba(15, 15, 25, 0.95) 0%,
        rgba(8, 8, 15, 0.98) 100%);
    border: 1px solid var(--header-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(147, 197, 253, 0.1);
    max-height: calc(100vh - var(--header-height) - 20px);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s;
    pointer-events: none;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.panel.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Panel positioning based on type */
.panel-market,
.panel-inventory,
.panel-equipment,
.panel-leaderboard,
.panel-social {
    left: 50%;
    transform: translateX(-50%);
    width: min(800px, calc(100vw - 40px));
}

.panel-stream {
    pointer-events: auto !important;
}

.panel-wallet,
.panel-notifications,
.panel-settings,
.panel-profile {
    right: 20px;
    width: 360px;
}

/* Panel Close Button */
.panel-close {
    display: block; /* BUGFIX: Show close button on all screen sizes */
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg,
        rgba(30, 41, 59, 0.4) 0%,
        rgba(51, 65, 85, 0.5) 100%);
    border: 1px solid rgba(147, 197, 253, 0.2);
    color: var(--text-primary);
    font-size: 20px;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 1;
    transition: all 0.2s;
}

.panel-close:hover {
    background: rgba(255, 64, 64, 0.2);
    border-color: var(--accent-danger);
    box-shadow: 0 0 10px rgba(255, 64, 64, 0.4);
}

/* Panel Content */
.panel-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height) - 40px);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--header-border);
}

.panel-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--text-secondary);
    font-family: 'RemiliaMincho', serif;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
}

.panel-tabs {
    display: flex;
    gap: 4px;
}

.tab {
    background: linear-gradient(135deg, 
        rgba(30, 41, 59, 0.3) 0%,
        rgba(51, 65, 85, 0.4) 100%);
    border: 1px solid rgba(147, 197, 253, 0.2);
    color: var(--text-secondary);
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
    font-family: 'RemiliaMincho', serif;
}

.tab:hover {
    background: rgba(147, 197, 253, 0.1);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.tab.active {
    background: linear-gradient(135deg, 
        rgba(147, 197, 253, 0.15) 0%,
        rgba(147, 197, 253, 0.25) 100%);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--glow-blue);
}

/* Mobile Drawer - Enhanced */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    pointer-events: none;
}

.mobile-drawer.active {
    pointer-events: auto;
}

.drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-drawer.active .drawer-overlay {
    opacity: 1;
}

.drawer-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background: linear-gradient(180deg, 
        rgba(15, 15, 25, 0.98) 0%,
        rgba(8, 8, 15, 1) 100%);
    border-right: 1px solid var(--header-border);
    transform: translateX(-100%);
    transition: transform 0.3s;
    overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.8);
}

.mobile-drawer.active .drawer-content {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--header-border);
    background: var(--header-bg);
}

.drawer-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-gold);
    font-family: 'RemiliaMincho', serif;
    text-shadow: 0 0 10px var(--accent-primary);
}

.drawer-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    transition: all 0.2s;
}

.drawer-close:hover {
    color: var(--accent-danger);
    text-shadow: 0 0 10px var(--accent-danger);
}

.drawer-nav {
    padding: 12px 0;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'RemiliaMincho', serif;
    position: relative;
}

.drawer-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent-primary);
    transition: height 0.2s;
}

.drawer-item:hover {
    background: rgba(147, 197, 253, 0.1);
    color: var(--text-primary);
    padding-left: 24px;
}

.drawer-item:hover::before {
    height: 70%;
}

.drawer-icon {
    font-size: 20px;
    filter: drop-shadow(0 0 3px currentColor);
}

.drawer-divider {
    height: 1px;
    background: var(--header-border);
    margin: 8px 20px;
}

/* Animations */
@keyframes glow-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes notification-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   COMPACT MODE FOR SMALLER SCREENS
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Medium screens - make everything more compact */
@media (max-width: 1200px) {
    .header-right {
        max-width: 55%; /* Adjusted for new layout */
        gap: 6px;
    }

    .header-section {
        gap: 6px;
    }

    .header-btn {
        padding: 5px 8px;
        font-size: 12px;
        gap: 3px;
    }

    .icon-only {
        padding: 5px;
    }

    /* Unified Hollowcore Display - Compact */
    .hollowcore-status-display {
        gap: 8px;
        padding: 3px 6px;
    }

    .companion-selector-btn {
        max-width: 140px;
        gap: 6px;
    }

    .companion-avatar-img {
        width: 28px;
        height: 28px;
    }

    .companion-name-display {
        font-size: 12px;
    }

    .resources-section {
        gap: 8px;
    }

    .resource-display {
        padding: 3px 6px;
        font-size: 11px;
        gap: 4px;
        height: 28px; /* Slightly smaller but still consistent */
        min-height: 28px;
    }

    .resource-icon {
        font-size: 12px;
    }

    .btn-icon {
        font-size: 16px;
    }

    .balance-display {
        max-width: 140px;
        gap: 4px !important;
        padding: 5px 10px;
    }

    .balance-icon {
        font-size: 14px;
    }

    .balance-amount {
        font-size: 12px;
    }
}

/* Very small screens - ultra compact */
@media (max-width: 900px) {
    .hollowcore-status-display {
        gap: 6px;
        padding: 2px 4px;
    }

    .companion-selector-btn {
        max-width: 100px;
        padding-right: 8px;
    }

    .companion-avatar-img {
        width: 24px;
        height: 24px;
    }

    .companion-icon-fallback {
        font-size: 20px;
    }

    .companion-name-display {
        font-size: 11px;
        max-width: 60px;
    }

    .dropdown-arrow-icon {
        display: none; /* Hide on very small screens */
    }

    .resources-section {
        gap: 6px;
    }

    .resource-display {
        padding: 2px 5px;
        font-size: 10px;
        height: 24px; /* Even smaller but still aligned */
        min-height: 24px;
    }

    .resource-icon {
        font-size: 11px;
    }
}

/* Responsive Styles - Keep existing breakpoints */
@media (max-width: 900px) and (orientation: landscape) {
    .logo-full {
        display: none;
    }
    
    .logo-compact {
        display: inline;
    }
    
    .btn-text {
        display: none;
    }
    
    .header-btn {
        padding: 8px;
    }
    
    .balance-amount {
        display: none;
    }
    
    .panel {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0;
        transform: none !important;
    }
    
    .panel-close {
        display: block;
    }
    
    .panel.active {
        transform: translateY(0) !important;
    }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MOBILE PORTRAIT MODE - COMPREHENSIVE OPTIMIZATIONS
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@media (max-width: 900px) and (orientation: portrait) {
    /* ===== HEADER OPTIMIZATIONS ===== */

    .header-center {
        display: none;
    }

    .logo-full {
        display: none;
    }

    .logo-compact {
        display: inline;
    }

    /* Vertical hollowcore display for portrait */
    .hollowcore-status-display {
        flex-direction: column;
        gap: 8px;
        padding: 8px 10px;
        max-width: none;
    }

    .companion-selector-btn {
        width: 100%;
        max-width: none;
        padding: 6px 10px;
        border-right: none;
        border-bottom: 1px solid rgba(212, 175, 55, 0.2);
        padding-bottom: 8px;
        margin-bottom: 4px;
        margin-right: 0;
    }

    .resources-section {
        width: 100%;
        justify-content: space-around;
        gap: 12px;
    }

    /* Ensure touch targets are large enough */
    .header-btn,
    .resource-display,
    .companion-selector-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .resource-display {
        flex: 1;
        justify-content: center;
        padding: 6px 10px;
    }

    .balance-display {
        padding: 8px 12px;
        min-height: 44px;
    }

    .balance-amount {
        font-size: 14px;
    }

    /* ===== FULLSCREEN PANEL OPTIMIZATIONS ===== */

    .panel {
        position: fixed !important;
        top: var(--header-height) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        max-height: calc(100vh - var(--header-height)) !important;
        transform: none !important;
        border-left: none;
        border-right: none;
    }

    /* Sticky panel headers */
    .panel-header {
        position: sticky;
        top: 0;
        background: var(--panel-bg);
        z-index: 10;
        padding: 14px 16px;
        margin-bottom: 0;
        border-bottom: 2px solid var(--header-border);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .panel-header h2 {
        font-size: 18px;
        line-height: 1.3;
    }

    /* Panel content with proper mobile padding */
    .panel-content {
        padding: 16px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
    }

    /* Better text readability */
    .panel-body {
        font-size: 15px;
        line-height: 1.6;
    }

    /* ===== MOBILE-FRIENDLY TABS ===== */

    .panel-tabs {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin: 8px -16px 0;
        padding-left: 16px;
        padding-right: 16px;
        scrollbar-width: none;
    }

    .panel-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        flex-shrink: 0;
        min-width: 90px;
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* ===== IMPROVED CLOSE BUTTON ===== */

    .panel-close {
        display: block !important;
        width: 44px;
        height: 44px;
        font-size: 24px;
        top: 8px;
        right: 8px;
        background: linear-gradient(135deg, rgba(255, 64, 64, 0.8), rgba(220, 38, 38, 0.9));
        border: 2px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        z-index: 100;
        border-radius: 8px;
        color: white;
        font-weight: bold;
    }

    .panel-close:active {
        transform: scale(0.95);
    }

    /* ===== TOUCH-FRIENDLY LISTS & CARDS ===== */

    .companion-card,
    .item-card,
    .friend-card,
    .notification-item,
    .storylet-card,
    .achievement-card,
    .auction-item,
    .market-item {
        padding: 16px;
        margin-bottom: 12px;
        min-height: 72px;
        border-radius: 12px;
    }

    /* ===== GRID TO STACK CONVERSION ===== */

    .companions-grid,
    .items-grid,
    .market-grid,
    .inventory-grid,
    .codex-doc-categories,
    .landscape-triple {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        grid-template-columns: none !important;
    }

    /* Stack side-by-side layouts */
    .profile-layout,
    .equipment-layout,
    .stats-layout,
    .landscape-split,
    .landscape-split-60-40,
    .landscape-split-70-30,
    .landscape-sidebar {
        flex-direction: column !important;
        grid-template-columns: none !important;
    }

    .landscape-split-left,
    .landscape-split-right,
    .sidebar-nav,
    .sidebar-main-content {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding: 16px;
    }

    /* ===== FULL-WIDTH BUTTONS ===== */

    .panel-body button,
    .panel-body .btn,
    .panel-body .action-btn,
    .codex-link,
    .codex-action {
        width: 100%;
        min-height: 48px;
        margin: 8px 0;
        font-size: 16px;
        padding: 12px 16px;
        border-radius: 12px;
    }

    /* ===== BOTTOM ACTION AREA ===== */

    .panel-actions {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        background: linear-gradient(to top, var(--panel-bg) 80%, transparent);
        display: flex;
        gap: 12px;
        z-index: 5;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .panel-actions button {
        flex: 1;
        min-height: 48px;
        font-size: 16px;
        border-radius: 12px;
    }

    /* ===== BOTTOM SHEET STYLE FOR SMALL PANELS ===== */

    .panel-wallet,
    .panel-settings,
    .panel-notifications {
        top: auto !important;
        bottom: 0 !important;
        max-height: 85vh !important;
        height: auto !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6) !important;
    }

    /* Swipe indicator */
    .panel-wallet::before,
    .panel-settings::before,
    .panel-notifications::before {
        content: '';
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        width: 48px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
        z-index: 1;
    }

    .panel-wallet .panel-header,
    .panel-settings .panel-header,
    .panel-notifications .panel-header {
        padding-top: 24px; /* Space for swipe indicator */
    }

    /* ===== STAT ROWS TO VERTICAL ===== */

    .stat-row,
    .info-row,
    .resource-row {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    .stat-item,
    .info-item {
        width: 100% !important;
        min-height: 48px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        background: rgba(0, 0, 0, 0.2);
        border-radius: 8px;
    }

    /* ===== FORM INPUTS ===== */

    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
        border-radius: 12px;
    }

    textarea {
        min-height: 120px;
    }

    /* ===== MODAL ADJUSTMENTS ===== */

    .companion-switcher-modal,
    .modal,
    .dialog {
        max-width: 95vw !important;
        margin: 20px auto;
        border-radius: 16px !important;
    }

    /* ===== CODEX/DOC SPECIFIC ===== */

    .codex-panel {
        max-height: none;
    }

    .codex-entity-list,
    .codex-tab-brief,
    .codex-tab-systems,
    .codex-markdown-content {
        padding-right: 8px;
    }

    .codex-entity-item {
        padding: 14px;
    }

    .codex-entity-avatar img {
        width: 56px;
        height: 56px;
    }

    /* ===== HORIZONTAL SCROLL SECTIONS ===== */

    .landscape-horizontal-flow {
        margin: 0 -16px;
        padding: 16px;
        gap: 12px;
    }

    .landscape-horizontal-card {
        min-width: 140px;
    }

    /* ===== SAFE AREA INSETS (iPhone notch/bottom bar) ===== */

    body {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .persistent-header {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
    }

    .mobile-drawer .drawer-content {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* ===== EXTREME SMALL SCREENS (< 400px) ===== */

@media (max-width: 400px) and (orientation: portrait) {
    .companion-name-display {
        font-size: 10px;
        max-width: 50px;
    }

    .resource-value {
        font-size: 11px;
    }

    .resource-icon {
        font-size: 13px;
    }

    .dropdown-arrow-icon {
        display: none;
    }

    .panel-header h2 {
        font-size: 16px;
    }

    .tab {
        min-width: 70px;
        font-size: 12px;
        padding: 8px 12px;
    }
}

@media (min-width: 901px) and (max-width: 1400px) {
    .btn-text {
        font-size: 13px;
    }
    
    .header-btn {
        padding: 8px 10px;
    }
}

@media (min-width: 1401px) {
    .header-center {
        gap: 8px;
    }
    
    .header-btn {
        padding: 10px 16px;
    }
    
    .panel-market,
    .panel-inventory,
    .panel-equipment {
        width: 900px;
    }
}
/* Codex panel styling */
.codex-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 140px);
}

.codex-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.codex-heading h2 {
    margin: 0;
    font-size: 20px;
    color: var(--accent-gold);
    text-shadow: 0 0 8px rgba(147, 197, 253, 0.25);
}

.codex-heading .codex-subheading {
    margin: 4px 0 0;
    color: rgba(186, 166, 116, 0.7);
    font-size: 12px;
}

.codex-actions {
    margin-left: auto;
}

.codex-action {
    background: linear-gradient(135deg, rgba(147, 197, 253, 0.18) 0%, rgba(147, 197, 253, 0.05) 100%);
    border: 1px solid rgba(147, 197, 253, 0.35);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    text-shadow: 0 0 6px rgba(147, 197, 253, 0.35);
}

.codex-tab-bar {
    display: flex;
    gap: 8px;
}

.codex-tab-btn {
    flex: 1 1 auto;
    border: 1px solid rgba(147, 197, 253, 0.22);
    background: rgba(30, 41, 59, 0.55);
    color: rgba(186, 166, 116, 0.85);
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s, border-color 0.2s;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

.codex-tab-btn.active {
    background: linear-gradient(135deg, rgba(147, 197, 253, 0.22) 0%, rgba(147, 197, 253, 0.12) 100%);
    color: var(--text-primary);
    border-color: rgba(147, 197, 253, 0.4);
    box-shadow: 0 0 12px rgba(147, 197, 253, 0.25);
}

.codex-body {
    flex: 1 1 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.codex-tab {
    display: none;
    flex: 1 1 auto;
    overflow: hidden;
}

.codex-tab.active {
    display: flex;
}

.codex-tab-brief,
.codex-tab-systems,
.codex-tab-patchline,
.codex-tab-article {
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 6px;
}

.codex-brief-list {
    list-style: decimal;
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 12px;
}

.codex-system-card {
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid rgba(147, 197, 253, 0.22);
    border-radius: 8px;
    padding: 16px;
    display: grid;
    gap: 8px;
    box-shadow: inset 0 0 12px rgba(15, 23, 42, 0.6);
}

.codex-system-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.codex-status {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.codex-status-live {
    color: #74f2b6;
}

.codex-status-planned,
.codex-status-draft {
    color: #f6d860;
}

.codex-link {
    justify-self: flex-start;
    background: rgba(147, 197, 253, 0.18);
    border: 1px solid rgba(147, 197, 253, 0.32);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.codex-link:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.codex-article-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 8px;
}

.codex-article-scroll main,
.codex-article-scroll article {
    background: rgba(30, 41, 59, 0.7);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid rgba(147, 197, 253, 0.16);
}

.codex-article-scroll h1,
.codex-article-scroll h2,
.codex-article-scroll h3 {
    color: var(--text-primary);
}

.codex-article-scroll table {
    width: 100%;
    border-collapse: collapse;
}

.codex-article-scroll th,
.codex-article-scroll td {
    border: 1px solid rgba(147, 197, 253, 0.16);
    padding: 8px;
}

.codex-loading,
.codex-placeholder,
.codex-error {
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid rgba(147, 197, 253, 0.2);
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    color: rgba(186, 166, 116, 0.85);
}

.codex-error strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.codex-patchline pre {
    background: rgba(15, 23, 42, 0.7);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid rgba(147, 197, 253, 0.2);
}

.codex-hint {
    font-size: 11px;
    color: rgba(186, 166, 116, 0.7);
}

.codex-markdown {
    white-space: pre-wrap;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-primary);
}

.codex-brief-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.codex-tag {
    border: 1px solid rgba(147, 197, 253, 0.3);
    background: rgba(147, 197, 253, 0.12);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ANDROID FULLSCREEN OPTIMIZATIONS
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Android Chrome - Hide address bar on scroll */
@media screen and (max-width: 900px) {
    html {
        /* Force height to allow address bar to hide */
        height: 100%;
        overflow: hidden;
    }

    body {
        /* Use viewport height units that exclude browser chrome */
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow-y: auto;
        overflow-x: hidden;
        position: relative;
        /* Prevent pull-to-refresh on Android */
        overscroll-behavior-y: contain;
    }

    /* Ensure panels use full available height */
    .panel {
        height: 100vh;
        height: -webkit-fill-available;
    }
}

/* PWA Fullscreen Mode (when installed on home screen) */
@media all and (display-mode: standalone) {
    body {
        /* Remove any top padding when in standalone mode */
        padding-top: 0;
    }

    /* Adjust header for notch in standalone mode */
    .persistent-header {
        padding-top: env(safe-area-inset-top, 0px);
    }

    /* Hide any browser UI indicators */
    .browser-only-notice {
        display: none;
    }
}

/* PWA Fullscreen Mode (iOS) */
@media all and (display-mode: fullscreen) {
    html, body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }

    .persistent-header {
        padding-top: env(safe-area-inset-top, 0px);
    }
}

/* Android - Prevent overscroll bounce effect */
@media screen and (max-width: 900px) {
    body {
        overscroll-behavior: contain;
    }

    .panel-content,
    .hollowcore-hub-body,
    .chat-messages {
        overscroll-behavior: contain;
    }
}

/* Android - Better viewport handling */
@supports (-webkit-touch-callout: none) {
    /* iOS specific - fill available height */
    body {
        min-height: -webkit-fill-available;
    }
}

/* Prevent zoom on input focus (Android) */
@media screen and (max-width: 900px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on Android */
    }
}

/* Android - Dark navigation bar when in browser */
@media screen and (max-width: 900px) {
    /* This is handled by meta tags, but adding for completeness */
    :root {
        color-scheme: dark;
    }
}
