:root {
    --max-size: max(100vh, 100vw);
    --min-size: min(100vh, 100vw);
    --primary-blue: hsl(207, 83%, 60%);
    --accent-red: hsl(0, 83%, 60%);
    --active-green: hsl(121, 60%, 60%);
    --pause-yellow: hsl(52, 95%, 45%);
    --reset-purple: hsl(268, 60%, 60%);
    --text-dark: hsl(0, 0%, 40%);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    font-family: "Montserrat", sans-serif;
    background-color: hsl(207, 83%, 60%);
    background-image: linear-gradient(180deg, #ffffff 0%, hsl(207, 83%, 60%) 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

/* ========================================================
   BASE / LANDSCAPE & SQUARE SCREENS (Default)
   ======================================================== */

.body {
    background-image: linear-gradient(white, hsl(207, 83%, 60%));
    background-repeat: no-repeat;
    background-color: hsl(207, 83%, 60%);
    width: var(--min-size);
    height: var(--min-size);
    margin: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 0.5vh 0;
}

.title {
    color: var(--text-dark);
    font-family: "Montserrat", sans-serif;
    font-weight: 900;
    margin: auto;
    text-align: center;
    font-size: calc(var(--min-size) * 0.05);
    height: calc(var(--min-size) * 0.07);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.muscle-emoji-btn {
    cursor: pointer;
    display: inline-block;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.muscle-emoji-btn:hover {
    transform: scale(1.22) rotate(8deg);
}

.muscle-emoji-btn:active {
    transform: scale(0.95);
}

.subtitle {
    color: var(--text-dark);
    font-family: "Montserrat", sans-serif;
    font-weight: 700;
    text-align: center;
    font-size: calc(var(--min-size) * 0.025);
    height: calc(var(--min-size) * 0.03);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.switches {
    display: flex;
    width: 85%;
    height: calc(var(--min-size) * 0.04);
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    margin: 0;
}

.buttonSection {
    width: 85%;
    height: calc(var(--min-size) * 0.05);
    display: flex;
    margin-top: calc(var(--min-size) * 0.005);
    margin-left: 0;
    margin-right: 0;
    margin-bottom: calc(var(--min-size) * 0.01);
    justify-content: space-between;
    align-content: center;
    align-items: center;
}

.buttonSection button {
    font-family: "Montserrat", sans-serif;
    border-radius: calc(var(--min-size) / 100 * 2);
    padding: calc(var(--min-size) / 100 * 1) 0;
    font-size: calc(var(--min-size) / 100 * 2.25);
    font-weight: 700;
    border: 0;
    min-width: calc(var(--min-size) / 100 * 18);
    max-width: calc(var(--min-size) / 100 * 20);
    min-height: calc(var(--min-size) / 100 * 4);
    max-height: calc(var(--min-size) / 100 * 7);
    color: white;
    cursor: pointer;
    box-shadow: rgba(0, 0, 0, .2) 0 3px 5px -1px, rgba(0, 0, 0, .14) 0 6px 10px 0, rgba(0, 0, 0, .12) 0 1px 18px 0;
    transition: box-shadow 280ms cubic-bezier(.4, 0, .2, 1), opacity 15ms linear 30ms, transform 270ms cubic-bezier(0, 0, .2, 1) 0ms, background-color 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.playButton,
.pauseButton,
.stopButton,
.loudButton,
.muteButton,
.unMuteButton {
    height: calc(var(--min-size) / 100 * 2.25);
    width: calc(var(--min-size) / 100 * 2.25);
    margin-top: 1px;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-right: 4px;
    fill: currentColor;
}

.resetButton {
    height: calc(var(--min-size) / 100 * 2.25);
    width: calc(var(--min-size) / 100 * 2.25);
    margin-top: 1px;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-right: 5px;
    stroke-width: 2;
    stroke: currentColor;
}

button:hover {
    opacity: 0.85;
}

button:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.button1 {
    /* RANDOMIZE BUTTON */
    background-color: hsl(207, 83%, 60%);
}

.buttonSection button.button2,
.button2 {
    /* MUTE / UNMUTE BUTTON */
    background-color: hsl(0, 0%, 100%);
    color: hsl(121, 65%, 38%);
}

.button3 {
    /* PLAY BUTTON */
    background-color: hsl(121, 60%, 60%);
}

.button4 {
    /* STOP BUTTON */
    background-color: hsl(0, 83%, 60%);
}

button.pause {
    /* PAUSE BUTTON */
    background-color: hsl(52, 95%, 45%);
}

button.reset {
    /* RESET BUTTON */
    background-color: hsl(268, 60%, 60%);
}

button:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    background-color: hsl(0, 0%, 30%);
}

.buttonSection button.soundOff,
button.soundOff {
    /* SOUND OFF STATE */
    color: hsl(0, 83%, 55%);
}

.timebarSection {
    width: calc(var(--min-size) / 100 * 85);
    height: calc(var(--min-size) * 0.05);
    display: flex;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: calc(var(--min-size) * 0.012);
    justify-content: center;
    align-content: center;
    align-items: center;
}

.timebar {
    display: flex;
    justify-content: center;
    align-content: center;
    align-items: center;
    flex-grow: 1;
    background-image: linear-gradient(to left, white 100%, hsl(0, 83%, 60%) 0%);
    font-family: "Montserrat", sans-serif;
    border-radius: calc(var(--min-size) / 100 * 1.75);
    margin: 0;
    font-size: calc(var(--min-size) / 100 * 4);
    font-weight: 700;
    color: hsl(0, 0%, 40%);
    text-shadow: 0px 0px 10px hsla(0, 0%, 100%, 0.917), 0px 0px 4px hsla(0, 0%, 100%, 0.917);
    border: 0px;
    box-shadow: rgba(0, 0, 0, .2) 0 3px 5px -1px, rgba(0, 0, 0, .14) 0 6px 10px 0, rgba(0, 0, 0, .12) 0 1px 18px 0;
    padding: 0;
    min-height: calc(var(--min-size) / 100 * 3);
    transition: 1s ease;
    transform: translateZ(0);
    will-change: background-image;
}

.card {
    color: hsl(0, 0%, 40%);
    background-color: white;
    border-radius: calc(var(--min-size) / 100 * 1.75);
    opacity: 1;
    outline: none;
    font-family: "Montserrat", sans-serif;
    box-shadow: rgba(0, 0, 0, .2) 0 3px 5px -1px, rgba(0, 0, 0, .14) 0 6px 10px 0, rgba(0, 0, 0, .12) 0 1px 18px 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: calc(var(--min-size) * 0.008) calc(var(--min-size) * 0.012);
    margin: 0;
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 0;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform, opacity;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.inact {
    opacity: 0.45;
    transform: scale(0.97, 0.97);
}

.act {
    transform: scale(1.03, 1.03);
    opacity: 1;
    outline: calc(var(--min-size) / 100 * 0.6) solid hsl(0, 83%, 60%);
    box-shadow: 0 4px 16px rgba(235, 59, 59, 0.35);
    z-index: 2;
}

.workouts {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
    align-items: center;
    gap: calc(var(--min-size) * 0.008);
    width: calc(var(--min-size) / 100 * 85);
    height: calc(var(--min-size) / 100 * 75);
    min-height: 0;
}

.workoutpair {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: calc(var(--min-size) * 0.01);
    flex-grow: 1;
    flex: 1;
    width: 100%;
    min-height: 0;
}

img {
    border-radius: calc(var(--min-size) / 100 * 1);
    margin: 0 auto;
    object-fit: cover;
    width: auto;
    max-width: min(100%, calc(var(--min-size) * 0.34));
    aspect-ratio: 2.75 / 1;
    height: 100%;
    flex: 1;
    min-height: 0;
    max-height: calc(100% - calc(var(--min-size) * 0.024));
    object-position: 50% 80%;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    image-rendering: auto;
}

h4 {
    font-weight: 700;
    margin: calc(var(--min-size) * 0.004) 0 0 0;
    font-size: calc(var(--min-size) * 0.018);
    line-height: 1.15;
}

/* ========================================================
   VERTICAL ORIENTATION / MOBILE FRIENDLY LAYOUT
   Stretches components vertically to intuitively fill screen
   ======================================================== */

@media (orientation: portrait), (max-aspect-ratio: 1/1) {
    .body {
        width: 100%;
        max-width: 560px;
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        margin: 0 auto;
        padding: max(8px, env(safe-area-inset-top, 8px)) max(10px, env(safe-area-inset-right, 10px)) max(8px, env(safe-area-inset-bottom, 8px)) max(10px, env(safe-area-inset-left, 10px));
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        overflow: hidden;
        background-image: linear-gradient(180deg, #ffffff 0%, hsl(207, 83%, 60%) 100%);
    }

    .title {
        font-size: clamp(1.35rem, 5.5vw, 1.85rem);
        height: auto;
        margin: 0 0 2px 0;
        line-height: 1.15;
        flex-shrink: 0;
    }

    .subtitle {
        font-size: clamp(0.68rem, 2.7vw, 0.88rem);
        height: auto;
        margin: 0 0 6px 0;
        line-height: 1.2;
        flex-shrink: 0;
    }

    .buttonSection {
        width: 100%;
        height: auto;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        gap: 6px;
        margin: 0 0 9px 0;
        flex-shrink: 0;
    }

    .buttonSection button {
        flex: 1;
        min-width: 0;
        max-width: none;
        min-height: 38px;
        height: clamp(38px, 5.2vh, 46px);
        font-size: clamp(0.75rem, 3.2vw, 0.95rem);
        border-radius: 12px;
        padding: 0 4px;
        gap: 4px;
    }

    .playButton,
    .pauseButton,
    .stopButton,
    .loudButton,
    .muteButton,
    .unMuteButton {
        width: clamp(15px, 3.8vw, 18px);
        height: clamp(15px, 3.8vw, 18px);
        margin: 0;
    }

    .resetButton {
        width: clamp(15px, 3.8vw, 18px);
        height: clamp(15px, 3.8vw, 18px);
        margin: 0;
    }

    .timebarSection {
        width: 100%;
        height: auto;
        margin: 0 0 10px 0;
        flex-shrink: 0;
    }

    .timebar {
        width: 100%;
        min-height: 0;
        height: clamp(34px, 4.8vh, 44px);
        font-size: clamp(1.2rem, 5vw, 1.7rem);
        border-radius: 12px;
    }

    .workouts {
        width: 100%;
        flex: 1;
        height: auto;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        gap: 6px;
        margin: 0;
        min-height: 0;
    }

    .workoutpair {
        flex: 1;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        gap: 6px;
        width: 100%;
        min-height: 0;
    }

    .card {
        flex: 1;
        width: 100%;
        min-width: 0;
        min-height: 0;
        margin: 0;
        padding: 6px 8px;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transform: translateZ(0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
        will-change: transform, opacity;
    }

    img {
        flex: 1;
        width: auto;
        max-width: min(100%, 280px);
        aspect-ratio: 2.5 / 1;
        height: 100%;
        min-height: 0;
        max-height: calc(100% - 19px);
        object-fit: cover;
        object-position: 50% 80%;
        border-radius: 8px;
        margin: 0 auto;
    }

    h4 {
        margin: 4px 0 0 0;
        font-size: clamp(0.62rem, 2.5vw, 0.85rem);
        font-weight: 800;
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        letter-spacing: 0.2px;
    }

    .act {
        transform: scale(1.02);
        outline: 3.5px solid hsl(0, 83%, 60%);
        box-shadow: 0 4px 16px rgba(235, 59, 59, 0.4);
    }

    .inact {
        opacity: 0.42;
        transform: scale(0.97);
    }
}

/* ========================================================
   CONFETTI & DONATION MODAL OVERLAY
   ======================================================== */

.confetti-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 999;
    padding: 16px;
    animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.confetti-overlay[hidden] {
    display: none !important;
}

.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    pointer-events: none;
    z-index: 1000;
}

.donation-popup {
    background: #ffffff;
    padding: clamp(1.5rem, 4vw, 2.1rem) clamp(1.2rem, 3.5vw, 1.8rem) clamp(1.4rem, 4vw, 1.8rem);
    border-radius: 1.5rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.06);
    max-width: 95%;
    width: 480px;
    z-index: 1001;
    font-family: "Montserrat", sans-serif;
    color: hsl(0, 0%, 35%);
    position: relative;
    animation: popupIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

@keyframes popupIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(16px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.celebration-badge {
    display: inline-block;
    background: linear-gradient(135deg, hsl(121, 60%, 92%), hsl(121, 60%, 82%));
    color: hsl(121, 70%, 28%);
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 0.35rem 0.9rem;
    border-radius: 2rem;
    margin-bottom: 0.75rem;
    border: 1px solid hsl(121, 60%, 75%);
}

.popup-title {
    color: hsl(207, 83%, 45%);
    margin: 0 0 0.4rem 0;
    font-size: clamp(1.1rem, 4.3vw, 1.6rem);
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
}

.popup-subtitle {
    font-size: clamp(0.78rem, 3vw, 0.95rem);
    font-weight: 600;
    color: hsl(0, 0%, 50%);
    margin: 0 0 0.8rem 0;
    line-height: 1.3;
    white-space: nowrap;
}

.donation-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1), transparent);
    margin: 0.75rem 0;
}

.donation-text {
    font-size: clamp(0.8rem, 2.7vw, 0.88rem);
    font-weight: 500;
    line-height: 1.45;
    margin: 0 auto 1.2rem auto;
    max-width: 420px;
    color: hsl(0, 0%, 45%);
}

.donate-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #0070BA 0%, #003087 100%);
    color: #ffffff;
    padding: 0.85rem 2rem;
    border-radius: 2.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: clamp(0.95rem, 3.2vw, 1.05rem);
    box-shadow: 0 6px 18px rgba(0, 112, 186, 0.35), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    max-width: 290px;
    box-sizing: border-box;
    margin: 0 auto;
}

.donate-button .paypal-icon {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
    flex-shrink: 0;
    margin: 0;
}

.donate-button:hover {
    background: linear-gradient(135deg, #0079c1 0%, #003b9e 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 112, 186, 0.45), 0 3px 6px rgba(0, 0, 0, 0.12);
}

.donate-button:active {
    transform: translateY(1px);
    box-shadow: 0 3px 8px rgba(0, 112, 186, 0.3);
}

button.close-popup-btn,
.close-popup-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.06) !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    color: hsl(0, 0%, 40%) !important;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
    transform: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10;
    flex: none !important;
}

button.close-popup-btn:hover,
.close-popup-btn:hover {
    background: rgba(239, 68, 68, 0.12) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
    transform: scale(1.08) !important;
    opacity: 1 !important;
}

button.close-popup-btn:active,
.close-popup-btn:active {
    transform: scale(0.94) !important;
}

.close-popup-btn svg {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    max-width: 16px !important;
    stroke: currentColor;
    display: block;
    margin: auto;
    flex: none !important;
}
