* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-align: left;
    font-size: 14px;
}

:root {
    --blue: #174EA6;
    --red: #A50E0E;
    --orange: #E37400;
    --green: #0D652D;
    --medium-blue: #4285F4;
    --medium-red: #EA4335;
    --yellow: #FBBC04;
    --medium-green: #34A853;
    --light-blue: #D2E3FC;
    --light-red: #FAD2CF;
    --light-yellow: #FEEFC3;
    --light-green: #CEEAD6;
    --light-grey: #F1F3F4;
    --grey: #9AA0A6;
    --black: #202124;
}

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

body {
    font-family: 'Roboto', sans-serif;
    background: var(--black);
    color: var(--grey);
    font-weight: 400;
    overflow: hidden;
    line-height: 1.6;
}

*:focus-visible {
    outline: 2px solid var(--medium-blue);
    outline-offset: 2px;
}

.material-icons {
    vertical-align: middle;
    text-align: left;
}

.material-icons.inline-icon {
    vertical-align: middle;
    margin-right: 4px;
}

.game-container {
    display: flex;
    height: 100vh;
    background: var(--black);
}

.main-panel {
    flex: 1;
    background: var(--black);
    overflow-y: auto;
    padding: 10px;
}

.upgrades-panel {
    flex: 1;
    background: var(--black);
    border-left: 2px solid var(--red);
    /* Red dominant architecture core */
    overflow-y: auto;
    padding: 10px;
}

@media (max-width: 1200px) {
    .game-container {
        flex-direction: column;
    }

    .upgrades-panel {
        border-left: none;
        border-top: 2px solid var(--red);
    }
}

/* ----------------------------------
   Text colors
----------------------------------- */
.chaos-label,
.breakdown-label,
.breakdown-value,
.stat-label,
.stat-rate,
.escalate-text,
.escalate-sub,
.action-label,
.action-info,
.action-cost,
.action-effect,
.action-cd,
.action-efficiency,
.action-note,
.upgrade-name,
.upgrade-cost,
.upgrade-owned,
.upgrade-owned-big,
.tech-name,
.tech-effect,
.tech-hint {
    color: inherit;
}

.chaos-explainer,
.stat-explainer,
.escalate-help,
.actions-explainer,
.upgrades-explainer,
.tech-explainer,
.prestige-explainer {
    color: var(--grey);
    margin: 10px 0;
}

/* ----------------------------------
   Top Elements (Escalate button)
----------------------------------- */
.escalate-btn {
    width: 100%;
    background: var(--black);
    border: 1px solid var(--red);
    /* Red dominant action */
    color: var(--grey);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

/* FIX: Soft hover, no solid red background convulsions */
.escalate-btn:hover {
    border-color: var(--medium-red);
    box-shadow: inset 0 0 15px rgba(234, 67, 53, 0.15);
    /* Medium-red wash */
}

.escalate-btn:hover .escalate-help,
.escalate-btn:hover .material-icons,
.escalate-btn:hover .escalate-sub {
    color: var(--light-grey);
}

.escalate-btn:active {
    box-shadow: inset 0 0 30px rgba(234, 67, 53, 0.3);
}

.escalate-help {
    margin-top: 5px;
}

.charge-bar {
    width: 100%;
    height: 4px;
    background: #333333;
    margin: 5px 0;
}

.charge-bar-fill {
    height: 100%;
    background: var(--medium-red);
    width: 0%;
    transition: none;
}

/* ----------------------------------
   Chaos Display
----------------------------------- */
.chaos-display {
    border: 1px solid var(--red);
    padding: 10px;
    margin-bottom: 10px;
}

.chaos-value {
    color: var(--medium-red);
    font-weight: bold;
}

.chaos-rate {
    color: var(--red);
}

.breakdown-row {
    display: block;
}

/* ----------------------------------
   Stats Grid
----------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

.stat-card {
    border: 1px solid var(--yellow);
    /* Influence uses Yellow to differentiate from red Chaos */
    padding: 10px;
}

.stat-card .stat-value {
    color: var(--yellow);
    font-weight: bold;
}

.stat-card .stat-rate {
    color: var(--yellow);
}

/* SMART COLORING: Heat element isolated to Orange */
#heatCard {
    border: 1px solid var(--orange);
}

#heatCard .stat-value,
#heatCard .stat-rate,
#heatCard .heat-label {
    color: var(--orange);
}

.heat-bar {
    width: 100%;
    height: 4px;
    background: #333333;
    margin: 5px 0;
}

.heat-bar-fill {
    height: 100%;
    background: var(--orange);
    width: 0%;
    transition: width 0.3s;
}

/* Heat overload state */
.stat-card.heat-critical {
    border-color: var(--red);
    background: var(--red);
    color: var(--black);
}

.stat-card.heat-critical .stat-value,
.stat-card.heat-critical .stat-rate,
.stat-card.heat-critical .heat-label,
.stat-card.heat-critical .stat-explainer {
    color: var(--black);
}

.stat-card.heat-critical .heat-bar-fill {
    background: var(--black);
}

.stat-card.heat-critical .material-icons {
    color: var(--black);
}

/* ----------------------------------
   Actions (Abilities) Grid
----------------------------------- */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .actions-grid {
        grid-template-columns: 1fr;
    }
}

.action-btn {
    background: var(--black);
    color: var(--grey);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--yellow);
    /* Abilities consume Influence */
}

.action-btn .material-icons {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--yellow);
}

/* FIX: Subtle hover, no bright solid background. */
.action-btn:hover:not(:disabled) {
    border-color: var(--light-yellow);
    color: var(--light-grey);
    box-shadow: inset 0 0 10px rgba(251, 188, 4, 0.1);
}

.action-btn:active:not(:disabled) {
    box-shadow: inset 0 0 20px rgba(251, 188, 4, 0.2);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #444;
}

.action-btn:disabled .material-icons {
    color: #444;
}

/* ----------------------------------
   Upgrades Array (Chaos Cost -> Red)
----------------------------------- */
.upgrade-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.upgrade-item {
    background: var(--black);
    border: 1px solid #444;
    padding: 10px;
    margin: 0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--grey);
    aspect-ratio: 1;
    /* Makes it perfectly square */
}

.upgrade-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
    width: 100%;
}

.upgrade-icon {
    font-size: 32px !important;
    color: #444;
}

.upgrade-owned-big {
    font-size: 24px !important;
    font-weight: bold;
    color: #444;
}

.upgrade-name {
    font-size: 13px !important;
    font-weight: bold;
    margin-bottom: 5px;
    line-height: 1.2;
    min-height: 31px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upgrade-cost {
    font-size: 14px !important;
    color: var(--grey);
}

.upgrade-item.affordable {
    border-color: var(--red);
}

.upgrade-item.affordable .upgrade-icon {
    color: var(--medium-red);
}

.upgrade-item.affordable .upgrade-owned-big {
    color: var(--light-red);
}

/* Smooth hover without flashing the background to bright red */
.upgrade-item.affordable:hover {
    border-color: var(--medium-red);
    box-shadow: inset 0 0 15px rgba(234, 67, 53, 0.15);
}

.upgrade-item.affordable:hover .upgrade-icon,
.upgrade-item.affordable:hover .upgrade-name,
.upgrade-item.affordable:hover .upgrade-owned-big {
    color: var(--light-red);
}

.upgrade-item.affordable:active {
    box-shadow: inset 0 0 30px rgba(234, 67, 53, 0.3);
}

.upgrade-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #444;
}

/* ----------------------------------
   Tech Upgrades (Influence Cost -> Yellow)
----------------------------------- */
.tech-item {
    background: var(--black);
    border: 1px solid #444;
    padding: 10px;
    margin: 5px 0;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--grey);
}

.tech-item:not(.disabled):not(.unlocked) {
    border-color: var(--yellow);
}

.tech-item:not(.disabled):not(.unlocked):hover {
    border-color: var(--light-yellow);
    box-shadow: inset 0 0 10px rgba(251, 188, 4, 0.15);
}

.tech-item.unlocked {
    background: rgba(251, 188, 4, 0.15);
    border-color: var(--yellow);
    color: var(--light-yellow);
    cursor: default;
}

.tech-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    border-color: #444;
}

@keyframes tech-flash {
    0% {
        background: var(--light-yellow);
        border-color: var(--light-yellow);
        color: var(--black);
    }

    100% {
        background: rgba(251, 188, 4, 0.15);
        border-color: var(--yellow);
        color: var(--light-yellow);
    }
}

.tech-item.tech-flash {
    animation: tech-flash 0.7s ease-out;
}

/* ----------------------------------
   Prestige Section
----------------------------------- */
.prestige-box {
    background: var(--black);
    border: 1px solid var(--medium-green);
    padding: 10px;
    margin-top: 20px;
}

.prestige-info {
    display: block;
}

.prestige-label,
.prestige-value {
    color: var(--medium-green);
    font-weight: bold;
}

.prestige-stats {
    background: var(--black);
    border: 1px dashed var(--medium-green);
    padding: 10px;
    margin: 10px 0;
}

.prestige-stat-row,
.prestige-stat-row span {
    color: var(--grey);
}

.prestige-btn {
    width: 100%;
    background: var(--black);
    border: 1px solid var(--medium-green);
    color: var(--medium-green);
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.prestige-btn:hover:not(:disabled) {
    border-color: var(--light-green);
    box-shadow: inset 0 0 15px rgba(52, 168, 83, 0.2);
    color: var(--light-green);
}

.prestige-btn:active:not(:disabled) {
    box-shadow: inset 0 0 30px rgba(52, 168, 83, 0.4);
}

.prestige-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #444;
    color: #444;
}

.prestige-warning {
    color: var(--medium-red);
    margin-top: 10px;
}

/* ----------------------------------
   Miscellaneous
----------------------------------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--black);
}

::-webkit-scrollbar-thumb {
    background: var(--red);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--medium-red);
}

.info-badge,
.info-badge-inline {
    display: inline-block;
    background: var(--black);
    color: var(--grey);
    border: 1px solid var(--grey);
    width: 16px;
    height: 16px;
    line-height: 14px;
    border-radius: 50%;
    cursor: help;
    margin-left: 6px;
    text-align: center;
}

.info-badge:hover,
.info-badge-inline:hover {
    border-color: var(--light-grey);
    color: var(--light-grey);
}

@keyframes float-up {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-40px);
        opacity: 0;
    }
}

.click-feedback {
    position: fixed;
    pointer-events: none;
    color: var(--red);
    font-weight: bold;
    animation: float-up 0.8s ease-out;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}