* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
}

body {
    align-items: center;
    background: rgb(244, 246, 241);
    color: rgb(24, 32, 28);
    display: flex;
    font-family: "Georgia", "Noto Serif SC", "STSong", "Songti SC", "SimSun", "KaiTi", "楷体", serif;
    justify-content: center;
    margin: 0px;
    min-height: 100%;
    overflow: hidden;
    user-select: none;
}

.page-shell {
    max-width: 960px;
    width: min(960px, -24px + 100vw);
}

.game-shell {
    background: rgb(255, 253, 246);
    border: 2px solid rgb(40, 52, 45);
    border-radius: 8px;
    box-shadow: rgba(32, 42, 35, 0.16) 0px 18px 48px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.hud {
    align-items: center;
    background: rgb(255, 255, 255);
    border-bottom: 2px solid rgb(40, 52, 45);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 56px;
    padding: 10px 16px;
}

.hud strong {
    display: block;
    font-size: 18px;
    line-height: 1.2;
}

.hud span {
    color: rgb(94, 102, 93);
    display: block;
    font-size: 13px;
    line-height: 1.4;
}

.scoreboard {
    color: rgb(27, 47, 37);
    display: flex;
    flex-wrap: wrap;
    font-family: "Courier New", monospace;
    font-size: 18px;
    font-weight: 700;
    gap: 14px;
    justify-content: flex-end;
    min-width: 170px;
    text-align: right;
}

canvas {
    aspect-ratio: 8 / 3;
    background: rgb(247, 251, 255);
    display: block;
    height: auto;
    touch-action: manipulation;
    width: 100%;
}

.mobile-controls {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
    touch-action: none;
    user-select: none;
}

.control-button {
    border-radius: 12px;
    border: 2px solid rgb(22, 56, 38);
    color: rgb(255, 255, 255);
    font-size: 20px;
    font-weight: 700;
    min-height: 58px;
    min-width: 0px;
    padding: 0px 12px;
    touch-action: none;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.05s ease-out, filter 0.1s ease-out;
    box-shadow: 0 4px 0 rgba(22, 56, 38, 0.4);
}

.control-button:active {
    transform: translateY(2px) scale(0.98);
    filter: brightness(0.9);
    box-shadow: 0 2px 0 rgba(22, 56, 38, 0.4);
}

.jump-button {
    background: rgb(31, 111, 74);
}

.duck-button {
    background: rgb(69, 83, 74);
    border-color: rgb(40, 50, 45);
    box-shadow: 0 4px 0 rgba(40, 50, 45, 0.4);
}

.duck-button:active {
    box-shadow: 0 2px 0 rgba(40, 50, 45, 0.4);
}

.overlay {
    align-items: center;
    background: rgba(255, 253, 246, 0.88);
    display: flex;
    flex-direction: column;
    inset: 56px 0px 0px;
    justify-content: center;
    padding: 24px;
    position: absolute;
    text-align: center;
}

.overlay.hidden {
    display: none;
}

.footer-link {
    margin: 16px 0px 0px;
    text-align: center;
}

.footer-link a {
    color: rgb(77, 85, 77);
    font-size: 18px;
    text-decoration: underline;
}

.footer-link a:hover {
    color: rgb(31, 111, 74);
}

.overlay h1 {
    font-size: clamp(30px, 7vw, 64px);
    letter-spacing: 0px;
    line-height: 1;
    margin: 0px 0px 12px;
}

.overlay p {
    color: rgb(77, 85, 77);
    font-size: clamp(14px, 2.5vw, 18px);
    line-height: 1.6;
    margin: 0px 0px 18px;
    max-width: 520px;
}

button {
    background: rgb(31, 111, 74);
    border: 2px solid rgb(22, 56, 38);
    border-radius: 6px;
    color: rgb(255, 255, 255);
    cursor: pointer;
    font: 700 18px / 1 "Georgia", "Noto Serif SC", "STSong", "Songti SC", "SimSun", "KaiTi", "楷体", serif;
    min-height: 44px;
    min-width: 112px;
    padding: 0px 22px;
}

button:active {
    transform: translateY(1px);
}

@media (max-width: 768px) {
    .hud strong {
        font-size: 16px;
    }

    .hud span {
        font-size: 12px;
    }

    .scoreboard {
        font-size: 16px;
        gap: 10px;
        min-width: 140px;
    }
}

@media (max-width: 560px) {
    body {
        align-items: flex-start;
        padding-top: 8px;
    }

    .hud {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
        min-height: auto;
        padding: 10px 12px;
    }

    .hud > div:first-child {
        width: 100%;
    }

    .hud strong {
        font-size: 15px;
    }

    .hud span {
        font-size: 12px;
    }

    .scoreboard {
        align-self: flex-end;
        font-size: 15px;
        gap: 8px;
        min-width: auto;
    }

    .overlay {
        inset: 0;
    }

    .page-shell {
        display: flex;
        flex-direction: column;
        min-height: calc(-8px + 100vh);
        width: min(960px, -12px + 100vw);
    }

    .game-shell {
        flex-shrink: 0;
    }

    .mobile-controls {
        flex: 1 1 0%;
        align-content: center;
        gap: 12px;
        padding: 8px 10px 16px;
    }

    .control-button {
        font-size: 22px;
        min-height: 80px;
        font-weight: 700;
    }

    .footer-link {
        font-size: 14px;
        margin: 8px 0 0;
    }

    .footer-link a {
        font-size: 14px;
    }
}

@media (max-width: 380px) {
    .hud {
        padding: 8px 10px;
    }

    .hud strong {
        font-size: 14px;
    }

    .hud span {
        font-size: 11px;
    }

    .scoreboard {
        font-size: 14px;
        gap: 6px;
    }

    .control-button {
        font-size: 20px;
        min-height: 70px;
    }

    .overlay h1 {
        font-size: 28px;
    }

    .overlay p {
        font-size: 13px;
    }
}

@media (max-height: 600px) and (max-width: 768px) {
    .mobile-controls {
        padding: 4px 10px 10px;
    }

    .control-button {
        min-height: 60px;
        font-size: 18px;
    }

    .hud {
        min-height: auto;
        padding: 6px 10px;
    }
}
