html {
    height: var(--mc-vvh, 100svh);
    max-height: var(--mc-vvh, 100svh);
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    background-color: #ffffff;
    color: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: var(--mc-vvh, 100svh);
    max-height: var(--mc-vvh, 100svh);
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    padding: 16px 20px;
    gap: 10px;
}

.title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    margin-bottom: 24px;
}

.subtitle {
    font-size: 10pt;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0;
    color: #000000;
}

.title {
    font-family: 'Dancing Script', cursive;
    font-weight: 700;
    color: #000000;
    font-size: 3em;
    margin: 0;
    line-height: 1.1;
}

.top-container {
    display: grid;
    grid-template-columns: repeat(3, 120px);
    column-gap: 15px;
    align-items: stretch;
    width: 390px;
    max-width: 100%;
    flex-shrink: 0;
}

button,
button * {
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    touch-action: manipulation;
}

#learn-btn,
#play-btn {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    color: #000000;
    border: 2px solid #000000;
}

#learn-btn:hover,
#play-btn:hover {
    background-color: #000000;
    color: #ffffff;
}

.btn-icon {
    display: none;
    font-size: 1.15em;
    font-weight: 700;
    line-height: 1;
}

#play-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#play-btn:disabled:hover {
    background-color: #ffffff;
    color: #000000;
}

.play-icon {
    display: inline-block;
}

.audio-active .play-icon {
    animation: play-pulse-away 0.8s infinite ease-in-out;
}

@keyframes play-pulse-away {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-5px); }
}

#score {
    box-sizing: border-box;
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 16px;
    color: #000000;
    background: #ffffff;
    border: 2px solid #000000;
    padding: 8px;
    border-radius: 5px;
}

.stage {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr 1.15fr 1fr;
    align-items: center;
    width: min(100%, 36rem);
    height: 17.5rem;
    margin-top: 8px;
}

.horizon {
    position: absolute;
    left: 6%;
    right: 6%;
    top: 50%;
    z-index: 0;
    border-top: 2px dashed #000000;
    opacity: 0.12;
    pointer-events: none;
}

.choice-btn {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 140px;
    height: 140px;
    justify-self: center;
    padding: 10px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.15;
    white-space: normal;
    cursor: pointer;
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    touch-action: manipulation;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
    scale: 1;
    transition: scale 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s, opacity 0.25s, box-shadow 0.25s;
}

.choice-btn--flat {
    background-color: #5B8DEF;
    margin-top: 3.6rem;
    animation: dip 2.8s ease-in-out infinite;
}

.choice-btn--intune {
    width: 168px;
    height: 168px;
    font-size: 20px;
    background-color: #2ECC71;
    z-index: 2;
    animation: heartbeat 1.6s ease-in-out infinite;
}

.choice-btn--sharp {
    background-color: #F46C3F;
    margin-bottom: 3.6rem;
    animation: lift 2.8s ease-in-out infinite;
}

.choice-btn:active {
    scale: 0.94;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35);
}

@media (hover: hover) and (pointer: fine) {
    .choice-btn:hover {
        scale: 1.1;
        z-index: 3;
    }
}

.stage.is-idle .choice-btn,
.choice-btn.is-wrong {
    filter: grayscale(1);
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
}

@keyframes dip {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(12px); }
}

@keyframes lift {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    16% { transform: scale(1.07); }
    28% { transform: scale(1); }
    42% { transform: scale(1.05); }
    58% { transform: scale(1); }
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: rgba(0, 0, 0, 0.45);
}

.overlay.hidden {
    display: none;
}

.ed-modal {
    position: relative;
    box-sizing: border-box;
    width: min(100%, 20rem);
    padding: 1.5rem 1.35rem 1.25rem;
    border: 2px solid #000000;
    border-radius: 12px;
    background: #ffffff;
    color: #000000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.ed-modal--result {
    height: 18.5rem;
    display: flex;
    flex-direction: column;
}

.ed-modal__title {
    margin: 0;
    text-align: center;
    font-family: 'Dancing Script', cursive;
    font-size: 2rem;
    font-weight: 700;
    color: #000000;
}

.ed-modal__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.ed-modal__lead,
.ed-modal__cents,
.ed-modal__prompt {
    margin: 0;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.4;
}

.ed-modal__prompt {
    margin-top: 0.85rem;
}

.ed-modal__answer {
    margin: 0;
    min-height: 1.7em;
    font-size: 1.35rem;
    font-weight: 700;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ed-modal__btn {
    display: block;
    width: 100%;
    margin-top: 1rem;
    padding: 0.65rem 0.75rem;
    border: 2px solid #000000;
    border-radius: 5px;
    background: #ffffff;
    color: #000000;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.ed-modal__actions {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    margin-top: 1rem;
}

.ed-modal__actions .ed-modal__btn {
    margin-top: 0;
    flex: 1;
}

.ed-modal__btn--ghost {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
}

.ed-modal__btn:hover {
    background: #000000;
    color: #ffffff;
}

.ed-modal__btn:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

@media screen and (max-width: 767px) {
    .container {
        padding: max(12px, env(safe-area-inset-top)) 20px max(12px, env(safe-area-inset-bottom));
        gap: 10px;
    }
    .subtitle { font-size: 8pt; }
    .title { font-size: 2em; }
    .title-container { margin-bottom: 16px; }
    .top-container {
        display: flex;
        justify-content: center;
        align-items: stretch;
        gap: 8px;
        width: auto;
        max-width: min(100vw - 40px, 22rem);
    }
    #play-btn,
    #learn-btn {
        flex: 0 0 48px;
        width: 48px;
        min-height: 44px;
        min-width: 44px;
        padding: 8px 0;
        font-size: 18px;
    }
    .btn-label { display: none; }
    .btn-icon { display: inline; }
    #score {
        width: auto;
        flex: 0 0 auto;
        min-height: 44px;
        padding: 8px 12px;
        font-size: 15px;
        white-space: nowrap;
    }
    .stage {
        width: min(100%, 22rem);
        height: 14.5rem;
    }
    .choice-btn {
        width: 96px;
        height: 96px;
        font-size: 14px;
    }
    .choice-btn--flat { margin-top: 2.4rem; }
    .choice-btn--intune {
        width: 112px;
        height: 112px;
        font-size: 15px;
    }
    .choice-btn--sharp { margin-bottom: 2.4rem; }
    .ed-modal--result { height: 19rem; }
    .ed-modal__actions { flex-direction: column; }
    .ed-modal__btn { min-height: 44px; }
}

@media screen and (max-width: 767px) and (max-height: 500px) {
    .title-container { margin-bottom: 8px; }
    .title { font-size: 1.6em; }
    .stage { height: 11rem; }
    .choice-btn { width: 72px; height: 72px; font-size: 12px; }
    .choice-btn--intune { width: 84px; height: 84px; font-size: 13px; }
    .ed-modal--result { height: 16.5rem; }
}
