:root {
    --text-color: #1a1a1a;
    --hint-color: rgba(255, 255, 255, 0.65);
}

.figures {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: clamp(8px, 4vw, 48px);
    width: 100%;
    height: 100dvh;
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(10px, 2.5vh, 32px) clamp(10px, 3vw, 40px);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.fig {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    flex: 1 1 0;
    max-width: min(50%, 480px);
    height: 100%;
    max-height: 100%;
    margin: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
}

.figure {
    height: auto;
    width: auto;
    max-height: clamp(200px, 54vh, 640px);
    max-width: 100%;
    object-fit: contain;
    opacity: 0.2;
    filter: brightness(0.85);
    transition: opacity 0.3s ease, filter 0.3s ease;
    pointer-events: none;
    display: block;
}

.cloud {
    position: absolute;
    top: 0;
    width: 100%;
    height: 10%;
    object-fit: cover;
    display: block;
}

.speech-bubble-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: clamp(160px, 40vw, 440px);
    margin-bottom: clamp(6px, 1.5vh, 20px);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9);
    transform-origin: bottom center;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.25s ease;
    z-index: 10;
}

.speech-bubble-wrapper-steve {
    align-self: flex-start;
    margin-left: 4%;
}

.speech-bubble-wrapper-alex {
    align-self: flex-end;
    margin-right: 4%;
}

.speech-bubble {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.5));
    pointer-events: none;
}

.speech-bubble-text {
    position: absolute;
    top: 6%;
    left: 5%;
    width: 90%;
    height: 58%;
    margin: 0;
    padding: clamp(6px, 1.5vw, 18px);
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-color);
    font-weight: 600;
    font-size: clamp(0.75rem, 2.2vw, 1.2rem);
    line-height: 1.28;
    white-space: pre-line;
    pointer-events: none;
}

.speech-bubble-text a,
.cloud-bubble-text a {
    vertical-align: baseline;
}

.speech-content {
    display: block;
    width: 100%;
}

.cloud-bubble-text {
    height: 90%;
    display: grid;
    place-content: center;
    line-height: 1.45;
    white-space: pre-line;
}

.cloud-content {
    display: block;
    width: 100%;
}

.cloud-line {
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    white-space: nowrap;
}

.cloud-bubble-text sup,
.speech-bubble-text sup {
    font-size: 0.75em;
    line-height: 0;
    vertical-align: super;
}

.spoken .figure {
    opacity: 1;
    filter: brightness(1);
    transform: translateY(-2%);
}

.spoken .speech-bubble-wrapper,
.spoken .speech-bubble,
.spoken .speech-bubble-text {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.speaking .figure {
    animation: bounceAnimation 0.65s infinite ease-in-out;
}

@keyframes bounceAnimation {
    0%, 100% {
        transform: translateY(-2%);
    }
    50% {
        transform: translateY(-4.5%);
    }
}

.tap-hint {
    position: absolute;
    bottom: clamp(12px, 2.5vh, 28px);
    left: 50%;
    transform: translateX(-50%);
    color: var(--hint-color);
    font-size: clamp(0.72rem, 2vw, 0.92rem);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    pointer-events: none;
    animation: pulseHint 2.2s infinite ease-in-out;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    z-index: 20;
    text-align: center;
    white-space: nowrap;
}

.tap-hint.hidden {
    opacity: 0;
    visibility: hidden;
}

@keyframes pulseHint {
    0%, 100% {
        opacity: 0.35;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 0.9;
        transform: translateX(-50%) translateY(-3px);
    }
}

@media (max-width: 600px) {
    .figures {
        gap: 6px;
        padding: 8px 6px clamp(32px, 5vh, 44px) 6px;
    }

    .fig {
        max-width: 50%;
    }

    .figure {
        max-height: clamp(170px, 46vh, 360px);
    }

    .speech-bubble-wrapper {
        width: clamp(140px, 47vw, 220px);
        margin-bottom: 6px;
    }

    .speech-bubble-wrapper-steve {
        margin-left: 0;
    }

    .speech-bubble-wrapper-alex {
        margin-right: 0;
    }

    .speech-bubble-text {
        font-size: clamp(0.68rem, 3.1vw, 0.88rem);
        padding: 4px 6px;
        line-height: 1.2;
    }
}

@media (max-height: 1200px) {
    .fig {
        transform: translateY(clamp(28px, 5vh, 56px));
    }
}

@media (max-height: 500px) {
    .figures {
        padding: 4px 16px;
    }

    .figure {
        max-height: 52vh;
    }

    .fig {
        transform: translateY(clamp(42px, 7vh, 72px));
    }

    .speech-bubble-wrapper {
        width: clamp(150px, 30vw, 260px);
        margin-bottom: 3px;
    }

    .speech-bubble-text {
        font-size: clamp(0.68rem, 2.2vh, 0.92rem);
        padding: 3px 6px;
    }

    .tap-hint {
        bottom: 3px;
        font-size: 0.65rem;
    }
}