@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');

html, body { 
    height: 100%; 
    width: 100%; 
    margin: 0;
    padding: 0;
    background-color: #75ba75; 
    transition: background-color 1s ease-in-out;
    user-select: none; 
    overflow: hidden; 
    font-family: 'Nunito', sans-serif;
}

img {
    -webkit-user-drag: none;
}

body.frenzy-active {
    background-color: #f2ff00;
}

#bg-img {
    background-image: url('main/squirrel.png');
    opacity: 0.15;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    position: fixed;
    transition: opacity 1s ease-in-out;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

body.frenzy-active #bg-img {
    opacity: 0.2;
}
        
html > * {
    font-family: "Nunito" !important; 
}

.shop-btn, .danger-btn, #toggle-sidebar-btn, #toggle-army-btn {
    font-family: 'Nunito', sans-serif !important;
}

#bg-canvas, #fg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
}

#bg-canvas { z-index: 5; }
#fg-canvas { z-index: 15; }

.golden-squirrel {
    position: fixed;
    width: 80px;
    height: 80px;
    cursor: pointer;
    z-index: 1000;

    animation: 
        popup-golden 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
        pulse-golden 2s ease-in-out 0.5s infinite;
    touch-action: manipulation;
}

@keyframes popup-golden {
    0% { transform: scale(0) rotate(-45deg); opacity: 0; filter: drop-shadow(0 0 0px gold); }
    100% { transform: scale(1) rotate(-5deg); opacity: 1; filter: drop-shadow(0 0 10px gold); }
}

@keyframes pulse-golden {
    0% { transform: scale(1) rotate(-5deg); filter: drop-shadow(0 0 10px gold); }
    50% { transform: scale(1.1) rotate(5deg); filter: drop-shadow(0 0 20px gold); }
    100% { transform: scale(1) rotate(-5deg); filter: drop-shadow(0 0 10px gold); }
}

#counter {
    transition: transform 0.1s ease;
    display: inline-block;
    margin: 0;
    color: white;
    text-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 20;
}

.text-bump {
    transform: scale(1.1) rotate(2deg);
}

#c {
    width: 230px;
    height: 230px;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
    touch-action: none;
    -webkit-user-drag: none;
    border-radius: 50%;
    z-index: 10;
    position: relative;
}

#c:hover { transform: scale(1.05); }
#c:active { transition: transform 0.05s ease; transform: scale(0.95); }

#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 310px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    padding: 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 50;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.shop-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.shop-header-container h2 {
    margin: 0;
    color: white;
    text-align: left;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-size: 28px;
}

.buy-sell-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    position: relative;
    width: 100px;
    height: 28px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 800;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    z-index: 2;
    transition: color 0.2s;
}

.toggle-option.active {
    color: #000;
}

.buy-sell-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: #fdef8a;
    border-radius: 20px;
    transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

body.sell-mode .buy-sell-toggle::before {
    transform: translateX(100%);
}

#sidebar.closed { transform: translateX(-100%); }
body.sidebar-closed #game-container {
    margin-left: 0;
    width: calc(100vw - 350px);
}

#toggle-sidebar-btn {
    position: fixed;
    left: 325px;
    top: 15px;
    z-index: 60;
    background: #f1c40f;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    font-weight: 900;
    transition: left 0.3s ease, transform 0.1s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
#toggle-sidebar-btn:hover { transform: scale(1.1); }
body.sidebar-closed #toggle-sidebar-btn { left: 15px; }

:root {
    --left-space: 310px;
    --right-space: 420px;
}

body.sidebar-closed { --left-space: 0px; }
body.army-closed { --right-space: 0px; }

#toggle-army-btn {
    position: fixed;
    right: 435px;
    top: 15px;
    z-index: 60;
    background: #f1c40f;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 900;
    transition: right 0.3s ease, transform 0.1s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
#toggle-army-btn:hover { transform: scale(1.1); }
body.army-closed #toggle-army-btn { right: 15px; }

.rowCanvas {
    width: 100%;
    height: 135px;
    display: block;
    border-bottom: 6px solid #2e2319;
    box-sizing: border-box;
    background-color: #555;
}

body.is-dragging, body.is-dragging * {
    cursor: grabbing !important;
}

#building-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: 420px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: -2px 0 10px rgba(0,0,0,0.2);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
}

#building-sidebar.closed {
    transform: translateX(100%);
}

#building-sidebar::-webkit-scrollbar, #sidebar::-webkit-scrollbar { width: 12px; }
#building-sidebar::-webkit-scrollbar-track, #sidebar::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.5); border-left: 1px solid rgba(0,0,0,0.8); }
#building-sidebar::-webkit-scrollbar-thumb, #sidebar::-webkit-scrollbar-thumb { background: linear-gradient(90deg, #555, #777); border-radius: 6px; border: 1px solid #111; }

.shop-btn {
    background-color: #f1c40f;
    color: #333;
    border: none;
    border-radius: 16px;
    padding: 13px 18px;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    transition: transform 0.1s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    line-height: 1.25;
}

#game-container {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    position: fixed;
    left: 50%;
    top: 20px;
    transform: translateX(-50%);
    gap: 20px;
    pointer-events: none;
    z-index: 25;
}

#clicker-wrapper { 
    position: fixed; 
    left: 50%;
    top: 50%;
    width: 230px; 
    height: 230px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    margin: 0; 
    z-index: 10; 
    pointer-events: none; 
    transform: translate(-50%, -50%); 
}

.shop-btn:hover:not(:disabled) { transform: scale(1.05); background-color: #f39c12; }
.shop-btn:active:not(:disabled) { transform: scale(0.95); }
.shop-btn:disabled { background-color: #95a5a6; color: #ecf0f1; cursor: not-allowed; box-shadow: none; }

@keyframes icon-sin { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.btn-icon { width: 24px; height: 24px; animation: icon-sin 1.5s ease-in-out infinite; pointer-events: none; }

#buffs-container { position: fixed; top: 70px; right: 440px; display: flex; flex-direction: column; gap: 15px; z-index: 2000; transition: right 0.3s ease; }
body.army-closed #buffs-container { right: 20px; }

.buff-box { width: 60px; height: 60px; background-color: #f1c40f; border-radius: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.2); position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.buff-icon-img { width: 36px; height: 36px; z-index: 1; pointer-events: none; }
.buff-overlay { position: absolute; top: 0; left: 0; width: 100%; background: rgba(0, 0, 0, 0.55); z-index: 2; pointer-events: none; }

#toast-container { position: fixed; bottom: 20px; right: 440px; display: flex; flex-direction: column; gap: 10px; z-index: 3000; pointer-events: none; transition: right 0.3s ease; }
body.army-closed #toast-container { right: 20px; }

.toast { background: rgba(0, 0, 0, 0.8); color: #f1c40f; padding: 15px 25px; border-radius: 10px; border-left: 5px solid #f1c40f; box-shadow: 0 4px 6px rgba(0,0,0,0.3); font-family: 'Nunito', sans-serif; animation: slideIn 0.5s ease-out, fadeOut 0.5s ease-in 4.5s forwards; max-width: 280px; word-wrap: break-word; }

.toast h4 { margin: 0 0 5px 0; font-size: 18px; }
.toast p { margin: 0; font-size: 14px; color: white; }

@keyframes slideIn { from { transform: translateX(120%); } to { transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

#achievements-panel, #settings-panel, #ascension-panel, #tutorial-panel, #upgrade-panel { 
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0); 
    background: #fff; padding: 20px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    z-index: 4000; max-height: 70vh; overflow-y: auto; transition: transform 0.1s ease-out; 
}

#achievements-panel, #settings-panel, #ascension-panel { width: 540px; }

#tutorial-panel { width: 560px; padding: 0; background: #f0f0f0; border: 4px solid #b3b3b3; overflow: hidden; display: flex; flex-direction: column; }
#upgrade-panel { width: 340px; text-align: center; overflow-x: hidden; }

#achievements-panel.open, #settings-panel.open, #ascension-panel.open, #tutorial-panel.open, #upgrade-panel.open { 
    transform: translate(-50%, -50%) scale(1); 
}

.ach-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #eee; padding-bottom: 12px; margin-bottom: 18px; }
.ach-header h2 { margin: 0; color: #333; font-size: 28px; }
.close-btn { cursor: pointer; font-weight: bold; font-size: 24px; color: #e74c3c; }

.ach-item { 
    padding: 14px 10px; border-bottom: 1px solid #eee; 
    display: flex; flex-direction: row; align-items: center; gap: 18px; 
    opacity: 0.5; filter: grayscale(1); 
}
.ach-item.unlocked { opacity: 1; filter: grayscale(0); }
.ach-icon { width: 60px; height: 60px; object-fit: contain; flex-shrink: 0; }
.ach-text-content { display: flex; flex-direction: column; }
.ach-item h4 { margin: 0 0 5px 0; color: #2980b9; font-size: 19px; }
.ach-item.unlocked h4 { color: #f39c12; }
.ach-item p { margin: 0; font-size: 15px; color: #666; }

.danger-btn { background-color: #e74c3c; color: white; border: none; border-radius: 10px; padding: 15px; font-size: 16px; font-weight: 800; cursor: pointer; width: 100%; transition: transform 0.1s, background-color 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }
.danger-btn:hover { background-color: #c0392b; transform: scale(1.02); }
.danger-btn:active { transform: scale(0.98); }

#modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); z-index: 3500; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
#modal-overlay.active { opacity: 1; pointer-events: auto; }

#zoom-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.6); color: white; padding: 10px 20px; border-radius: 20px; display: flex; align-items: center; gap: 10px; z-index: 60; }
#c { pointer-events: auto; }

#reset-zoom-btn { background: none; border: none; color: white; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: transform 0.3s ease; outline: none; }        #reset-zoom-btn:hover { transform: rotate(-180deg) scale(1.2); }
#reset-zoom-btn:active { transform: rotate(-180deg) scale(0.9); }

#fps-counter { 
    position: fixed; 
    bottom: 20px; 
    left: 270px; 
    background: rgba(0, 0, 0, 0.6); 
    color: white; 
    padding: 10px 20px; 
    border-radius: 20px; 
    align-items: center; 
    gap: 5px; 
    z-index: 60; 
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    transition: left 0.3s ease;
    display: none;
}
body.sidebar-closed #fps-counter { left: 20px; }

#tutorial-panel.open, #upgrade-panel.open { transform: translate(-50%, -50%) scale(1); }

@media (max-width: 900px) {
    #toggle-army-btn {
        top: 55px;
    }
}
#tut-level-img {
    transition: transform 0.25s cubic-bezier(.29,1.74,.46,.66);
}

#loading-screen {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #75ba75;
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}
#loading-content {
    text-align: center;
}
#loading-bar-container {
    width: 300px; height: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    margin: 0 auto;
    overflow: hidden;
    border: 2px solid #fff;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
#loading-bar {
    width: 0%; height: 100%;
    background: #f1c40f;
    transition: width 0.1s ease;
}
