:root {
    --bg-color: #f0f2f5;
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --text-color: #333;
    --panel-bg: #ffffff;
    --stone-gray: #7f8c8d;
    --highlight: #f1c40f;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    /* Added to stack game, article, footer */
    justify-content: flex-start;
    /* Changed from center to allow scrolling if content overflows */
    align-items: center;
    min-height: 100vh;
    color: var(--text-color);
    transition: background 0.5s ease;
    padding: 20px 0;
    /* Add some padding */
}

body.fever-mode {
    background: linear-gradient(45deg, #2c3e50, #e74c3c);
    animation: fever-bg 2s infinite alternate;
}

@keyframes fever-bg {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

.game-container {
    background-color: var(--panel-bg);
    width: 90%;
    max-width: 600px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header {
    text-align: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: #2c3e50;
}

#timer {
    font-size: 1.2rem;
    font-weight: bold;
    color: #e74c3c;
    margin-top: 5px;
}

/* Mining Section */
.mining-section {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background-color: #ecf0f1;
    border-radius: 10px;
    padding: 20px;
}

.stone-display {
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s;
}

.stone-display:active {
    transform: scale(0.95);
}

.clean-stone {
    width: 100px;
    /* Larger for better visibility */
    height: 100px;
    object-fit: contain;
    margin: 0 auto 10px;
    position: relative;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.2));
}

.fever-mode .clean-stone {
    filter: drop-shadow(0 0 15px #f1c40f);
    animation: fever-pulse 0.5s infinite;
}

@keyframes fever-pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Particle Effects */
.particle {
    position: absolute;
    pointer-events: none;
    font-size: 1.2rem;
    font-weight: bold;
    color: #f1c40f;
    animation: floatUp 1s ease-out forwards;
    z-index: 100;
}

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

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

.big-stone {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.resource-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.resource-item {
    font-size: 1.1rem;
    font-weight: bold;
}

.action-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.action-btn:hover {
    background-color: #357abd;
}

.action-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* Inventory Section */
.inventory-section {
    text-align: center;
}

.guide-text {
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 10px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    background-color: #dfe6e9;
    padding: 10px;
    border-radius: 10px;
    min-height: 200px;
}

.inv-slot {
    background-color: #fff;
    border-radius: 8px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.inv-slot:hover {
    border-color: #ccc;
}

.inv-slot.selected {
    border-color: var(--highlight);
    background-color: #fff9c4;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.inv-slot.drag-over {
    background-color: #e0f7fa;
    border-color: var(--secondary-color);
    transform: scale(1.05);
}

.stone.dragging {
    opacity: 0.5;
    transform: scale(1.1);
}

/* Merge Animation */
@keyframes merge-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
        filter: brightness(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.merge-anim {
    animation: merge-pop 0.4s ease-out;
}

/* Stone Styles by Level */
.stone {
    width: 60px;
    height: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.3));
    background-color: transparent;
    border-radius: 0;
}

.lv-1 {
    background-image: url('stone_lv1.png?v=3');
}

.lv-2 {
    background-image: url('stone_lv2.png?v=2');
}

.lv-3 {
    background-image: url('stone_lv3.png?v=2');
}

.lv-4 {
    background-image: url('stone_lv4.png?v=2');
}

.lv-5 {
    background-image: url('stone_lv5.png?v=2');
}

.lv-6 {
    background-image: url('stone_lv6.png?v=2');
}

.lv-7 {
    background-image: url('stone_lv7.png?v=2');
}

.lv-8 {
    background-image: url('stone_lv8.png?v=2');
}

.lv-9 {
    background-image: url('stone_lv9.png?v=2');
}

.lv-10 {
    background-image: url('stone_lv10.png?v=3');
    /* Clip white corners */
    animation: pulse 2s infinite;
}

/* Floating Buttons */
.floating-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: #e67e22;
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    z-index: 500;
}

.floating-btn:hover {
    transform: translateY(-3px);
    background-color: #d35400;
}

.floating-btn:active {
    transform: translateY(1px);
}

.lang-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    z-index: 600;
}

.lang-toggle:hover {
    background-color: white;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(129, 236, 236, 0.6);
        /* Softer glow */
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(0, 206, 201, 0.8);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(129, 236, 236, 0.6);
    }
}

/* Ranking */
.ranking-board {
    background-color: #2d3436;
    color: #dfe6e9;
    padding: 15px;
    border-radius: 10px;
}

.ranking-board h3 {
    margin-top: 0;
    border-bottom: 1px solid #636e72;
    padding-bottom: 5px;
}

#ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

#ranking-list li {
    padding: 5px 0;
    border-bottom: 1px solid #636e72;
}

/* Modals */
.modal {
    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: 1000;
}

.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    position: relative;
    max-width: 400px;
    width: 90%;
}

.ad-content {
    background: linear-gradient(to bottom right, #ffffff, #f0f0f0);
    border: 1px solid #ddd;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    font-weight: bold;
    color: #aaa;
}

.close-btn:hover {
    color: #333;
}

.fake-ad-banner {
    background-color: #0984e3;
    color: white;
    padding: 20px;
    margin: 15px 0;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 5px;
}

#player-name {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin: 10px 0;
    width: 70%;
}

.secondary-btn {
    background-color: #95a5a6;
    border: none;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
}

/* Fever Popup */
#fever-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    pointer-events: none;
    /* Let clicks pass through */
    width: 80%;
    max-width: 400px;
}

#fever-popup img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
}

.fever-popup-anim {
    animation: popFadeOut 2s forwards;
}

@keyframes popFadeOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    20% {
        transform: translate(-50%, -50%) scale(1.0);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}

/* Celebration Popup */
#celebration-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2500;
    pointer-events: none;
    width: 90%;
    max-width: 500px;
}

#celebration-popup img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

.celebration-anim {
    animation: celebrateShow 2.5s forwards;
}

@keyframes celebrateShow {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    20% {
        transform: translate(-50%, -50%) scale(1.0);
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.5);
    }
}