:root {
    color-scheme: light;
    font-family: "Arial", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
    color: #173126;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    background: linear-gradient(150deg, #c9e9f3 0%, #f8e7b9 48%, #d8ead1 100%);
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.page-shell {
    width: 100%;
    min-height: 100svh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 0 24px;
}

.game-frame {
    position: relative;
    width: min(100vw, 640px);
    min-height: 100svh;
    height: 100svh;
    overflow: hidden;
    border: 1px solid rgba(25, 67, 49, 0.22);
    background:
        linear-gradient(90deg, rgba(23, 49, 38, 0.05) 1px, transparent 1px),
        linear-gradient(180deg, rgba(23, 49, 38, 0.05) 1px, transparent 1px),
        linear-gradient(180deg, #fafff4 0%, #e4f2dc 100%);
    background-size:
        30px 30px,
        30px 30px,
        auto;
    box-shadow: 0 20px 70px rgba(24, 54, 43, 0.25);
}

.panel,
.play-panel {
    position: absolute;
    inset: 0;
    display: grid;
    padding: max(22px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
    text-align: center;
}

.panel {
    z-index: 2;
    align-content: center;
    gap: 16px;
    background: linear-gradient(180deg, rgba(255, 252, 237, 0.95), rgba(225, 244, 229, 0.96));
}

.start-panel {
    grid-template-rows: auto auto minmax(150px, 1fr) auto auto auto auto;
}

h1,
h2,
h3,
p,
figure {
    margin: 0;
}

.kicker {
    justify-self: center;
    padding: 6px 12px;
    border: 1px solid rgba(35, 116, 79, 0.32);
    border-radius: 999px;
    color: #185b3b;
    background: rgba(255, 255, 246, 0.76);
    font-size: 12px;
    font-weight: 900;
}

.start-panel h1 {
    color: #153f31;
    font-size: clamp(32px, 9vw, 56px);
    line-height: 0.98;
    letter-spacing: 0;
}

.start-field {
    width: min(100%, 430px);
    align-self: center;
    justify-self: center;
}

.start-field img {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    border-radius: 10px;
    filter: drop-shadow(0 18px 18px rgba(35, 80, 54, 0.18));
}

.lead {
    width: min(100%, 430px);
    justify-self: center;
    color: #314b3f;
    font-size: 16px;
    line-height: 1.65;
}

.hint,
.copyright {
    color: #597468;
    font-size: 13px;
}

.copyright {
    font-size: 12px;
}

.primary-button,
.secondary-button {
    width: min(100%, 310px);
    min-height: 58px;
    justify-self: center;
    border: 1px solid rgba(23, 49, 38, 0.28);
    border-radius: 10px;
    color: #fffdf2;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    touch-action: manipulation;
}

.primary-button {
    background: linear-gradient(135deg, #207349, #2f9160 58%, #1f5064);
    box-shadow:
        0 10px 0 #143827,
        0 18px 28px rgba(34, 65, 43, 0.22);
}

.secondary-button {
    background: linear-gradient(135deg, #806147, #a36d3b 58%, #5a3c2b);
    box-shadow:
        0 10px 0 #422c20,
        0 18px 28px rgba(34, 65, 43, 0.18);
}

.primary-button:active,
.secondary-button:active {
    transform: translateY(5px);
    box-shadow:
        0 4px 0 #143827,
        0 12px 20px rgba(34, 65, 43, 0.2);
}

.hud {
    position: absolute;
    z-index: 4;
    top: max(9px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.meter {
    min-width: 0;
    padding: 7px 5px;
    border: 1px solid rgba(24, 72, 45, 0.2);
    border-radius: 8px;
    background: rgba(255, 252, 239, 0.88);
    box-shadow: 0 5px 14px rgba(24, 72, 45, 0.12);
}

.meter span {
    display: block;
    color: #5b725f;
    font-size: 10px;
    font-weight: 800;
}

.meter strong {
    display: block;
    margin-top: 2px;
    color: #163c2b;
    font-size: clamp(15px, 4vw, 21px);
    line-height: 1.1;
}

.play-panel {
    z-index: 3;
    grid-template-rows: minmax(290px, 50svh) 1fr auto;
    gap: 12px;
    padding-top: max(68px, calc(env(safe-area-inset-top) + 62px));
    background: linear-gradient(180deg, #d8f3ff 0%, #fff3ce 38%, #e4f3d9 100%);
}

.stadium {
    position: relative;
    align-self: stretch;
    min-height: 290px;
    overflow: hidden;
    border: 1px solid rgba(22, 61, 113, 0.18);
    border-radius: 8px;
    background: #eaf1f7;
    box-shadow: 0 10px 24px rgba(24, 72, 45, 0.14);
}

.stadium img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

.ball-marker {
    position: absolute;
    left: 50%;
    top: 78%;
    width: 24px;
    height: 24px;
    border: 3px solid #b53a30;
    border-radius: 50%;
    background: #fff9ef;
    box-shadow: 0 8px 12px rgba(66, 38, 22, 0.28);
    transform: translate(-50%, -50%);
    opacity: 0;
}

.ball-marker.pitch {
    opacity: 1;
    animation: pitchBall 800ms ease-in-out infinite alternate;
}

.ball-marker.single {
    opacity: 1;
    animation: singleBall 920ms ease-out forwards;
}

.ball-marker.double {
    opacity: 1;
    animation: doubleBall 960ms ease-out forwards;
}

.ball-marker.homerun {
    opacity: 1;
    animation: homerunBall 1050ms ease-out forwards;
}

.ball-marker.out {
    opacity: 1;
    animation: outBall 760ms ease-out forwards;
}

.scoreboard {
    position: absolute;
    left: 50%;
    top: 22%;
    width: min(80%, 390px);
    min-height: 112px;
    display: grid;
    place-content: center;
    gap: 7px;
    padding: 12px 14px;
    border: 5px solid #f5fbff;
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 40%),
        #102f2a;
    color: #fff8d9;
    box-shadow:
        0 10px 0 rgba(36, 51, 70, 0.55),
        0 18px 26px rgba(8, 18, 28, 0.24);
    transform: translateX(-50%);
}

.category-text {
    justify-self: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f7d15e;
    color: #173126;
    font-size: 12px;
    font-weight: 900;
}

.scoreboard h2 {
    font-size: clamp(18px, 5vw, 27px);
    line-height: 1.28;
    letter-spacing: 0;
}

.count-text {
    color: #bde9cf;
    font-size: 12px;
    font-weight: 800;
}

.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    align-content: center;
}

.choice-button {
    position: relative;
    min-height: 66px;
    padding: 10px 8px 10px 42px;
    border: 1px solid rgba(31, 80, 50, 0.26);
    border-radius: 8px;
    color: #173126;
    background: #fffaf0;
    box-shadow:
        0 6px 0 #d6bd83,
        0 12px 20px rgba(39, 71, 46, 0.14);
    cursor: pointer;
    touch-action: manipulation;
}

.choice-button:disabled {
    cursor: default;
}

.choice-index {
    position: absolute;
    top: 50%;
    left: 10px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: #fffaf0;
    background: #276344;
    font-size: 13px;
    font-weight: 900;
    transform: translateY(-50%);
}

.choice-label {
    display: block;
    font-size: clamp(15px, 4.1vw, 20px);
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.choice-button.correct {
    color: #0d3625;
    background: #9decaa;
    box-shadow:
        0 6px 0 #3e9b57,
        0 12px 20px rgba(39, 71, 46, 0.14);
}

.choice-button.wrong {
    color: #fff7ee;
    background: #c74d3e;
    box-shadow:
        0 6px 0 #863327,
        0 12px 20px rgba(68, 25, 21, 0.14);
}

.judge-text {
    min-height: 30px;
    color: #173126;
    font-size: 16px;
    font-weight: 900;
}

.finish-panel h2 {
    color: #173126;
    font-size: clamp(30px, 8vw, 44px);
}

.result-score {
    color: #bb3f31;
    font-size: clamp(54px, 18vw, 86px);
    font-weight: 950;
    line-height: 1;
}

.result-summary,
.high-score {
    color: #39584a;
    font-size: 16px;
    font-weight: 800;
}

.review-box {
    display: grid;
    gap: 10px;
    width: min(100%, 470px);
    max-height: 32svh;
    justify-self: center;
    overflow: auto;
    padding: 14px;
    border: 1px solid rgba(23, 49, 38, 0.18);
    border-radius: 8px;
    background: rgba(255, 250, 238, 0.82);
    text-align: left;
}

.review-box h3 {
    color: #173126;
    font-size: 15px;
}

.review-list {
    display: grid;
    gap: 9px;
    margin: 0;
    padding-left: 22px;
}

.review-list li {
    color: #405c50;
    font-size: 13px;
    line-height: 1.5;
}

.review-list strong,
.review-list span {
    display: block;
}

.finish-actions {
    display: grid;
    gap: 14px;
}

@keyframes pitchBall {
    from {
        transform: translate(-50%, -70%) scale(0.8);
    }
    to {
        transform: translate(-50%, -30%) scale(1.12);
    }
}

@keyframes singleBall {
    to {
        left: 31%;
        top: 63%;
        transform: translate(-50%, -50%) scale(0.82);
    }
}

@keyframes doubleBall {
    to {
        left: 50%;
        top: 31%;
        transform: translate(-50%, -50%) scale(0.72);
    }
}

@keyframes homerunBall {
    55% {
        left: 73%;
        top: 14%;
        transform: translate(-50%, -50%) scale(0.55);
    }
    100% {
        left: 84%;
        top: -8%;
        transform: translate(-50%, -50%) scale(0.34);
    }
}

@keyframes outBall {
    to {
        left: 47%;
        top: 80%;
        transform: translate(-50%, -50%) scale(0.7);
        opacity: 0.7;
    }
}

@media (min-width: 700px) {
    .page-shell {
        padding-top: 18px;
    }

    .game-frame {
        height: min(920px, calc(100svh - 36px));
        min-height: 720px;
        border-radius: 22px;
    }
}

@media (max-height: 690px) {
    .play-panel {
        grid-template-rows: minmax(230px, 42svh) 1fr auto;
        gap: 8px;
    }

    .choice-button {
        min-height: 56px;
    }

    .stadium {
        min-height: 230px;
    }

    .scoreboard {
        top: 22%;
        min-height: 90px;
        padding: 9px 10px;
    }

    .scoreboard h2 {
        font-size: clamp(16px, 4.6vw, 22px);
    }
}
