:root {
    --growth-dock-height: 96px;
}

body {
    padding-bottom: var(--growth-dock-height);
}

html {
    scroll-padding-bottom: calc(var(--growth-dock-height) + 16px);
}

.tuner-growth-dock {
    position: fixed;
    inset: auto 0 0;
    z-index: 1100;
    background: var(--white-stripes);
    color: var(--deep-purple);
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgb(20 0 55 / 16%);
}

.tuner-growth-dock-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: var(--max-width);
    margin: 0 auto;
}

.tuner-growth-icon {
    flex-shrink: 0;
    border-radius: 13px;
}

.tuner-growth-dock p {
    flex: 1;
    font-size: 20px;
    line-height: 1.3;
}

.tuner-growth-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    min-height: 52px;
    padding: 14px 26px;
    border-radius: 30px;
    background: var(--purple-haze);
    color: var(--white-stripes);
    font-family: 'Byrd Simply', sans-serif;
    font-weight: 700;
    font-size: 18px;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
}

.tuner-growth-button:hover {
    background: #7600d5;
}

.tuner-growth-button:focus-visible,
.tuner-completion-close:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 4px;
}

.tuner-completion-prompt[hidden] {
    display: none;
}

.tuner-completion-prompt {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--deep-purple);
    color: var(--white-stripes);
    padding: calc(64px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
}

.tuner-completion-close {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.tuner-completion-close span {
    font-size: 40px;
    line-height: 1;
}

.tuner-completion-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 375px;
    height: min(667px, calc(100vh - 88px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    min-height: 440px;
    margin: auto;
    text-align: center;
}

@supports (height: 100dvh) {
    .tuner-completion-content {
        height: min(667px, calc(100dvh - 88px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)));
    }
}

.tuner-completion-content h2 {
    flex-shrink: 0;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 14px;
    font-size: 32px;
    line-height: 1.2;
    text-align: center;
}

.tuner-completion-content p {
    flex-shrink: 0;
    max-width: 338px;
    margin: 0 auto;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.4;
}

.tuner-completion-artwork {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
    margin: 8px 0 20px;
}

.tuner-completion-artwork img {
    display: block;
    width: min(100%, 308px);
    height: 100%;
    max-height: 318px;
    object-fit: contain;
}

.tuner-completion-cta {
    width: min(100%, 320px);
    min-height: 52px;
    animation: tuner-completion-pulse 2.7s ease-in-out infinite;
}

@keyframes tuner-completion-pulse {
    0%, 22%, 100% { transform: scale(1); }
    11% { transform: scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
    .tuner-completion-cta { animation: none; }
}

/* Reserve the visible screen between the navigation and the measured dock.
   Flutter scales the guitar to the space below its compact tuning bar. */
@media (max-width: 599px) {
    :root {
        --header-height: 72px;
        --app-min-height: 0px;
        --mobile-app-height: max(0px, calc(100vh - var(--header-height) - var(--growth-dock-height)));
    }

    @supports (height: 100dvh) {
        :root {
            --mobile-app-height: max(0px, calc(100dvh - var(--header-height) - var(--growth-dock-height)));
        }
    }

    .header-container {
        height: 100%;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 16px;
    }

    .hamburger {
        flex-shrink: 0;
        padding: 10px;
    }

    .logo {
        min-width: 0;
    }

    .logo img {
        display: block;
        width: auto;
        max-width: 100%;
        height: auto;
        max-height: 40px;
    }

    #app-container {
        height: var(--mobile-app-height) !important;
    }

    .tuner-loading-shell {
        height: 100%;
    }

    .tuner-preview {
        height: 100%;
    }

    .tuner-preview-indicator {
        width: 240px;
        height: 96px;
    }

    .tuner-preview-indicator img {
        width: 240px;
        height: 76px;
    }

    .tuner-preview-cents {
        left: 104px;
        width: 32px;
        height: 16px;
        font-size: 10px;
        line-height: 16px;
    }

    /* Keep the first-frame preview's artwork and peg labels together too. */
    .tuner-preview-guitar {
        --preview-unit: max(0px, min(1px, calc(100vw / 350), calc((var(--mobile-app-height) - 96px) / 480)));
        width: calc(350 * var(--preview-unit));
        height: calc(480 * var(--preview-unit));
        margin: 0 auto;
        left: auto;
        transform: none;
    }

    .tuner-preview-guitar-image {
        left: calc(25 * var(--preview-unit));
        width: calc(300 * var(--preview-unit));
        height: calc(480 * var(--preview-unit));
    }

    .tuner-preview-peg {
        width: calc(50 * var(--preview-unit));
        height: calc(50 * var(--preview-unit));
        padding-left: calc(12 * var(--preview-unit));
        font-size: calc(20 * var(--preview-unit));
        line-height: calc(50 * var(--preview-unit));
    }

    .tuner-preview-peg.peg-1 { left: calc(242 * var(--preview-unit)); top: calc(220 * var(--preview-unit)); }
    .tuner-preview-peg.peg-2 { left: calc(246 * var(--preview-unit)); top: calc(138 * var(--preview-unit)); }
    .tuner-preview-peg.peg-3 { left: calc(249.5 * var(--preview-unit)); top: calc(56 * var(--preview-unit)); }
    .tuner-preview-peg.peg-4 { left: calc(50.5 * var(--preview-unit)); top: calc(56 * var(--preview-unit)); }
    .tuner-preview-peg.peg-5 { left: calc(54 * var(--preview-unit)); top: calc(138 * var(--preview-unit)); }
    .tuner-preview-peg.peg-6 { left: calc(58 * var(--preview-unit)); top: calc(220 * var(--preview-unit)); }

    .tuner-preview-peg.peg-4,
    .tuner-preview-peg.peg-5,
    .tuner-preview-peg.peg-6 {
        padding-right: calc(12 * var(--preview-unit));
        padding-left: 0;
    }
}

@media (max-width: 600px) {
    :root {
        --growth-dock-height: 142px;
    }

    .tuner-growth-dock {
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .tuner-growth-dock-inner {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 10px 12px;
    }

    .tuner-growth-icon {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .tuner-growth-dock p {
        font-size: 16px;
        line-height: 1.3;
    }

    .tuner-growth-dock .tuner-growth-button {
        grid-column: 1 / -1;
        min-height: 44px;
        font-size: 16px;
        padding: 12px 20px;
    }

}
