/* ===== CREATIO EX NIHILO - Flexbox Layout ===== */

/* === CSS Variables === */
:root {
    /* Base colors */
    --bg-void: #1a1a1a;
    --bg-dark: #111111;
    --bg-panel: #1a1a1a;

    /* Accent colors */
    --glow-green: #00ff41;
    --glow-amber: #ffa500;
    --glow-cyan: #00d4ff;
    --glow-red: #ff3333;
    --glow-gold: #ffd700;

    /* Status bar colors */
    --bar-health: #ff4444;
    --bar-saturation: #ff8800;
    --bar-hydration: #00aaff;
    --bar-warmth: #ffcc00;
    --bar-stamina: #00ff66;

    /* Home panel - warm browns */
    --home-bg: #3d2817;
    --home-bg-light: #5a3d2a;
    --home-border: #6b4423;
    --home-text: #e8d5c4;

    /* Grass/nature colors */
    --grass-light: #4a7c3f;
    --grass-mid: #3d6834;
    --grass-dark: #2d4f27;

    /* Text */
    --text-bright: #cccccc;
    --text-dim: #666666;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 13px;
    color: var(--text-bright);
    background: linear-gradient(180deg, #1a2a1a 0%, #0d1a0d 100%);
}

/* === Mobile Warning === */
#mobile-warning {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

#mobile-warning.hidden { display: none; }

#mobile-warning-content {
    background: linear-gradient(180deg, #3d2817 0%, #2d1807 100%);
    border: 4px solid #6b4423;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.mobile-warning-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

#mobile-warning-content h2 {
    color: var(--glow-amber);
    font-size: 20px;
    margin-bottom: 12px;
}

#mobile-warning-content p {
    color: #c4a882;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 8px;
}

#mobile-warning-dismiss {
    margin-top: 16px;
    background: #5a3d2a;
    border-color: #7a5a40;
    color: #e8d5c4;
}

#mobile-warning-dismiss:hover {
    background: #6a4d3a;
}

/* ===================================================================
   MAIN LAYOUT - All Flexbox
   =================================================================== */

/* Game container - column layout */
#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: var(--space-sm);
    gap: var(--space-sm);
}

/* Main row - contains left content + resources */
#main-row {
    display: flex;
    flex-direction: row;
    flex: 1;
    gap: var(--space-sm);
    min-height: 0; /* Important for nested flex overflow */
}

/* Left content - contains top controls + main area */
#left-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: var(--space-sm);
    min-width: 0; /* Important for nested flex overflow */
}

/* Top controls row - status, inventory, crafting, time/menu */
#top-controls {
    display: flex;
    flex-direction: row;
    gap: var(--space-sm);
    align-items: stretch;
}

/* Main area row - left panels + center view */
#main-area {
    display: flex;
    flex-direction: row;
    flex: 1;
    gap: var(--space-sm);
    min-height: 0;
}

/* Left panels column - home + explore */
#left-panels {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: 160px;
    flex-shrink: 0;
}

/* ===================================================================
   STATUS PANEL
   =================================================================== */
#status-bars {
    width: 200px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #1c1c1c 0%, #141414 100%);
    border: 2px solid #333;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
}

#status-bars .panel-header {
    background: #222;
    padding: var(--space-xs) var(--space-sm);
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 2px;
    color: var(--glow-green);
    border-bottom: 1px solid #333;
}

#status-bars .panel-body {
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.bar-label {
    width: 28px;
    font-size: 9px;
    font-weight: bold;
    color: var(--text-dim);
}

.bar-container {
    flex: 1;
    height: 12px;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 2px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

#health-bar .bar-fill { background: var(--bar-health); }
#saturation-bar .bar-fill { background: var(--bar-saturation); }
#hydration-bar .bar-fill { background: var(--bar-hydration); }
#warmth-bar .bar-fill { background: var(--bar-warmth); }
#stamina-bar .bar-fill { background: var(--bar-stamina); }

.bar-value {
    width: 36px;
    font-size: 10px;
    text-align: right;
    color: #888;
}

.bar-fill.critical { animation: critical-flash 0.3s infinite; }
.bar-fill.warning { animation: warning-pulse 1s infinite; }

@keyframes critical-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes warning-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===================================================================
   INVENTORY TABS
   =================================================================== */
#inventory-equipment-tabs {
    flex: 1;
    max-width: 300px;
    min-width: 200px;
    background: #0d0d0d;
    border: 2px solid #444;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
}

#inventory-equipment-tabs .panel-header.tabbed {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: #1a1a1a;
    border-bottom: 1px solid #444;
}

.tab-button {
    padding: 4px 10px;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 2px;
    color: #999;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
}

.tab-button.active {
    background: #2a2a2a;
    color: #fff;
    border-color: var(--glow-green);
}

.collapse-btn {
    width: 20px;
    height: 20px;
    margin-left: auto;
    background: #1a1a1a;
    border: 1px solid #555;
    border-radius: 2px;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn:hover {
    background: #2a2a2a;
    color: #fff;
}

#inventory-tab-content {
    padding: var(--space-sm);
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: #0a0a0a;
}

#inventory-tab-content.collapsed {
    flex: 0;
    padding: 0;
    overflow: hidden;
}

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

.tab-panel.hidden { display: none; }

.inventory-slot {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #151515;
    border: 1px solid #3a3a3a;
    border-radius: 3px;
    font-size: 11px;
}

.inventory-slot.usable {
    cursor: pointer;
    border-color: #4a6a4a;
}

.inventory-slot.usable:hover {
    background: #1a2a1a;
    border-color: var(--glow-green);
    box-shadow: 0 0 6px rgba(0, 255, 65, 0.3);
}

.item-icon { font-size: 12px; }
.item-name { color: #ddd; }
.item-quantity { color: #888; font-size: 10px; }

/* ===================================================================
   CRAFTING PANEL - Beige with expandable body
   =================================================================== */
#crafting-panel {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #2a2418 0%, #1a1810 100%);
    border: 2px solid #4a3a28;
    border-radius: 4px;
    transition: flex 0.2s ease;
}

/* When expanded, panel takes more vertical space */
#crafting-panel.expanded {
    flex: 2;
}

.crafting-header {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px var(--space-sm);
    background: linear-gradient(180deg, #3a2a18 0%, #2a2010 100%);
    border-bottom: 1px solid #4a3a28;
    flex-shrink: 0;
}

.crafting-title {
    font-size: 9px;
    font-weight: bold;
    color: #c4a060;
    letter-spacing: 1px;
    white-space: nowrap;
}

#crafting-methods {
    display: flex;
    gap: 2px;
    flex: 1;
}

.craft-method {
    padding: 2px 6px;
    background: #1a1510;
    border: 1px solid #3a2a18;
    border-radius: 2px;
    font-size: 9px;
    font-weight: bold;
    color: #8a7050;
    cursor: pointer;
    transition: all 0.1s ease;
}

.craft-method:hover {
    background: #2a2018;
    color: #b08060;
}

.craft-method.active {
    background: #3a2a18;
    color: #d4a870;
    border-color: #5a4a30;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}

.craft-method.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

.crafting-expand-btn {
    width: 18px;
    height: 18px;
    background: #1a1510;
    border: 1px solid #3a2a18;
    border-radius: 2px;
    color: #8a7050;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.crafting-expand-btn:hover:not(:disabled) {
    background: #2a2018;
    color: #d4a870;
}

.crafting-expand-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

#crafting-panel.expanded .crafting-expand-btn {
    /* Show minus when expanded */
}

#crafting-panel.expanded .crafting-expand-btn::after {
    content: '−';
}

#crafting-panel:not(.expanded) .crafting-expand-btn::after {
    content: '+';
}

/* Hide the text content of button, use ::after for symbol */
.crafting-expand-btn {
    font-size: 0;
}

.crafting-expand-btn::after {
    font-size: 12px;
}

/* Crafting body - shows recipes */
#crafting-body {
    flex: 1;
    min-height: 0;
    padding: var(--space-xs);
    overflow-y: auto;
    background: #151210;
}

#recipe-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-content: flex-start;
}

.recipe-item {
    padding: 4px 8px;
    background: #1a1510;
    border: 1px solid #3a2a18;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

/* Craftable items glow */
.recipe-item.craftable {
    border-color: #6a5030;
    box-shadow: 0 0 8px rgba(210, 160, 80, 0.4), inset 0 0 4px rgba(210, 160, 80, 0.1);
    animation: craftable-glow 2s ease-in-out infinite;
}

@keyframes craftable-glow {
    0%, 100% { box-shadow: 0 0 6px rgba(210, 160, 80, 0.3), inset 0 0 3px rgba(210, 160, 80, 0.1); }
    50% { box-shadow: 0 0 12px rgba(210, 160, 80, 0.5), inset 0 0 6px rgba(210, 160, 80, 0.2); }
}

.recipe-item.craftable:hover {
    background: #2a2018;
    transform: translateY(-1px);
    box-shadow: 0 0 14px rgba(210, 160, 80, 0.6), 0 4px 8px rgba(0,0,0,0.3);
}

.recipe-item.unavailable {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    animation: none;
}

.recipe-item.unavailable:hover {
    transform: none;
    box-shadow: none;
    background: #1a1510;
}

.recipe-name {
    font-size: 9px;
    font-weight: bold;
    color: #c4a060;
    display: block;
}

.recipe-item.unavailable .recipe-name {
    color: #6a5040;
}

.recipe-ingredients {
    font-size: 8px;
    color: #8a7050;
    display: block;
    margin-top: 1px;
}

.recipe-empty {
    color: #5a4a3a;
    font-size: 10px;
    padding: var(--space-xs);
    text-align: center;
    width: 100%;
}

/* ===================================================================
   TIME AND MENU - Column on far right of top controls
   =================================================================== */
#time-menu {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex-shrink: 0;
    position: relative;
}

#time-display {
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 4px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-label {
    font-size: 9px;
    color: #666;
}

.time-value {
    font-size: 12px;
    font-weight: bold;
    color: var(--glow-gold);
}

#menu-buttons {
    display: flex;
    gap: 4px;
}

.menu-btn {
    flex: 1;
    padding: 4px 8px;
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 4px;
    color: #aaa;
    font-size: 9px;
    font-weight: bold;
    cursor: pointer;
}

.menu-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

/* Settings Dropdown - Marble/Chinese teaware style */
#settings-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    z-index: 500;
    min-width: 150px;
}

#settings-dropdown.hidden {
    display: none;
}

.settings-dropdown-content {
    background: linear-gradient(180deg, #f8f9fc 0%, #e8eef8 50%, #d8e4f4 100%);
    border: 2px solid #a8c4e8;
    border-radius: 6px;
    padding: var(--space-sm);
    box-shadow:
        0 4px 16px rgba(100, 150, 200, 0.3),
        0 0 20px rgba(150, 200, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    animation: dropdown-glow 2s ease-in-out infinite;
}

@keyframes dropdown-glow {
    0%, 100% { box-shadow: 0 4px 16px rgba(100, 150, 200, 0.3), 0 0 20px rgba(150, 200, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.8); }
    50% { box-shadow: 0 4px 20px rgba(100, 150, 200, 0.4), 0 0 30px rgba(150, 200, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.9); }
}

.settings-option {
    padding: 4px 0;
}

.settings-option label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    color: #2a4a6a;
    font-size: 11px;
    font-weight: 500;
}

.settings-option input[type="checkbox"] {
    accent-color: #4a8ac8;
}

/* Version Indicator */
#version-indicator {
    font-size: 8px;
    color: #555;
    text-align: center;
    margin-top: auto;
    padding-top: 2px;
}

/* ===================================================================
   HOME PANEL - Warm brown style
   =================================================================== */
#home-panel {
    background: linear-gradient(180deg, var(--home-bg-light) 0%, var(--home-bg) 100%);
    border: 3px solid var(--home-border);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.1);
}

#home-panel .panel-header {
    background: var(--home-border);
    padding: var(--space-xs) var(--space-sm);
    font-size: 11px;
    font-weight: bold;
    color: var(--home-text);
    border-radius: 5px 5px 0 0;
    text-align: center;
}

#home-panel .panel-body {
    padding: var(--space-sm);
}

.home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.home-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: linear-gradient(180deg, #5a4030 0%, #4a3020 100%);
    border: 2px solid #7a5a40;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.1s ease;
}

.home-btn:hover {
    background: linear-gradient(180deg, #6a5040 0%, #5a4030 100%);
    border-color: #9a7a60;
}

.home-btn:active {
    transform: scale(0.95);
}

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

.home-btn-icon {
    font-size: 18px;
}

.home-btn-label {
    font-size: 9px;
    font-weight: bold;
    color: var(--home-text);
}

/* Progression phases */
#home-panel.phase-1 {
    background: linear-gradient(180deg, #3d2817 0%, #2d1807 100%);
}

#home-panel.phase-2 {
    background: linear-gradient(180deg, #4d3827 0%, #3d2817 100%);
    border-color: #8b5a2b;
}

#home-panel.phase-3 {
    background: linear-gradient(180deg, #5d4837 0%, #4d3827 100%);
    border-color: #a07040;
    box-shadow: inset 0 0 20px rgba(255, 200, 100, 0.1);
}

/* ===================================================================
   EXPLORE PANEL - Industrial style
   =================================================================== */
#explore-panel {
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 3px solid #3a3a3a;
    border-radius: 4px;
}

#explore-panel .panel-header {
    background: linear-gradient(90deg, #333 0%, #2a2a2a 100%);
    padding: var(--space-xs) var(--space-sm);
    font-size: 10px;
    font-weight: bold;
    color: var(--glow-amber);
    border-bottom: 2px solid #1a1a1a;
}

#explore-panel .panel-body {
    padding: var(--space-sm);
}

.explore-icon {
    display: inline-block;
    animation: walk 0.4s steps(2) infinite;
}

@keyframes walk {
    0% { transform: translateX(-1px); }
    50% { transform: translateX(1px); }
}

/* Rarity Selector */
#rarity-selector {
    margin-bottom: var(--space-sm);
    padding: var(--space-xs);
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
    border-radius: 2px;
}

.rarity-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.rarity-label {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border: 2px solid;
    border-radius: 2px;
    cursor: pointer;
}

.rarity-label.common { color: #888; border-color: #555; background: #1a1a1a; }
.rarity-label.uncommon { color: var(--glow-green); border-color: #2a5a2a; background: #0a1a0a; }
.rarity-label.rare { color: var(--glow-cyan); border-color: #2a4a5a; background: #0a1a2a; }
.rarity-label.ultimate { color: var(--glow-gold); border-color: #5a4a2a; background: #1a1a0a; }

.rarity-label.locked { opacity: 0.25; cursor: not-allowed; }
.rarity-label.active { transform: scale(1.1); box-shadow: 0 0 8px currentColor; }

#rarity-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #555 0%, #555 25%, #2a5a2a 25%, #2a5a2a 50%, #2a4a5a 50%, #2a4a5a 75%, #5a4a2a 75%);
    border-radius: 3px;
    margin: 6px 0;
}

#rarity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 14px;
    background: #4a4a4a;
    border: 1px solid #666;
    border-radius: 2px;
    cursor: pointer;
}

.rarity-info {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
}

#rarity-name { font-weight: bold; color: #888; }
#rarity-name.uncommon { color: var(--glow-green); }
#rarity-name.rare { color: var(--glow-cyan); }
#rarity-name.ultimate { color: var(--glow-gold); }

#rarity-cost { color: var(--bar-stamina); }
#rarity-cost.insufficient { color: var(--glow-red); }

/* Action button */
.btn {
    padding: 6px 12px;
    background: #3a3a3a;
    border: 2px solid #555;
    border-radius: 4px;
    color: #aaa;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
}

.btn:hover { background: #4a4a4a; color: #fff; }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.btn.primary {
    background: linear-gradient(180deg, #2a5a2a 0%, #1a4a1a 100%);
    border-color: #3a7a3a;
    color: var(--glow-green);
}

.btn.primary:hover {
    background: linear-gradient(180deg, #3a6a3a 0%, #2a5a2a 100%);
    color: #fff;
}

.action-btn {
    display: block;
    width: 100%;
    text-align: center;
}

/* ===================================================================
   CENTER VIEW - Grassy area
   =================================================================== */
#center-view {
    flex: 1;
    background: linear-gradient(180deg,
        #87CEEB 0%,
        #87CEEB 20%,
        var(--grass-light) 20%,
        var(--grass-mid) 60%,
        var(--grass-dark) 100%
    );
    border: 3px solid #2d4f27;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

/* Grass texture overlay */
#center-view::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 20px,
            rgba(0,0,0,0.03) 20px,
            rgba(0,0,0,0.03) 40px
        );
    pointer-events: none;
}

#world-display {
    display: flex;
    height: 100%;
    align-items: center;
    justify-content: center;
    position: relative;
}

.world-entities {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    max-height: 100%;
    overflow-y: auto;
}

#world-entities-left {
    align-items: flex-end;
}

#world-entities-right {
    align-items: flex-start;
}

#player-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-lg);
}

#player-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-sprite {
    font-size: 48px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* World entity icons */
.world-entity {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.world-entity:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    transform: scale(1.05);
}

.world-entity-icon {
    font-size: 24px;
}

.world-entity-name {
    font-size: 8px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
}

/* ===================================================================
   RESOURCES PANEL - Full height on right
   =================================================================== */
#resources-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #2a2a1a 0%, #1a1a0a 100%);
    border: 3px solid #4a4a2a;
    border-radius: 4px;
}

#resources-panel > .panel-header {
    background: #3a3a2a;
    padding: var(--space-xs) var(--space-sm);
    font-size: 10px;
    font-weight: bold;
    color: var(--glow-amber);
    border-bottom: 2px solid #2a2a1a;
}

#resource-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.resource-empty {
    color: #666;
    font-size: 11px;
    text-align: center;
    padding: var(--space-lg);
}

/* Individual resource card */
.resource-card {
    background: linear-gradient(180deg, #3a3a2a 0%, #2a2a1a 100%);
    border: 2px solid #5a5a3a;
    border-radius: 6px;
    overflow: hidden;
}

.resource-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: #4a4a3a;
    border-bottom: 1px solid #5a5a3a;
}

.resource-card-icon {
    font-size: 16px;
}

.resource-card-name {
    font-size: 11px;
    font-weight: bold;
    color: var(--glow-amber);
    flex: 1;
}

.resource-card-body {
    padding: var(--space-sm);
}

/* Resource yields within card */
.resource-yields {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: var(--space-sm);
}

.resource-yield {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 10px;
}

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

.resource-yield-name {
    flex: 1;
    color: #aaa;
}

.resource-yield-amount {
    color: #888;
    font-size: 9px;
}

.resource-yield-bar {
    width: 40px;
    height: 6px;
    background: #1a1a0a;
    border: 1px solid #3a3a2a;
    border-radius: 2px;
    overflow: hidden;
}

.resource-yield-fill {
    height: 100%;
    background: var(--glow-amber);
    transition: width 0.3s ease;
}

/* Resource actions */
.resource-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.resource-action-btn {
    flex: 1;
    min-width: 60px;
    padding: 4px 8px;
    background: #4a4a3a;
    border: 1px solid #6a6a4a;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    color: #ccc;
    cursor: pointer;
    text-align: center;
}

.resource-action-btn:hover {
    background: #5a5a4a;
    color: #fff;
}

.resource-action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.resource-card.depleted {
    opacity: 0.4;
}

.resource-card.depleted .resource-card-header {
    background: #3a3a3a;
}

/* ===================================================================
   CONSOLE - Fixed height, expandable over content
   =================================================================== */
#console-wrapper {
    position: relative;
    flex-shrink: 0;
    height: 100px; /* Fixed height for collapsed state */
}

#console-wrapper.expanded {
    height: 100px; /* Same base height, content expands upward */
}

#console {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0a0a0a;
    border: 2px solid #2a2a2a;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    height: 100px; /* Fixed default height showing several lines */
    transition: height 0.2s ease;
    z-index: 50;
}

#console-wrapper.expanded #console {
    height: 300px; /* Expanded height */
    z-index: 300; /* Above other content */
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
}

#console .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    background: #1a1a1a;
    border-bottom: 1px solid #2a2a2a;
    font-size: 10px;
    font-weight: bold;
    color: var(--glow-green);
    min-height: 24px;
    flex-shrink: 0;
}

.console-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.expand-btn {
    width: 20px;
    height: 20px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 2px;
    color: #888;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.expand-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

#console-wrapper.expanded .expand-btn {
    transform: rotate(180deg);
}

#console-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

#console-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-sm);
    font-size: 11px;
    line-height: 1.4;
    min-height: 0;
}

.console-message {
    padding: 1px 0;
}

.console-message .timestamp {
    color: #336633;
    margin-right: var(--space-sm);
}

.console-message.info { color: #669966; }
.console-message.success { color: var(--glow-green); }
.console-message.warning { color: var(--glow-amber); }
.console-message.danger { color: var(--glow-red); }
.console-message.special { color: var(--glow-cyan); }

/* Console input */
#console-input-container {
    display: flex;
    align-items: center;
    padding: 4px var(--space-sm);
    background: #050505;
    border-top: 1px solid #1a1a1a;
    position: relative;
    flex-shrink: 0;
}

.input-prompt {
    font-size: 12px;
    font-weight: bold;
    color: var(--glow-green);
    margin-right: var(--space-sm);
}

#console-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 11px;
    color: var(--glow-green);
}

#console-input::placeholder {
    color: #2a4a2a;
}

#console-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: #0a0a0a;
    border: 1px solid var(--glow-green);
    border-bottom: none;
    max-height: 150px;
    overflow-y: auto;
    z-index: 100;
}

#console-suggestions.hidden { display: none; }

.suggestion-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    font-size: 10px;
    cursor: pointer;
    border-bottom: 1px solid #1a1a1a;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: rgba(0, 255, 65, 0.15);
}

.suggestion-text { color: var(--glow-green); }
.suggestion-desc { color: #446644; font-size: 9px; }

/* ===================================================================
   EXPLORATION OVERLAY
   =================================================================== */
#exploration-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#exploration-overlay.hidden { display: none; }

.exploration-frame {
    min-width: 320px;
    background: linear-gradient(180deg, #2a3a2a 0%, #1a2a1a 100%);
    border: 4px solid #3a5a3a;
    border-radius: 8px;
    text-align: center;
}

.exploration-frame .panel-header {
    background: #3a5a3a;
    padding: var(--space-sm);
    font-size: 14px;
    font-weight: bold;
    color: var(--glow-green);
    border-radius: 4px 4px 0 0;
}

.explore-walking {
    display: inline-block;
    animation: walk-big 0.3s steps(2) infinite;
}

@keyframes walk-big {
    0% { transform: translateX(-2px) scaleX(1); }
    50% { transform: translateX(2px) scaleX(-1); }
}

.exploration-frame .panel-body {
    padding: var(--space-lg);
}

#rolling-container {
    margin: var(--space-md) 0;
    padding: var(--space-lg);
    background: #0a1a0a;
    border: 3px solid #1a3a1a;
    border-radius: 4px;
}

#rolling-number {
    font-size: 60px;
    font-weight: bold;
    color: var(--glow-green);
    text-shadow: 0 0 20px var(--glow-green);
    letter-spacing: 6px;
}

#rolling-number.match {
    color: var(--glow-gold);
    text-shadow: 0 0 30px var(--glow-gold);
    animation: match-flash 0.2s ease 3;
}

@keyframes match-flash {
    50% { opacity: 0.5; }
}

#target-display {
    font-size: 12px;
    color: #666;
    margin-bottom: var(--space-sm);
}

#target-number {
    color: var(--glow-cyan);
    font-weight: bold;
}

#exploration-status {
    font-size: 11px;
    color: #666;
    margin-bottom: var(--space-sm);
    min-height: 16px;
}

#exploration-status.success {
    color: var(--glow-green);
    font-weight: bold;
}

#exploration-status.failure {
    color: var(--glow-red);
}

#exploration-progress {
    height: 8px;
    background: #0a1a0a;
    border: 1px solid #1a3a1a;
    border-radius: 4px;
    overflow: hidden;
}

#exploration-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--glow-green) 0%, var(--glow-gold) 100%);
    width: 0%;
    transition: width 0.1s linear;
}

/* ===================================================================
   ENTITY POPUP
   =================================================================== */
#entity-popup {
    position: fixed;
    z-index: 1500;
    pointer-events: none;
}

#entity-popup.hidden { display: none; }

#entity-popup-content {
    background: linear-gradient(180deg, #3a3a2a 0%, #2a2a1a 100%);
    border: 2px solid #5a5a3a;
    border-radius: 6px;
    padding: var(--space-sm);
    min-width: 150px;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.popup-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid #4a4a3a;
    margin-bottom: var(--space-sm);
}

.popup-icon { font-size: 20px; }
.popup-name { font-size: 12px; font-weight: bold; color: var(--glow-amber); }

.popup-yields {
    margin-bottom: var(--space-sm);
}

.popup-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ===================================================================
   MODAL
   =================================================================== */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

#modal-overlay.hidden { display: none; }

#modal-content {
    min-width: 300px;
    max-width: 400px;
    background: #2a2a2a;
    border: 3px solid #4a4a4a;
    border-radius: 8px;
}

#modal-content .panel-body {
    padding: var(--space-lg);
}

#modal-content h2 {
    font-size: 14px;
    color: var(--glow-amber);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid #4a4a4a;
}

#modal-content p {
    margin-bottom: var(--space-md);
    line-height: 1.5;
    color: #aaa;
}

.entity-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

.close-modal {
    margin-top: var(--space-md) !important;
}

.settings-section {
    margin-bottom: var(--space-md);
}

.settings-section label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    color: #aaa;
}

.save-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid #4a4a4a;
    margin-top: var(--space-md);
}

.btn.danger {
    background: #4a2a2a;
    border-color: #6a3a3a;
    color: var(--glow-red);
}

/* ===================================================================
   SAVES MODAL - 5 Save Slots
   =================================================================== */
.saves-modal-content {
    min-width: 400px;
}

.saves-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid #4a4a4a;
}

.saves-header h2 {
    color: var(--glow-amber);
    font-size: 14px;
    margin: 0;
    border: none;
    padding: 0;
}

.saves-version {
    font-size: 10px;
    color: #666;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 3px;
}

.save-slots {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.save-slot {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.save-slot:hover {
    border-color: #555;
    background: #222;
}

.save-slot.active {
    border-color: var(--glow-green);
    background: rgba(0, 255, 65, 0.05);
}

.save-slot-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: #888;
    flex-shrink: 0;
}

.save-slot.has-data .save-slot-number {
    background: var(--glow-green);
    color: #000;
}

.save-slot-info {
    flex: 1;
    min-width: 0;
}

.save-slot-title {
    font-size: 11px;
    font-weight: bold;
    color: #ccc;
}

.save-slot-empty {
    font-size: 11px;
    color: #555;
    font-style: italic;
}

.save-slot-meta {
    font-size: 9px;
    color: #666;
    margin-top: 2px;
}

.save-slot-version {
    font-size: 8px;
    color: #555;
    margin-left: var(--space-sm);
}

.save-slot-version.outdated {
    color: var(--glow-amber);
}

.save-slot-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.save-slot-btn {
    padding: 4px 8px;
    background: #333;
    border: 1px solid #444;
    border-radius: 3px;
    font-size: 9px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.save-slot-btn:hover {
    background: #444;
    color: #fff;
}

.save-slot-btn.save {
    background: #2a4a2a;
    border-color: #3a5a3a;
    color: var(--glow-green);
}

.save-slot-btn.load {
    background: #2a3a4a;
    border-color: #3a4a5a;
    color: var(--glow-cyan);
}

.save-slot-btn.delete {
    background: #4a2a2a;
    border-color: #5a3a3a;
    color: var(--glow-red);
}

.save-slot-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===================================================================
   SCROLLBARS
   =================================================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 1000px) {
    #top-controls {
        flex-wrap: wrap;
    }

    #crafting-drawer {
        order: 10;
        width: 100%;
        flex: none;
    }
}

@media (max-width: 768px) {
    #main-row {
        flex-direction: column;
    }

    #resources-panel {
        width: 100%;
        max-height: 200px;
    }

    #main-area {
        flex-direction: column;
    }

    #left-panels {
        flex-direction: row;
        width: 100%;
    }
}
