@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700&display=swap');

/* ── CRT / Scanline Overlay ────────────────────────────────── */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 9999;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.45) 100%);
    pointer-events: none;
    z-index: 9998;
}

/* ── Base ───────────────────────────────────────────────────── */
body {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    background-color: #0a0a0a;
    color: #00ff00;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

* {
    box-sizing: border-box;
}

/* ── Container ─────────────────────────────────────────────── */
.container {
    max-width: 860px;
    margin: 0 auto;
}

/* ── Header ────────────────────────────────────────────────── */
.header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.header h1 {
    font-family: 'Orbitron', 'Share Tech Mono', monospace;
    font-size: 2.4em;
    font-weight: 700;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: #00ff00;
    text-shadow:
        0 0 7px #00ff00,
        0 0 20px #00ff0088,
        0 0 42px #00ff0044;
    margin: 0 0 4px 0;
    animation: headerPulse 4s ease-in-out infinite;
}

.header .subtitle {
    font-size: 0.75em;
    color: #00aa00;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0.8;
}

@keyframes headerPulse {
    0%, 100% { text-shadow: 0 0 7px #00ff00, 0 0 20px #00ff0088, 0 0 42px #00ff0044; }
    50%      { text-shadow: 0 0 10px #00ff00, 0 0 30px #00ff00aa, 0 0 60px #00ff0066; }
}

/* ── Resource Bar ──────────────────────────────────────────── */
.resources {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    padding: 12px;
    background: linear-gradient(135deg, #111 0%, #1a1a1a 100%);
    border: 1px solid #003300;
    border-radius: 6px;
    margin-bottom: 0;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.stat {
    font-size: 0.95em;
    font-weight: bold;
    text-align: center;
    padding: 8px 6px;
    border: 1px solid #004d00;
    border-radius: 4px;
    background-color: #0d0d0d;
    transition: border-color 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.stat:hover {
    border-color: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.2);
}

/* Resource-specific accent colors */
.stat-computers { color: #00ffff; border-color: #004d4d; }
.stat-computers:hover { border-color: #00ffff; box-shadow: 0 0 8px rgba(0, 255, 255, 0.2); }
.stat-money { color: #ffff00; border-color: #4d4d00; }
.stat-money:hover { border-color: #ffff00; box-shadow: 0 0 8px rgba(255, 255, 0, 0.2); }
.stat-ram { color: #ff66ff; border-color: #4d004d; }
.stat-ram:hover { border-color: #ff66ff; box-shadow: 0 0 8px rgba(255, 102, 255, 0.2); }
.stat-cpu { color: #ff8844; border-color: #4d2200; }
.stat-cpu:hover { border-color: #ff8844; box-shadow: 0 0 8px rgba(255, 136, 68, 0.2); }
.stat-storage { color: #44aaff; border-color: #002244; }
.stat-storage:hover { border-color: #44aaff; box-shadow: 0 0 8px rgba(68, 170, 255, 0.2); }

.stat .stat-label {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    display: block;
    margin-bottom: 2px;
}

.stat .stat-value {
    font-size: 1.2em;
}

.stat .stat-rate {
    font-size: 0.65em;
    opacity: 0.5;
    display: block;
    margin-top: 2px;
}

/* ── Income Bar ────────────────────────────────────────────── */
.income-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 6px 12px;
    margin-bottom: 20px;
    font-size: 0.78em;
    color: #008800;
    letter-spacing: 1px;
    border-bottom: 1px solid #1a2a1a;
}

.income-bar span {
    opacity: 0.8;
}

/* ── Main Layout ───────────────────────────────────────────── */
.main-section {
    display: grid;
    grid-gap: 16px;
    grid-template-columns: 1fr 1fr;
}

.production-section {
    grid-column: 1 / -1;
}

/* ── Section Panels ────────────────────────────────────────── */
.production-section,
.automation-section,
.upgrades-section,
.resources-section {
    background: linear-gradient(180deg, #151515 0%, #111 100%);
    padding: 18px;
    border-radius: 6px;
    border: 1px solid #1a2a1a;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Section unlock animation */
.section-unlocking {
    animation: sectionUnlock 0.6s ease-out;
}

@keyframes sectionUnlock {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

h2 {
    margin: 0 0 8px 0;
    font-family: 'Orbitron', monospace;
    font-size: 1em;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #00cc00;
    text-shadow: 0 0 6px #00ff0044;
    border-bottom: 1px solid #1a2a1a;
    padding-bottom: 8px;
}

/* ── Buttons: Base ─────────────────────────────────────────── */
.action-button,
.upgrade-button,
.resource-button {
    background: linear-gradient(180deg, #0a2a0a 0%, #041a04 100%);
    color: #00ff00;
    border: 1px solid #00aa00;
    padding: 10px 16px;
    margin: 2px;
    cursor: pointer;
    border-radius: 5px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.88em;
    transition: all 0.15s ease;
    width: auto;
    min-width: 200px;
    align-self: center;
    position: relative;
    overflow: hidden;
}

.action-button::after,
.upgrade-button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(0,255,0,0.06) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.action-button:hover::after,
.upgrade-button:hover::after {
    transform: translateX(100%);
}

.action-button:hover,
.upgrade-button:hover {
    background: linear-gradient(180deg, #0f3a0f 0%, #082808 100%);
    border-color: #00ff00;
    box-shadow: 0 0 12px rgba(0, 255, 0, 0.15), inset 0 0 12px rgba(0, 255, 0, 0.05);
}

.action-button:active,
.upgrade-button:active {
    background: linear-gradient(180deg, #1a4a1a 0%, #0f3a0f 100%);
    transform: scale(0.97);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.25);
}

/* Button click flash */
@keyframes buttonFlash {
    0%   { box-shadow: 0 0 5px rgba(0,255,0,0.3); }
    50%  { box-shadow: 0 0 25px rgba(0,255,0,0.5), inset 0 0 15px rgba(0,255,0,0.1); }
    100% { box-shadow: 0 0 5px rgba(0,255,0,0.3); }
}

.button-flash {
    animation: buttonFlash 0.3s ease-out;
}

/* ── Buttons: Disabled ─────────────────────────────────────── */
.action-button.disabled,
.upgrade-button.disabled,
.control-button.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #333;
    background: #0a0a0a;
    box-shadow: none;
}

.action-button.disabled:hover,
.upgrade-button.disabled:hover,
.control-button.disabled:hover {
    box-shadow: none;
    border-color: #333;
    background: #0a0a0a;
}

.action-button.disabled::after,
.upgrade-button.disabled::after {
    display: none;
}

/* ── Buttons: Resource (non-interactive label) ─────────────── */
.resource-button {
    cursor: default;
    pointer-events: none;
    min-width: 180px;
}

/* ── Manual Gathering ──────────────────────────────────────── */
.manual-gathering {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.manual-gathering .action-button {
    min-width: 150px;
}

/* ── Production Controls ───────────────────────────────────── */
.production-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 4px 0;
}

.control-button {
    background: linear-gradient(180deg, #0a2a0a 0%, #041a04 100%);
    color: #00ff00;
    border: 1px solid #00aa00;
    border-radius: 4px;
    width: 44px;
    height: 44px;
    cursor: pointer;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.4em;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.control-button:hover {
    background: linear-gradient(180deg, #0f3a0f 0%, #082808 100%);
    border-color: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.2);
}

.control-button:active {
    transform: scale(0.92);
    background: linear-gradient(180deg, #1a4a1a 0%, #0f3a0f 100%);
}

/* ── Small Text ────────────────────────────────────────────── */
.small {
    font-size: 0.8em;
    opacity: 0.8;
}

/* ── Hidden ────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Toast Notifications ───────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    font-family: 'Share Tech Mono', monospace;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 0.85em;
    pointer-events: auto;
    animation: toastIn 0.4s ease-out, toastOut 0.4s ease-in forwards;
    max-width: 320px;
    border: 1px solid;
}

.toast-unlock {
    background: rgba(0, 40, 0, 0.95);
    color: #00ff00;
    border-color: #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.toast-milestone {
    background: rgba(40, 40, 0, 0.95);
    color: #ffff00;
    border-color: #ffff00;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.3);
}

.toast-achievement {
    background: rgba(40, 0, 40, 0.95);
    color: #ff66ff;
    border-color: #ff66ff;
    box-shadow: 0 0 20px rgba(255, 102, 255, 0.3);
}

.toast-save {
    background: rgba(0, 20, 40, 0.9);
    color: #44aaff;
    border-color: #44aaff66;
    box-shadow: 0 0 10px rgba(68, 170, 255, 0.15);
    font-size: 0.75em;
    padding: 6px 14px;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px) scale(0.9); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    0%, 75% { opacity: 1; transform: translateX(0); }
    100%    { opacity: 0; transform: translateX(40px); }
}

/* ── Number Pop Animation ──────────────────────────────────── */
.number-pop {
    position: fixed;
    pointer-events: none;
    font-family: 'Share Tech Mono', monospace;
    font-weight: bold;
    font-size: 1.1em;
    z-index: 10001;
    animation: numberFloat 1s ease-out forwards;
    text-shadow: 0 0 8px currentColor;
}

@keyframes numberFloat {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(0.7); }
}

/* ── Welcome Back Modal ────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: linear-gradient(180deg, #151515 0%, #0a0a0a 100%);
    border: 1px solid #00ff00;
    border-radius: 8px;
    padding: 30px 40px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 255, 0, 0.2);
    animation: modalPop 0.4s ease-out;
}

.modal h2 {
    font-family: 'Orbitron', monospace;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 15px;
}

.modal p {
    font-size: 0.85em;
    color: #00cc00;
    line-height: 1.6;
    margin: 8px 0;
}

.modal .modal-dismiss {
    margin-top: 20px;
    background: linear-gradient(180deg, #0a2a0a 0%, #041a04 100%);
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 10px 30px;
    border-radius: 5px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal .modal-dismiss:hover {
    background: linear-gradient(180deg, #0f3a0f 0%, #082808 100%);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}

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

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Achievements Panel ────────────────────────────────────── */
.achievements-section {
    grid-column: 1 / -1;
    background: linear-gradient(180deg, #151515 0%, #111 100%);
    padding: 18px;
    border-radius: 6px;
    border: 1px solid #1a2a1a;
}

.achievements-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.achievement {
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.78em;
    color: #444;
    transition: all 0.4s ease;
    min-width: 120px;
    text-align: center;
}

.achievement.unlocked {
    color: #ffff00;
    border-color: #666600;
    background: linear-gradient(180deg, #1a1a00 0%, #111100 100%);
    box-shadow: 0 0 8px rgba(255, 255, 0, 0.1);
}

.achievement .ach-icon {
    font-size: 1.4em;
    display: block;
    margin-bottom: 4px;
}

.achievement .ach-name {
    display: block;
    font-weight: bold;
}

.achievement .ach-desc {
    display: block;
    font-size: 0.85em;
    opacity: 0.6;
    margin-top: 2px;
}

/* ── Debug Button ──────────────────────────────────────────── */
.debug-button {
    background-color: #400000;
    color: #ff0000;
    border: 2px solid #ff0000;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.8em;
    margin-top: 10px;
}

.debug-button:hover {
    background-color: #600000;
}

.debug-button.active {
    background-color: #800000;
}

/* ── Footer ────────────────────────────────────────────────── */
.footer {
    text-align: center;
    margin-top: 30px;
    padding: 12px;
    font-size: 0.7em;
    color: #333;
    letter-spacing: 1px;
    border-top: 1px solid #1a1a1a;
}

/* ── About Popup ──────────────────────────────────────────── */
.about-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 8px;
}

.about-link {
    background: none;
    border: none;
    color: #335533;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1em;
    cursor: pointer;
    letter-spacing: 1px;
    padding: 2px 6px;
    transition: color 0.2s, text-shadow 0.2s;
}

.about-link:hover {
    color: #00ff00;
    text-shadow: 0 0 6px #00ff0066;
}

.about-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    width: 300px;
    background: linear-gradient(180deg, #151515 0%, #0a0a0a 100%);
    border: 1px solid #00aa00;
    border-radius: 6px;
    padding: 18px 20px;
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.15), 0 0 60px rgba(0, 255, 0, 0.05);
    z-index: 200;
    animation: aboutPopIn 0.25s ease-out;
}

@keyframes aboutPopIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.about-popup .about-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.95em;
    font-weight: 700;
    color: #00ff00;
    text-shadow: 0 0 6px #00ff0044;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.about-popup .about-desc {
    font-size: 0.78em;
    color: #00aa00;
    line-height: 1.6;
    margin: 0 0 10px 0;
    opacity: 0.85;
}

.about-popup .about-credit {
    font-size: 0.78em;
    color: #00cc00;
    margin: 0 0 12px 0;
}

.about-popup .about-links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.75em;
}

.about-popup .about-links a {
    color: #008800;
    text-decoration: none;
    transition: color 0.2s, text-shadow 0.2s;
}

.about-popup .about-links a:hover {
    color: #00ff00;
    text-shadow: 0 0 6px #00ff0044;
}

.about-popup .about-links span {
    color: #333;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 800px) {
    .main-section {
        grid-template-columns: 1fr;
    }

    .production-section,
    .achievements-section {
        grid-column: auto;
    }

    .header h1 {
        font-size: 1.6em;
        letter-spacing: 3px;
    }

    .toast-container {
        left: 10px;
        right: 10px;
    }

    .toast {
        max-width: 100%;
    }

    .income-bar {
        flex-wrap: wrap;
        gap: 8px;
    }
}
