@import url('https://fonts.googleapis.com/css2?family=Mali:wght@400;600;700&display=swap');

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Mali', cursive;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background: #f9fafb;
    color: #1f2937;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar {
    display: none;
}

/* ===== PET CONTAINER ===== */
.pet-container {
    transition: transform 0.1s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: env(safe-area-inset-bottom, 20px);
    width: 100%;
}

.pet-container:active {
    transform: scale(0.95);
}

/* ===== NEW ICONS ===== */
.stat-icon {
    height: 1.25em;
    vertical-align: text-bottom;
    object-fit: contain;
}

.stat-icon.inline {
    height: 1em;
    vertical-align: middle;
}

.reset-icon {
    width: 1.5rem;
    height: 1.5rem;
    object-fit: contain;
    transition: transform 0.2s;
}

.btn-reset:hover .reset-icon {
    transform: rotate(45deg);
}

/* ===== PET IMAGE ===== */
.pet-image {
    width: 180px;
    height: 180px;
    object-fit: contain;
    image-rendering: auto;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.12));
    transition: filter 0.5s ease, opacity 0.3s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom center;
}

/* Growth pop when fed */
.pet-image.growth-pop {
    animation: growth-pop 0.4s ease;
}

@keyframes growth-pop {
    0%   { filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.12)) brightness(1); }
    40%  { filter: drop-shadow(0 12px 32px rgba(251, 146, 60, 0.35)) brightness(1.15); }
    100% { filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.12)) brightness(1); }
}

/* ===== BOUNCE ANIMATION ===== */
.bounce {
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-15px); }
}

/* ===== FLOATING TEXT ===== */
.floating-text {
    position: absolute;
    animation: floatUp 1s ease-out forwards;
    pointer-events: none;
    font-weight: bold;
    color: #ec4899;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(1.2); }
}

/* ===== STATUS PANEL ===== */
.status-panel {
    background: #fce7f3;
    width: 100%;
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 2rem 2rem;
    flex-shrink: 0;
    transition: all 0.3s;
}

.status-panel-inner {
    padding: 1.25rem;
    flex: 1;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.game-logo {
    display: block;
    height: 2.5rem;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.btn-reset {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-reset:hover {
    background: rgba(0,0,0,0.05);
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== MONEY DISPLAY ===== */
.money-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.money-label {
    font-weight: 700;
    color: #eab308;
    font-size: 1rem;
}

.money-value {
    font-weight: 700;
    color: #374151;
    font-size: 1.125rem;
    transition: color 0.3s;
}

.money-value.debt {
    color: #ef4444;
}

/* ===== STAT BARS ===== */
.stat-row label {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 0.5rem;
}

.bar-track {
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 9999px;
    height: 1rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.bar-fill.hunger-bar {
    background: #fb923c;
}

.bar-fill.hunger-bar.critical {
    background: #ef4444;
    animation: pulse-bar 0.8s infinite alternate;
}

.bar-fill.energy-bar {
    background: #60a5fa;
}

.bar-fill.energy-bar.critical {
    background: #ef4444;
    animation: pulse-bar 0.8s infinite alternate;
}

@keyframes pulse-bar {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

/* ===== ACTION BUTTONS (Desktop) ===== */
.desktop-buttons {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding: 2rem;
    padding-top: 0;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-family: 'Mali', cursive;
    font-weight: 700;
    font-size: 1.125rem;
    padding: 1rem;
    border-radius: 1rem;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.action-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.action-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
}

.action-btn .btn-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-feed {
    background: white;
    border-color: #fed7aa;
    color: #ea580c;
}
.btn-feed:hover:not(:disabled) { background: #fff7ed; }

.btn-sleep {
    background: white;
    border-color: #bfdbfe;
    color: #2563eb;
}
.btn-sleep:hover:not(:disabled) { background: #eff6ff; }

.btn-work {
    background: white;
    border-color: #e9d5ff;
    color: #9333ea;
}
.btn-work:hover:not(:disabled) { background: #faf5ff; }

/* ===== PET AREA ===== */
.pet-area {
    flex: 1;
    min-height: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 20px));
    cursor: pointer;
    overflow: hidden;
    transition: background-color 0.5s ease;
    background: #eff6ff;
    background-image: url('image/bg.jpg');
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
}

.pet-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(239, 246, 255, 0.3);
    transition: background 0.5s ease;
    z-index: 0;
}

.pet-area > *:not(.floating-text) {
    position: relative;
    z-index: 1;
}

.pet-area.state-sleep::before {
    background: rgba(30, 27, 75, 0.75);
}
.pet-area.state-sleep {
    cursor: not-allowed;
}

.pet-area.state-work::before {
    background: rgba(243, 232, 255, 0.5);
}
.pet-area.state-work {
    cursor: not-allowed;
}

.pet-area.state-hungry::before {
    background: rgba(255, 247, 237, 0.45);
}

.pet-area.state-sick::before {
    background: rgba(254, 242, 242, 0.5);
}

/* ===== BADGES ROW (in status panel) ===== */
.badges-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.status-badge {
    background: white;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    color: #374151;
    transition: all 0.3s;
}

/* ===== GROWTH BADGE ===== */
.growth-badge {
    background: white;
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    color: #374151;
    transition: all 0.4s ease;
    border: 2px solid transparent;
}

.growth-badge[data-tier="0"] { border-color: #d1d5db; color: #6b7280; }
.growth-badge[data-tier="1"] { border-color: #86efac; color: #16a34a; }
.growth-badge[data-tier="2"] { border-color: #93c5fd; color: #2563eb; }
.growth-badge[data-tier="3"] { border-color: #fbbf24; color: #d97706; }
.growth-badge[data-tier="4"] { border-color: #fb923c; color: #ea580c; }
.growth-badge[data-tier="5"] { border-color: #f472b6; color: #db2777; background: rgba(252, 231, 243, 0.95); }
.growth-badge[data-tier="6"] { border-color: #a855f7; color: #7e22ce; background: linear-gradient(to right, #f3e8ff, #ffffff); }
.growth-badge[data-tier="7"] { border-color: #6366f1; color: #4338ca; background: linear-gradient(to right, #e0e7ff, #ffffff); box-shadow: 0 0 15px rgba(99, 102, 241, 0.3); }
.growth-badge[data-tier="8"] { border-color: #06b6d4; color: #0e7490; background: linear-gradient(to right, #cffafe, #ffffff); box-shadow: 0 0 20px rgba(6, 182, 212, 0.4); }
.growth-badge[data-tier="9"] { border-color: #f59e0b; color: #b45309; background: linear-gradient(135deg, #fef3c7 0%, #ffffff 100%); border-style: double; border-width: 4px; box-shadow: 0 0 25px rgba(245, 158, 11, 0.5); }
.growth-badge[data-tier="10"] { 
    border-color: #ef4444; color: #b91c1c; 
    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%); 
    border-style: solid; border-width: 2px;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    animation: glow-red 2s infinite alternate;
}

@keyframes glow-red {
    from { box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
    to { box-shadow: 0 0 30px rgba(239, 68, 68, 0.8); }
}

/* ===== PET ACCESSORIES ===== */
.pet-accessories {
    font-size: 2.5rem;
    height: 2rem;
    transition: all 0.3s;
    flex-shrink: 0;
}

/* ===== MOBILE BUTTONS ===== */
.mobile-buttons {
    background: white;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -10px 20px -10px rgba(0, 0, 0, 0.1);
    z-index: 20;
    border-radius: 2rem 2rem 0 0;
    flex-shrink: 0;
}

.mobile-btn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.mobile-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Mali', cursive;
    font-weight: 700;
    padding: 0.75rem;
    border-radius: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    height: 5rem;
}

.mobile-action-btn:disabled {
    opacity: 0.5;
}

.mobile-action-btn .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.25rem;
}

.mobile-action-btn .btn-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mobile-action-btn .btn-label {
    font-size: 0.75rem;
}

.mobile-btn-feed {
    background: #fff7ed;
    color: #ea580c;
}
.mobile-btn-feed:active:not(:disabled) { background: #ffedd5; }

.mobile-btn-sleep {
    background: #eff6ff;
    color: #2563eb;
}
.mobile-btn-sleep:active:not(:disabled) { background: #dbeafe; }

.mobile-btn-work {
    background: #faf5ff;
    color: #9333ea;
}
.mobile-btn-work:active:not(:disabled) { background: #f3e8ff; }

/* ===== EVENT TOAST NOTIFICATIONS ===== */
.event-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 340px;
    width: calc(100% - 2rem);
}

.event-toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    animation: toast-in 0.4s ease forwards, toast-out 0.4s ease forwards 3.5s;
    border-left: 4px solid #ef4444;
    transform: translateX(120%);
}

.event-toast.positive {
    border-left-color: #22c55e;
}

@keyframes toast-in {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0);    opacity: 1; max-height: 120px; margin-bottom: 0; }
    to   { transform: translateX(120%); opacity: 0; max-height: 0;     margin-bottom: -0.5rem; }
}

.event-toast .toast-image {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}

.event-toast .toast-body {
    flex: 1;
    min-width: 0;
}

.event-toast .toast-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-toast .toast-effect {
    font-size: 0.8rem;
    font-weight: 600;
    color: #ef4444;
    margin-top: 0.15rem;
}

.event-toast.positive .toast-effect {
    color: #22c55e;
}

/* ===== GAME OVER OVERLAY ===== */
.gameover-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.gameover-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.gameover-card {
    background: white;
    border-radius: 2rem;
    padding: 2.5rem 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.4s ease;
}

.gameover-overlay.active .gameover-card {
    transform: scale(1);
}

.gameover-card .gameover-image {
    width: 150px;
    height: 150px;
    object-fit: contain;
    margin: 0 auto 1rem;
}

.gameover-card .gameover-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: #ef4444;
    margin-bottom: 0.5rem;
}

.gameover-card .gameover-subtitle {
    font-size: 1rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.gameover-card .gameover-stats {
    font-size: 0.95rem;
    color: #9ca3af;
    margin-bottom: 1.5rem;
}

.gameover-restart-btn {
    font-family: 'Mali', cursive;
    font-weight: 700;
    font-size: 1.25rem;
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: white;
    border: none;
    padding: 1rem 3rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(219, 39, 119, 0.4);
}

.gameover-restart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(219, 39, 119, 0.5);
}

/* ===== SLEEP OVERLAY EFFECT ===== */
.sleep-particles {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 5;
}

.zzz {
    position: absolute;
    font-size: 2rem;
    opacity: 0;
    animation: zzz-float 3s ease-in-out infinite;
    color: rgba(199, 210, 254, 0.7);
}

@keyframes zzz-float {
    0% { opacity: 0; transform: translateY(0) scale(0.5); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-120px) translateX(30px) scale(1.3); }
}

/* ===== RESPONSIVE (Desktop) ===== */
@media (min-width: 768px) {
    body {
        flex-direction: row;
    }

    .status-panel {
        width: 24rem;
        border-radius: 0 2rem 2rem 0;
    }

    .status-panel-inner {
        padding: 2rem;
    }

    .game-logo {
        height: 3.5rem;
    }

    .header-row {
        margin-bottom: 2.5rem;
    }

    .stats-grid {
        gap: 1.5rem;
    }

    .money-label,
    .money-value {
        font-size: 1.25rem;
    }

    .stat-row label {
        font-size: 1rem;
    }

    .desktop-buttons {
        display: flex;
    }

    .mobile-buttons {
        display: none;
    }

    .status-badge {
        font-size: 1rem;
    }

    .growth-badge {
        font-size: 1rem;
    }

    .pet-image {
        width: 320px;
        height: 320px;
    }

    .pet-accessories {
        font-size: 5rem;
        margin-top: 2rem;
        height: 6rem;
    }

    .event-toast-container {
        top: 1.5rem;
        right: 1.5rem;
        max-width: 380px;
    }
}

/* ===== TUTORIAL OVERLAY ===== */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.tutorial-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.tutorial-card {
    background: white;
    border-radius: 2rem;
    padding: 2rem 1.5rem;
    max-width: 380px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
    transform: scale(0.85) translateY(20px);
    transition: transform 0.4s ease;
}

.tutorial-overlay.active .tutorial-card {
    transform: scale(1) translateY(0);
}

.tutorial-card .tutorial-step-indicator {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.tutorial-card .tutorial-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin: 0 auto 1rem;
}

.tutorial-card .tutorial-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #db2777;
    margin-bottom: 0.5rem;
}

.tutorial-card .tutorial-desc {
    font-size: 0.95rem;
    color: #4b5563;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.tutorial-card .tutorial-desc span {
    display: inline-block;
    background: #fce7f3;
    padding: 0.1rem 0.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    color: #db2777;
}

.tutorial-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.tutorial-btn {
    font-family: 'Mali', cursive;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.tutorial-btn.primary {
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: white;
    box-shadow: 0 4px 16px rgba(219, 39, 119, 0.35);
}

.tutorial-btn.primary:hover {
    transform: scale(1.05);
}

.tutorial-btn.skip {
    background: #f3f4f6;
    color: #6b7280;
}

.tutorial-btn.skip:hover {
    background: #e5e7eb;
}
