:root {
    --leaf-dark: #123524;
    --leaf-mid: #28643b;
    --leaf-bright: #7fdd5a;
    --sun-gold: #ffcf57;
    --cream: #f6f1d1;
    --ink: #20301e;
    --stage-jungle: linear-gradient(135deg, rgba(102, 202, 106, 0.32), rgba(15, 68, 38, 0.6));
    --stage-sunset: linear-gradient(135deg, rgba(255, 181, 92, 0.34), rgba(106, 42, 12, 0.6));
    --stage-night: linear-gradient(135deg, rgba(109, 170, 255, 0.26), rgba(8, 23, 52, 0.68));
}

body {
    margin: 0;
    overflow: hidden;
    touch-action: manipulation;
    background:
        radial-gradient(circle at top, rgba(255, 232, 163, 0.3), transparent 40%),
        linear-gradient(180deg, #7ad692 0%, #2a6c44 42%, #132f23 100%);
    font-family: "Trebuchet MS", "Arial Black", sans-serif;
    user-select: none;
}

canvas {
    display: block;
    touch-action: none;
    position: fixed;
    inset: 0;
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
    background:
        radial-gradient(circle at top, rgba(255, 239, 180, 0.18), transparent 28%),
        rgba(4, 17, 11, 0.62);
    backdrop-filter: blur(7px);
    z-index: 10;
    color: white;
    text-align: center;
}

.screen.active {
    display: flex;
}

.nature-title {
    margin: 0 0 12px;
    font-size: clamp(2.6rem, 7vw, 4.6rem);
    color: var(--sun-gold);
    letter-spacing: 0.08em;
    text-shadow: 0 4px 0 #7b4e10, 0 12px 28px rgba(0, 0, 0, 0.35);
}

.subtitle {
    max-width: 700px;
    margin: 0 0 18px;
    color: var(--cream);
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    line-height: 1.45;
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: 14px;
    width: min(720px, 100%);
    margin: 10px 0 22px;
}

.stat-card,
.shop-card {
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stat-label,
.shop-meta {
    display: block;
    color: #d6efca;
    font-size: 0.92rem;
    margin-bottom: 8px;
}

.menu-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.controls-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
    width: min(920px, 100%);
    margin-top: 18px;
}

.control-card {
    padding: 18px;
    border-radius: 20px;
    text-align: left;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.control-card h3 {
    margin: 0 0 12px;
    color: #ffeaa1;
    font-size: 1.05rem;
}

.control-card p {
    margin: 0 0 8px;
    color: #edf6d4;
    line-height: 1.4;
}

button {
    padding: 15px 34px;
    margin: 10px;
    background: linear-gradient(180deg, #ffe174, #ffb831);
    border: none;
    border-bottom: 5px solid #a85c09;
    color: var(--ink);
    font-size: 1.05rem;
    font-family: inherit;
    font-weight: 900;
    cursor: pointer;
    border-radius: 16px;
    transition: transform 0.1s ease, border-bottom-width 0.1s ease, filter 0.1s ease;
    text-transform: uppercase;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

button:hover {
    filter: brightness(1.04);
}

button:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
}

.pause-button {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    min-width: 160px;
    max-width: 240px;
    width: clamp(140px, 18vw, 200px);
    padding: 12px 18px;
    letter-spacing: 0.08em;
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.22);
}

.settings-card {
    width: min(460px, 100%);
    padding: 24px 26px;
    border-radius: 28px;
    background: rgba(10, 29, 14, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
    text-align: center;
}

.audio-settings {
    display: grid;
    gap: 18px;
    margin: 22px 0 8px;
}

.setting-row {
    display: grid;
    gap: 10px;
    text-align: left;
}

.setting-row label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #f6f1d1;
    font-weight: 700;
    font-size: 0.98rem;
}

.setting-row input[type="range"] {
    width: 100%;
    accent-color: #ffb831;
}

.btn-back,
.btn-secondary {
    background: linear-gradient(180deg, #ff9d5c, #ff6a3d);
    border-bottom-color: #97331b;
    color: white;
}

.level-grid,
.shop-grid {
    display: grid;
    width: min(900px, 100%);
    max-height: min(460px, 58vh);
    overflow-y: auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.level-grid {
    grid-template-columns: 1fr;
    gap: 18px;
}

.shop-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 16px;
}

.btn-lvl {
    width: 100%;
    min-height: 92px;
    margin: 0;
    padding: 10px 8px;
    font-size: 0.95rem;
    line-height: 1.25;
    white-space: pre-line;
}

.btn-lvl.locked {
    background: linear-gradient(180deg, #5b644e, #39452f);
    border-bottom-color: #1d2417;
    color: #c7d7bf;
}

.stage-card {
    padding: 18px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.07);
    text-align: left;
}

.stage-card.stage-jungle {
    background: var(--stage-jungle);
}

.stage-card.stage-sunset {
    background: var(--stage-sunset);
}

.stage-card.stage-night {
    background: var(--stage-night);
}

.stage-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stage-title {
    margin: 0 0 6px;
    color: #ffeaa1;
    font-size: 1.35rem;
}

.stage-copy {
    margin: 0;
    color: #edf6d4;
    line-height: 1.45;
}

.stage-badge {
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff8d6;
    font-weight: 900;
    white-space: nowrap;
}

.stage-levels {
    display: grid;
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    gap: 14px;
}

.shop-card h3 {
    margin: 0 0 10px;
    color: #ffeaa1;
}

.shop-preview {
    width: 100%;
    height: 170px;
    margin-bottom: 14px;
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.14), transparent 26%),
        linear-gradient(180deg, rgba(146, 255, 172, 0.24), rgba(18, 50, 32, 0.55));
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
}
.shop-preview canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.shop-preview svg {
    width: 100%;
    height: 100%;
    display: block;
}

.shop-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.shop-card button {
    margin: 12px 0 0;
    width: 100%;
}

.shop-coins {
    margin-bottom: 16px;
    font-size: 1.2rem;
    color: #ffeaa1;
}

.pause-button {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 40;
    display: none;
    margin: 0;
    padding: 12px 20px;
    background: linear-gradient(180deg, #7dd1ff, #338ed6);
    border-bottom-color: #18558a;
    color: #081724;
}

.pause-card {
    width: min(460px, calc(100vw - 32px));
    padding: 28px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(17, 41, 27, 0.94), rgba(10, 24, 16, 0.94));
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.35);
}

#mobile-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 24px;
    display: none;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}

.ctrl-btn {
    pointer-events: auto;
    border-radius: 18px;
    min-width: min(82vw, 280px);
    padding: 18px 28px;
    border-bottom-width: 6px;
    touch-action: none;
}

.swing-btn {
    background: linear-gradient(180deg, #7df17b, #2dbd47);
    border-bottom-color: #117229;
    color: #08240f;
}

@media (max-width: 780px) {
    .home-stats {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        grid-template-columns: 1fr;
    }

    .stage-levels {
        grid-template-columns: repeat(3, minmax(92px, 1fr));
    }

    .shop-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    button {
        font-size: 0.95rem;
        padding: 14px 24px;
    }

    .screen {
        padding: 16px;
    }

    .control-card {
        padding: 14px;
    }

    #mobile-controls {
        bottom: 14px;
    }

    .ctrl-btn {
        min-width: min(92vw, 340px);
        padding: 20px 22px;
        font-size: 1rem;
    }

    .stage-header {
        flex-direction: column;
    }

    .pause-button {
        top: 14px;
        right: 14px;
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}
