:root {
    /* Day Theme (Darker/Cozy Mode) */
    --bg-gradient: linear-gradient(135deg, #cf9ba9 0%, #b86e7a 100%);
    /* Dusty Rose/Mauve */

    --card-bg: rgba(255, 255, 255, 0.15);
    --card-border: rgba(255, 255, 255, 0.3);
    --text-color: #fff;
    --heading-color: #fff;

    --plushie-color: #f2e6e8;
    /* Soft Off-White/Grey-Pink */
    --plushie-shadow: #9e858b;

    --accent-glow: 0 0 15px rgba(255, 255, 255, 0.3);

    --font-heading: 'Baloo 2', cursive;
    --font-body: 'Nunito', sans-serif;
}

[data-theme="night"] {
    --bg-gradient: linear-gradient(135deg, #2d3436 0%, #6c5ce7 100%);
    --card-bg: rgba(20, 20, 40, 0.4);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-color: #dfe6e9;
    --heading-color: #a29bfe;
    --plushie-color: #ff9ebd;
    --accent-glow: 0 0 20px rgba(162, 155, 254, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background 0.5s ease, color 0.5s ease;
}

body {
    font-family: var(--font-body);
    background: var(--bg-gradient);
    color: var(--text-color);
    height: 100vh;
    /* Lock to viewport height */
    overflow: hidden;
    /* Prevent scroll */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    user-select: none;
}

/* Glassmorphism Utility */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 25px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

/* Background Hearts (Floating Up) */
.background-hearts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.floating-heart {
    position: absolute;
    color: #ff4d88;
    font-size: 20px;
    animation: floatUp 6s linear infinite;
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
    /* Keep behind */
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-10vh) scale(1.5);
        opacity: 0;
    }
}

/* Rain Effect for Sad Mode */
.rain-drop {
    position: absolute;
    color: rgba(140, 158, 255, 0.6);
    font-size: 1.2rem;
    animation: rainFall linear forwards;
    z-index: 10;
}

@keyframes rainFall {
    0% {
        transform: translateY(-10vh);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

/* Counters & Toggles */
.candy-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    background: var(--card-bg);
    padding: 8px 12px;
    border-radius: 20px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1rem;
    color: white;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(5px);
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    font-size: 1.2rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Wardrobe Panel */
.wardrobe-panel {
    position: absolute;
    left: 20px;
    top: 70px;
    width: 70px;
    padding: 10px;
    z-index: 90;
    text-align: center;
    transition: transform 0.3s ease;
}

.wardrobe-panel h3 {
    font-size: 0.7rem;
    margin-bottom: 5px;
    color: white;
}

.wardrobe-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wardrobe-item {
    background: rgba(255, 255, 255, 0.4);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.wardrobe-item:hover {
    transform: scale(1.1);
    background: white;
}

.wardrobe-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.wardrobe-item.active {
    border-color: white;
    background: rgba(255, 255, 255, 0.8);
}

.wardrobe-hint {
    font-size: 0.5rem;
    margin-top: 5px;
    opacity: 0.8;
    color: white;
}

/* Happiness Meter */
.meter-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 300px;
    z-index: 90;
    text-align: center;
}

.meter-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-heading);
    font-weight: 800;
    color: white;
    margin-bottom: 3px;
    font-size: 0.8rem;
}

.meter-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #a8ff78 0%, #78ffd6 100%);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 10px rgba(120, 255, 214, 0.5);
}

/* Main Layout */
.main-container {
    padding: 10px;
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Center vertically */
    z-index: 10;
    gap: 15px;
    /* Spacing between elements */
}

header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-top: 40px;
    /* Clear meter */
    flex-shrink: 0;
}

header h1 {
    font-family: var(--font-heading);
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.top-controls {
    display: flex;
    gap: 8px;
}

.icon-toggle {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.icon-toggle:hover {
    background: white;
    transform: scale(1.1);
}

.icon-toggle.active {
    background: white;
    box-shadow: 0 0 10px white;
}

/* Plushie Section */
.plushie-section {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
    /* Allow to take available space */
    justify-content: center;
    width: 100%;
    max-height: 45vh;
    /* Cap height to leave room for buttons */
}

.speech-bubble {
    background: white;
    padding: 8px 15px;
    border-radius: 15px;
    border: none;
    margin-bottom: 15px;
    text-align: center;
    font-family: var(--font-heading);
    color: #4a5568;
    position: relative;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.4s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
}

.speech-bubble.visible {
    opacity: 1;
    transform: translateY(0);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

.plushie-wrapper {
    position: relative;
    width: 180px;
    /* Slightly smaller base size */
    height: 220px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    transition: transform 0.1s linear;
    /* Smooth follow delay */
}

/* Waddle Animation */
.plushie-wrapper.waddle .plushie {
    animation: waddle 0.6s infinite ease-in-out;
}

@keyframes waddle {

    0%,
    100% {
        transform: rotate(-5deg) translateY(0);
    }

    50% {
        transform: rotate(5deg) translateY(-5px);
    }
}

/* Plushie CSS Art */
.plushie {
    width: 160px;
    height: 200px;
    position: relative;
    transition: transform 0.3s ease;
}

/* Accessories on Plushie */
.accessories-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

.acc-item {
    position: absolute;
    font-size: 3rem;
}

.acc-bow {
    top: -15px;
    left: 85px;
}

.acc-hat {
    top: -25px;
    left: 60px;
    transform: rotate(-10deg);
    font-size: 3.5rem;
}

.acc-scarf {
    top: 120px;
    left: 55px;
    font-size: 4rem;
    z-index: 10;
    transform: rotate(-5deg);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

.acc-crown {
    top: -35px;
    left: 70px;
    font-size: 3.5rem;
    filter: drop-shadow(0 0 10px gold);
}

/* Body Parts */
.head {
    width: 110px;
    height: 100px;
    background: var(--plushie-color);
    border-radius: 50% 50% 45% 45%;
    position: absolute;
    top: 15px;
    left: 25px;
    z-index: 5;
    box-shadow: inset -5px -5px 15px rgba(0, 0, 0, 0.1);
}

.ear {
    width: 40px;
    height: 40px;
    background: var(--plushie-color);
    border-radius: 50%;
    position: absolute;
    top: 8px;
    z-index: 1;
}

.ear.left {
    left: 15px;
}

.ear.right {
    right: 15px;
}

.face {
    position: relative;
    width: 100%;
    height: 100%;
}

.eye {
    width: 14px;
    height: 18px;
    background: #333;
    border-radius: 50%;
    position: absolute;
    top: 45px;
    transition: all 0.3s ease;
}

.eye.left {
    left: 28px;
}

.eye.right {
    right: 28px;
}

.pupil {
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    right: 3px;
}

/* Expression Helpers */
.sad-eyes .eye {
    height: 12px;
    border-radius: 50% 50% 0 0;
    top: 60px;
    transform: rotate(10deg);
}

.sad-eyes .eye.right {
    transform: rotate(-10deg);
}

.sleepy-eyes .eye {
    height: 4px;
    top: 62px;
}

.happy-eyes .eye {
    height: 15px;
    border-radius: 50%;
}

.cheeks {
    width: 20px;
    height: 12px;
    background: #ffb7d2;
    border-radius: 50%;
    position: absolute;
    top: 60px;
    opacity: 0.6;
}

.cheeks.left {
    left: 15px;
}

.cheeks.right {
    right: 15px;
}

.snout {
    width: 32px;
    height: 24px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 55px;
    left: 39px;
}

.nose {
    width: 10px;
    height: 6px;
    background: #ff7eb9;
    border-radius: 50%;
    position: absolute;
    top: 5px;
    left: 11px;
}

.mouth {
    width: 12px;
    height: 6px;
    border-bottom: 3px solid #333;
    border-radius: 0 0 16px 16px;
    position: absolute;
    top: 12px;
    left: 10px;
    transition: all 0.3s ease;
}

/* Mouth Variations */
.mouth.smile {
    border-bottom: 3px solid #333;
    border-radius: 0 0 16px 16px;
    height: 8px;
}

.mouth.frown {
    border-bottom: none;
    border-top: 3px solid #333;
    border-radius: 16px 16px 0 0;
    top: 20px;
}

.mouth.o-mouth {
    width: 10px;
    height: 10px;
    border: 3px solid #333;
    border-radius: 50%;
    top: 16px;
    left: 15px;
    border-bottom: 3px solid #333;
}

.body {
    width: 96px;
    height: 90px;
    background: var(--plushie-color);
    border-radius: 45% 45% 50% 50%;
    position: absolute;
    top: 100px;
    left: 32px;
    z-index: 4;
}

.belly {
    width: 48px;
    height: 40px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    position: absolute;
    top: 20px;
    left: 24px;
}

.arm {
    width: 32px;
    height: 40px;
    background: var(--plushie-color);
    border-radius: 20px;
    position: absolute;
    top: 105px;
    z-index: 6;
    transform-origin: top center;
    transition: all 0.5s ease;
}

.arm.left {
    left: 20px;
    transform: rotate(20deg);
}

.arm.right {
    right: 20px;
    transform: rotate(-20deg);
}

.leg {
    width: 36px;
    height: 40px;
    background: var(--plushie-color);
    border-radius: 20px;
    position: absolute;
    bottom: -5px;
    z-index: 3;
}

.leg.left {
    left: 36px;
}

.leg.right {
    right: 36px;
}

.shadow {
    width: 140px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    position: absolute;
    bottom: 20px;
    z-index: 0;
    animation: shadowPulse 4s ease-in-out infinite;
}

/* Feeding Area */
.feeding-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: -10px;
    margin-bottom: 5px;
    z-index: 30;
}

.food-btn {
    background: var(--card-bg);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.food-btn:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.6);
}

/* Interaction Area */
.interaction-area {
    width: 95%;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.mood-buttons {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    flex-wrap: wrap;
}

.mood-btn {
    flex: 1;
    min-width: 80px;
    padding: 8px 5px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.25);
    font-family: var(--font-body);
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    white-space: nowrap;
}

.mood-btn:hover {
    transform: translateY(-2px);
    background: white;
    color: var(--plushie-shadow);
}

/* Hug Button */
.hug-btn {
    width: 100%;
    padding: 12px;
    background: white;
    border: none;
    border-radius: 15px;
    color: #ff758c;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.hug-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(255, 154, 158, 0.6);
    background: #fff0f6;
}

.hug-btn:active {
    transform: scale(0.98);
}

.surprise-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px dashed white;
    color: white;
    border-radius: 15px;
    font-family: var(--font-heading);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.surprise-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    letter-spacing: 1px;
}

.diary-btn {
    background: transparent;
    border: none;
    text-decoration: underline;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.8;
}

.personalization input {
    width: 100%;
    padding: 8px;
    text-align: center;
    border-radius: 15px;
    border: none;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 0.9rem;
}

.personalization input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 200;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    padding: 25px;
    width: 90%;
    max-width: 350px;
    text-align: center;
    color: var(--text-color);
}

.modal h3 {
    font-family: var(--font-heading);
    color: var(--heading-color);
    margin-bottom: 10px;
}

.modal textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin: 15px 0;
    font-family: var(--font-body);
    resize: none;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-buttons button {
    padding: 8px 16px;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    font-weight: 600;
}

.submit-btn {
    background: var(--heading-color);
    color: white;
}

.close-btn {
    background: #eee;
    color: #555;
}

/* Breathing Overlay */
.breathing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 10, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s;
    z-index: 300;
}

.breathing-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.breathing-circle {
    width: 200px;
    height: 200px;
    border: 4px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
    transform: scale(0.8);
}

.breathing-overlay.active .breathing-circle {
    animation: breatheGuide 12s infinite ease-in-out;
}

@keyframes breatheGuide {
    0% {
        transform: scale(0.6);
        border-color: #a29bfe;
        box-shadow: 0 0 20px #a29bfe;
    }

    /* Inhale Start */
    40% {
        transform: scale(1.2);
        border-color: #ff9ebd;
        box-shadow: 0 0 50px #ff9ebd;
    }

    /* Inhale End */
    60% {
        transform: scale(1.2);
        border-color: #ff9ebd;
    }

    /* Hold */
    100% {
        transform: scale(0.6);
        border-color: #a29bfe;
    }

    /* Exhale End */
}

.close-overlay-btn {
    margin-top: 50px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid white;
    border-radius: 20px;
    cursor: pointer;
}

.close-overlay-btn:hover {
    background: white;
    color: #333;
}

/* Sleep Mode */
.sleeping-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 10, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s;
    z-index: 50;
}

body.is-sleeping .sleeping-overlay {
    opacity: 1;
}

body.is-sleeping .plushie {
    opacity: 0.8;
    filter: brightness(0.9);
}

/* Animation Keyframes */
@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

@keyframes blink {

    0%,
    45%,
    55%,
    100% {
        transform: scaleY(1);
    }

    50% {
        transform: scaleY(0.1);
    }
}

@keyframes hug-squeeze {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.15) translateZ(20px);
    }

    50% {
        transform: scale(0.9) translateZ(0);
    }

    /* Squeeze in */
    100% {
        transform: scale(1);
    }
}

@keyframes eat {
    0% {
        transform: translateY(0);
    }

    25% {
        transform: translateY(-5px) rotate(-5deg);
    }

    50% {
        transform: translateY(0) rotate(5deg);
    }

    75% {
        transform: translateY(-3px);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes shadowPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.1;
    }

    50% {
        transform: scale(0.9);
        opacity: 0.05;
    }
}

/* Interactive Classes */
.hugging .arm.left {
    transform: rotate(-50deg) translateX(15px);
}

.hugging .arm.right {
    transform: rotate(50deg) translateX(-15px);
}

.hugging .plushie {
    animation: hug-squeeze 1s ease forwards;
}

.sparkle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #fff, transparent);
    pointer-events: none;
    animation: sparkleFade 1s forwards;
}

@keyframes sparkleFade {
    0% {
        opacity: 1;
        transform: scale(0);
    }

    100% {
        opacity: 0;
        transform: scale(2);
    }
}

/* Mobile Modifiers */
@media (max-width: 600px) {
    .plushie {
        transform: scale(0.95);
    }

    .interaction-area {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8rem;
        margin-top: 50px;
    }

    .wardrobe-panel {
        transform: translateX(-120%);
    }

    /* Hide on mobile initially */
    .wardrobe-panel.active {
        transform: translateX(0);
    }
}

/* Responsive Adjustments */
@media (max-height: 700px) {

    /* Laptop / Short Screen Optimization */
    .plushie-wrapper {
        transform: scale(0.85);
        margin: -10px auto;
    }

    .plushie-section {
        max-height: 40vh;
    }

    header {
        margin-top: 50px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .interaction-area {
        padding: 10px;
        gap: 8px;
    }

    .hug-btn {
        padding: 10px;
        font-size: 1.1rem;
    }

    .wardrobe-panel {
        top: 60px;
        scale: 0.9;
        transform-origin: top left;
    }
}

@media (max-width: 400px) {

    /* Mobile Optimization */
    .mood-btn {
        font-size: 0.7rem;
        padding: 6px 2px;
    }

    .wardrobe-panel {
        display: none;
    }

    /* Hide wardrobe on very small screens or make toggleable via JS if needed, user said "mobile friendly" */
    .wardrobe-panel.active {
        display: block;
        left: 50%;
        transform: translateX(-50%);
        top: 100px;
        width: 200px;
        background: rgba(0, 0, 0, 0.8);
    }

    .wardrobe-items {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
}