:root {
    /* Palette Corporate "Premium" (Début) */
    --bg-color: #f4f6f8;
    --sidebar-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    --accent-primary: #0056b3;
    /* Bleu Conseil sérieux */
    --accent-secondary: #17a2b8;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --message-color: #c0392b;
    /* Rouge pour les messages de pression */
    --font-main: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Consolas', monospace;
    --border-color: #e9ecef;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* Mode "Singularité" (Activé via JS plus tard) */
body.mode-dark {
    --bg-color: #0f1115;
    --sidebar-bg: #161b22;
    --text-main: #e6edf3;
    --text-muted: #8b949e;
    --accent-primary: #58a6ff;
    --message-color: #ff6b6b;
    --border-color: #30363d;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 1s ease, color 1s ease;
}

/* --- HEADER --- */
header {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    z-index: 10;
    flex-shrink: 0;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand span {
    color: var(--accent-primary);
}

.kpi-ticker {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- LAYOUT --- */
main {
    display: grid;
    grid-template-columns: 320px 280px 1fr;
    /* Smaller center, wider right */
    flex-grow: 1;
    overflow: hidden;
}

/* --- COLUMNS --- */
.panel {
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-right: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    transition: background 1s, border-color 1s;
}

.panel-center {
    background: var(--bg-color);
    border-right: 1px solid var(--border-color);
    align-items: center;
    justify-content: flex-start;
    padding-top: 2rem;
    /* Reduced from 3rem */
    position: relative;
}

/* --- LEFT COLUMN: METRICS --- */
.metric-card {
    background: var(--bg-color);
    padding: 1.2rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-primary);
}

.metric-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0.5rem 0;
    font-family: var(--font-mono);
}

.metric-delta {
    font-size: 0.8rem;
    color: var(--success-color);
}

/* Jauges */
.gauge-container {
    margin-top: auto;
}

.gauge-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.gauge-bg {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    background: var(--accent-primary);
    width: 100%;
    transition: width 0.5s, background 0.5s;
}

/* --- CENTER: CORE INTERACTION --- */
#action-btn {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    outline: none;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

#action-btn:active {
    transform: scale(0.96);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.btn-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.btn-icon {
    font-size: 2rem;
    color: var(--accent-primary);
}

/* Click Floating Text */
.floater {
    position: absolute;
    font-weight: bold;
    color: var(--success-color);
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    font-family: var(--font-mono);
    z-index: 50;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.2);
        opacity: 0;
    }
}

#log-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 280px;
    padding: 1rem 2rem;
    overflow-y: hidden;
    border-top: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column-reverse;
    mask-image: linear-gradient(to bottom, transparent, black 10%);
}

.log-entry {
    font-size: 0.85rem;
    margin-bottom: 6px;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
    color: var(--text-muted);
    animation: slideIn 0.3s ease;
}

.log-entry.urgent {
    border-color: var(--danger-color);
    color: var(--text-main);
    font-weight: 600;
}

/* Nouveaux styles narratifs */
.log-entry.pressure {
    border-color: var(--message-color);
    color: var(--message-color);
    font-style: italic;
    background: rgba(255, 0, 0, 0.05);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- RIGHT: STRATEGY & UPGRADES --- */
.section-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.upgrade-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    position: relative;
}

.upgrade-card:not(.locked):hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    transition: all 0.2s;
}

.upgrade-card.locked {
    opacity: 0.6;
    background: #f8f9fa;
    cursor: not-allowed;
}

/* Teased upgrades (visible but not affordable/unlocked fully yet) */
.upgrade-card.teased {
    opacity: 0.8;
    background: var(--bg-color);
    border-style: solid;
    cursor: not-allowed;
}

.upgrade-card.teased .up-cost {
    color: var(--danger-color);
}


.up-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.up-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.up-cost {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-primary);
    font-weight: 700;
}

.up-count {
    background: var(--border-color);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 8px;
}

.up-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* --- MODALS --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: white;
    padding: 2.5rem;
    width: 550px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    border-top: 4px solid var(--accent-primary);
}

body.mode-dark .modal-box {
    background: #161b22;
    color: #e6edf3;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.up-roi {
    font-size: 0.85rem;
    color: var(--success-color);
    margin-top: 6px;
    font-weight: 700;
    background: rgba(40, 167, 69, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
}

/* Responsive */
@media (max-width: 1000px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        overflow-y: auto;
        height: 100vh;
    }

    .panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: auto;
        max-height: none;
        padding: 1rem;
        flex-shrink: 0;
        /* Prevent shrinking */
    }

    /* Reorder for mobile: Center (Action) -> Left (Stats) -> Right (Upgrades) */
    #panel-center {
        order: 1;
        padding: 1.5rem 0;
        border-bottom: 1px solid var(--border-color);
    }

    #panel-left {
        order: 2;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    #panel-right {
        order: 3;
        padding-bottom: 6rem;
        overflow-y: visible;
    }

    /* Extra padding for scroll */

    .metric-card {
        margin-bottom: 0;
    }

    #log-area {
        position: relative;
        height: 120px;
        border-top: 1px solid var(--border-color);
        width: 100%;
        margin-top: 1rem;
    }

    #action-btn {
        width: 160px;
        height: 160px;
    }

    header {
        padding: 0 1rem;
        height: 50px;
    }

    .kpi-ticker {
        font-size: 0.65rem;
        text-align: right;
    }
}