/* ---- 彩蛋：咕咕嘎嘎飞行 ----
   舞台固定铺满视口；桌面端中间是一块带圆角的棋盘，左右留出纸色空白，
   手机端直接铺满。棋盘里的所有图形都由 js/flappy.js 画在 canvas 上。 */

.egg-stage {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    background: var(--bg);
    overscroll-behavior: none;
}

/* 彩蛋开着时锁住底下的页面：只盖一层视觉不够，手指滑动照样会推动文档。 */
html.egg-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.egg-game {
    --egg-sky-top: #f6f0e3;
    --egg-sky-bottom: #dce8e4;
    --egg-orb: #fff8df;
    --egg-hill-far: #d3dfd8;
    --egg-hill-near: #b8cec4;
    --egg-snow: #ddcfb4;
    --egg-snow-shadow: #ab987a;
    --egg-snow-highlight: #fbf7ec;
    --egg-snow-cap: #fbf7ec;
    --egg-flake: #fffdf8;
    --egg-stone-light: #b9b0a2;
    --egg-stone: #948b7e;
    --egg-stone-dark: #6c655b;
    --egg-ice-light: #e6f6f8;
    --egg-ice: #b8dfe6;
    --egg-ice-dark: #79b4c0;
    --egg-ink: #2b2721;
    --egg-bird-body: #2b2721;
    --egg-bird-belly: #fffdf8;
    --egg-bird-wing: #2b2721;
    --egg-bird-rim: transparent;
    --egg-accent: #c8452c;
    --egg-panel: rgba(255, 253, 248, 0.92);
    --egg-panel-line: rgba(43, 39, 33, 0.12);
    --egg-scrim: rgba(255, 253, 248, 0.18);
    --egg-hud-shadow: 0 1px 0 rgba(255, 253, 248, 0.65);

    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--egg-sky-bottom);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@media (prefers-color-scheme: dark) {
    .egg-game {
        --egg-sky-top: #1c2527;
        --egg-sky-bottom: #101719;
        --egg-orb: #efe4c2;
        --egg-hill-far: #243133;
        --egg-hill-near: #1a2426;
        --egg-snow: #202a2b;
        --egg-snow-shadow: #11191a;
        --egg-snow-highlight: #4a5a56;
        --egg-snow-cap: #e9e1d3;
        --egg-flake: #d8d0c0;
        --egg-stone-light: #a99c8a;
        --egg-stone: #83766a;
        --egg-stone-dark: #5c5146;
        --egg-ice-light: #c7ecf1;
        --egg-ice: #79b9c5;
        --egg-ice-dark: #427f8c;
        --egg-ink: #ece5d8;
        --egg-bird-body: #17130f;
        --egg-bird-belly: #f4efe3;
        --egg-bird-wing: #1b1713;
        --egg-bird-rim: rgba(255, 253, 248, 0.24);
        --egg-accent: #e0664e;
        --egg-panel: rgba(36, 31, 27, 0.94);
        --egg-panel-line: rgba(236, 229, 216, 0.14);
        --egg-scrim: rgba(0, 0, 0, 0.28);
        --egg-hud-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    }
}

.egg-game:focus {
    outline: none;
}

.egg-game:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.egg-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 桌面：不再是 420×720 的小竖条。高度吃满视口，左右留白由舞台承担。 */
@media (min-width: 720px) {
    .egg-stage {
        padding: 48px;
    }

    .egg-game {
        width: clamp(560px, 80vw, 1240px);
        height: min(calc(100vh - 96px), 880px);
        height: min(calc(100dvh - 96px), 880px);
        border-radius: 18px;
        box-shadow: var(--shadow);
    }
}

/* ---- 分数 ---- */
.egg-hud {
    position: absolute;
    inset: 0 0 auto;
    z-index: 2;
    padding: 18px 20px;
    text-align: center;
    pointer-events: none;
}

.egg-hud[hidden] {
    display: none;
}

.egg-hud-score {
    font-family: "Instrument Serif", var(--ui);
    font-size: clamp(34px, 6vmin, 56px);
    font-weight: 400;
    line-height: 1;
    color: var(--egg-ink);
    text-shadow: var(--egg-hud-shadow);
}

.egg-hud-best {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--egg-ink);
    opacity: 0.55;
    text-shadow: var(--egg-hud-shadow);
}

/* ---- 开始 / 结束 / 暂停 ---- */
.egg-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--egg-scrim);
    pointer-events: none;
}

.egg-overlay[hidden] {
    display: none;
}

.egg-panel {
    width: min(320px, 100%);
    padding: 28px 26px 24px;
    border: 1px solid var(--egg-panel-line);
    border-radius: 16px;
    background: var(--egg-panel);
    box-shadow: var(--shadow);
    text-align: center;
    pointer-events: none;
    animation: egg-panel-in 0.24s var(--ease);
}

.egg-kicker {
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--egg-accent);
}

.egg-title {
    font-family: "Instrument Serif", var(--ui);
    font-size: 30px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--egg-ink);
}

.egg-hint {
    margin-top: 12px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--egg-ink);
    opacity: 0.62;
}

.egg-best {
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--egg-ink);
    opacity: 0.58;
}

.egg-best strong,
.egg-result strong {
    font-family: "Instrument Serif", var(--ui);
    font-size: 24px;
    font-weight: 400;
}

.egg-result {
    margin-top: 14px;
    font-size: 14px;
    color: var(--egg-ink);
    opacity: 0.72;
}

.egg-result strong {
    margin-left: 4px;
    font-size: 32px;
}

.egg-reason {
    margin-top: 6px;
    font-size: 13px;
    color: var(--egg-ink);
    opacity: 0.55;
}

.egg-record {
    margin-top: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--egg-accent);
}

/* 按钮是这张面板上唯一接收指针事件的元素；点面板空白处等于点画面，开始/重开。 */
.egg-button {
    display: inline-block;
    min-height: 42px;
    margin-top: 18px;
    padding: 9px 24px;
    border: 0;
    border-radius: 999px;
    background: var(--egg-accent);
    color: #fff;
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.egg-button:hover,
.egg-button:focus-visible {
    transform: scale(1.06);
}

.egg-button:active {
    transform: scale(0.94);
    transition-duration: 0.11s;
}

@keyframes egg-panel-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ---- 左上角退出 / 右上角音效 ---- */
.egg-close,
.egg-sound {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(36, 31, 26, 0.08);
    color: var(--ink);
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.25s var(--ease);
}

.egg-close {
    left: max(14px, env(safe-area-inset-left));
}

.egg-sound {
    right: max(14px, env(safe-area-inset-right));
}

.egg-close:hover,
.egg-close:active,
.egg-sound:hover,
.egg-sound:active {
    background: rgba(36, 31, 26, 0.16);
    /* 小圆钮用自己的幅度：横移小、转角大，才像在晃而不是在滑 */
    --jx: 2px;
    --jr: 6deg;
    animation: jolt 0.36s var(--ease);
}

@media (prefers-color-scheme: dark) {
    .egg-close,
    .egg-sound {
        background: rgba(236, 229, 216, 0.1);
    }

    .egg-close:hover,
    .egg-close:active,
    .egg-sound:hover,
    .egg-sound:active {
        background: rgba(236, 229, 216, 0.18);
    }
}

.egg-close svg,
.egg-sound svg {
    display: block;
    width: 18px;
    height: 18px;
}

.egg-sound-off {
    display: none;
}

.egg-sound.is-muted .egg-sound-wave {
    display: none;
}

.egg-sound.is-muted .egg-sound-off {
    display: block;
}

/* ---- 触摸屏 ---- */
@media (pointer: coarse) {
    .egg-close,
    .egg-sound {
        width: 44px;
        height: 44px;
    }

    .egg-close svg,
    .egg-sound svg {
        width: 20px;
        height: 20px;
    }

    .egg-button {
        min-height: 44px;
    }

    /* 触摸端点完按钮后 :hover 会粘住，别让它一直大 6%。 */
    .egg-button:hover,
    .egg-button:focus-visible {
        transform: none;
    }

    .egg-close:hover,
    .egg-sound:hover {
        animation: none;
    }
}

/* ---- 小屏 ---- */
@media (max-width: 719px) {
    .egg-panel {
        padding: 24px 20px 20px;
    }

    .egg-title {
        font-size: 28px;
    }
}

/* ---- 减少动态效果 ----
   游戏本身没法不动，但面板入场、按钮弹跳和飘雪都可以省掉。 */
@media (prefers-reduced-motion: reduce) {
    .egg-panel {
        animation: none;
    }

    .egg-button,
    .egg-close,
    .egg-sound {
        transition: none;
    }

    .egg-button:hover,
    .egg-button:focus-visible,
    .egg-button:active,
    .egg-close:hover,
    .egg-close:active,
    .egg-sound:hover,
    .egg-sound:active {
        transform: none;
        animation: none;
    }
}
