/*
 * Portrait-mobile arena only.
 * Keep every visual mobile adjustment for Catch the Fly in this file.
 */
html.catch-the-fly-mobile-portrait,
html.catch-the-fly-mobile-portrait body {
    height: 100dvh;
    overflow: hidden;
}

/* The desktop animation scales from the viewport width. On portrait phones,
 * use otherwise empty vertical space for a 30% taller play area. */
html.catch-the-fly-mobile-portrait body.catch-the-fly-playing #animation_container {
    /* Preserve layout space for the 30% visual height increase. */
    margin-bottom: calc(23.08vw + 90px);
    transform: scaleY(1.3);
    transform-origin: top center;
}

#catch-the-fly-mobile-menu {
    display: none;
}

html.catch-the-fly-mobile-portrait #catch-the-fly-mobile-menu:not([hidden]) {
    box-sizing: border-box;
    display: block;
    width: min(92vw, 430px);
    margin: 0 auto;
    padding: 10px 13px 18px;
    color: #fff;
    font-family: Arial, sans-serif;
    text-align: center;
    text-shadow: 0.1em 0.1em 0.3em rgb(0 0 0 / 50%);
    background: linear-gradient(145deg, #263e5a, #18283b);
    border: 2px solid #53687f;
    border-radius: 16px;
    box-shadow: inset 0 1px rgb(255 255 255 / 25%), 0 4px 10px rgb(0 0 0 / 35%);
}

#catch-the-fly-mobile-menu p {
    margin: 0;
}

.catch-the-fly-mobile-menu__label {
    margin: 10px 0 18px !important;
    color: #fffeb5;
    font-size: clamp(1.05rem, 5vw, 1.4rem);
    font-weight: 800;
}

.catch-the-fly-mobile-menu__levels {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.catch-the-fly-mobile-menu button {
    min-height: 54px;
    padding: 8px 12px;
    color: #fff;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-shadow: 0.1em 0.1em 0.3em rgb(0 0 0 / 50%);
    border: 2px solid #657487;
    border-radius: 10px;
    box-shadow: inset 0 1px rgb(255 255 255 / 20%);
}

.catch-the-fly-mobile-menu__levels button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    font-size: clamp(1.05rem, 5vw, 1.4rem);
    text-align: left;
    background: linear-gradient(145deg, #526174, #3d4a5d);
}

.catch-the-fly-mobile-menu__levels button::after {
    display: grid;
    width: 1.45em;
    height: 1.45em;
    place-items: center;
    color: #f2f2c0;
    font-size: 1.1em;
    font-weight: 400;
    line-height: 1;
    content: '×';
    border: 2px solid currentColor;
    border-radius: 50%;
}

.catch-the-fly-mobile-menu__levels button.is-selected {
    color: #fffda9;
    background: linear-gradient(145deg, #5a5950, #3e3d38);
    border-color: #ded28b;
}

.catch-the-fly-mobile-menu__levels button.is-selected::after {
    content: '✓';
}

.catch-the-fly-mobile-menu button:active {
    transform: translateY(1px);
    filter: brightness(0.92);
}

.catch-the-fly-mobile-menu__start {
    width: 100%;
    min-height: 68px !important;
    font-size: clamp(1.55rem, 8vw, 2.25rem) !important;
    background: linear-gradient(#98d4f3 49%, #70b8e0 50%);
    border-color: #c3ecff;
    border-bottom-width: 5px;
    border-radius: 16px;
}

#catch-the-fly-mobile-hud {
    display: none;
}

html.catch-the-fly-mobile-portrait body.catch-the-fly-playing #catch-the-fly-mobile-hud:not([hidden]) {
    position: absolute;
    z-index: 20;
    top: 0;
    right: 0;
    left: 0;
    display: block;
    font: 700 0.9rem/1 Arial, sans-serif;
    pointer-events: none;
}

.catch-the-fly-mobile-hud__panel,
#catch-the-fly-mobile-hud button {
    position: absolute;
    min-height: 32px;
    box-sizing: border-box;
    color: #034f66;
    background: #fff;
    border: 4px solid #2fd0fc;
    border-radius: 5px;
    box-shadow: 1px 2px 3px rgb(0 0 0 / 45%);
}

.catch-the-fly-mobile-hud__score {
    top: calc(100vw - 104px);
    left: 8px;
    width: 32vw;
    min-width: 120px;
    min-height: 48px;
    font-size: 1.1rem;
}

.catch-the-fly-mobile-hud__level {
    top: 8px;
    left: 8px;
    width: 28vw;
    min-width: 100px;
}

.catch-the-fly-mobile-hud__panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 5px;
}

.catch-the-fly-mobile-hud__panel strong {
    min-width: 1.5em;
    padding: 3px 6px;
    color: #6e6761;
    text-align: center;
    background: #d5f7ff;
    border: 1px solid #9aedf1;
    border-radius: 3px;
}

.catch-the-fly-mobile-hud__answer {
    top: calc(100vw + 16px);
    left: 8px;
    width: 42vw;
    min-width: 130px;
    justify-content: center;
    min-height: 52px;
    color: #0006f6;
    font-size: 1.35rem;
    letter-spacing: 0.08em;
}

#catch-the-fly-mobile-hud button {
    padding: 4px;
    color: #034f66;
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
    pointer-events: auto;
}

.catch-the-fly-mobile-hud__hint {
    top: calc(100vw + 16px);
    right: 8px;
    width: 35vw;
    min-width: 112px;
    min-height: 52px !important;
    color: #6e6761 !important;
    font-size: 1.2rem !important;
}

.catch-the-fly-mobile-hud__hint.is-revealing {
    overflow: hidden;
    color: #034f66 !important;
    font-size: 0.95rem !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.catch-the-fly-mobile-hud__repeat {
    top: calc(100vw + 16px);
    right: auto;
    left: calc(52vw - 23px);
    display: grid;
    width: 46px;
    min-height: 46px !important;
    padding: 0 !important;
    place-items: center;
    color: transparent !important;
    font-size: 0 !important;
    background: transparent url('../images/repeat.png') center / 36px 34px no-repeat !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

#catch-the-fly-mobile-hud button:active {
    transform: translateY(1px);
}

#catch-the-fly-mobile-end {
    display: none;
}

html.catch-the-fly-mobile-portrait #catch-the-fly-mobile-end:not([hidden]) {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px 0;
    box-sizing: border-box;
    overflow-y: auto;
    color: #fff;
    font-family: Arial, sans-serif;
    text-align: center;
    background: transparent;
    pointer-events: none;
}

.catch-the-fly-mobile-end h2,
.catch-the-fly-mobile-end h3,
.catch-the-fly-mobile-end p {
    margin: 0;
}

.catch-the-fly-mobile-end h2 {
    color: #3c2728;
    font-size: clamp(1.8rem, 9vw, 2.4rem);
}

.catch-the-fly-mobile-end__score {
    margin: 8px 0 18px !important;
    font-size: clamp(1.2rem, 6vw, 1.55rem);
    text-shadow: 1px 2px 2px rgb(0 0 0 / 55%);
}

.catch-the-fly-mobile-end__entry {
    width: min(100%, 310px);
    padding: 12px 16px 14px;
    box-sizing: border-box;
    background: rgb(54 38 27 / 88%);
    box-shadow: 0 3px 7px rgb(0 0 0 / 35%);
    pointer-events: auto;
}

.catch-the-fly-mobile-end__entry label {
    display: block;
    margin-bottom: 7px;
    font-size: 1.05rem;
    font-weight: 700;
}

.catch-the-fly-mobile-end__entry div {
    display: flex;
    gap: 8px;
}

.catch-the-fly-mobile-end__entry input,
.catch-the-fly-mobile-end__entry button,
.catch-the-fly-mobile-end__new-game {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    font: 700 1rem Arial, sans-serif;
}

.catch-the-fly-mobile-end__entry input {
    width: 100%;
    min-width: 0;
    padding: 0 12px;
    color: #18344a;
}

.catch-the-fly-mobile-end__entry button {
    display: block;
    width: 68px;
    flex: 0 0 68px;
    margin: 0;
    color: #fff;
    background: linear-gradient(#90d0f1, #54a8d3);
    box-shadow: inset 0 1px rgb(255 255 255 / 50%);
}

.catch-the-fly-mobile-end__new-game {
    padding: 0 18px;
    color: #fff;
    background: linear-gradient(#90d0f1, #54a8d3);
    box-shadow: inset 0 1px rgb(255 255 255 / 50%);
    pointer-events: auto;
}

.catch-the-fly-mobile-end__board {
    width: min(100%, 470px);
    margin-top: 20px;
    padding: 10px 12px 16px;
    box-sizing: border-box;
    background: linear-gradient(160deg, #263e5a, #18283b);
    border: 1px solid #778da5;
    border-radius: 13px;
    box-shadow: 0 4px 10px rgb(0 0 0 / 38%);
    pointer-events: auto;
}

.catch-the-fly-mobile-end__new-game {
    width: 100%;
    min-height: 60px;
    font-size: clamp(1.5rem, 8vw, 2.15rem);
    text-shadow: 1px 2px 2px rgb(0 0 0 / 45%);
    border: 3px solid #b8e7ff;
    border-bottom-width: 6px;
}

.catch-the-fly-mobile-end h3 {
    margin-bottom: 7px;
    color: #fff8a9;
    font-size: 1.3rem;
    text-shadow: 1px 2px 2px rgb(0 0 0 / 45%);
}

.catch-the-fly-mobile-end__scores {
    width: min(100%, 390px);
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid #7ca1b8;
    border-radius: 8px;
    overflow: hidden;
}

.catch-the-fly-mobile-end__scores li {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 5px 10px;
    background: rgb(255 255 255 / 12%);
    border-bottom: 1px solid rgb(255 255 255 / 18%);
    font-size: 0.95rem;
}

.catch-the-fly-mobile-end__scores li:last-child {
    border-bottom: 0;
}

#catch-the-fly-keyboard {
    display: none;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#catch-the-fly-keyboard[hidden] {
    display: none !important;
}

html.catch-the-fly-mobile-portrait body.catch-the-fly-playing #catch-the-fly-keyboard:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 0.34rem;
    width: min(100vw, 520px);
    margin: 16px auto 0;
    padding: 0 max(0.85rem, env(safe-area-inset-left)) max(0.45rem, env(safe-area-inset-bottom)) max(0.85rem, env(safe-area-inset-right));
    box-sizing: border-box;
}

.catch-the-fly-keyboard__row {
    display: grid;
    width: 100%;
    column-gap: 0.34rem;
}

.catch-the-fly-keyboard__row.row-10 {
    grid-template-columns: repeat(10, minmax(0, 1fr));
}

.catch-the-fly-keyboard__row.row-9 {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    padding: 0 4.8%;
    box-sizing: border-box;
}

.catch-the-fly-keyboard__row.row-7 {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    padding: 0 14.4%;
    box-sizing: border-box;
}

.catch-the-fly-keyboard__row.row-space {
    grid-template-columns: minmax(8rem, 44%);
    justify-content: center;
}

.catch-the-fly-keyboard__row button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 2.55rem;
    padding: 0;
    box-sizing: border-box;
    color: #fff;
    font: 900 1.18rem/1 Arial, sans-serif;
    text-shadow: 1px 1px 1px #000;
    background: linear-gradient(145deg, #9bd7f3, #55acd7);
    border: 0;
    border-radius: 6px;
    box-shadow: inset 2px 2px 3px rgb(255 255 255 / 80%), inset -2px -2px 3px rgb(0 0 0 / 35%);
    cursor: pointer;
    touch-action: manipulation;
}

.catch-the-fly-keyboard__row button:active {
    transform: translateY(1px);
    box-shadow: inset -2px -2px 2px rgb(255 255 255 / 45%), inset 2px 2px 3px rgb(0 0 0 / 45%);
}

@media (max-height: 720px) {
    html.catch-the-fly-mobile-portrait body.catch-the-fly-playing #catch-the-fly-keyboard {
        gap: 0.22rem;
        padding-right: 0.85rem;
        padding-left: 0.85rem;
    }

    .catch-the-fly-keyboard__row {
        column-gap: 0.22rem;
    }

    .catch-the-fly-keyboard__row button {
        min-height: 2.05rem;
        font-size: 1rem;
    }
}
