@import url("https://fonts.googleapis.com/css2?family=Syne:wght@600;700&family=Manrope:wght@500;700&display=swap");

:root {
    --bg-1: #fff8e7;
    --bg-2: #f6ead2;
    --ink: #2f2820;
    --muted: #5a5145;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    font-family: "Manrope", "Segoe UI Variable", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 20%, #ffffffa8 0%, transparent 46%),
        radial-gradient(circle at 85% 80%, #ffe7b5c7 0%, transparent 52%),
        linear-gradient(145deg, var(--bg-1), var(--bg-2));
    overflow: hidden;
}

.app {
    position: fixed;
    inset: 0;
}

.hud {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 2;
    width: min(34rem, calc(100% - 8.5rem));
    padding: 1rem 1.2rem;
    border-radius: 1rem;
    background: #fffcf2cf;
    border: 1px solid #d8c8a4;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 22px #523e141a;
}

.hud h1 {
    margin: 0;
    font-family: "Syne", "Avenir Next", sans-serif;
    letter-spacing: 0.02em;
    font-size: clamp(1.4rem, 2.7vw, 2rem);
}

.hud p {
    margin: 0.45rem 0 0;
    color: var(--muted);
    font-size: clamp(0.92rem, 1.8vw, 1rem);
    line-height: 1.35;
}

.settings-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    border: 1px solid #d7c9a8;
    border-radius: 999px;
    background: #fffaedee;
    color: #504739;
    font-size: 0.88rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    box-shadow: 0 6px 18px #523e141a;
}

.settings-gear {
    font-size: 1rem;
    line-height: 1;
}

.settings-panel {
    position: absolute;
    top: 4.1rem;
    right: 1rem;
    z-index: 3;
    width: min(28rem, calc(100% - 2rem));
    max-height: min(74vh, 37rem);
    overflow: auto;
    padding: 0.8rem 0.85rem 0.9rem;
    border-radius: 1rem;
    border: 1px solid #d8c8a4;
    background: #fffcf2ee;
    backdrop-filter: blur(6px);
    box-shadow: 0 12px 28px #523e1420;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 0.5rem;
}

.settings-header h2 {
    margin: 0;
    font-size: 0.98rem;
    color: #4d4538;
    letter-spacing: 0.02em;
}

.controls {
    margin-top: 0.8rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.38rem;
}

.control-row {
    display: grid;
    grid-template-columns: 7.4rem 1fr 3.4rem;
    align-items: center;
    gap: 0.5rem;
}

.control-row label {
    font-size: 0.78rem;
    color: #5a5145;
    letter-spacing: 0.02em;
}

.label-with-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
}

.tooltip-trigger {
    position: relative;
    border: 1px solid #d8c9a7;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 999px;
    background: #fff6e1;
    color: #665844;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    cursor: help;
}

.tooltip-trigger.is-open {
    background: #2f7f68;
    border-color: #2f7f68;
    color: #fffdf7;
    box-shadow: 0 0 0 2px #2f7f6830;
}

.tooltip-text {
    position: absolute;
    left: 0;
    top: calc(100% + 0.36rem);
    width: 14.5rem;
    padding: 0.42rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid #d8c9a7;
    background: #fffaf0;
    color: #5b5145;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    box-shadow: 0 8px 18px #523e141f;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-2px);
    transition: opacity 120ms ease, transform 120ms ease;
    pointer-events: none;
    z-index: 6;
}

.tooltip-trigger:hover .tooltip-text,
.tooltip-trigger:focus-visible .tooltip-text,
.tooltip-trigger.is-open .tooltip-text {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

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

.control-row input[type="color"] {
    width: 100%;
    height: 1.6rem;
    border: 1px solid #d7c9a8;
    border-radius: 0.4rem;
    background: #fff7e7;
    padding: 0.1rem;
}

.control-row select {
    border: 1px solid #d7c9a8;
    background: #fff7e7;
    border-radius: 0.5rem;
    padding: 0.32rem 0.45rem;
    font-size: 0.78rem;
    color: #4e4639;
    width: 100%;
}

.control-row output {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.76rem;
    color: #5f5548;
}

#resetTune {
    margin-top: 0.2rem;
    justify-self: end;
    border: 1px solid #d7c9a8;
    border-radius: 0.5rem;
    background: #fff6e3;
    color: #4f473b;
    font-size: 0.77rem;
    padding: 0.34rem 0.55rem;
    cursor: pointer;
}

#resetTune:hover {
    background: #fff1d5;
}

#stage {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

#stage:active {
    cursor: grabbing;
}

.credit-link {
    position: absolute;
    left: 1rem;
    bottom: 0.9rem;
    z-index: 2;
    color: #6b5f4f;
    background: #fff8e7cc;
    border: 1px solid #d7c9a8;
    border-radius: 999px;
    padding: 0.32rem 0.64rem;
    font-size: 0.76rem;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.credit-link:hover {
    color: #4f4538;
    background: #fff2d7;
}

@media (max-width: 640px) {
    .hud {
        top: 0.7rem;
        left: 0.7rem;
        width: calc(100% - 6.3rem);
        padding: 0.8rem 0.9rem;
    }

    .settings-toggle {
        top: 0.7rem;
        right: 0.7rem;
        padding: 0.42rem 0.65rem;
    }

    .settings-panel {
        top: 3.6rem;
        right: 0.7rem;
        width: calc(100% - 1.4rem);
    }

    .credit-link {
        left: 0.7rem;
        bottom: 0.7rem;
        font-size: 0.72rem;
    }

    .control-row {
        grid-template-columns: 6.1rem 1fr 2.9rem;
        gap: 0.38rem;
    }

    .tooltip-text {
        width: 12rem;
    }

}