/* --- General Setup --- */
:root {
    --primary-color: #8a2be2;
    --primary-hover: #6a1a9a;
    --background-color: #f0f2f5;
    --container-bg: rgba(255, 255, 255, 0.2);
    --text-color: #333;
    --border-color: #e0e0e0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    margin: 0;
    padding: 1rem;
    transition: background-image 0.5s, background-color 0.5s;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* --- Layout --- */
.main-layout {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: auto;
}
.left-column, .right-column {
    flex-basis: 50%;
}
.game-container {
    background-color: var(--container-bg);
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    position: relative;
    backdrop-filter: blur(5px);
}

/* --- Audio Controls --- */
#audio-controls {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10;
}
#mute-button {
    width: 32px;
    height: 32px;
    cursor: pointer;
}

/* --- Section Headers --- */
h1, h2 {
    color: var(--primary-color);
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 0;
}
h1 {
    font-size: 2.5rem;
}
h2 {
    font-size: 1.5rem;
}

/* --- Components --- */
.stats-container, .weather-container {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
}
.weather-status {
    font-weight: bold;
    color: #ff8c00; /* Default color, can be changed dynamically */
}

.clicker-container, .shop-container, .bonuses-container, .options-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 5px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    transition: all 0.3s;
    margin: 5px;
}

#crystal-clicker {
    width: 150px;
    height: 150px;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.1s;
    object-fit: cover;
}
#crystal-clicker:active {
    transform: scale(0.9);
}

#floating-text-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.floating-text {
    position: absolute;
    color: #ffd700;
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
}

@keyframes floatUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-50px);
        opacity: 0;
    }
}

#buy-booster, #buy-booster-10 {
    background-color: #28a745;
    color: white;
    border: 2px solid transparent;
}
#buy-booster:hover, #buy-booster-10:hover {
    background-color: #218838;
}

/* --- Classes utilitaires pour le liseré des boutons --- */
.can-afford {
    border-color: #ffd700 !important; /* Liseré doré/jaune par défaut */
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    /* Animation pour l'effet arc-en-ciel */
    animation: rainbowBorder 3s linear infinite;
}

@keyframes rainbowBorder {
    0%   { border-color: #ff0000; box-shadow: 0 0 8px rgba(255, 0, 0, 0.6); }
    15%  { border-color: #ff7f00; box-shadow: 0 0 8px rgba(255, 127, 0, 0.6); }
    30%  { border-color: #ffff00; box-shadow: 0 0 8px rgba(255, 255, 0, 0.6); }
    45%  { border-color: #00ff00; box-shadow: 0 0 8px rgba(0, 255, 0, 0.6); }
    60%  { border-color: #0000ff; box-shadow: 0 0 8px rgba(0, 0, 255, 0.6); }
    75%  { border-color: #4b0082; box-shadow: 0 0 8px rgba(75, 0, 130, 0.6); }
    90%  { border-color: #8b00ff; box-shadow: 0 0 8px rgba(139, 0, 255, 0.6); }
    100% { border-color: #ff0000; box-shadow: 0 0 8px rgba(255, 0, 0, 0.6); }
}


/* --- Elemental Bonuses --- */
.elemental-bonus-btn {
    background-color: #ffc107;
    color: #212529;
    display: block;
    width: 90%;
    margin: 8px auto;
    font-weight: 500;
}
.elemental-bonus-btn:hover {
    background-color: #e0a800;
}
.elemental-bonus-btn:disabled {
    background-color: #6c757d;
    color: white;
    cursor: not-allowed;
}

#reset-button {
    background-color: #dc3545;
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}
#reset-button:hover {
    background-color: #c82333;
}

.environments-container button {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    margin: 5px;
}
.environments-container button:hover {
    background-color: var(--primary-color);
    color: white;
}
.environments-container button:disabled {
    background-color: var(--primary-hover);
    color: white;
    border-color: var(--primary-hover);
    cursor: not-allowed;
}

/* --- Waifu Slots --- */
.waifu-slots-container {
    margin-bottom: 2rem;
}
#waifu-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}
.waifu-slot {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f8f9fa;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.waifu-slot:hover {
    border-color: var(--primary-color);
}
.waifu-slot img {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    object-fit: cover;
}
#unlock-slot-button {
    display: block;
    margin: 0 auto;
    background-color: #17a2b8;
    color: white;
}
#unlock-slot-button:hover {
    background-color: #138496;
}


/* --- Waifu Collection --- */
#waifu-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.waifu-card {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    position: relative; /* For rebirth button positioning */
    cursor: pointer;
}
.waifu-card:hover {
    transform: translateY(-5px);
}
.waifu-card img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    border: 3px solid var(--primary-color);
    transition: all 0.3s ease;
}

/* Tooltip for lore/info */
.waifu-card .tooltiptext, .waifu-slot .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    bottom: 110%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    font-size: 0.85rem;
    pointer-events: none;
}
.waifu-card:hover .tooltiptext, .waifu-slot:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Rebirth styles */
.waifu-card[data-stars="1"] img { border-color: silver; box-shadow: 0 0 10px silver; }
.waifu-card[data-stars="2"] img { border-color: gold; box-shadow: 0 0 15px gold; }
.waifu-card[data-stars="3"] img { border-color: #ff1493; box-shadow: 0 0 20px #ff1493; }

.waifu-name {
    font-weight: bold;
    color: var(--primary-color);
}
.waifu-level, .waifu-desc {
    font-size: 0.8rem;
    color: #6c757d;
}

.rebirth-btn {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff8c00;
    color: white;
    padding: 2px 8px;
    font-size: 0.7rem;
    border-radius: 10px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.rebirth-btn:hover { background-color: #e67e22; }

/* --- Notifications --- */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}
.notification {
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    opacity: 0;
    transform: translateX(100%);
    animation: slideIn 0.5s forwards;
}
.notification.imprint {
    border-left: 5px solid #17a2b8;
}
.notification.weather {
    border-left: 5px solid #ff8c00;
}
.notification.error {
    border-left: 5px solid #dc3545;
}
@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Modal --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
}
.modal-content {
    background-color: #fff;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    max-width: 400px;
    position: relative;
}
#offline-gains-amount {
    color: var(--primary-color);
    font-size: 2rem;
    margin: 1rem 0;
}
.limit-message {
    font-size: 0.9rem;
    color: #dc3545;
    margin-bottom: 1rem;
}
#close-modal-btn {
    background-color: var(--primary-color);
    color: white;
}

/* --- Waifu Detail Modal --- */
.waifu-detail-content {
    max-width: 900px;
    text-align: left;
}
.close-waifu-detail-modal {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}
.close-waifu-detail-modal:hover {
    color: #333;
}
#waifu-detail-header {
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
#waifu-detail-name {
    margin-bottom: 0;
}
#waifu-detail-rarity {
    margin-top: 5px;
    font-weight: bold;
    text-transform: uppercase;
}
#waifu-detail-body {
    display: flex;
    gap: 1.5rem;
}
#waifu-detail-image {
    width: 400px;
    height: 400px;
    border-radius: 10px;
    border: 4px solid var(--primary-color);
    object-fit: cover;
}
#waifu-detail-info p {
    margin: 0.5rem 0;
}
#waifu-detail-info strong {
    color: var(--primary-color);
}
#waifu-detail-lore {
    font-style: italic;
    color: #6c757d;
    margin-top: 1rem;
    display: block;
}


/* --- Booster Overlay --- */
.booster-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.98) 100%);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.booster-content {
    text-align: center;
    color: white;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease-in-out;
    position: relative;
    max-width: 800px;
    width: 90%;
}

.booster-content img {
    width: 250px;
    height: 250px;
    border-radius: 20px;
    border: 5px solid white;
    box-shadow: 0 0 50px rgba(255, 255, 255, 0.5);
    margin: 20px 0;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
    100% { transform: translateY(0px); }
}

.booster-rarity {
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 5px;
    margin: 0;
    animation: pulseText 2s infinite;
}

@keyframes pulseText {
    0% { opacity: 0.7; }
    50% { opacity: 1; text-shadow: 0 0 20px currentColor; }
    100% { opacity: 0.7; }
}

#booster-name {
    font-size: 3.5rem;
    margin: 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#booster-description {
    font-size: 1.2rem;
    max-width: 400px;
    margin: 0 auto 30px auto;
    color: #e0e0e0;
}

#booster-close-btn {
    background-color: transparent;
    border: 2px solid white;
    color: white;
    font-size: 1.2rem;
    padding: 10px 30px;
    border-radius: 30px;
    transition: all 0.3s;
    margin-top: 20px;
    position: relative;
    z-index: 10; /* Ensure button is above particles */
}

#booster-close-btn:hover {
    background-color: white;
    color: black;
    transform: scale(1.1);
}

/* Multi-pull Grid */
.multi-pull-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.multi-pull-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: scale(0);
}

.multi-pull-item img {
    width: 100px;
    height: 100px;
    margin: 5px;
    animation: none; /* Disable float for multi-pull */
}

.multi-pull-item .item-name {
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
}

@keyframes popIn {
    to { opacity: 1; transform: scale(1); }
}

/* Particle Effects */
.particles {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1; /* Keep particles behind text and buttons */
}

/* Base class for particle, the JS script handles the rest inline */
.particle {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 50%;
}

/* --- Responsive Design --- */
@media (max-width: 992px) {
    .main-layout {
        flex-direction: column;
    }
    .left-column, .right-column {
        flex-basis: 100%;
    }
}

@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    .game-container {
        padding: 1rem;
    }
    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.3rem;
    }
    #waifu-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    .waifu-slot {
        width: 70px;
        height: 70px;
    }
    .booster-content img {
        width: 200px;
        height: 200px;
    }
    #booster-name {
        font-size: 2.5rem;
    }
    #waifu-detail-body {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    button {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    #crystal-clicker {
        width: 120px;
        height: 120px;
    }
    .shop-container, .bonuses-container {
        display: flex;
        flex-direction: column;
    }
    .shop-container button, .bonuses-container button {
        margin-bottom: 10px;
    }
    #waifu-list {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    .waifu-card img {
        width: 60px;
        height: 60px;
    }
    .modal-content {
        padding: 1.5rem;
        max-width: 90%;
    }
    #offline-gains-amount {
        font-size: 1.5rem;
    }
}