:root {
    --bg-base: #120f1d;
    --bg-panel: rgba(17, 15, 28, 0.78);
    --bg-panel-strong: rgba(10, 9, 18, 0.92);
    --text-main: #f8edd6;
    --text-soft: #efe3ca;
    --accent: #ff9f6e;
    --accent-soft: #ffd36e;
    --teal: #7be0d6;
    --border: rgba(255, 255, 255, 0.12);
    --shadow: rgba(0, 0, 0, 0.35);
}

body {
    margin: 0;
    padding: 0;
    background:
        linear-gradient(135deg, rgba(6, 7, 14, 0.84), rgba(29, 16, 52, 0.72)),
        radial-gradient(circle at top right, rgba(255, 157, 110, 0.25), transparent 32%),
        radial-gradient(circle at bottom left, rgba(123, 224, 214, 0.22), transparent 30%),
        url("../resources/after-realising-the-currents-and-let-it-happen-artworks-v0-CZVR_gFkrC7VlDArV1_pQHpLDtWOrw88yLoKWRdX3B4.webp") center center / cover fixed;
    font-size: 16px;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--text-main);
    overflow: auto;
    min-height: 100%;
}

a {
    color: var(--accent-soft);
    font-size: 14px;
}

#main {
    width: 100%;
    min-height: 100vh;
    padding: 18px;
    box-sizing: border-box;
}

#wrap {
    position: relative;
    margin: 0 auto;
    width: 1100px;
    height: 680px;
    margin-top: 12px;
    border-radius: 28px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(14, 12, 25, 0.5), rgba(39, 15, 54, 0.28));
    box-shadow: 0 28px 60px var(--shadow);
    border: 1px solid var(--border);
    backdrop-filter: blur(0px);
}

#story-panels {
    position: absolute;
    left: 52px;
    top: 34px;
    z-index: 3;
    width: 430px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#text {
    width: 100%;
    min-height: 0;
    position: relative;
    z-index: 3;
    box-sizing: border-box;
    padding: 22px 24px;
    border-radius: 24px;
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.22);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(22px) scale(0.98);
    transition: opacity 0.75s ease, transform 0.75s ease, visibility 0.75s ease;
}

#code {
    display: none;
    font-size: 19px;
    line-height: 1.45;
    letter-spacing: 0.02em;
    color: var(--text-main);
    position: relative;
    z-index: 4;
}

#clock-box {
    position: relative;
    width: 100%;
    font-size: 22px;
    z-index: 3;
    box-sizing: border-box;
    padding: 16px 20px;
    border-radius: 22px;
    background: var(--bg-panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(22px) scale(0.98);
    transition: opacity 0.75s ease, transform 0.75s ease, visibility 0.75s ease;
}

#clock-box a {
    font-size: 28px;
    text-decoration: none;
}

#clock-box-inside-text {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--teal);
}

#clock {
    margin-left: 0;
    line-height: 1.6;
    color: var(--text-soft);
}

#clock .digit {
    display: inline-block;
    min-width: 48px;
    margin: 0 6px 0 0;
    font-size: 32px;
    line-height: 1;
    color: var(--accent-soft);
    font-weight: 700;
}

.clock-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-main);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#tree-stage {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 1100px;
    height: 680px;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 100% 100% !important;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

#error {
    margin: 0 auto;
    text-align: center;
    margin-top: 60px;
    display: none;
}

.hand {
    cursor: pointer;
}

.say {
    display: block;
    margin-left: 0;
    margin-bottom: 14px;
    text-shadow: 0 3px 16px rgba(0, 0, 0, 0.35);
}

.space {
    margin-right: 150px;
}

.music-toggle {
    position: fixed;
    z-index: 10001;
    top: 10px;
    right: 10px;
    cursor: pointer;
    width: 28px;
    height: 28px;
}

.soundcloud-player-shell {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 10000;
    width: 320px;
    min-height: 120px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.soundcloud-player-shell.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

#soundcloud-player-container iframe {
    display: block;
    width: 320px;
    height: 120px;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.32);
}

.rotateImages {
    -webkit-animation: myRotate 10s linear infinite;
    animation: myRotate 10s linear infinite;
}

@-webkit-keyframes myRotate {
    0% { -webkit-transform: rotate(0deg); }
    50% { -webkit-transform: rotate(180deg); }
    100% { -webkit-transform: rotate(360deg); }
}

@keyframes myRotate {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
    100% { transform: rotate(360deg); }
}

body.text-visible #text {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

body.clock-visible #clock-box {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

@media (max-width: 1140px) {
    #main {
        padding: 12px;
    }

    #story-panels {
        left: 24px;
        top: 24px;
        width: min(430px, calc(100% - 48px));
    }

    #wrap {
        width: 100%;
        height: 680px;
        min-height: 680px;
    }

    #text,
    #clock-box {
        width: 100%;
        margin: 0;
    }
}

@media (max-width: 600px) {
    body {
        overflow-x: hidden;
        background-attachment: scroll;
        background-position: 75% center;
    }

    #main {
        min-height: 100svh;
        padding:
            max(10px, env(safe-area-inset-top))
            max(10px, env(safe-area-inset-right))
            max(10px, env(safe-area-inset-bottom))
            max(10px, env(safe-area-inset-left));
    }

    #wrap {
        height: calc(100svh - 20px);
        min-height: 640px;
        margin-top: 0;
        border-radius: 22px;
    }

    #story-panels {
        left: 12px;
        top: 12px;
        width: calc(100% - 24px);
        gap: 10px;
    }

    #text {
        padding: 15px 16px;
        border-radius: 17px;
    }

    #code {
        font-size: clamp(13px, 3.7vw, 16px);
        line-height: 1.4;
    }

    .say {
        margin-bottom: 9px;
    }

    #clock-box {
        padding: 12px 14px;
        border-radius: 17px;
        font-size: 14px;
    }

    #clock-box-inside-text {
        margin-bottom: 5px;
        font-size: 10px;
    }

    .clock-label {
        margin-bottom: 6px;
        font-size: 9px;
    }

    #clock {
        line-height: 1.5;
    }

    #clock .digit {
        min-width: 0;
        margin-right: 2px;
        font-size: clamp(20px, 6vw, 25px);
    }

    #tree-stage {
        inset: auto;
        top: 180px;
        left: 0;
        width: 100%;
        height: auto;
        aspect-ratio: 1100 / 680;
        transition: top 0.8s ease, left 0.8s ease, width 0.8s ease;
    }

    body.clock-visible #tree-stage {
        top: clamp(300px, 40svh, 360px);
        left: -82%;
        width: 180%;
    }

    #canvas {
        width: 100%;
        height: 100%;
    }

    .music-toggle {
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
        width: 24px;
        height: 24px;
    }

    .soundcloud-player-shell {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        width: min(270px, calc(100vw - 32px));
        min-height: 92px;
    }

    #soundcloud-player-container iframe {
        width: 100%;
        height: 92px;
        border-radius: 14px;
    }
}
