* { margin: 0; padding: 0; box-sizing: border-box; }
  html, body {
    width: 100%; height: 100%;
    background: #1d2b1f;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    overflow: hidden;
  }
  #wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
  canvas {
    background: #8ecf7a; box-shadow: 0 12px 40px rgba(0,0,0,.45); border-radius: 12px;
    width: min(100vw, 177.78vh); height: auto; max-width: 100%; max-height: 100%;
    touch-action: none;
  }
  .overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 20px;
    background: rgba(18, 34, 20, .78); color: #fff; text-align: center; z-index: 10;
  }
  .overlay h1 {
    font-size: clamp(34px, 4.2vmin, 108px); letter-spacing: clamp(2px, .3vmin, 8px);
    margin-bottom: clamp(10px, 1.5vmin, 28px); text-shadow: 0 3px 10px rgba(0,0,0,.5);
  }
  .overlay h2 { font-size: clamp(26px, 3.2vmin, 84px); margin-bottom: clamp(10px, 1.5vmin, 28px); }
  .overlay p {
    font-size: clamp(14px, 1.7vmin, 38px); line-height: 1.9; opacity: .92;
    max-width: clamp(620px, 48vw, 1700px); margin-bottom: clamp(14px, 1.7vmin, 32px);
  }
  .btnrow { display: flex; gap: clamp(10px, 1.5vmin, 30px); flex-wrap: wrap; justify-content: center; }
  .overlay button {
    font-size: clamp(17px, 2.2vmin, 46px); padding: clamp(9px, 1.3vmin, 26px) clamp(24px, 3.4vmin, 64px);
    border: none; border-radius: 999px;
    background: #ffd34d; color: #3a2c00; font-weight: 700; cursor: pointer;
    box-shadow: 0 6px 18px rgba(0,0,0,.35); transition: transform .12s;
  }
  .overlay button.ghost { background: rgba(255,255,255,.18); color: #fff; }
  .overlay button:hover { transform: scale(1.06); }
  .hidden { display: none !important; }
  #stats, #clearStats { font-size: clamp(15px, 1.9vmin, 40px); margin-bottom: clamp(14px, 1.7vmin, 32px); line-height: 1.9; }
  #stats b, #clearStats b { color: #ffd34d; }
  .overlay .hint { font-size: clamp(11px, 1.4vmin, 30px); opacity: .7; margin-top: clamp(12px, 1.5vmin, 30px); margin-bottom: 0; }
  .overlay .story-route { color: #ffd34d; font-size: clamp(13px, 1.6vmin, 34px); letter-spacing: .08em; opacity: .95; }

  /* 永久强化 */
  #upgrade {
    justify-content: flex-start; overflow-y: auto;
    padding: clamp(20px, 2.4vmin, 52px) clamp(16px, 2vw, 44px);
    background: rgba(18, 34, 20, .95);
  }
  #upgrade h1 { font-size: clamp(28px, 3.4vmin, 84px); margin-bottom: clamp(2px, .4vmin, 8px); }
  #upgrade .upgrade-crystals {
    font-size: clamp(14px, 1.7vmin, 34px); opacity: .95;
    margin-bottom: clamp(2px, .4vmin, 8px); max-width: none;
  }
  #upgrade .upgrade-crystals b { color: #ffd34d; font-size: 1.25em; }
  .upgrade-msg {
    min-height: clamp(18px, 2.2vmin, 40px); font-size: clamp(12px, 1.3vmin, 26px);
    color: #ffe9a3; margin-bottom: clamp(4px, .6vmin, 10px);
  }
  .upgrade-list {
    width: 100%; max-width: clamp(760px, 62vw, 1900px);
    display: flex; flex-direction: column; gap: clamp(8px, 1vmin, 18px);
    margin-bottom: clamp(12px, 1.5vmin, 28px);
  }
  .upgrade-row {
    display: flex; align-items: center; gap: clamp(10px, 1.4vmin, 26px);
    padding: clamp(10px, 1.2vmin, 24px) clamp(12px, 1.6vmin, 30px);
    background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13);
    border-radius: clamp(10px, 1.2vmin, 22px); text-align: left;
  }
  .upgrade-info { flex: 1 1 auto; min-width: 0; }
  .upgrade-name { font-size: clamp(15px, 1.6vmin, 34px); font-weight: 700; color: #ffd34d; }
  .upgrade-lv { font-size: clamp(11px, 1.2vmin, 24px); color: #fff; opacity: .75; margin-left: 8px; }
  .upgrade-desc { font-size: clamp(12px, 1.3vmin, 26px); opacity: .8; margin-top: 4px; }
  #upgrade .upgrade-btn {
    flex: 0 0 auto; font-size: clamp(12px, 1.3vmin, 28px);
    padding: clamp(7px, .8vmin, 16px) clamp(12px, 1.5vmin, 30px);
    border-radius: 999px; background: #ffd34d; color: #3a2c00; box-shadow: none;
  }
  #upgrade .upgrade-btn:hover { transform: none; filter: brightness(1.06); }
  #upgrade .upgrade-btn:disabled { background: rgba(255,255,255,.16); color: #999; cursor: not-allowed; filter: none; }
  #upgradeBack { margin-top: clamp(2px, .4vmin, 8px); }
  #shop { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .95); }
  #shop .shop-btn { flex: 0 0 auto; font-size: clamp(13px, 1.5vmin, 30px); padding: 10px 20px; box-shadow: none; }
  #shop .shop-btn:disabled { background: rgba(255,255,255,.16); color: #aaa; cursor: default; transform: none; }
  #shopCoins { color: #ffd34d; }
  #shopBack { position: sticky; top: 0; z-index: 1; align-self: flex-end; font-size: 16px; padding: 8px 20px; }
  #shopList { max-width: 1000px; }
  #shopList .upgrade-row canvas { width: 48px; height: 48px; box-shadow: none; background: none; }
  #quickShop { justify-content: flex-start; overflow-y: auto; background: rgba(18,34,20,.96); }
  #quickShop > * { flex-shrink: 0; }
  #quickShop .upgrade-row { flex-wrap: wrap; }
  #quickShop .upgrade-info { flex: 1 1 160px; }
  #quickShop .quick-buy { font-size: 14px; padding: 9px 16px; margin-left: auto; box-shadow: none; }
  #quickShop button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
  #quickShop canvas { width: 44px; height: 44px; flex: 0 0 44px; background: none; box-shadow: none; }
  #quickShopBack { position: sticky; bottom: 0; margin: 12px 0; }
  #future { justify-content: flex-start; overflow-y: auto; background: #142a32; gap: 12px; }
  #future > * { flex-shrink: 0; }
  #future h2, #future p { margin-bottom: 0; }
  #futureTop { width: 100%; max-width: 1080px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
  #future button { font-size: 14px; padding: 10px 16px; box-shadow: none; }
  #future button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
  #futureMsg { color: #ffe4a0; min-height: 24px; max-width: 1080px; white-space: pre-line; }
  #futureBody { width: 100%; max-width: 1080px; padding-bottom: 28px; }
  .future-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0; }
  .future-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; margin: 12px 0; }
  .future-card { background: #263d46; color: #f0f3db; border: 2px solid var(--rarity,#90a6b0); border-radius: 12px; padding: 10px; text-align: center; overflow-wrap: anywhere; }
  .future-card.selected { outline: 3px solid #fff4bc; }
  .future-card.missing { opacity: .5; }
  #future canvas, #zombieCampaign canvas { width: 76px; height: 76px; display: block; margin: 0 auto; background: none; box-shadow: none; border-radius: 0; }
  #zombieCampaign { justify-content: flex-start; overflow-y: auto; background: #20312d; gap: 12px; }
  #zombieCampaign > * { flex-shrink: 0; }
  #zombieBody { width: 100%; max-width: 1080px; padding-bottom: 20px; }
  #zombieCampaign button { font-size: 13px; padding: 8px 10px; box-shadow: none; }
  #zombieCampaign button.future-card { background: #263d46; color: #f0f3db; }
  #zombieCampaign button:disabled { opacity: .4; cursor: not-allowed; transform: none; }
  #zombieMsg { color: #ffe4a0; min-height: 24px; }
  #future .future-card small { display: block; font-size: 12px; line-height: 1.65; }
  #future .future-story { max-width: 780px; margin: 16px auto; white-space: pre-line; text-align: left; line-height: 2; color: #dae9df; }
  #future .future-arena { background: #203840; border-radius: 12px; padding: 12px; margin: 10px 0; }
  #future .future-arena h3 { margin-bottom: 8px; }
  #future .future-log { white-space: pre-line; font-size: 13px; line-height: 1.8; padding: 12px; background: #10232b; border-radius: 10px; }
  #future .future-pack { text-align: left; line-height: 1.8; }
  @media(max-width:600px) {
    #future { padding: 12px; }
    .future-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    #zombieCampaign { padding: 12px; }
    #future .future-card { padding: 8px; }
    #future canvas { width: 62px; height: 62px; }
    #futureTop h2 { font-size: 25px; }
  }
  #inn { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .96); }
  #inn > *, #shop > * { flex-shrink: 0; }
  #innList { width: 100%; max-width: 1000px; }
  #inn .inn-btn { font-size: 14px; padding: 10px 16px; flex-shrink: 0; }
  #innList canvas { width: 44px; height: 44px; box-shadow: none; background: none; }
  #inn button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
  #innBack { position: sticky; bottom: 0; margin: 16px 0; }
  #shopPositions { width: 100%; max-width: 1000px; margin-bottom: 24px; }
  #positionGridWrap { overflow-x: auto; max-width: 100%; }
  #positionGrid { display: grid; grid-template-columns: repeat(var(--field-cols, 7), minmax(0, 1fr)); gap: 6px; margin: 12px 0; }
  #shop .position-cell { font-size: 13px; padding: 10px 2px; border-radius: 8px; white-space: pre-line; box-shadow: none; }
  #shop .position-cell.selected { outline: 3px solid #fff; }
  #shop .position-cell:disabled { background: rgba(255,255,255,.12); color: #aaa; transform: none; cursor: not-allowed; }
  #positionInfo { line-height: 1.8; margin-bottom: 10px; }
  #loadout { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .95); }
  #loadoutSlots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0; }
  #loadout .deck-slot { font-size: 14px; padding: 8px 12px; border-radius: 10px; box-shadow: none; }
  #loadout .deck-slot.empty { background: rgba(255,255,255,.08); color: #aaa; }
  #loadoutList {
    width: 100%; max-width: 1000px; display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0;
  }
  #loadout .loadout-card { border-radius: 12px; padding: 10px; font-size: 15px; background: rgba(255,255,255,.12); color: #fff; box-shadow: none; }
  #loadout .loadout-card.selected { background: #ffd34d; color: #3a2c00; }
  #loadout .loadout-card:disabled { opacity: .45; cursor: default; transform: none; }
  #loadout .loadout-card canvas { width: 44px; height: 44px; display: block; margin: 0 auto 6px; background: none; box-shadow: none; }
  #loadout .loadout-desc { display: block; font-size: 11px; margin-top: 5px; line-height: 1.5; }
  #loadout .loadout-actions { position: sticky; bottom: 0; padding: 10px; background: #203728; border-radius: 12px; }
  #loadout .loadout-actions button { font-size: 16px; padding: 10px 18px; }
  #loadoutStart:disabled { opacity: .5; cursor: default; transform: none; }
  #casual { justify-content: flex-start; overflow-y: auto; background: rgba(22, 48, 38, .95); }
  #casual .casual-list { width: 100%; max-width: 880px; display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
  #casual .casual-choice { border-radius: 14px; text-align: left; font-size: 18px; padding: 16px 22px; }
  #casual .casual-choice span { display: block; font-size: 13px; font-weight: 400; margin-top: 6px; line-height: 1.6; }
  @media (max-height: 620px) { #casual { justify-content: flex-start; } }
  @media (max-width: 600px) {
    #shop .upgrade-row, #inn .upgrade-row { flex-wrap: wrap; }
    #shop .upgrade-info { flex-basis: 180px; }
    #shop .shop-btn { margin-left: auto; }
  }
  #menu { align-items: flex-end; padding: clamp(20px, 4vw, 80px); overflow-y: auto; }
  #menu h1 {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    font-size: clamp(48px, 8vw, 160px); white-space: nowrap; margin: 0; color: #ffe9a3;
  }
  #menu .menu-actions {
    width: clamp(160px, 19vw, 330px); display: flex; flex-direction: column;
    gap: clamp(8px, 1.5vh, 24px); flex: 0 0 auto; z-index: 1;
  }
  #menu .menu-actions button { width: 100%; padding: 12px 16px; border-radius: 14px; }
  #settings { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .96); }
  #settings .hint { margin-bottom: 20px; }
  #casualResult { justify-content: flex-start; overflow-y: auto; }
  #casual > *, #settings > *, #casualResult > * { flex-shrink: 0; }
  #casual > h1, #settings > h1, #casualResult > h1 { margin-top: auto; }
  #casual > :last-child, #settings > :last-child, #casualResult > :last-child { margin-bottom: auto; }
  #casualStats { line-height: 1.9; margin-bottom: 20px; max-width: 760px; }
  #casualStats b { color: #ffd34d; }
  #casualStats .rating { font-size: clamp(36px, 6vmin, 80px); }
  #casual .rating-rules { max-width: 880px; font-size: 13px; line-height: 1.8; margin-bottom: 16px; }
  #casual .rating-rules summary { cursor: pointer; color: #ffd34d; }
  #diary { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .96); }
  #diary > * { flex-shrink: 0; }
  #diaryList { width: 100%; max-width: 900px; }
  .diary-entry {
    text-align: left; padding: 18px; margin: 14px 0; border-radius: 14px;
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,211,77,.25);
  }
  .overlay .diary-entry h2 { color: #ffe9a3; font-size: clamp(18px, 2vmin, 32px); margin-bottom: 8px; }
  .overlay .diary-entry p { max-width: none; white-space: pre-line; margin: 0; font-size: clamp(14px, 1.6vmin, 26px); }
  #diaryBack { position: sticky; bottom: 0; margin: 16px 0; }
  #achievements { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .96); }
  #achievements > * { flex-shrink: 0; }
  #achievementList { width: 100%; max-width: 1000px; }
  #achievements .achievement-btn { font-size: 14px; padding: 10px 16px; flex-shrink: 0; }
  #achievements button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
  #achievements .upgrade-row { flex-wrap: wrap; }
  #achievementBack { position: sticky; bottom: 0; margin: 16px 0; }
  #codex { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .96); z-index: 11; }
  #codex > * { flex-shrink: 0; }
  #codexList { width: 100%; max-width: 1000px; }
  #codexList canvas { width: 48px; height: 48px; background: none; box-shadow: none; }
  #codexBack { position: sticky; bottom: 0; margin: 16px 0; }
  #clear { justify-content: flex-start; overflow-y: auto; }
  #clear button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
  #clearDiary { width: 100%; max-width: 900px; }
  @media (max-width: 700px) {
    #menu { padding: 20px 16px; }
    #menu h1 { left: 28%; font-size: clamp(36px, 8vw, 56px); white-space: normal; width: 2.2em; line-height: 1.3; }
    #menu .menu-actions { width: 43%; }
    #menu .menu-actions button { font-size: 16px; padding: 11px 8px; }
  }
  @media (max-height: 620px) {
    #menu { justify-content: flex-start; }
    #menu .menu-actions { gap: 6px; }
    #menu .menu-actions button { font-size: 16px; padding: 7px 12px; }
    #settings, #casualResult { justify-content: flex-start; }
  }
  #saveSlots { justify-content: flex-start; overflow-y: auto; background: rgba(18, 34, 20, .95); }
  #saveSlots > * { flex-shrink: 0; }
  .save-transfer {
    width: 100%; max-width: 760px; padding: 16px; margin-bottom: 16px;
    border: 1px solid rgba(255,255,255,.2); border-radius: 14px;
  }
  .save-transfer p { font-size: clamp(13px, 1.4vmin, 24px); white-space: pre-line; overflow-wrap: anywhere; max-width: 100%; margin: 10px 0; }
  .save-transfer button { font-size: clamp(14px, 1.5vmin, 28px); padding: 10px 18px; }
  #saveImportPreview { margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.2); }
  #saveImportTitle { font-size: clamp(20px, 2.2vmin, 36px); }
  #saveTransferMsg { color: #ffe9a3; }
  #saveSlots .slot-btn { flex: 0 0 auto; font-size: clamp(14px, 1.6vmin, 34px); padding: 10px 22px; }
  #saveSlots .slot-btn:disabled { background: rgba(255,255,255,.16); color: #aaa; cursor: default; transform: none; }
  #saveSlots .current-slot { border-color: #ffd34d; }
  #saveError {
    position: absolute; bottom: 10px; left: 5%; width: 90%; z-index: 20;
    padding: 10px; border-radius: 10px; background: #702d24; color: #fff; text-align: center;
  }
  @media (max-height: 620px) { #saveSlots { justify-content: flex-start; } }

  /* 难度选择 */
  .difficulty {
    display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
    gap: clamp(6px, .9vmin, 16px); margin-bottom: clamp(6px, .9vmin, 16px);
  }
  .diff-label { font-size: clamp(13px, 1.5vmin, 30px); opacity: .85; }
  #settings .diff-btn {
    font-size: clamp(13px, 1.5vmin, 32px);
    padding: clamp(6px, .9vmin, 16px) clamp(14px, 1.8vmin, 36px);
    border-radius: 999px; background: rgba(255,255,255,.14); color: #fff;
    box-shadow: none; font-weight: 700;
  }
  #settings .diff-btn:hover { transform: none; background: rgba(255,255,255,.26); }
  #settings .diff-btn.active { background: #ffd34d; color: #3a2c00; box-shadow: 0 0 0 2px rgba(255,255,255,.42); }
  #settings .diff-desc {
    font-size: clamp(12px, 1.45vmin, 30px); opacity: .72; max-width: none;
    margin-bottom: clamp(12px, 1.5vmin, 30px);
  }

  /* 选关面板 */
  #select { justify-content: flex-start; padding: clamp(20px, 2.4vmin, 52px) clamp(16px, 2vw, 44px); overflow-y: auto; background: rgba(18, 34, 20, .94); }
  #select > *, #clear > * { flex-shrink: 0; }
  @media (max-height: 620px) { #select { justify-content: flex-start; } }
  #select h1 { font-size: clamp(28px, 3.4vmin, 84px); margin-bottom: 2px; }
  #selectProgress { font-size: clamp(12px, 1.5vmin, 32px); opacity: .8; margin-bottom: 2px; }
  #chapList { width: 100%; max-width: clamp(820px, 60vw, 2300px); }
  .chap { width: 100%; max-width: none; margin: clamp(6px, .9vmin, 16px) 0; text-align: left; }
  .chap-title { font-size: clamp(14px, 1.8vmin, 40px); font-weight: 700; margin-bottom: clamp(4px, .6vmin, 10px); color: #ffd34d; }
  .lv-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: clamp(5px, .8vmin, 14px); }
  #select .lv-btn {
    height: clamp(36px, 4.8vmin, 100px); padding: 0; border: none; border-radius: clamp(7px, .9vmin, 16px); cursor: pointer;
    font-size: clamp(13px, 1.7vmin, 36px); font-weight: 700; background: rgba(255,255,255,.9); color: #222;
    box-shadow: none;
  }
  #select .lv-btn:hover { transform: none; background: #ffe9a3; }
  #select .lv-btn.cleared { background: #7cc468; color: #0f3a12; }
  #select .lv-btn.cleared:hover { background: #93d77d; }
  #select .lv-btn.locked { background: rgba(255,255,255,.18); color: #888; cursor: not-allowed; }
  #select .lv-btn.locked:hover { background: rgba(255,255,255,.18); }
  #select .back { margin-top: clamp(10px, 1.3vmin, 26px); }
