:root {
    --soil-color: #5d4037;
    --soil-active: #795548;
    --accent: #00ff88;
    --glow: #00ff88;
    --text-color: #ffffff;
    --shelf-bg: rgba(62, 39, 35, 0.9);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-image: url('assets/image/garden_bg.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    color: var(--text-color);
    font-family: 'Fredoka', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: rgba(0, 0, 0, 0.1);
    padding: 10px;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

h1 {
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.controls {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.btn {
    background-color: #ff9800;
    color: white;
    border: 3px solid #e65100;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.1s;
}

.btn:hover {
    background-color: #f57c00;
    transform: translateY(-2px);
}

.bpm-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
}

input[type="number"] {
    background: #fff;
    border: none;
    padding: 0.2rem;
    border-radius: 5px;
    width: 60px;
    text-align: center;
    font-family: inherit;
    font-weight: 700;
}

/* Range Slider Styling */
#bpm-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 120px;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

#bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #ff9800;
    border: 2px solid #e65100;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

#bpm-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#bpm-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #ff9800;
    border: 2px solid #e65100;
    border-radius: 50%;
    cursor: pointer;
}

main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    perspective: 1200px;
    padding: 1vh 10vw;
    min-height: 0;
}

.grid-container {
    display: flex;
    flex-direction: column;
    gap: 1.2vh;
    transform: rotateX(45deg);
    /* Removed preserve-3d to fix drag-drop hitbox targeting */
    height: 90%;
    width: 100%;
    padding-left: 14%;
    padding-right: 14%;
    padding-top: 8%;
}

.lane-row {
    display: grid;
    grid-template-columns: repeat(16, 1fr);
    gap: 8px;
    flex: 1;
    transform: translateZ(0);
    /* Create separate layer for clean rendering */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lane-row.inactive {
    opacity: 0.25;
    filter: blur(1.5px) grayscale(0.3);
    pointer-events: none;
}

.lane-row-0 .pad {
    grid-column: span 4;
}

.lane-row-1 .pad {
    grid-column: span 2;
}

.lane-row-2 .pad {
    grid-column: span 1;
}

.pad {
    width: 100%;
    height: 100%;
    background-color: var(--soil-color);
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-shadow: inset 4px 4px 10px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(46, 125, 50, 0.6);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pad.drag-over {
    background-color: #8d6e63;
    border-color: var(--accent);
}

/* Plant styling */
.plant {
    width: 80%;
    height: 80%;
    position: relative;
    pointer-events: none;
    animation: grow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fruit-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@keyframes grow {
    from {
        transform: scale(0) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Playhead */
.playing {
    box-shadow: 0 0 20px #fff, inset 0 0 10px #fff;
    border-color: #fff;
    z-index: 10;
}

/* Gameplay Footer */
.game-footer {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1vh 2vw;
    background: var(--shelf-bg);
    border-top: 4px solid #5d4037;
    border-radius: 20px 20px 0 0;
    flex-shrink: 0;
    height: 18vh;
    gap: 10px;
}

.basket-container,
.tool-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    flex: 1;
}

/* The seed icon */
.seed {
    width: clamp(50px, 9vh, 100px);
    height: clamp(50px, 9vh, 100px);
    cursor: grab;
    transition: transform 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.seed:active {
    cursor: grabbing;
}

.seed:hover {
    transform: scale(1.1);
}

.seed-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.inventory-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.seed-count {
    background: #ffc107;
    color: #3e2723;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.lane-label-game {
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffcc80;
    text-transform: uppercase;
}

/* Shovel Tool */
.tool {
    width: clamp(50px, 9vh, 100px);
    height: clamp(50px, 9vh, 100px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tool.active {
    background: #ff5252;
    box-shadow: 0 0 15px #ff5252;
    transform: scale(1.1);
}

.shovel-img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

/* Delete Mode Cursor */
body.delete-mode,
body.delete-mode .btn,
body.delete-mode .pad,
body.delete-mode .tool,
body.delete-mode input {
    cursor: url('assets/image/shovel_small.png') 32 32, auto !important;
}

/* Responsive Media Queries */
@media (max-width: 600px) {
    .container {
        padding: 5px;
    }

    header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        text-align: center;
    }

    .controls {
        gap: 10px;
        width: 100%;
        justify-content: center;
    }

    .bpm-control {
        flex-grow: 1;
        justify-content: center;
    }

    main {
        padding: 1vh 2vw;
    }

    .grid-container {
        padding-left: 16%;
        padding-right: 16%;
        gap: 0.5vh;
    }

    .game-footer {
        padding: 10px 5px;
        min-height: 20vh;
    }

    .lane-row {
        gap: 2px;
    }

    .lane-label-game {
        font-size: 0.65rem;
    }

    .seed-count {
        font-size: 0.75rem;
        padding: 1px 6px;
    }
}