:root {
    --clicker-bg: #0d1117;
    --clicker-card: #161b22;
    --clicker-text: #e6edf3;
    --gold: #d1b87a;
    --gold-hover: #e5cc8f;
    --blue: #2b4c7e;
}

body.clicker-body {
    background-color: var(--clicker-bg);
    color: var(--clicker-text);
    margin: 0;
    overflow: hidden;
    font-family: 'Noto Sans JP', sans-serif;
    cursor: url('../../images/lab_mouse_icon.png'), auto;
}

.clicker-body-wrapper {
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: 'Noto Sans JP', sans-serif;
    min-height: 100vh;
    margin-top: -80px;
    padding-top: 80px;
}

.cookie-wrapper, .upgrade-card, button, a {
    cursor: url('../../images/lab_mouse_icon.png'), pointer !important;
}

.clicker-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 300px;
    background-color: var(--clicker-card);
    border-right: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    z-index: 10;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.75rem;
    color: #444;
    line-height: 1.5;
}

.system-reset {
    margin-top: 20px;
    border-top: 1px solid #222;
    padding-top: 10px;
}

#btn-reset-game {
    background: none;
    border: none;
    color: #555;
    font-size: 0.65rem;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.shop {
    width: 350px;
    border-right: none;
    border-left: 1px solid #30363d;
}

.shop-title {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.2rem;
    border-bottom: 1px solid #30363d;
    padding-bottom: 10px;
}

/* Main Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: radial-gradient(circle, rgba(43, 76, 126, 0.1) 0%, rgba(13, 17, 23, 1) 70%);
}

.stats-display {
    text-align: center;
    margin-bottom: 50px;
    z-index: 5;
}

.stats-display h1 {
    font-size: 3rem;
    color: var(--gold);
    margin: 0;
    text-shadow: 0 0 20px rgba(209, 184, 122, 0.3);
}

.stats-display p {
    font-size: 1.2rem;
    color: #8b949e;
    margin: 5px 0 0;
}

/* The Cookie */
.cookie-wrapper {
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s;
}

.cookie-wrapper:active {
    transform: scale(0.95);
}

.cookie-button {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    box-shadow: 0 0 50px rgba(0,0,0,0.5), 0 0 20px rgba(209, 184, 122, 0.2);
    transition: box-shadow 0.3s, transform 0.2s;
    object-fit: cover;
}

.cookie-wrapper:hover .cookie-button {
    box-shadow: 0 0 70px rgba(209, 184, 122, 0.4);
    transform: scale(1.02);
}



/* Shop Items */
.shop-items {
    overflow-y: auto;
    flex: 1;
    margin-top: 20px;
}

.upgrade-card {
    background: #21262d;
    border: 1px solid #30363d;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upgrade-card:hover:not(.disabled) {
    border-color: var(--gold);
    background: #30363d;
    transform: translateX(-5px);
}

.upgrade-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.upgrade-info h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--clicker-text);
}

.upgrade-info p {
    margin: 5px 0 0;
    font-size: 0.8rem;
    color: #8b949e;
}

.upgrade-cost {
    font-weight: bold;
    color: var(--gold);
}

.upgrade-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--blue);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Floating Points Animation */
@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-100px); }
}

.floating-point {
    position: absolute;
    color: var(--gold);
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: floatUp 0.8s forwards ease-out;
    z-index: 100;
}

/* Mobile Header & Nav (Hidden on Desktop) */
.mobile-header, .mobile-nav {
    display: none;
}

/* Responsive */
@media screen and (max-width: 900px) {
    body.clicker-body {
        overflow-y: auto; /* Allow natural scrolling */
        height: auto;
        min-height: 100dvh;
    }

    .clicker-container {
        flex-direction: column;
        height: auto;
        min-height: 100dvh;
        padding-top: 60px; /* Space for mobile header */
        padding-bottom: calc(70px + env(safe-area-inset-bottom)); /* Space for mobile nav */
        overflow: visible; /* Allow content to expand */
    }

    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: var(--clicker-card);
        border-bottom: 1px solid #30363d;
        z-index: 1000;
        align-items: center;
        justify-content: space-around;
        padding: 0 15px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }

    .header-stat {
        font-size: 1.2rem;
        font-weight: bold;
        color: var(--gold);
    }

    .header-ops {
        font-size: 0.8rem;
        color: #8b949e;
    }

    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 70px;
        background: var(--clicker-card);
        border-top: 1px solid #30363d;
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .nav-item {
        background: none;
        border: none;
        color: #8b949e;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center; /* Center content vertically */
        gap: 5px;
        flex: 1;
        height: 100%; /* Fill nav bar height */
        padding: 0; /* Remove padding for larger hit area */
        transition: color 0.2s;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent; /* Cleaner mobile tap */
    }

    .nav-item.active {
        color: var(--gold);
    }

    .nav-icon {
        font-size: 1.4rem;
    }

    .nav-label {
        font-size: 0.7rem;
    }

    /* Tab Switching Logic */
    .sidebar, .shop, .main-area {
        display: none !important;
        width: 100% !important;
        border: none !important;
        flex: 1;
        overflow-y: visible; /* Use body scroll */
        z-index: 10;
        position: relative;
        min-height: calc(100dvh - 130px - env(safe-area-inset-bottom));
    }

    #tab-research.active, #tab-shop.active, #tab-measure.active {
        display: flex !important;
        z-index: 20;
    }

    .main-area {
        justify-content: center;
        align-items: center;
        padding: 20px;
    }

    .stats-display {
        margin-bottom: 30px;
    }

    .stats-display h1 {
        font-size: 2.2rem;
    }

    .cookie-button {
        width: 200px;
        height: 200px;
    }

    .upgrade-card:hover:not(.disabled) {
        transform: none; /* Disable hover shift on touch */
    }

    .console-overlay {
        bottom: 90px;
        left: 10px;
        font-size: 0.85rem;
        max-width: calc(100% - 20px);
    }

    .nav-item.discovery-pulse .nav-icon {
        animation: nav-pulse-anim 1s infinite alternate;
        color: #ff0000;
    }

    @keyframes nav-pulse-anim {
        from { transform: scale(1); filter: drop-shadow(0 0 2px rgba(255,0,0,0)); }
        to { transform: scale(1.3); filter: drop-shadow(0 0 8px rgba(255,0,0,0.8)); }
    }
}

/* Meat Protocol Special Effects */
.glitch-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 0, 0, 0.05);
    pointer-events: none;
    z-index: 9999;
    display: none;
    mix-blend-mode: overlay;
}

.glitch-active .glitch-overlay {
    display: block;
    animation: glitch-noise 0.2s infinite;
}

@keyframes glitch-noise {
    0% { transform: translate(0); }
    20% { transform: translate(-5px, 5px); }
    40% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    80% { transform: translate(5px, -5px); }
    100% { transform: translate(0); }
}

.meat-flicker {
    filter: hue-rotate(290deg) saturate(3) brightness(0.8) !important;
}

.console-overlay {
    position: fixed;
    bottom: 20px;
    left: 20px;
    color: #ff0000;
    font-family: monospace;
    font-size: 1rem;
    z-index: 10000;
    pointer-events: none;
    text-shadow: 0 0 5px #ff0000;
    display: none;
}

.glitch-active .console-overlay {
    display: block;
}

.secret-upgrade {
    display: none;
    border-color: #ff0000 !important;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.3) !important;
}

.secret-upgrade:hover {
    background: #4a0404 !important;
    border-color: #ff0000 !important;
}

.secret-upgrade .upgrade-cost {
    color: #ff0000 !important;
}

.glitch-text {
    animation: text-flicker 0.1s infinite;
    color: #ff0000 !important;
}

@keyframes text-flicker {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* UX Improvements for Discovery */
.pulse-red {
    animation: pulse-red-anim 1.5s infinite;
    border-color: #ff0000 !important;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
}

@keyframes pulse-red-anim {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(255, 0, 0, 0.8); }
    100% { transform: scale(1); }
}

.discovery-flash {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 0, 0, 0.9);
    color: white;
    padding: 20px 40px;
    border-radius: 4px;
    font-family: 'Noto Serif JP', serif;
    font-size: 1.5rem;
    z-index: 10001;
    pointer-events: none;
    animation: fade-out-up 3s forwards;
    text-align: center;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

@keyframes fade-out-up {
    0% { opacity: 0; transform: translate(-50%, -30%); }
    10% { opacity: 1; transform: translate(-50%, -50%); }
    80% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -70%); }
}

.instructions-box {
    margin-top: 30px;
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid var(--gold);
}

.instructions-box h4 {
    margin: 0 0 10px 0;
    color: var(--gold);
    font-size: 0.9rem;
}

.instructions-box ul {
    margin: 0;
    padding-left: 18px;
    font-size: 0.75rem;
    color: #8b949e;
    line-height: 1.6;
}

.sidebar {
    overflow-y: auto;
}



/* Floating Mouse Animation */
.floating-mouse {
    position: fixed;
    width: 40px;
    pointer-events: none;
    z-index: 1000;
    animation: mouseScatter 1s forwards ease-out;
}

@keyframes mouseScatter {
    0% { transform: scale(0.5) rotate(0); opacity: 1; }
    100% { transform: scale(1.5) translate(var(--tx), var(--ty)) rotate(var(--tr)); opacity: 0; }
}




