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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    cursor: none; /* hide OS cursor by default; glove will be shown */
    /* Sky-only background; grass is represented by hills behind gameplay */
    background: linear-gradient(180deg, #b9e6ff 0%, #a8ddff 45%, #9fd8ff 70%, #9ad4ff 100%);
    overflow: hidden;
}

/* Remove old distant hills; we'll draw procedural hills instead */
body:before,
body:after {
    content: none;
}

#scoreboard {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 1.2rem;
    background: rgba(255,255,255,0.9);
    padding: 12px 20px;
    border-radius: 14px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.12);
    z-index: 1000;
    font-weight: 700;
}

/*************************
 * EcoBuddy assistant UI *
 *************************/
.ecobuddy-button {
    position: fixed;
    bottom: 40%;
    left: 16px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #ffffffcc;
    box-shadow: 0 10px 18px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    border: 3px solid #4fc36a;
    cursor: pointer;
}
.ecobuddy-button img { width: 48px; height: 48px; }
.ecobuddy-button:hover { transform: translateY(-1px); }

.ecobuddy-panel {
    position: fixed;
    bottom: calc(40% + 76px);
    left: 16px;
    width: 320px;
    max-height: 55vh;
    background: rgba(255,255,255,0.98);
    border: 2px solid #4fc36a;
    border-radius: 16px;
    box-shadow: 0 16px 28px rgba(0,0,0,0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1100;
}
.ecobuddy-header {
    background: linear-gradient(90deg,#4fc36a,#43b35f);
    color: #fff;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}
.ecobuddy-header img { width: 22px; height: 22px; }
.ecobuddy-close { margin-left: auto; background: #ffffff22; border: none; color: #fff; padding: 6px 10px; border-radius: 10px; cursor: pointer; }

.ecobuddy-messages {
    padding: 10px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ecobuddy-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.35;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.ecobuddy-msg.user { align-self: flex-end; background: #e8f9ef; border: 1px solid #c8f1d6; }
.ecobuddy-msg.bot { align-self: flex-start; background: #f1fff4; border: 1px solid #d8f7df; }

.ecobuddy-input {
    display: flex;
    padding: 8px;
    gap: 6px;
    border-top: 1px solid #e6e6e6;
}
.ecobuddy-input input[type="text"] {
    flex: 1;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #cfd8dc;
    outline: none;
}
.ecobuddy-input button {
    background: #4fc36a;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
}

/* Hint cloud near EcoBuddy button */
.ecobuddy-hint {
    position: fixed;
    left: 90px; /* near the button at left:16px + width 64px + margin */
    bottom: calc(40% + 12px);
    background: #ffffff;
    color: #2e7d32;
    border: 2px solid #4fc36a;
    border-radius: 18px;
    padding: 8px 12px;
    font-weight: 600;
    box-shadow: 0 10px 20px rgba(0,0,0,0.12);
    z-index: 1120;
    transition: opacity .25s ease;
}
.ecobuddy-hint:after {
    content: "";
    position: absolute;
    left: -10px;
    bottom: 10px;
    width: 0; height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid #ffffff;
}
.ecobuddy-hint.fade { opacity: 0; }

/* Suggestion chip/button */
.ecobuddy-suggest {
    position: fixed;
    right: 50%;
    transform: translateX(50%);
    top: 16px;
    background: #fff;
    color: #1b5e20;
    border: 2px solid #43b35f;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    box-shadow: 0 10px 18px rgba(0,0,0,0.12);
    cursor: pointer;
    z-index: 1400;
}
.ecobuddy-suggest:hover { background: #f1fff4; }

.trash-area {
    position: fixed;
    bottom: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    padding: 24px 24px 32px;
}

section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Realistic-ish bin using gradients; preserves lid as inner span so rotation effect works */
.trash {
    width: 86px;
    height: 110px;
    position: relative;
    display: inline-block;
    border-bottom-right-radius: 10px;
    border-bottom-left-radius: 10px;
    box-shadow: inset 0 8px 14px rgba(255,255,255,0.25), inset 0 -10px 16px rgba(0,0,0,0.15), 0 10px 18px rgba(0,0,0,0.2);
}

.trash:before{
    content:'';
    position:absolute;
    left: 8px; right: 8px; top: 10px; bottom: 14px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0) 50%);
    pointer-events:none;
}

/* lid */
.trash span {
    position: absolute;
    height: 16px;
    top: -24px;
    left: -12px;
    right: -12px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    transform: rotate(0deg);
    transition: transform 250ms;
    transform-origin: 18% 100%;
    box-shadow: 0 6px 10px rgba(0,0,0,0.25);
}

.trash span:after {
    content: '';
    position: absolute;
    width: 34px;
    height: 8px;
    top: -12px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    left: 38px;
}

/* front slats */
.trash i {
    position: relative;
    width: 7px;
    height: 70px;
    background: rgba(255,255,255,0.85);
    display: block;
    margin: 18px auto;
    border-radius: 6px;
}

.trash i:after,
.trash i:before {
    content: '';
    width: 7px;
    height: 70px;
    background: rgba(255,255,255,0.85);
    position: absolute;
    border-radius: 6px;
}

.trash i:after { left: -22px; }
.trash i:before { right: -22px; }

/* Color themes for bins */
.glass { background: linear-gradient(180deg, #66d3ff, #2db1e6); }
.glass span, .glass span:after { background: #2db1e6; }

.paper { background: linear-gradient(180deg, #9be49f, #5fb86b); }
.paper span, .paper span:after { background: #5fb86b; }

.plastic { background: linear-gradient(180deg, #ffe36e, #ffbb00); }
.plastic span, .plastic span:after { background: #ffbb00; }

.metal { background: linear-gradient(180deg, #c3ced6, #8da2b0); }
.metal span, .metal span:after { background: #8da2b0; }

.mixed { background: linear-gradient(180deg, #c39a86, #8a6b5f); }
.mixed span, .mixed span:after { background: #8a6b5f; }

.organic { background: linear-gradient(180deg, #a4743f, #6b4a2d); }
.organic span, .organic span:after { background: #6b4a2d; }

.label {
    margin-top: 8px;
    font-weight: 700;
    font-size: 16px;
    text-shadow: 0 2px 0 rgba(255,255,255,0.5);
}

.trash-item {
    width: 140px;
    position: absolute;
    top: 40%;
    left: 50%;
    margin-left: -70px;
    margin-top: -70px;
    cursor: none; /* hide OS cursor over draggable item; glove represents cursor */
    z-index: 10;
    text-align: center;
}

.trash-item img { filter: drop-shadow(0 8px 10px rgba(0,0,0,0.25)); }

.trash-item span {
    display: block;
    font-size: 14px;
    margin-top: 6px;
}

/* Floating feedback text */
.feedback {
    position: absolute;
    color: #2e7d32;
    font-weight: 700;
    font-size: 20px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 1200;
}
.feedback.negative { color: #c62828; }

/* Custom glove cursor */
#glove-cursor {
    position: fixed;
    width: 56px;
    height: 56px;
    z-index: 12000; /* above game-over overlay (z-index: 9999) */
    transform: translate(-40%, -40%);
    pointer-events: none;
    display: grid;
    place-items: center;
    filter: drop-shadow(0 6px 8px rgba(0,0,0,0.3));
    opacity: 1; /* visible by default; hidden only while tutorial overlay is up (unless demo-running) */
}
#glove-cursor .icon {
    width: 48px;
    height: 48px;
    display: block;
    transform-origin: 50% 50%;
}

/* Decorative background layer (sun and clouds only; trees removed) */
#bg-decor {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: none;
    background-repeat: no-repeat;
}

/* Moving clouds layer */
#bg-decor::before {
    content: none;
}

/* Sun in the top-right with glow */
#bg-decor::after {
    content: '';
    position: fixed;
    top: 4vh;
    right: 4vw;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fffde7 0%, #fff59d 35%, #ffe082 60%, #ffca28 80%, #ffb300 100%);
    box-shadow:
      0 0 40px 10px rgba(255, 202, 40, 0.45),
      0 0 120px 30px rgba(255, 202, 40, 0.25);
    z-index: 0; /* keep sun behind clouds */
}

/* Procedural hills: realistic overlapping shapes behind gameplay */
.hill {
    position: fixed;
    bottom: 0;
    border-top-left-radius: 50% 100%;
    border-top-right-radius: 50% 100%;
    background: radial-gradient(120% 90% at 50% 100%, #a6e7a6 0%, #7bd07f 55%, #55b861 100%);
    box-shadow: inset 0 -18px 40px rgba(0,0,0,0.08);
    pointer-events: none;
    z-index: 0; /* same layer as grass, behind trash and cans */
}
.hill:after {
    content: '';
    position: absolute;
    left: 10%;
    right: 10%;
    top: 8%;
    height: 30%;
    border-top-left-radius: 50% 100%;
    border-top-right-radius: 50% 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.0));
}
/* Depth variants tweak saturation/contrast and blur for realism */
.hill.far   { filter: saturate(0.85) brightness(1.06) blur(0.4px); opacity: 0.8; }
.hill.mid   { filter: saturate(0.95) brightness(1.0);               opacity: 0.92; }
.hill.near  { filter: saturate(1.05) brightness(0.98);              opacity: 1; }

/* Slight ground contact shadow (global) */
.hills-ground-shadow {
    position: fixed;
    bottom: -2vh;
    left: 0;
    right: 0;
    height: 10vh;
    background: radial-gradient(80% 100% at 50% 0%, rgba(0,0,0,0.08), rgba(0,0,0,0));
    pointer-events: none;
    z-index: 0;
}

/* Kevin Jannis CodePen-style clouds */
.cloud {
    position: fixed;
    width: 200px;
    height: 60px;
    background: #fff;
    border-radius: 100px;
    opacity: 0.8;
    filter: drop-shadow(0 10px 12px rgba(0,0,0,0.08));
    pointer-events: none;
    z-index: 1; /* above the sun */
    left: 110vw; /* start off-screen right during any delays */
}
.cloud:before, .cloud:after {
    content: '';
    position: absolute;
    background: #fff;
    width: 100px;
    height: 80px;
    position: absolute;
    top: -15px;
    left: 10px;
    border-radius: 100px;
    transform: rotate(30deg);
}
.cloud:after {
    width: 120px;
    height: 120px;
    top: -55px;
    left: auto;
    right: 15px;
}

/* Cloud animations */
@keyframes cloud-left {
  0% { left: 110vw; }
  100% { left: -50vw; }
}

/* Variants for size, speed, and initial position */
/* Clouds continuously travel left; each loop restarts off-screen right so new clouds enter from outside. */
/* Use staggered negative delays that are different fractions of their durations so they don't all start at the same position. */
.cloud.x1 { top: 10vh; animation: cloud-left 140s linear infinite; animation-delay: -14s;  transform: scale(0.9); will-change: left, transform; }   /* ~10% */
.cloud.x2 { top: 16vh; animation: cloud-left 170s linear infinite; animation-delay: -102s; transform: scale(1.1); will-change: left, transform; }  /* ~60% */
.cloud.x3 { top: 8vh;  animation: cloud-left 200s linear infinite; animation-delay: -40s;  transform: scale(1.4); opacity: 0.9; will-change: left, transform; }  /* ~20% */
.cloud.x4 { top: 22vh; animation: cloud-left 230s linear infinite; animation-delay: -184s; transform: scale(0.8); opacity: 0.8; will-change: left, transform; } /* ~80% */
.cloud.x5 { top: 5vh;  animation: cloud-left 260s linear infinite; animation-delay: -78s;  transform: scale(1.6); opacity: 0.85; will-change: left, transform; } /* ~30% */

/* Tutorial overlay */
#tutorial-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, rgba(255,255,255,0.35), rgba(0,0,0,0.55));
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 3000;
    display: none; /* shown by JS */
    align-items: center;
    justify-content: center;
    text-align: center;
}
#tutorial-overlay .tutorial-box {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffffee;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    max-width: 620px;
    width: calc(100% - 32px);
    text-align: center;
    z-index: 3100;
}
#tutorial-overlay h2 {
    margin: 0 0 8px;
    font-size: 22px;
}
#tutorial-overlay .tutorial-text {
    margin: 0 0 14px;
    font-size: 16px;
}
#tutorial-overlay .tutorial-btn {
    appearance: none;
    border: none;
    background: #2db1e6;
    color: #fff;
    font-weight: 700;
    padding: 10px 26px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(45,177,230,0.4);
    font-size: 19px;
}
#tutorial-overlay .tutorial-btn:active { transform: translateY(1px) }

/* Demo hand animation path from center towards bottom (bins area) */
#tutorial-overlay .demo-hand {
    position: absolute;
    width: 60px;
    height: 60px;
    left: 50%;
    top: 40%;
    margin-left: -30px;
    margin-top: -30px;
    filter: drop-shadow(0 8px 10px rgba(0,0,0,0.35));
    animation: demoDrag 2.2s ease-in-out infinite;
}
#tutorial-overlay .demo-center-marker {
    position: absolute;
    left: 50%;
    top: 40%;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.15);
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 0 8px rgba(255,255,255,0.35);
    animation: ping 1.6s ease-out infinite;
}

@keyframes ping {
    0% { transform: scale(0.9); opacity: 1; }
    70% { transform: scale(1.25); opacity: 0; }
    100% { transform: scale(1.25); opacity: 0; }
}

@keyframes demoDrag {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    20% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    60% { transform: translate(-10px, 230px) rotate(6deg) scale(1.02); opacity: 1; }
    80% { transform: translate(-10px, 230px) rotate(6deg) scale(1.02); opacity: 0.95; }
    100% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 0.9; }
}

/* While tutorial is active, pulse bins and keep OS cursor visible */
body.tutorial-active { cursor: auto; }
body.tutorial-active section .trash {
    animation: binPulse 1.4s ease-in-out infinite;
}
@keyframes binPulse {
    0% { transform: translateZ(0) scale(1); box-shadow: 0 10px 18px rgba(0,0,0,0.2); }
    50% { transform: translateZ(0) scale(1.04); box-shadow: 0 16px 24px rgba(0,0,0,0.25); }
    100% { transform: translateZ(0) scale(1); box-shadow: 0 10px 18px rgba(0,0,0,0.2); }
}
body.tutorial-active #glove-cursor { opacity: 0; }
/* During demo run, show glove above everything */
body.tutorial-active.demo-running #glove-cursor { opacity: 1; z-index: 4000; transform: none; }
