* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation
}

/*タブレット連打時の拡大防止 */
html {
    margin: 0;
    height: 100%
}

body {
    margin: 0;
    height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
    background: linear-gradient(#3a7bd5, #5ac8ea);
    display: flex;
    justify-content: center;
    align-items: center
}

button {
    font: inherit;
    -webkit-tap-highlight-color: transparent
}

.container {
    position: relative;
    margin: 0 auto;
    width: 100%;
    max-width: 1196px;
    height: 540px;
    overflow: hidden;
    border: 2px solid #245b74;
    border-radius: 26px;
    background: linear-gradient(#87ceeb, #cdefb3);
    box-shadow: 0 12px 40px #0005;
    display: flex;
    flex-direction: column
}

.game-header {
    position: relative;
    z-index: 100;
    height: 50px;
    flex: 0 0 50px;
    padding: 5px 12px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 900
}

.start-mode .game-header {
    display: none
}

.start-mode .game-main {
    flex-basis: 540px
}

.header-score {
    color: #e64a19;
    background: #ffffffe6;
    padding: 7px 14px;
    border-radius: 22px;
    box-shadow: 0 3px #0002
}

.header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: #164f65;
    font-size: 21px;
    letter-spacing: 2px;
    white-space: nowrap;
    text-shadow: 0 2px #fff
}

.header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto
}

.header-btn {
    border: 0;
    border-radius: 22px;
    padding: 7px 14px;
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px #0004
}

.quit-btn {
    background: #ef5350
}

.sound-btn {
    min-width: 68px;
    background: #43a047;
    font-size: 18px
}

.sound-btn.off {
    background: #78909c
}

.header-btn:active {
    transform: translateY(2px)
}

.game-main {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: grid;
    place-items: center;
    background: linear-gradient(#87ceeb, #cdefb3)
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center
}

.hidden {
    display: none !important
}

.start-screen,
.result-screen {
    background: linear-gradient(#6ec6ff 0 55%, #c8f2b0 55%, #9fe07f)
}

.sun {
    position: absolute;
    top: 28px;
    right: 6%;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff59d, #ffca28);
    box-shadow: 0 0 38px 12px #ffca2899
}

.cloud {
    position: absolute;
    background: #fff;
    border-radius: 50px;
    opacity: .9
}

.cloud:before,
.cloud:after {
    content: "";
    position: absolute;
    background: #fff;
    border-radius: 50%
}

.cloud-one {
    top: 52px;
    left: 7%;
    width: 90px;
    height: 32px
}

.cloud-one:before {
    width: 46px;
    height: 46px;
    top: -22px;
    left: 12px
}

.cloud-one:after {
    width: 34px;
    height: 34px;
    top: -16px;
    left: 50px
}

.cloud-two {
    top: 112px;
    left: 23%;
    width: 70px;
    height: 26px
}

.cloud-two:before {
    width: 36px;
    height: 36px;
    top: -18px;
    left: 8px
}

.cloud-two:after {
    width: 26px;
    height: 26px;
    top: -12px;
    left: 38px
}

.game-title {
    z-index: 1;
    margin: 0 0 4px;
    font-size: clamp(38px, 6vw, 58px);
    font-weight: 900;
    letter-spacing: 4px;
    -webkit-text-stroke: 3px #fff;
    text-shadow: 0 6px #0002
}

.game-title span:nth-child(1) {
    color: #ff5252
}

.game-title span:nth-child(2) {
    color: #ff9800
}

.game-title span:nth-child(3) {
    color: #ffca28
}

.game-title span:nth-child(4) {
    color: #66bb6a
}

.game-title span:nth-child(5) {
    color: #26c6da
}

.game-title span:nth-child(6) {
    color: #5c6bc0
}

.game-title span:nth-child(7) {
    color: #ab47bc
}

.game-title span:nth-child(8) {
    color: #ec407a
}

.start-melon {
    z-index: 1;
    width: 120px;
    height: 120px;
    animation: bounce 1.6s infinite
}

.start-melon svg,
.melon-whole svg,
.half svg {
    width: 100%;
    height: 100%;
    display: block
}

.howto {
    z-index: 1;
    margin: 3px 0 13px;
    padding: 7px 22px;
    border-radius: 20px;
    background: #ffffffc2;
    color: #1b5e20;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center
}

.play-btn,
.back-btn {
    z-index: 1;
    border: 0;
    border-radius: 50px;
    padding: 13px 52px;
    color: #fff;
    font-size: 27px;
    font-weight: 900;
    letter-spacing: 3px;
    cursor: pointer
}

.play-btn {
    background: linear-gradient(#ff8a65, #ff5722);
    box-shadow: 0 7px #d84315, 0 10px 18px #0004;
    animation: pulse 1.3s infinite
}

.start-screen .play-btn {
    margin-top: 14px
}

.ground {
    position: absolute;
    inset: auto 0 0;
    height: 42px;
    background: #7cb342;
    border-top: 6px solid #558b2f
}

@keyframes bounce {
    50% {
        transform: translateY(-9px)
    }
}

@keyframes pulse {
    50% {
        transform: scale(1.05)
    }
}

.game-screen {
    background:
        linear-gradient(to bottom,
            #82d8f5 0 43%,
            #2eb6df 43% 55%,
            #168fca 55% 68%,
            #f7dc96 68% 100%)
}

.game-screen::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: 48%;
    left: 0;
    width: 100%;
    height: 18px;
    background: repeating-radial-gradient(ellipse at 50% 100%, #ffffffb8 0 3px, transparent 4px 18px);
    pointer-events: none
}
.round-progress {
    position: absolute;
    z-index: 20;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 7px
}

.round-dot {
    width: 15px;
    height: 15px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #90a4ae;
    box-shadow: 0 2px 3px #0003
}

.round-dot.done {
    background: #ffca28
}

.track-wrap {
    position: absolute;
    top: 120px;
    inset-inline: 0;
    z-index: 5;
    display: flex;
    justify-content: center
}

.track {
    position: relative;
    width: 78%;
    max-width: 620px;
    height: 34px;
    border: 4px solid #37474f;
    border-radius: 20px;
    background: linear-gradient(#fff, #dfe9f2);
    box-shadow: inset 0 3px 6px #0003
}

.target-zone {
    position: absolute;
    inset: 0 0 0 auto;
    width: 20%;
    border-radius: 0 14px 14px 0;
    background: repeating-linear-gradient(45deg, #ffca28 0 8px, #ff7043 8px 16px)
}

.marker {
    position: absolute;
    top: 2px;
    left: 0;
    width: 30px;
    height: 26px;
    border: 3px solid #e65100;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff, #ffd54f 60%, #ff9800)
}

.callout-wrap {
    position: absolute;
    left: 78%;
    bottom: 100%;
    width: 22%;
    display: flex;
    justify-content: center
}

.callout {
    position: relative;
    z-index: 2;
    margin-bottom: 9px;
    padding: 5px 9px;
    border: 3px solid #ff7043;
    border-radius: 14px;
    background: #fff;
    color: #d84315;
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
    animation: bob 1.1s infinite
}

.callout-tail {
    position: absolute;
    z-index: -1;
    bottom: -9px;
    left: 50%;
    width: 14px;
    height: 14px;
    background: #fff;
    border-right: 3px solid #ff7043;
    border-bottom: 3px solid #ff7043;
    transform: translateX(-50%) rotate(45deg)
}

@keyframes bob {
    50% {
        transform: translateY(-4px)
    }
}

.play-field {
    position: relative;
    width: 100%;
    height: 100%
}

.hit-layer {
    position: absolute;
    inset: 0;
    z-index: 12;
    cursor: pointer;
    touch-action: none
}

.stick {
    position: absolute;
    z-index: 15;
    top: 126px;
    left: 50%;
    width: 18px;
    height: 112px;
    border: 3px solid #6d3f20;
    border-radius: 10px;
    background: linear-gradient(90deg, #8d552f, #d19a5b 42%, #a86635 70%, #70401f);
    box-shadow: inset 3px 0 #ffffff3d, 2px 3px 5px #0004;
    transform: translateX(-50%) rotate(-48deg);
    transform-origin: 50% 90%;
    pointer-events: none
}

.stick.swing {
    animation: swing .32s
}

@keyframes swing {
    45% {
        transform: translate(-50%, 10px) rotate(38deg)
    }

    75% {
        transform: translateX(-50%) rotate(-58deg)
    }
}

.melon-whole,
.melon-split {
    position: absolute;
    z-index: 10;
    top: 305px;
    left: 50%;
    width: 240px;
    height: 240px;
    transform: translate(-50%, -50%)
}

.melon-whole.shake {
    animation: shake .4s
}

@keyframes shake {
    20% {
        transform: translate(-56%, -50%) rotate(-6deg)
    }

    40% {
        transform: translate(-44%, -50%) rotate(6deg)
    }

    60% {
        transform: translate(-54%, -50%) rotate(-4deg)
    }

    80% {
        transform: translate(-46%, -50%) rotate(4deg)
    }
}

.crack-svg {
    position: absolute;
    inset: 0;
    opacity: 0
}

.crack-svg.show {
    opacity: 1
}

.melon-split {
    display: flex
}

.half {
    width: 120px;
    height: 240px;
    opacity: 0;
    transition: transform .85s, opacity .85s
}

.half-right svg {
    transform: scaleX(-1)
}

.melon-split.open .half {
    opacity: 1
}

.melon-split.open .half-left {
    transform: translate(-55px, 55px) rotate(-25deg)
}

.melon-split.open .half-right {
    transform: translate(55px, 55px) rotate(25deg)
}

.chip {
    position: absolute;
    z-index: 9;
    top: 305px;
    left: 50%;
    width: 16px;
    height: 16px;
    border-radius: 40% 60%;
    background: #4caf50
}

.feedback {
    position: absolute;
    z-index: 25;
    top: 185px;
    left: 50%;
    opacity: 0;
    transform: translate(-50%, -50%) scale(.3);
    font-size: 38px;
    font-weight: 900;
    white-space: nowrap;
    text-shadow: 0 3px #fff
}

.feedback.good {
    color: #ff5722
}

.feedback.bad {
    color: #5d4037
}

.feedback.show {
    animation: pop .9s forwards
}

.game-top {
    position: relative;
    z-index: 31
}

.level-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 8px auto 2px;
    padding: 6px 10px;
    width: fit-content;
    border-radius: 18px;
    background: #ffffffd9;
    box-shadow: 0 2px 7px #0002
}

.level-label {
    color: #2e7d32;
    font-size: 15px;
    font-weight: 900
}

.level-btn {
    border: 2px solid #66bb6a;
    border-radius: 16px;
    padding: 5px 11px;
    background: #fff;
    color: #2e7d32;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer
}

.level-btn.selected {
    border-color: #ef6c00;
    background: #ff9800;
    color: #fff;
    box-shadow: 0 3px #e65100
}

.current-level {
    position: absolute;
    top: 34px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 6px 18px;
    width: 180px;
    text-align: center;
    white-space: nowrap;
    border-radius: 18px;
    background: #ffffffd9;
    color: #2e7d32;
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 2px 7px #0002
}

.current-level strong {
    color: #ef6c00
}
@keyframes pop {
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2)
    }

    80% {
        opacity: 1;
        transform: translate(-50%, -60%)
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -90%)
    }
}

.confetti-layer {
    position: absolute;
    inset: 0;
    z-index: 30;
    pointer-events: none
}

.confetti {
    position: absolute;
    top: 225px;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    animation: fly .9s forwards
}

@keyframes fly {
    to {
        transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
        opacity: 0
    }
}


.result-screen h2 {
    z-index: 1;
    margin: 0;
    color: #d84315;
    font-size: 44px;
    text-shadow: 0 3px #fff
}

.result-melon {
    z-index: 1;
    margin: 8px;
    font-size: 100px;
    animation: bounce 1.4s infinite
}

.result-screen p {
    z-index: 1;
    margin: 0 0 19px;
    padding: 8px 24px;
    border-radius: 22px;
    background: #ffffffcc;
    color: #1b5e20;
    font-size: 25px;
    font-weight: 900
}

.result-screen .best-score {
    margin-top: -12px;
    padding: 5px 18px;
    font-size: 18px
}

.new-record {
    position: absolute;
    z-index: 20;
    top: 88px;
    left: 50%;
    opacity: 0;
    padding: 10px 22px;
    border: 3px solid #ff9800;
    border-radius: 24px;
    background: #fff8d5;
    color: #e65100;
    font-size: 25px;
    font-weight: 900;
    white-space: nowrap;
    pointer-events: none;
    transform: translateX(-50%) scale(.3)
}

.new-record.show {
    animation: new-record-pop 1.8s both
}

@keyframes new-record-pop {
    20%, 75% {
        opacity: 1;
        transform: translateX(-50%) scale(1.08) rotate(-2deg)
    }

    40%, 65% {
        opacity: 1;
        transform: translateX(-50%) scale(1) rotate(2deg)
    }

    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1)
    }
}
.result-actions {
    z-index: 1;
    display: flex;
    gap: 16px
}

.play-btn.small,
.back-btn {
    padding: 12px 30px;
    font-size: 21px;
    animation: none
}

.back-btn {
    background: #42a5f5;
    box-shadow: 0 7px #1565c0
}

@media(max-width:600px) {
    .container {
        border-radius: 0
    }

    .header-title {
        font-size: 15px;
        letter-spacing: 0
    }

    .header-score,
    .header-btn {
        padding: 6px 8px;
        font-size: 13px
    }

    .sound-btn {
        min-width: 56px
    }

    .round-progress {
        gap: 4px
    }

    .round-dot {
        width: 12px;
        height: 12px;
        border-width: 2px
    }

    .result-actions {
        flex-direction: column;
        gap: 12px
    }
}
