:root {
    /* GameBoy Reference Palette */
    --gb-case: #c0c0c0;
    /* Classic Grey */
    --gb-case-shadow: #999;
    --gb-screen-bezel: #767a89;
    /* Darker blue-grey bezel */
    --gb-screen-bezel-shadow: #4d4f59;

    --gb-screen-on: #9bbc0f;
    /* Light green */
    --gb-screen-off: #8b9c0f;
    /* Slightly darker */

    --gb-btn-a: #a90e20;
    /* Deep Red */
    --gb-btn-b: #a90e20;
    --gb-dpad: #222;
    --gb-select-start: #666;
    /* Rubber Grey */

    --gb-text-blue: #00008b;
    /* "GAME BOY" Text */
    --gb-text-label: #333;
    /* Button labels */

    /* Pixel Palette */
    --pixel-darkest: #0f380f;
    --pixel-dark: #306230;
    --pixel-light: #8bac0f;
    --pixel-lightest: #9bbc0f;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Press Start 2P', system-ui, sans-serif;
    background-color: #1a1a1a;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    flex-direction: column;
    padding: 20px 0;
}

/* --- INFO SECTION --- */
.info-section {
    max-width: 600px;
    margin: 40px 20px;
    color: #ccc;
    font-family: 'Inter', system-ui, sans-serif;
    /* Readable font for text */
    line-height: 1.6;
}

.content-block {
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #333;
}

.content-block h2 {
    color: var(--pixel-light);
    font-family: 'Press Start 2P', cursive;
    font-size: 16px;
    margin-bottom: 15px;
}

.content-block ul {
    list-style-position: inside;
    padding-left: 10px;
}

.content-block li {
    margin-bottom: 8px;
}

footer {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 12px;
    border-top: 1px solid #333;
    margin-top: auto;
}

footer a {
    color: #888;
    text-decoration: none;
}

footer a:hover {
    color: var(--pixel-light);
}

/* --- THE CONSOLE BODY --- */
.game-container {
    background-color: var(--gb-case);
    width: 380px;
    /* Slightly wider for realism */
    height: 640px;
    border-radius: 15px 15px 40px 15px;
    /* Signature GB corner */

    /* Realistic Plastic Shading */
    box-shadow:
        /* Right & Bottom heavy shadows */
        10px 10px 30px rgba(0, 0, 0, 0.6),
        /* Top & Left Highlights */
        inset 4px 4px 10px rgba(255, 255, 255, 0.7),
        inset -4px -4px 15px rgba(0, 0, 0, 0.2);

    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    border: 1px solid #aaa;
}

.hidden {
    display: none !important;
}

/* PRO Badge */
.pro-badge {
    background-color: #ffd700;
    color: #000;
    padding: 0 4px;
    border-radius: 2px;
    cursor: pointer;
    font-weight: bold;
    animation: pulsate 2s infinite;
}

@keyframes pulsate {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Pricing Screen (reuses overlay logic via JS toggling hidden) */
#pricing-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--pixel-lightest);
    z-index: 101;
    /* Above collection */
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.pricing-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.5;
}

.pricing-content .price {
    font-size: 24px;
    margin: 10px 0;
    color: var(--gb-text-blue);
    font-weight: 900;
}

.feature-list {
    font-size: 10px;
    text-align: left;
    margin-top: 10px;
}

/* Collection Screen Overlay */
#collection-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--pixel-lightest);
    z-index: 100;
    padding: 10px;
    display: flex;
    flex-direction: column;
    /* ensure it sits on top of everything but under glass */
}

.collection-header {
    text-align: center;
    border-bottom: 2px solid var(--pixel-darkest);
    margin-bottom: 10px;
    padding-bottom: 5px;
    color: var(--pixel-darkest);
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: min-content;
    /* Prevent stretching */
    gap: 5px;
    flex-grow: 1;
    overflow-y: auto;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
    align-content: start;
    /* Pack items at start */
}

.collection-grid::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.collection-item {
    aspect-ratio: 1;
    border: 2px solid var(--pixel-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--pixel-light);
    position: relative;
    image-rendering: pixelated;
    overflow: hidden;
    /* Keep content inside */
}

.collection-item.locked {
    background-color: var(--pixel-dark);
    opacity: 0.5;
}

.collection-item.locked::after {
    content: "?";
    font-size: 20px;
    color: var(--pixel-lightest);
}

.collection-item.locked.coming-soon::after {
    content: "SOON";
    font-size: 10px;
}

/* Style for the sprite div inside collection */
.collection-item>div {
    /* Main.js injects a div with background-image */
    transform-origin: center;
    transform: scale(1.5);
    /* Make them a bit bigger in the box */
}

/* Specific styling for unlocking visuals */
.collection-footer {
    border-top: 2px solid var(--pixel-darkest);
    margin-top: 5px;
    padding-top: 5px;
    text-align: center;
    font-size: 8px;
}

.main-display {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}



/* --- SCREEN BEZEL --- */
.screen-border {
    background-color: var(--gb-screen-bezel);
    width: 100%;
    padding: 30px 40px 30px 40px;
    /* Wide side bezels */
    border-radius: 15px 15px 40px 15px;
    box-shadow:
        inset 2px 2px 5px rgba(0, 0, 0, 0.5),
        2px 2px 2px rgba(255, 255, 255, 0.1);
    /* Subtle highlight */
    position: relative;
    margin-bottom: 20px;
}

/* Battery LED */
.power-led-wrapper {
    position: absolute;
    top: 10px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.power-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #555;
    /* Off state */
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.game-container.on .power-led {
    background-color: #f00;
    /* On state */
    box-shadow: 0 0 5px #f00, inset 1px 1px 2px rgba(255, 255, 255, 0.4);
}

.power-label {
    font-family: sans-serif;
    font-size: 8px;
    color: #ccc;
    font-weight: bold;
}

/* --- LCD SCREEN --- */
.screen-content {
    background-color: var(--pixel-lightest);
    width: 100%;
    height: 220px;
    box-shadow: inset 3px 3px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    position: relative;
    image-rendering: pixelated;
    color: var(--pixel-darkest);
    overflow: hidden;
    border: 1px solid #666;
}

/* LCD Matrix Effect (The "Grid") */
.screen-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(to bottom, rgba(168, 184, 15, 0.1) 50%, transparent 50%),
        linear-gradient(to right, rgba(168, 184, 15, 0.1) 50%, transparent 50%);
    background-size: 4px 4px;
    pointer-events: none;
    z-index: 10;
}

/* Glass Reflection overlay */
.screen-overlay-glass {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 40%, transparent 60%, rgba(255, 255, 255, 0.05) 100%);
    pointer-events: none;
    z-index: 20;
}


/* --- CONTROLS SECTION --- */
.controls {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    /* Align Dpad and Buttons */
    margin-bottom: 40px;
    padding: 0 10px;
}

/* D-PAD */
.d-pad-container {
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.d-pad {
    width: 90px;
    height: 90px;
    position: relative;
    /* D-pad Dish (indented area) */
    /* border-radius: 50%; 
       background: radial-gradient(#bbb, #ccc);
       box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2); 
       -- Removed dish for cleaner look, classic didn't have deep dish */
}

.d-pad div {
    background-color: var(--gb-dpad);
    position: absolute;
    box-shadow:
        2px 2px 0 #111,
        /* 3D side */
        4px 4px 5px rgba(0, 0, 0, 0.4);
    /* Shadow */
    cursor: pointer;
}

/* Dpad center fill for smooth cross */
.d-pad .center {
    width: 30px;
    height: 30px;
    top: 30px;
    left: 30px;
    z-index: 2;
    background: radial-gradient(circle at 30% 30%, #444, #222);
    box-shadow: none;
}

.d-pad .up {
    width: 30px;
    height: 30px;
    top: 0;
    left: 30px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(to top, #222, #444);
}

.d-pad .down {
    width: 30px;
    height: 30px;
    top: 60px;
    left: 30px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(to bottom, #222, #444);
}

.d-pad .left {
    width: 30px;
    height: 30px;
    top: 30px;
    left: 0;
    border-radius: 4px 0 0 4px;
    background: linear-gradient(to left, #222, #444);
}

.d-pad .right {
    width: 30px;
    height: 30px;
    top: 30px;
    left: 60px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(to right, #222, #444);
}

.d-pad div:active {
    box-shadow: inset 2px 2px 5px #000;
    transform: translate(1px, 1px);
}


/* ACTION BUTTONS (A/B) */
.action-buttons-container {
    display: flex;
    gap: 15px;
    /* Spacing between A and B wrappers */
    transform: rotate(-25deg);
    /* Classic Angle */
    margin-top: 20px;
    margin-right: 10px;
}

.btn-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    /* Space between button and label */
}

/* The Button Itself */
.game-btn {
    appearance: none;
    -webkit-appearance: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--gb-btn-a);
    border: none;

    /* Convex Plastic Feel */
    background: radial-gradient(circle at 30% 30%, #d6223a, #a90e20 60%, #7a0815);
    box-shadow:
        2px 2px 0 #500,
        /* 3D Side */
        5px 5px 8px rgba(0, 0, 0, 0.5);
    /* Drop Shadow */

    cursor: pointer;
    transition: transform 0.05s;
}

.game-btn:active {
    transform: translate(2px, 2px);
    box-shadow:
        0 0 0 #500,
        1px 1px 2px rgba(0, 0, 0, 0.5),
        inset 2px 2px 5px rgba(0, 0, 0, 0.6);
    /* Pressed inner shadow */
}

/* Button Labels (Painted on the case) */
.btn-label {
    font-family: sans-serif;
    /* Rounded sans */
    font-weight: 900;
    font-size: 14px;
    color: var(--gb-text-label);
    opacity: 0.8;
    transform: rotate(25deg);
    /* Counter-rotate to be straight vs user view? No, GB labels were angled with the buttons mostly, but let's make them readable */
    /* Actually GB labels are printed angled under the buttons. */
}


/* --- START / SELECT --- */
.sub-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

.capsule-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transform: rotate(-25deg);
}

.capsule-btn {
    appearance: none;
    -webkit-appearance: none;
    width: 60px;
    height: 14px;
    border-radius: 10px;
    background-color: var(--gb-select-start);
    border: none;

    /* Rubber feel */
    background: linear-gradient(to bottom, #777, #666);
    box-shadow:
        1px 1px 0 #333,
        2px 2px 3px rgba(0, 0, 0, 0.3);

    cursor: pointer;
}

.capsule-btn:active {
    transform: translate(1px, 1px);
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.capsule-label {
    font-family: sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--gb-text-label);
    text-transform: uppercase;
}

/* --- UI COMPONENTS IN SCREEN --- */
.status-bar {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    border-bottom: 2px solid var(--pixel-dark);
    padding-bottom: 4px;
    z-index: 2;
    font-weight: bold;
}

.egg-sprite {
    width: 100px;
    /* Increased size */
    height: 100px;
    background-image: url('assets/egg-sprite_color_2.png');
    /* Using auto height ensures the aspect ratio is preserved from the source image */
    background-size: 500% auto;
    background-repeat: no-repeat;
    background-position: 0% 50%;
    image-rendering: pixelated;
    transition: transform 0.1s;
    margin: 10px auto 0;
    /* Adjusted margin for larger size */
    mix-blend-mode: multiply;
    /* Hides the light checkerboard background */
}

/* ANIMATIONS & STATES */
/* (Keeping generated keyframes, ensuring they work) */
@keyframes sway {

    0%,
    100% {
        transform: rotate(-3deg);
    }

    50% {
        transform: rotate(3deg);
    }
}

@keyframes dance {
    0% {
        background-position: 0% 0%;
    }

    25% {
        background-position: 33.33% 0%;
    }

    50% {
        background-position: 66.66% 0%;
    }

    75% {
        background-position: 100% 0%;
    }
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    25% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    75% {
        transform: translate(3px, 1px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

.egg-stage-0 .egg-sprite {
    background-position: 0% 50%;
    animation: sway 3s infinite ease-in-out;
}

.egg-stage-1 .egg-sprite {
    background-position: 25% 50%;
    animation: sway 2.5s infinite ease-in-out;
}

.egg-stage-2 .egg-sprite {
    background-position: 50% 50%;
    animation: sway 2s infinite ease-in-out;
}

.egg-stage-3 .egg-sprite {
    background-position: 75% 50%;
    animation: shake 1s infinite;
}

.egg-stage-4 .egg-sprite {
    background-position: 100% 50%;
    animation: shake 0.5s infinite;
    filter: brightness(1.2);
}

.egg-hatched .egg-sprite {
    background-image: url('assets/chick-sprite_done.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: none;
}

/* NINJA VARIANT */
/* Applied to #egg-container if the session is ninja-type */
.ninja-egg .egg-sprite {
    background-image: url('assets/egg-ninja_color.png');
}

.egg-hatched.ninja-chick .egg-sprite {
    background-image: url('assets/chick-ninja_done.png');
    background-size: contain;
    background-position: center;
}

/* ALIEN VARIANT */
.alien-egg .egg-sprite {
    background-image: url('assets/egg-alien.png');
}

.egg-hatched.alien-chick .egg-sprite {
    background-image: url('assets/chick-alien_done.png');
    background-size: contain;
    background-position: center;
}

.timer-display {
    text-align: right;
    font-size: 24px;
    margin-bottom: 5px;
    z-index: 5;
}

.message-area {
    font-size: 10px;
    min-height: 12px;
    z-index: 5;
}