/* ==============================
🌾 BODY / LAYOUT CHUNG
============================== */

html, body {
    width: 100%;
    min-height: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
    overflow: hidden;
    background: url("img/background.png") no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch !important;
    justify-content: flex-start !important;
    text-align: initial !important;
    color: #fff;
    cursor: grab;
}

main.flex-fill {
    position: relative;
    overflow: hidden;
}

.content {
    position: relative;
    z-index: 2;
    transform: translateY(50px);
}

h1 {
    font-size: 3rem;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.5);
    margin-bottom: 30px;
}

footer {
    width: 100%;
    bottom: 0;
    left: 0;
    right: 0;
    position: relative;
    margin-top: auto;
}


/* ==============================
🎮 GAME VIEWPORT
============================== */

.game-viewport {
    position: relative;
    width: 100vw;
    height: calc(100vh - 56px);
    overflow: hidden;
}

.game-stage {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1300px;
    height: 720px;
    transform-origin: center center;
}

.page-recycle {
    position: absolute !important;
    inset: 0 !important;
    width: 1300px !important;
    height: 720px !important;
    overflow: visible !important;
    display: block !important;
}

.game-area {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 1300px !important;
    height: 720px !important;
    margin-left: 0 !important;
    z-index: 1 !important;
}


/* ==============================
🎨 CANVAS
============================== */

canvas {
    display: block;
    position: absolute;
}

#treeCanvas {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 1300px !important;
    height: 720px !important;
    z-index: 0 !important;
    background: transparent !important;
    pointer-events: none;
}

#gameCanvas {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    width: 720px !important;
    height: 720px !important;
    z-index: 2;
    background: transparent;
    display: none;
}

.trash-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 3;
    pointer-events: none;
}


/* ==============================
🧺 TOOLBAR / COIN / BUTTON
============================== */

.game-toolbar {
    position: fixed;
    top: 6px;
    right: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 45px;
}

.coin-panel {
    position: fixed;
    top: 62px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.btn-farm {
    background-color: #28a745;
    border: none;
    padding: 15px 40px;
    font-size: 1.3rem;
    border-radius: 50px;
    color: white;
    transition: 0.3s;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.btn-farm:hover {
    background-color: #218838;
    transform: scale(1.05);
}

.logout-container {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 9999;
}

.logout-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, #ff4d4d, #ff0000);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

#bag {
    position: absolute;
    color: black;
    right: -320px;
    top: -58px;
}

#bag i {
    font-size: 50px;
}

#anhStore {
    width: 1700px;
    height: 1080px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}


/* ==============================
🗑️ THÙNG RÁC
============================== */

.right {
    position: absolute;
    right: 250px !important;
    bottom: 400px !important;

    display: flex;          /* 🔥 đổi grid → flex */
    gap: 15px;

    width: fit-content;     /* 🔥 tự co */
    height: fit-content;    /* 🔥 tự co */

    z-index: 2;
}
.right .bin.graphic.red img {
    height: 210px !important;
    width: auto !important;
    margin-top: -10px;


}
.right .bin.graphic.green img {
    margin-top: -5px;


}

.right img {
    width: 180px;
    height: 180px;
}
.page-recycle .graphic {
    display: inline-flex;   /* 🔥 quan trọng */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;

    width: fit-content;     /* 🔥 fix khung */
    height: fit-content;

    overflow: visible;
}

.page-recycle .graphic p {
    margin-top: 10px;
    font-weight: 500;
}

.page-recycle .graphic.drag-over {
    border: 3px dotted #000;
    background: rgba(0, 0, 0, 0.03);
}

.page-recycle .graphic.shake {
    animation: shake 0.4s;
}

.bin-correct {
    animation: glow 1s ease;
}


/* ==============================
🌱 LUỐNG RÁC
============================== */

.luong {
    position: absolute;
    display: flex;
    gap: 30px;
    transform:
        rotate(-2deg)
        skewX(-1deg)
        scaleY(0.82);
    transform-origin: left center;
}

.luong-1 {
    top: 340px !important;
    left: 480px !important;
    gap: 150px !important;
}

.luong-2 {
    top: 450px !important;
    left: 320px !important;
    gap: 180px !important;
}

.luong-3 {
    top: 580px !important;
    left: 30px !important;
    gap: 280px !important;
}

.trash {
    width: 60px !important;
    height: auto !important;
    cursor: grab;
    pointer-events: auto;
}

.trash:active {
    cursor: grabbing;
}


/* ==============================
🦋 CON VẬT / GIF
============================== */

.gif.deco {
    position: absolute;
    width: 60px;
    pointer-events: none;
    z-index: 2;
}

.butterfly {
    top: 120px;
    left: 200px;
}

.fly-gif {
    position: absolute;
    top: 200px !important;
    left: 400px !important;
    width: 70px;
    pointer-events: none;
    z-index: 3;
    animation: loopFly 12s ease-in-out infinite;
}

.flyo-gif {
    position: absolute;
    top: 100px !important;
    left: 0 !important;
    width: 70px;
    pointer-events: none;
    z-index: 3;
    animation: circleFly 10s linear infinite;
}

.dog {
    z-index: 9999;
    pointer-events: auto;
    position: absolute;
    cursor: pointer;
    right: 60px !important;
    bottom: 430px !important;
    width: 100px !important;
}

.dog.dog-jump {
    animation: dogJump 0.5s ease;
}

.dog.go-right {
    right: 250px;
}

.dog.flip {
    transform: scaleX(-1);
}

.chicken {
    right: 260px !important;
    bottom: 230px !important;
    width: 160px !important;
}


/* ==============================
🍃 LÁ
============================== */

#leaf-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

.leaf {
    position: absolute;
    width: 18px;
    height: 30px;
    background: linear-gradient(135deg, #3cb371, #2e8b57);
    border-radius: 0 100% 0 100%;
    opacity: 0.8;
    transform-origin: center;
    animation: leafFloat linear infinite;
}

.leaf::after {
    content: "";
    position: absolute;
    width: 2px;
    height: 100%;
    background: rgba(255,255,255,0.4);
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}


/* ==============================
🔔 TOAST
============================== */

/* Bong bóng thoại kiểu phim hoạt hình */
#toast {
    position: fixed;
    top: 80px;          /* chỉnh vị trí */
    right: 800px;        /* đặt gần người nông dân */

    min-width: 220px;
    max-width: 320px;
    padding: 16px 22px;

    background: #ff3b30;
    color: #fff;
    font-weight: bold;
    font-size: 20px;
    text-align: center;

    border-radius: 25px;   /* bo tròn như bong bóng */
    box-shadow: 0 8px 18px rgba(0,0,0,.25);

    opacity: 0;
    transform: scale(0.8);
    transition: all .35s ease;

    z-index: 9999;
    pointer-events: none;
}

/* hiện lên */
#toast.show {
    opacity: 1;
    transform: scale(1);
}

#toast.error {
    background: #f44336;
}

#toast.success {
    background: #4caf50;
}

#toast.warn {
    background: #ff9800;
}


/* ==============================
✅ TICK
============================== */

.page-recycle .tick {
    position: absolute;
    font-size: 40px;
    color: green;
    font-weight: bold;
    z-index: 5;
    animation: fadeOut 1s forwards;
    top: 10px;
    right: 10px;
}


/* ==============================
🎞️ ANIMATION
============================== */

@keyframes shake {
    0% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(-3px, 0) rotate(-3deg); }
    40% { transform: translate(3px, 0) rotate(3deg); }
    60% { transform: translate(-3px, 0) rotate(-3deg); }
    80% { transform: translate(3px, 0) rotate(3deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes loopFly {
    0%   { transform: translate(0, 0) rotate(0deg); }
    25%  { transform: translate(120px, -60px) rotate(10deg); }
    50%  { transform: translate(240px, 0) rotate(-10deg); }
    75%  { transform: translate(120px, 80px) rotate(15deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes circleFly {
    0%   { transform: rotate(0deg) translateX(120px) rotate(0deg); }
    100% { transform: rotate(360deg) translateX(120px) rotate(-360deg); }
}

@keyframes leafFloat {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(50px, -40px) rotate(90deg);
    }
    50% {
        transform: translate(100px, 20px) rotate(180deg);
    }
    75% {
        transform: translate(50px, 60px) rotate(270deg);
    }
    100% {
        transform: translate(0, 0) rotate(360deg);
    }
}

@keyframes dogJump {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-40px); }
    100% { transform: translateY(0); }
}

@keyframes heartFly {
    from {
        opacity: 1;
        transform: translateX(0) translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-80px) translateY(-40px) scale(1.5);
    }
}

@keyframes heartUp {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateY(-120px) scale(1.6);
        opacity: 0;
    }
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes glow {
    0%   { box-shadow: 0 0 0px transparent; }
    50%  { box-shadow: 0 0 20px gold; }
    100% { box-shadow: 0 0 0px transparent; }
}

@keyframes dogRunRight {
    0%   { transform: translateX(0); }
    100% { transform: translateX(400px); }
}

@keyframes dogRunLeft {
    0%   { transform: translateX(400px) scaleX(-1); }
    100% { transform: translateX(0) scaleX(-1); }
}
/* ===== TOP TOOLBAR FIX ===== */

.top-toolbar {
    position: fixed;
    top: 60px;
    right: 150px;
    z-index: 99999;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;

    height: 56px;
}

.top-toolbar .toolbar-btn {
    width: 52px;
    height: 52px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: none;
    background: rgba(255, 255, 255, 0.65);
    color: black;
    text-decoration: none;

    border-radius: 14px;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;

    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.top-toolbar .toolbar-btn:hover {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.9);
}

.top-toolbar form {
    margin: 0;
    padding: 0;
    display: flex;
}

.top-toolbar .music-btn {
    font-size: 32px;
}

/* Tắt style cũ nếu còn sót */
.game-toolbar {
    display: none !important;
}

#bag {
    position: static !important;
}
.heart {
    position: fixed; /* 🔥 QUAN TRỌNG */
    font-size: 26px;
    pointer-events: none;
    z-index: 9999;
    animation: heartUp 1s ease-out forwards;
}

/* animation bay lên */
@keyframes heartUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}
* {
    user-select: none;
    -webkit-user-select: none;
}
/* ===== MAP SCREEN - KHÔNG CHE BASEHEADING ===== */

.navbar,
.main-navbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 99999 !important;
}

#mapScreen {
    position: relative !important;
    width: 100%;
    height: calc(100vh - 56px);
    min-height: calc(100vh - 56px);
    z-index: 1 !important;

    background: #7ec850;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#mapImage {
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0 !important;
}

.map-level-btn {
    position: absolute !important;
    z-index: 2 !important;

    padding: 12px 22px;
    border: none;
    border-radius: 18px;
    background: linear-gradient(135deg, #ffcc33, #ff9933);
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.map-level-btn span {
    font-size: 14px;
}

.map-level-btn:hover {
    transform: scale(1.08);
}

.map-level-btn.lv1 {
    top: 49%;
    left: 25%;
}

.map-level-btn.lv2 {
    top: 49%;
    left: 65%;
}

.map-level-btn.lv3 {
    top: 67%;
    left: 25%;
}

.map-level-btn.lv4 {
    top: 67%;
    left: 66%;
}

/* ===== LEVEL INTRO - CŨNG KHÔNG CHE NAVBAR ===== */

#levelIntroScreen {
    position: relative !important;
    width: 100%;
    height: calc(100vh - 56px);
    min-height: calc(100vh - 56px);
    z-index: 1 !important;

    display: none;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: black;
}

#levelIntroImage {
    width: 90%;
    max-width: 1500px;
    height: auto;
    max-height: calc(100vh - 80px);
    object-fit: contain;
    border-radius: 22px;
    box-shadow: 0 10px 35px rgba(0,0,0,0.5);
}

#cleanTrashBtn {
    position: absolute !important;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2 !important;

    padding: 16px 46px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    font-size: 26px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0,0,0,0.45);
    text-shadow: 0 2px 3px rgba(0,0,0,0.35);
}

#cleanTrashBtn:hover {
    transform: translateX(-50%) scale(1.07);
}
.shake {
  animation: shake 0.3s;
}