/* --- General Styling --- */
:root {
    --primary-bg: #000000;
    --panel-bg: #111111;
    --border-color: #444444;
    --text-color: #f0f0f0;
    --accent-color: #333333;
    --disabled-color: #222222;
}

body {
    font-family: 'Orbitron', sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    overflow-y: auto; /* Add scroll for smaller screens */
}

h1, h2, h3 {
    color: #ffffff;
    text-shadow: none;
}

button {
    font-family: 'Orbitron', sans-serif;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 12px 18px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}

button:hover {
    background-color: #555555;
}

button:disabled {
    background-color: #2b2b2b; /* Slightly darker than accent */
    color: #888; /* Dimmer text */
    cursor: default; /* Remove not-allowed cursor */
    border-color: #3a3a3a; /* Slightly darker border */
}

.button-title { font-weight: bold; font-size: 1.1em; }
.button-desc { font-size: 0.8em; margin-top: 5px; color: #ccc; }

.danger-button {
    background-color: #a03a3a;
    border-color: #c05c5c;
}

.danger-button:hover {
    background-color: #c03a3a;
}

/* --- Layout --- */
#app {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 1800px; /* Allow wider layout */
    margin: 0 auto;
}

#left-panel, #right-panel {
    flex: 1; /* Make both panels equal width */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: none;
}

/* --- Components --- */
#era-title { text-align: center; margin-bottom: 10px; font-size: 2.5em; }

.resource-line {
    margin: 10px 0;
    font-size: 1.1em;
    display: flex;
    justify-content: space-between;
}

#resources span { color: #fff; font-weight: normal; }

#main-clicker button { width: 100%; min-height: 120px; font-size: 1.8em; }

.item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background-color: #222222;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.item-details h3 { margin: 0 0 8px 0; }
.item-details p { margin: 0; font-size: 0.9em; color: #bbb; }

.cost {
    margin-top: 8px;
    font-size: 0.9em;
    color: #ccc;
}

.button-group { display: flex; gap: 10px; }
.toggle-button { width: 70px; }
.toggle-button.on { background-color: #3a5a3a; border-color: #5c8a5c; }
.toggle-button.off { background-color: #5a3a3a; border-color: #8a5c5c; }

/* --- Tabs --- */
.tabs { display: flex; gap: 5px; margin-bottom: 10px; }
.tab-button, .sub-tab-button {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--accent-color);
    box-shadow: none;
}
.tab-button.active, .sub-tab-button.active {
    background-color: #444444;
    border-bottom-color: transparent;
}
.tab-content, .sub-tab-content { display: none; }
.tab-content.active, .sub-tab-content.active { display: block; }

/* --- Effects --- */
#background-stars { display: none; } /* Hide background effect */

#particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden; /* Keep particles inside the button */
}

.particle {
    position: absolute;
    background-color: #ffffff; /* Simple white */
    width: 4px;
    height: 4px;
    border-radius: 0;
    opacity: 0;
    animation: particle-effect 0.5s ease-out;
}

@keyframes particle-effect {
    from {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    to {
        transform: translate(calc(cos(var(--angle)) * var(--distance)), calc(sin(var(--angle)) * var(--distance))) scale(0);
        opacity: 0;
    }
}

/* --- Temporal Anomaly --- */
#anomaly-container { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; pointer-events: none; }
.temporal-anomaly {
    position: absolute;
    width: 60px;
    height: 60px;
    cursor: pointer;
    pointer-events: all;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(150,100,255,0.7) 40%, rgba(50,0,150,0) 70%);
    border-radius: 50%;
    box-shadow: 0 0 15px 5px rgba(200, 150, 255, 0.7), 0 0 5px 2px #fff inset;
    animation: pulse-anomaly 2s infinite ease-in-out;
    transition: transform 0.2s ease-out;
}

.temporal-anomaly:hover {
    transform: scale(1.1);
}

@keyframes pulse-anomaly {
    0% { opacity: 0.7; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.7; transform: scale(0.95); }
}

.reward-text {
    position: absolute;
    color: #c8b6ff;
    font-size: 22px;
    font-weight: bold;
    text-shadow: 1px 1px 3px #000;
    transition: transform 2s, opacity 2s;
    pointer-events: none;
}

#prestige-container {
    margin-bottom: 20px;
}

#prestige-container p {
    margin-bottom: 15px;
}

.upgrade-items-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

#chrono-dust-upgrades-container .item {
    flex-direction: column;
    align-items: stretch; /* Make children full width */
    flex: 1 0 20%; /* Make items share space equally */
}

#chrono-dust-upgrades-container .item .item-details {
    margin-bottom: 15px; /* Add space between details and button */
}

/* --- Tooltip --- */
#game-tooltip {
    position: fixed;
    background-color: #282828;
    color: #f0f0f0;
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #555;
    font-size: 0.9em;
    font-family: 'Orbitron', sans-serif;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    white-space: normal; /* Allow text to wrap */
    max-width: 300px;
    line-height: 1.4; /* Improve readability for multi-line tooltips */
}

/* --- Automation UI --- */
#automation-controls, #automation-queue-container {
    margin-top: 15px;
    background-color: #222;
    padding: 15px;
}
.add-sequence-item {
    display: flex;
    gap: 10px;
    align-items: center;
}
#automation-target-select {
    flex-grow: 1;
    padding: 8px;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
}
#automation-queue-list {
    list-style-type: decimal;
    padding-left: 20px;
    margin: 0;
}
.automation-queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin-bottom: 5px;
    background-color: #333;
    border-radius: 4px;
}
.automation-queue-item span {
    font-size: 0.9em;
}
.automation-queue-item button {
    padding: 4px 8px;
    font-size: 0.8em;
    background-color: #a03a3a;
}

/* --- Save Management Buttons --- */
#save-management .save-management-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* --- Custom Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal-panel {
    width: 90%;
    max-width: 500px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 2px solid var(--border-color);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

#modal-title {
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

#modal-text {
    margin: 0;
    font-size: 1.1em;
    line-height: 1.5;
}

#modal-input-container {
    width: 100%;
}

#modal-textarea {
    width: 100%;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    min-height: 100px;
    padding: 10px;
    background-color: #222;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-family: monospace;
    resize: vertical;
}

#modal-buttons {
    justify-content: flex-end; /* Align buttons to the right */
    flex-wrap: wrap; /* Allow buttons to wrap on small screens */
}

/* --- Language Settings --- */
#language-settings {
    margin-top: 15px;
    background-color: #222;
    padding: 10px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#language-selector {
    padding: 5px;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
}

/* --- Leaderboard --- */
/* #leaderboard-name-container, #leaderboard-scores-container {
    margin-top: 15px;
    background-color: #222;
    padding: 15px;
}

.leaderboard-set-name-input {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#leaderboard-name-input {
    flex-grow: 1;
    padding: 8px;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
}

#leaderboard-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #333;
}

#leaderboard-list li:last-child {
    border-bottom: none;
}

#leaderboard-list .rank { flex-basis: 10%; font-weight: bold; }
#leaderboard-list .name { flex-basis: 60%; }
#leaderboard-list .score { flex-basis: 30%; text-align: right; } */

/* --- Responsive Design --- */

/* --- Tablets & Smaller Desktops --- */
@media (max-width: 1024px) {
    #app {
        flex-direction: column;
        align-items: stretch;
    }

    #left-panel, #right-panel {
        width: 100%;
        min-width: 0;
    }
}

/* --- Mobile Devices --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .panel {
        padding: 15px;
    }

    #era-title {
        font-size: 2em;
    }

    h2 {
        font-size: 1.3em;
    }

    .item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .item-details {
        text-align: center;
    }

    .button-group {
        justify-content: center;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-button, .sub-tab-button {
        flex-basis: 48%; /* Two buttons per row */
    }
}

/* --- Smaller Mobile Devices --- */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    #era-title {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.2em;
    }

    h3 {
        font-size: 1em;
    }

    button {
        padding: 10px 15px;
    }

    .button-title {
        font-size: 1em;
    }

    .resource-line {
        font-size: 1em;
    }

    #main-clicker button {
        min-height: 100px;
        font-size: 1.5em;
    }

    .tab-button, .sub-tab-button {
        flex-basis: 100%; /* One button per row */
    }

    .button-group {
        flex-direction: column;
    }

    .toggle-button {
        width: 100%;
    }
}
