/* Replacing time styling with Lives/Bomb styling in CSS */
:root {
    /* Dopamine-triggering Color Palette */
    --neon-green: #39ff14;
    --electric-blue: #00f3ff;
    --candy-red: #ff0055;
    --bright-yellow: #ffea00;
    --purple-grad-1: #8a2be2;
    --purple-grad-2: #4a00e0;

    --bg-dark: #0f172a;
    --board-bg: #1e293b;
    --grass-green: #22c55e;
    --grass-dark: #166534;
    --hole-dark: #000000;
    --hole-lip: #654321;

    --mole-brown: #fff;
    --mole-gold: #ffd700;
    --text-glow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px var(--electric-blue);

    --font-main: 'Fredoka', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    touch-action: manipulation;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--bg-dark) 0%, #170b2b 100%);
    color: white;
    /* Allow scrolling now for ads and article */
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* New wrapper to keep the game locked to screen size */
#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    flex-shrink: 0;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 10;
}

.screen.active {
    visibility: visible;
    opacity: 1;
}

#game-screen {
    z-index: 5;
    background: radial-gradient(circle at center, #1e293b 0%, var(--bg-dark) 100%);
}

.title-text {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    color: white;
    text-shadow:
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--electric-blue),
        0 0 40px var(--electric-blue),
        0 0 80px var(--purple-grad-1);
    animation: pulse-glow 2s infinite alternate;
}

#game-over-reason {
    font-size: 4rem;
    margin-bottom: 20px;
    color: #ff0055;
    text-shadow: 0 0 20px #ff0055, 0 0 40px #ff0055;
}

.subtitle {
    font-size: 1.5rem;
    color: var(--electric-blue);
    text-align: center;
    margin-bottom: 2rem;
    letter-spacing: 2px;
}

@keyframes pulse-glow {
    0% {
        text-shadow: 0 0 10px #fff, 0 0 20px var(--electric-blue), 0 0 40px var(--electric-blue);
    }

    100% {
        text-shadow: 0 0 20px #fff, 0 0 40px var(--neon-green), 0 0 80px var(--neon-green);
    }
}

.bouncing-btn {
    font-family: var(--font-main);
    font-size: 2rem;
    font-weight: 700;
    padding: 1rem 3rem;
    border: none;
    border-radius: 50px;
    background: linear-gradient(90deg, var(--candy-red), #ff6b6b);
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(255, 0, 85, 0.4), inset 0 -5px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
    animation: bounce-btn 2s infinite;
}

.bouncing-btn:active {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(255, 0, 85, 0.4), inset 0 -2px 5px rgba(0, 0, 0, 0.2);
}

@keyframes bounce-btn {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-10px) scale(1.05);
    }
}

.instructions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid var(--purple-grad-1);
    box-shadow: 0 0 15px var(--purple-grad-1);
}

.instruction-item {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    gap: 15px;
}

.mole-icon {
    width: 25px;
    height: 35px;
    /* This border radius makes it look like an egg instead of a simple circle */
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    display: inline-block;
    box-shadow: inset -2px -5px 5px rgba(0, 0, 0, 0.3);
}

.normal-icon {
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f0f0f0 40%, #d4c8b8 80%, #b8a691 100%);
}

.golden-icon {
    background: radial-gradient(circle at 35% 35%, #fff175 0%, #ffd700 40%, #c49600 80%, #7d5e00 100%);
    box-shadow: 0 0 10px var(--mole-gold), inset -2px -5px 5px rgba(0, 0, 0, 0.4);
}

.rainbow-icon {
    background: linear-gradient(45deg, red, orange, yellow, green, blue, indigo, violet);
}

.bomb-icon {
    background: radial-gradient(circle at 35% 35%, #555 0%, #222 40%, #000 80%, #000 100%);
    border: 2px solid var(--candy-red);
    box-shadow: 0 0 15px var(--candy-red), inset -2px -5px 5px rgba(255, 0, 85, 0.2);
}

.top-bar {
    position: absolute;
    /* Relative to #game-container */
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    padding: 15px 25px;
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.8rem;
    color: #94a3b8;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
}

.lives-box .stat-value {
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.combo-text {
    color: var(--bright-yellow);
}

.streak-announcer {
    position: absolute;
    top: 15%;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--bright-yellow);
    text-transform: uppercase;
    text-shadow: 0 0 20px var(--candy-red);
    opacity: 0;
    transform: scale(0.5) translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 100;
}

.streak-announcer.show {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.board-container {
    perspective: 800px;
    margin-top: 10vh;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 20px;
    background: var(--grass-green);
    border-radius: 20px;
    box-shadow:
        inset 0 10px 20px rgba(255, 255, 255, 0.2),
        inset 0 -15px 30px var(--grass-dark),
        0 20px 40px rgba(0, 0, 0, 0.6);
    transform: rotateX(20deg);
    border: 8px solid #3f6212;
}

.hole {
    position: relative;
    width: 90px;
    height: 90px;
    background: var(--hole-lip);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    box-shadow:
        inset 0 -5px 10px rgba(255, 255, 255, 0.2),
        0 5px 10px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

@media (min-width: 600px) {
    .hole {
        width: 120px;
        height: 120px;
    }

    .grid {
        gap: 25px;
        padding: 30px;
    }
}

.hole-inner {
    position: absolute;
    width: 80%;
    height: 60%;
    top: 20%;
    background: var(--hole-dark);
    border-radius: 50%;
    box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.9);
}

.hole-mask {
    position: absolute;
    bottom: -10%;
    width: 110%;
    height: 60%;
    background: radial-gradient(ellipse at top, #4ade80, var(--grass-green) 60%);
    border-top-left-radius: 50% 30%;
    border-top-right-radius: 50% 30%;
    z-index: 3;
    pointer-events: none;
}

/* --- Eggs --- */
.mole {
    position: absolute;
    bottom: 5%;
    /* Adjusted for slightly taller shape */
    width: 60%;
    height: 80%;
    /* Smooth Off-White Egg Gradient */
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #f0f0f0 40%, #d4c8b8 80%, #b8a691 100%);
    /* Asymmetrical border radius creates the classic narrow-top/wide-bottom egg shape */
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    z-index: 2;
    transition: transform 0.1s;
    transform: translateY(100%);
    cursor: crosshair;
    box-shadow:
        inset -5px -10px 15px rgba(0, 0, 0, 0.3),
        0 8px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
}

/* Add a beautiful specular highlight (the glossy reflection) */
.egg-shine {
    position: absolute;
    top: 15%;
    left: 20%;
    width: 25%;
    height: 35%;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 70%);
    transform: rotate(-30deg);
    pointer-events: none;
}

/* Remove old pseudo-elements entirely */
.mole::before,
.mole::after {
    display: none;
}

/* Animations */
.mole.up {
    animation: mole-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.mole.down {
    animation: mole-hide 0.2s ease-in forwards;
}

.mole.hit {
    animation: mole-squash 0.2s forwards;
    pointer-events: none;
    /* Prevent double hits */
}

@keyframes mole-pop {
    0% {
        transform: translateY(100%);
    }

    100% {
        transform: translateY(0%);
    }
}

@keyframes mole-hide {
    0% {
        transform: translateY(0%);
    }

    100% {
        transform: translateY(100%);
    }
}

@keyframes mole-squash {
    0% {
        transform: translateY(0%) scale(1);
    }

    50% {
        transform: translateY(20%) scale(1.2, 0.6);
        filter: brightness(2) drop-shadow(0 0 10px white);
    }

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

/* --- Variant Colors/Glows (kept on the main wrapper) --- */

/* Golden Egg */
.mole.golden {
    background: radial-gradient(circle at 35% 35%, #fff175 0%, #ffd700 40%, #c49600 80%, #7d5e00 100%);
    box-shadow:
        0 0 25px var(--mole-gold),
        inset -5px -10px 15px rgba(0, 0, 0, 0.4),
        0 8px 15px rgba(0, 0, 0, 0.5);
}

.mole.golden .coco-hole {
    background: #daa520;
}

.mole.rainbow {
    background: linear-gradient(45deg, red, orange, yellow, green, blue, purple);
    background-size: 200% 200%;
    animation: rainbow 2s infinite, mole-pop 0.3s forwards;
    box-shadow: 0 0 30px white;
}

@keyframes rainbow {
    0% {
        background-position: 0% 50%
    }

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

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

/* Bomb Variant (Black Egg) */
.mole.bomb {
    background: radial-gradient(circle at 35% 35%, #555 0%, #222 40%, #000 80%, #000 100%);
    box-shadow:
        0 0 30px var(--candy-red),
        inset -5px -10px 15px rgba(255, 0, 85, 0.2),
        /* Red underglow */
        0 8px 15px rgba(0, 0, 0, 0.9);
}

/* Spark effect for bomb */
.mole.bomb::first-child {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    width: 5px;
    height: 15px;
    background: orange;
    border-radius: 5px;
    animation: spark-flicker 0.1s infinite alternate;
}

@keyframes spark-flicker {
    0% {
        background: orange;
        box-shadow: 0 0 5px yellow;
    }

    100% {
        background: yellow;
        box-shadow: 0 0 10px orange;
    }
}

.floating-text {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 10px black, 0 0 5px var(--text-glow);
    pointer-events: none;
    animation: floatUp 0.8s ease-out forwards;
    z-index: 100;
}

.floating-text.bonus {
    color: var(--neon-green);
    font-size: 2.5rem;
}

.floating-text.critical {
    color: var(--mole-gold);
    font-size: 3rem;
}

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

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

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    box-shadow: 0 0 8px currentColor;
    animation: explode 0.6s forwards;
}

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

    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
    }
}

.screen-shake {
    animation: screenShake 0.15s both;
}

@keyframes screenShake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

#game-over-screen {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
}

.results-container {
    background: rgba(0, 0, 0, 0.5);
    padding: 30px;
    border-radius: 20px;
    border: 2px solid var(--electric-blue);
    margin: 20px 0 40px 0;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.3);
    min-width: 300px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.5rem;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.high-score-row {
    color: var(--bright-yellow);
    font-weight: bold;
}

.result-number {
    font-family: monospace;
    font-size: 1.8rem;
}

.new-high-score {
    animation: flash-rgb 0.5s infinite alternate;
}

@keyframes flash-rgb {
    0% {
        color: var(--neon-green);
        text-shadow: 0 0 20px var(--neon-green);
    }

    100% {
        color: var(--electric-blue);
        text-shadow: 0 0 20px var(--electric-blue);
    }
}

/* --- Global Navigation Styles --- */
.nav-container {
    width: 100%;
    max-width: 800px;
    margin: 10px auto;
    padding: 0 20px;
    display: flex;
    justify-content: center;
}

.back-home-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--electric-blue);
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 30px;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.back-home-btn:hover {
    background: var(--electric-blue);
    color: #0f172a;
    box-shadow: 0 0 20px var(--electric-blue);
    transform: translateX(-5px);
}

/* --- AdSense and Article Styles --- */
.ad-container {
    width: 100%;
    max-width: 728px;
    margin: 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    padding: 10px;
}

.top-ad {
    margin-top: 20px;
    height: 90px;
}

.bottom-ad {
    margin: 40px auto 20px auto;
    height: 250px;
    /* e.g. for medium rectangle or responsive */
}

.ad-placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.seo-article {
    width: 90%;
    max-width: 800px;
    margin: 40px auto 80px auto;
    padding: 30px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    line-height: 1.6;
    font-family: sans-serif;
    /* Readable font for long-form */
}

.seo-article h2 {
    color: var(--neon-green);
    font-family: var(--font-main);
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.3);
}

.seo-article h3 {
    color: var(--electric-blue);
    font-family: var(--font-main);
    font-size: 1.5rem;
    margin-top: 30px;
    margin-bottom: 15px;
}

.seo-article p {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.seo-article code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--candy-red);
}

/* --- Footer Styles --- */
.site-footer {
    width: 100%;
    margin-top: auto;
    padding: 25px 20px;
    background: #0f172a;
    border-top: 2px solid rgba(255, 255, 255, 0.05);
    text-align: center;
    color: #64748b;
    font-size: 0.95rem;
    font-family: sans-serif;
    letter-spacing: 0.5px;
}

.site-footer p {
    margin: 5px 0;
}