/* ============ 基础重置 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #2b3a1f;
    color: #fff;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.hidden { display: none !important; }

/* ============ 全屏层 ============ */
.screen { position: absolute; inset: 0; }

.overlay {
    background: radial-gradient(ellipse at center, #3a5a2a 0%, #1c2b14 80%);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 18px; text-align: center; padding: 24px; z-index: 50;
}

.game-title {
    font-size: clamp(36px, 8vw, 72px);
    color: #ffe94a;
    text-shadow: 3px 3px 0 #b8860b, 6px 6px 12px rgba(0,0,0,.5);
    letter-spacing: 4px;
}

.subtitle { font-size: 16px; color: #d9e7c5; opacity: .9; }

.big-btn {
    padding: 14px 42px;
    font-size: 20px; font-weight: bold;
    color: #3a2b00;
    background: linear-gradient(#ffe94a, #f5c518);
    border: 3px solid #7a5a00;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 6px 0 #7a5a00, 0 10px 20px rgba(0,0,0,.35);
    transition: transform .08s, box-shadow .08s;
}
.big-btn:hover { filter: brightness(1.05); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a5a00; }

.big-btn.danger { background: linear-gradient(#ff9d6b, #e0532f); border-color: #7a1f00; color: #fff; box-shadow: 0 6px 0 #7a1f00, 0 10px 20px rgba(0,0,0,.35); }

.tips {
    margin-top: 8px; font-size: 14px; line-height: 1.9; color: #cfe0b8;
    background: rgba(0,0,0,.25); padding: 12px 22px; border-radius: 12px;
}

/* 制作人署名 */
.credit {
    margin-top: 10px;
    font-size: 14px;
    color: #cfe0b8;
    opacity: .85;
    letter-spacing: 1px;
}


.result-title { font-size: clamp(30px, 6vw, 54px); }
.result-title.win { color: #ffe94a; text-shadow: 2px 2px 0 #b8860b; }
.result-title.lose { color: #ff7b6b; text-shadow: 2px 2px 0 #5a1f00; }

/* ============ HUD ============ */
#game-screen { display: flex; flex-direction: column; background: linear-gradient(#87c94a 0%, #5a9e3a 60%, #3d7a2a 100%); }

#hud {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    background: linear-gradient(#5c4326, #3e2b17);
    border-bottom: 3px solid #2a1d0f;
    box-shadow: 0 4px 10px rgba(0,0,0,.3);
    z-index: 10; flex-wrap: wrap;
}

#seed-bar { display: flex; gap: 8px; flex: 1; min-width: 260px; }

.seed-card {
    width: 58px; height: 74px;
    background: linear-gradient(#f5e9c8, #d9c39a);
    border: 2px solid #6b4e1f;
    border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,.15);
    transition: transform .1s;
}
.seed-card:hover { transform: translateY(-2px); }
.seed-card.selected { outline: 3px solid #ffe94a; transform: translateY(-4px); box-shadow: 0 6px 14px rgba(255,233,74,.5); }
.seed-card.disabled { filter: grayscale(.8) brightness(.7); cursor: not-allowed; }

.seed-icon { font-size: 30px; line-height: 1; }
.seed-cost { font-size: 12px; color: #6b4e1f; font-weight: bold; margin-top: 2px; }
.seed-name { font-size: 10px; color: #5a4326; }

.cd-mask {
    position: absolute; inset: 0; background: rgba(0,0,0,.55);
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: bold; color: #fff; pointer-events: none;
}

#sun-counter {
    display: flex; align-items: center; gap: 6px;
    background: rgba(0,0,0,.3); padding: 6px 14px; border-radius: 20px;
    font-size: 20px; font-weight: bold; color: #ffe94a;
}
.sun-icon { font-size: 24px; }

#btn-shovel {
    width: 58px; height: 74px;
    background: linear-gradient(#cfcfcf, #8a8a8a);
    border: 2px solid #3a3a3a; border-radius: 8px;
    font-size: 30px; cursor: pointer;
}
#btn-shovel.selected { outline: 3px solid #ff5b4a; }

/* ============ 触屏适配 ============ */
@media (hover: none) and (pointer: coarse) {
    .seed-card, #btn-shovel { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
    .big-btn, .mini-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
}

/* ============ 动画增强 ============ */
@keyframes pulseSun {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}
#sun-counter { animation: pulseSun 2s ease-in-out infinite; }

/* ============ 关卡选择 ============ */
#level-list { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; max-width: 380px; overflow-y: auto; max-height: 55vh; padding: 4px; }
.level-btn { text-align: left !important; padding: 12px 24px !important; font-size: 15px !important; line-height: 1.6; white-space: normal; }

/* ============ 帮助界面 ============ */
.help-tips { text-align: left; max-width: 560px; width: 92%; line-height: 1.8; font-size: 14px; overflow-y: auto; max-height: 72vh; }
.help-tips hr { border: none; border-top: 1px solid rgba(255,255,255,.2); margin: 10px 0; }
.help-btn { background: transparent; color: #ffe94a; border: 2px solid #ffe94a; padding: 8px 20px; font-size: 16px; }

/* ============ 键盘焦点可见性（无障碍）============ */
.big-btn:focus-visible, .mini-btn:focus-visible, .seed-card:focus-visible {
    outline: 3px solid #ffe94a; outline-offset: 2px;
}

/* ============ 滚动条隐藏（移动端）============ */
::-webkit-scrollbar { display: none; }

/* ============ 草坪区 ============ */
#lawn-wrap { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }

#game-canvas {
    width: 100%; height: 100%;
    display: block; touch-action: none; cursor: crosshair;
}

/* ============ 飘字层 ============ */
#fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }

.float-text {
    position: absolute; font-weight: bold; font-size: 18px;
    color: #ffe94a; text-shadow: 1px 1px 2px rgba(0,0,0,.6);
    animation: floatUp .9s ease-out forwards; pointer-events: none;
}
@keyframes floatUp {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-40px) scale(1.3); }
}

/* ============ 底部状态栏 ============ */
#status-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 14px; background: rgba(0,0,0,.35); font-size: 14px;
}

.mini-btn {
    padding: 4px 14px; border-radius: 8px; border: none;
    background: #ffe94a; color: #3a2b00; font-weight: bold; cursor: pointer;
}
.mini-btn:active { transform: translateY(1px); }

/* ============ 响应式 ============ */
@media (max-width: 600px) {
    .seed-card { width: 44px; height: 58px; }
    .seed-icon { font-size: 22px; }
    .seed-cost { font-size: 10px; }
    .seed-name { display: none; }
    #btn-shovel { width: 44px; height: 58px; font-size: 22px; }
}

@media (max-width: 400px) {
    .seed-card { width: 38px; height: 52px; }
    .seed-icon { font-size: 18px; }
    #btn-shovel { width: 38px; height: 52px; font-size: 18px; }
}

/* ============ 高对比度 / 无障碍 ============ */
@media (prefers-contrast: high) {
    .seed-card, #btn-shovel { border-width: 3px; }
    .big-btn { border-width: 4px; text-shadow: none; }
}

/* ============ 减少动画偏好 ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============ 深色模式适配（可选）============ */
@media (prefers-color-scheme: dark) {
    .overlay { background: radial-gradient(ellipse at center, #2a3d1f 0%, #0f1a08 80%); }
    .tips { background: rgba(0,0,0,.45); color: #e0ecd8; }
}

/* ================= 手机端 / 横屏优化 ================= */
/* iOS 安全区（刘海屏） */
@supports (padding: env(safe-area-inset-top)) {
    #hud { padding-top: max(8px, env(safe-area-inset-top)); }
    #hud { padding-left: max(12px, env(safe-area-inset-left)); }
    #hud { padding-right: max(12px, env(safe-area-inset-right)); }
    #status-bar { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
    #status-bar { padding-left: max(14px, env(safe-area-inset-left)); }
    #status-bar { padding-right: max(14px, env(safe-area-inset-right)); }
}

/* 触屏设备：双击/长按不缩放、不选中 */
@media (hover: none) and (pointer: coarse) {
    canvas, .seed-card, #btn-shovel, .big-btn, .mini-btn, #btn-music, #btn-pause {
        -webkit-touch-callout: none;
        touch-action: manipulation;
    }
    #game-canvas { touch-action: none; }
}

/* 移动端横屏：HUD 单行、种子卡可横向滚动，给草坪让出最大高度 */
@media (orientation: landscape) and (max-height: 520px) {
    #hud { flex-wrap: nowrap; padding: 4px 8px; gap: 6px; }
    #seed-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px;
        min-width: 0;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #seed-bar::-webkit-scrollbar { display: none; }
    .seed-card { width: 44px; height: 56px; flex-shrink: 0; }
    .seed-icon { font-size: 22px; }
    .seed-cost { font-size: 10px; }
    .seed-name { font-size: 9px; }
    #btn-shovel { width: 44px; height: 56px; font-size: 22px; flex-shrink: 0; }
    #sun-counter { padding: 4px 10px; font-size: 16px; }
    .sun-icon { font-size: 20px; }
    #status-bar { padding: 3px 8px; font-size: 12px; }
    .mini-btn { padding: 3px 10px; font-size: 13px; }
    .help-btn { padding: 4px 12px; font-size: 14px; }
    #lawn-wrap { min-height: 0; }
}

/*======= 旋转提示遮罩 =======*/
.rotate-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; text-align: center;
    background: rgba(15,26,8,.96);
    padding: 24px;
}
.rotate-phone {
    font-size: 64px;
    animation: rotateHint 1.6s ease-in-out infinite;
}
.rotate-overlay p { font-size: 18px; color: #e0ecd8; }
.rotate-overlay p:first-of-type { font-size: 22px; font-weight: bold; color: #ffe94a; }
.rotate-overlay .big-btn { margin-top: 12px; }
@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50%      { transform: rotate(-90deg); }
}

/* ================= 多端断点优化补充 ================= */
/* 超窄手机（<360），最小卡片保证可点 */
@media (max-width: 359px) {
    .seed-card { width: 34px; height: 48px; }
    .seed-icon { font-size: 16px; }
    .seed-cost { font-size: 9px; }
    .seed-name { font-size: 8px; }
    #btn-shovel { width: 34px; height: 48px; font-size: 16px; }
    #sun-counter { padding: 3px 8px; font-size: 14px; }
    .sun-icon { font-size: 16px; }
}

/* 平板竖屏：更宽敞的种子卡 + 居中更大草坪 */
@media (min-width: 768px) and (orientation: portrait) {
    .seed-card { width: 64px; height: 82px; }
    .seed-icon { font-size: 34px; }
    .seed-cost { font-size: 13px; }
    .seed-name { font-size: 12px; }
    #btn-shovel { width: 64px; height: 82px; font-size: 34px; }
    #sun-counter { font-size: 24px; }
    .sun-icon { font-size: 28px; }
}

/* 平板横屏 / 桌面（宽>1024）：种子卡更大，操作区舒适 */
@media (min-width: 1025px) {
    .seed-card { width: 68px; height: 88px; }
    .seed-icon { font-size: 36px; }
    .seed-cost { font-size: 14px; }
    .seed-name { font-size: 12px; }
    #btn-shovel { width: 68px; height: 88px; font-size: 36px; }
    #sun-counter { font-size: 26px; }
    .sun-icon { font-size: 30px; }
    #status-bar { padding: 10px 20px; font-size: 16px; }
    .mini-btn { padding: 6px 18px; font-size: 16px; }
    .help-btn { padding: 10px 24px; font-size: 18px; }
    .big-btn { padding: 16px 52px; font-size: 24px; }
}

/* 触屏点按视觉反馈（无 hover 的平板/手机） */
@media (hover: none) and (pointer: coarse) {
    .seed-card:active, #btn-shovel:active {
        transform: translateY(2px) scale(.97);
        box-shadow: inset 0 -3px 0 rgba(0,0,0,.2);
    }
    .big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #7a5a00; }
}

/* 横屏且高度很矮的手机（如 320 高）：极致压缩 HUD 给草坪 */
@media (orientation: landscape) and (max-height: 360px) {
    #hud { padding: 2px 6px; gap: 4px; }
    .seed-card { width: 38px; height: 46px; }
    .seed-icon { font-size: 18px; }
    .seed-cost { font-size: 8px; }
    .seed-name { font-size: 8px; }
    #btn-shovel { width: 38px; height: 46px; font-size: 18px; }
    #status-bar { padding: 2px 6px; font-size: 11px; }
    .mini-btn { padding: 2px 8px; font-size: 12px; }
}

/* 防止游戏运行时页面被拖拽露出背景（iOS） */
#game-screen, #start-screen, #level-screen {
    touch-action: none;
}

/* ================= \u690d\u7269\u9009\u62e9\u754c\u9762 ================= */
#plant-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 700px;
    max-height: 52vh;
    overflow-y: auto;
    padding: 6px;
}
.pick-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 10px 6px;
    background: linear-gradient(#f5e9c8, #d9c39a);
    border: 3px solid #6b4e1f; border-radius: 10px;
    cursor: pointer; position: relative;
    min-height: 88px;
    transition: transform .08s, border-color .08s, box-shadow .08s;
    box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
    touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.pick-card:active { transform: scale(.96); }
.pick-card .pick-icon { font-size: 30px; line-height: 1; }
.pick-card .pick-name { font-size: 12px; font-weight: bold; color: #3a2b00; text-shadow: none; }
.pick-card .pick-cost { font-size: 11px; color: #6b4e1f; font-weight: bold; }
.pick-card.picked {
    border-color: #2e9e2e;
    background: linear-gradient(#c9f2c0, #9edc94);
    box-shadow: 0 0 0 3px rgba(46,158,46,.35), inset 0 -3px 0 rgba(0,0,0,.08);
}
.pick-card.picked::after {
    content: "\\2713"; position: absolute; top: 2px; right: 6px;
    color: #fff; font-weight: bold; font-size: 16px;
    background: #2e9e2e; border-radius: 50%; width: 20px; height: 20px;
    line-height: 20px; text-align: center;
}
.picker-actions {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
    margin-top: 8px;
}
.picker-actions .big-btn { padding: 12px 30px; font-size: 18px; }
#picker-count.warn { color: #ff5b4a; font-weight: bold; }
#picker-count { transition: color .2s; }

/* \u7ad6\u5c4f\u624b\u673a\uff1a\u7f29\u5c0f\u5361\u7247\u3001\u4e09\u5217 */
@media (orientation: portrait) and (max-width: 480px) {
    #plant-picker-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 52vh; }
    .pick-card { min-height: 74px; padding: 6px 2px; }
    .pick-card .pick-icon { font-size: 24px; }
    .pick-card .pick-name { font-size: 10px; }
    .pick-card .pick-cost { font-size: 9px; }
    .picker-actions .big-btn { padding: 10px 22px; font-size: 16px; }
    .picker-actions .mini-btn { padding: 6px 10px; font-size: 13px; }
}
/* \u5c0f\u5c4f\u7ad6\u5c4f\uff08\u6781\u7a84\uff09 */
@media (orientation: portrait) and (max-width: 340px) {
    #plant-picker-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
    .pick-card { min-height: 64px; }
    .pick-card .pick-icon { font-size: 20px; }
}


/* ===== emoji 字体栈（确保植物图标不乱码/不成方块）===== */
.seed-icon, .pick-icon, #btn-shovel, .sun-icon {
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", "EmojiOne Color", sans-serif;
    letter-spacing: 0;
}
h1.game-title, .result-title { letter-spacing: 3px; }
/* ICP footer */
#beian-footer{position:fixed;left:0;right:0;bottom:0;text-align:center;font-size:12px;line-height:1.4;padding:2px 8px;background:rgba(0,0,0,.35);color:rgba(255,255,255,.7);z-index:999;pointer-events:auto;}
#beian-footer a{color:rgba(255,255,255,.7);text-decoration:none;}