/* DEEPMINE UI v4 — app shell: frame, top bar, mine screen, dock, panel sheet, toasts, splash.
   Structural contract with mobile.mjs: the field bands stay direct-child <section>s of #game-frame
   (they are made inert while a panel is open); #feedback-banner stays a direct child too. */
@layer shell {
  /* ───────────── Frame ───────────── */
  #game-frame {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--frame-max);
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    background:
      radial-gradient(120% 55% at 50% -8%, rgb(38 98 72 / .55) 0%, transparent 62%),
      var(--noise),
      linear-gradient(180deg, #0c251b 0%, #0a1c15 60%, #08170f 100%);
  }
  @media (min-width: 700px) {
    body {
      padding: 24px 0;
      background:
        radial-gradient(60% 50% at 50% 0%, #143a2c, transparent 70%),
        var(--noise),
        var(--bg-0);
    }
    #game-frame {
      height: calc(100dvh - 48px);
      border-radius: 34px;
      border: 1px solid var(--line-2);
      box-shadow: 0 0 0 10px #040c08, 0 0 0 11px var(--line-1), var(--sh-3);
    }
  }

  /* ───────────── Top bar: brand, currencies, utilities ───────────── */
  .game-header {
    position: relative;
    z-index: var(--z-header);
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) var(--gutter) 0;
    background: linear-gradient(180deg, rgb(7 22 16 / .98), rgb(9 27 20 / .9));
    border-bottom: 1px solid var(--line-1);
    box-shadow: 0 8px 18px -12px rgb(0 0 0 / .9);
  }
  .game-brand { flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin: 0 2px 0 -2px; font-size: 0; }
  .game-brand .gi { width: 36px; height: 36px; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .6)); }

  .wallet, .bag-hud {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    border-radius: 999px;
    background: linear-gradient(180deg, #06140e, #0c2219);
    border: 1px solid var(--line-2);
    box-shadow: inset 0 2px 5px rgb(0 0 0 / .55), 0 1px 0 rgb(255 255 255 / .05);
    color: var(--text-1);
    text-align: left;
    transition: border-color var(--dur-2), transform var(--dur-1);
  }
  .wallet::before, .bag-hud::before { content: ''; position: absolute; inset: -2px 0; }
  .wallet:active, .bag-hud:active { transform: scale(.97); }
  .wallet-group { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
  .wallet { flex: 1 1 auto; min-width: 0; padding: 0 38px 0 3px; border-color: rgb(242 205 128 / .34); }
  .wallet > div, .bag-hud > div { min-width: 0; display: flex; align-items: baseline; gap: 4px; }
  #wallet-icon, #bag-icon { flex: none; display: grid; place-items: center; }
  #wallet-icon .currency-icon { width: 30px; height: 30px; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .5)); }
  #coins, #bag-count {
    display: inline-block;
    font: 700 18px/1 var(--font-display);
    letter-spacing: .3px;
    color: var(--gold-50);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow: clip;
    overflow-clip-margin: 14px;
    transform-origin: left center;
    padding-top: 2px;
  }
  /* "Buy DMT" — a quiet outlined plus at the end of the wallet pill (the assist button owns the gold plate). */
  .hud-plus {
    position: absolute;
    top: 50%;
    right: 5px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgb(245 200 105 / .12);
    border: 1.5px solid var(--gold-300);
    transform: translateY(-50%);
    transition: background var(--dur-2), transform var(--dur-1);
  }
  .hud-plus:active { transform: translateY(-50%) scale(.9); background: rgb(245 200 105 / .24); }
  .hud-plus > i { position: absolute; inset: -7px; }
  .hud-plus::before, .hud-plus::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 3px;
    border-radius: 2px;
    background: var(--gold-200);
    transform: translate(-50%, -50%);
  }
  .hud-plus::after { transform: translate(-50%, -50%) rotate(90deg); }
  /* Progressive unlocks: without the + (TON locked) the pill drops the room reserved for it; a chip that opens nothing
     yet (aria-disabled) does not press in. The bag carries the "new" dot while 背包 or 图鉴 is unseen. */
  .wallet-group:has(> .hud-plus[hidden]) > .wallet { padding-right: 12px; }
  .wallet[aria-disabled="true"] { cursor: default; }
  .wallet[aria-disabled="true"]:active { transform: none; }
  .bag-hud.has-new::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffb3a1, #ef4f36 60%);
    box-shadow: 0 0 0 2px #0f2a1f;
    animation: nav-dot 1.6s ease-in-out 4;
  }
  .bag-hud { flex: 0 1 auto; min-width: 0; padding: 0 12px 0 5px; }
  .bag-hud small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #bag-icon .gi { width: 28px; height: 28px; }
  #bag-count { font-size: 16px; color: var(--text-1); }
  /* Outside Chinese the compact forms run long ("250 тыс.", "250.000", "4,5 mil"). Both numbers scale with their
     combined length (--hud-len, set by mobile.mjs) to the room the bar leaves them (--hud-chrome: everything else in
     the bar), so the balance never runs under the + button and is never cut; narrow phones also trim the pills. */
  :root:not(:lang(zh)) .game-header { --hud-chrome: 224px; --hud-coins-max: 18px; container-type: inline-size; }
  :root:not(:lang(zh)) #coins { font-size: clamp(12px, calc((100cqi - var(--hud-chrome)) / (var(--hud-len, 8) * .53)), var(--hud-coins-max)); }
  :root:not(:lang(zh)) #bag-count { font-size: clamp(12px, calc((100cqi - var(--hud-chrome)) / (var(--hud-len, 8) * .53) * .9), 16px); }
  @media (min-width: 400px) { :root:not(:lang(zh)) .game-header { --hud-chrome: 268px; } }
  @media (max-width: 359px) {
    :root:not(:lang(zh)) .game-header { --hud-chrome: 191px; --hud-coins-max: 16px; gap: 4px; }
    :root:not(:lang(zh)) :is(.wallet, .bag-hud) { gap: 4px; }
    :root:not(:lang(zh)) .wallet { padding-right: 34px; }
    :root:not(:lang(zh)) .hud-plus { right: 4px; width: 28px; height: 28px; }
    :root:not(:lang(zh)) #wallet-icon .currency-icon, :root:not(:lang(zh)) #bag-icon .gi { width: 24px; height: 24px; }
  }

  .header-actions { flex: none; display: flex; gap: 0; margin-right: -8px; }
  .header-actions button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    transition: transform var(--dur-1), background var(--dur-2);
  }
  .header-actions button:active { transform: scale(.92); background: rgb(255 255 255 / .05); }
  .header-actions .gi { width: 28px; height: 28px; filter: drop-shadow(0 2px 2px rgb(0 0 0 / .5)); }
  .header-actions #settings-button .gi { --gi-base: #7fcfa6; }
  .header-actions #help-button .gi { --gi-base: #b9d3c3; --gi-line: #0d2219; }

  /* ───────────── Quest + production ───────────── */
  .stage-header {
    flex: none;
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 10px var(--gutter) 10px;
  }
  #objective-button {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 6px 10px 8px 8px;
    border-radius: 16px;
    overflow: hidden;
    text-align: left;
    background:
      radial-gradient(90% 120% at 0% 0%, rgb(245 200 105 / .12), transparent 60%),
      linear-gradient(100deg, #1e4b38, #143527);
    border: 1px solid var(--line-gold);
    box-shadow: var(--hl-top), var(--sh-1);
    transition: transform var(--dur-1);
  }
  #objective-button:active { transform: scale(.985); }
  #objective-button::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: var(--objective-progress, 0%);
    background: linear-gradient(90deg, var(--gold-500), var(--gold-200));
    box-shadow: 0 0 8px rgb(245 200 105 / .7);
    transition: width var(--dur-4) var(--ease-out);
  }
  .objective-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: rgb(0 0 0 / .25); border: 1px solid var(--line-1); }
  .objective-icon .gi { width: 28px; height: 28px; }
  .objective-copy { flex: 1; min-width: 0; display: grid; gap: 1px; }
  .objective-kicker { font-size: var(--fs-11); font-weight: 700; letter-spacing: .06em; color: var(--gold-300); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #objective-title { font-size: var(--fs-14); font-weight: 800; color: var(--text-1); line-height: 1.22; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; text-wrap: balance; }
  @media (max-width: 400px) { .objective-kicker { display: none; } }
  /* Objective description: one quiet line under the (still 2-line clamped) title, on tall screens only. The full
     text is also the button's title / accessible label. */
  .objective-desc { display: none; }
  @media (min-height: 760px) {
    .objective-desc:not(:empty) { display: block; min-width: 0; font-size: var(--fs-11); font-weight: 600; line-height: 1.35; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  }
  #objective-caption {
    flex: none;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgb(0 0 0 / .3);
    border: 1px solid var(--line-1);
    font: 700 12px/1.4 var(--font-display);
    color: var(--gold-100);
  }
  #objective-caption:empty { display: none; }
  /* 即将解锁 line (#objective-next, filled by mobile.mjs): the next feature's name plus a mini meter. One quiet line,
     never wrapping, so the card height stays predictable in every locale. */
  .objective-next { display: flex; align-items: center; gap: 6px; min-width: 0; margin-top: 1px; }
  .objective-next-label {
    flex: 0 1 auto;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: var(--fs-11);
    font-weight: 700;
    line-height: 1.3;
    color: var(--gold-200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .objective-next-label::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 1.5px; background: var(--gold-300); box-shadow: 0 0 6px rgb(245 200 105 / .6); transform: rotate(45deg); }
  /* The name wins over the meter: the meter takes what is left (16–38px) and is dropped on the narrowest phones. */
  .objective-next-meter { flex: 1 1 0; min-width: 16px; max-width: 38px; height: 5px; }
  .objective-next-meter > span { transition: width var(--dur-4) var(--ease-out); }
  @media (max-width: 359px) {
    .objective-next { gap: 4px; }
    .objective-next-label { gap: 4px; }
    .objective-next-meter { display: none; }
  }

  .production-chip {
    flex: none;
    display: grid;
    align-content: center;
    justify-items: end;
    gap: 2px;
    min-width: 92px;
    max-width: 42%;
    padding: 6px 12px;
    border-radius: 16px;
    background: var(--grad-panel), var(--surface-1);
    border: 1px solid var(--line-1);
    box-shadow: var(--hl-top), var(--sh-1);
    color: var(--text-1);
    transition: transform var(--dur-1);
  }
  .production-chip:active { transform: scale(.97); }
  .production-chip > span { display: flex; align-items: baseline; gap: 3px; max-width: 100%; white-space: nowrap; }
  .production-chip small { min-width: 0; }
  .production-chip small { overflow: hidden; text-overflow: ellipsis; }
  .production-chip b { font: 700 16px/1 var(--font-display); color: var(--text-1); }
  .production-power b { color: var(--jade-300); font-size: 15px; }
  /* v10: 「{w}/{s}」 working slots in the count, and the 5-minute note for accounts without 离线挖矿 (mobile.mjs adds
     .production-note only on a v10 view; it never shows on today's server). */
  .production-chip .production-note { max-width: 100%; font-size: var(--fs-10); font-weight: 700; color: var(--warn); line-height: 1.1; white-space: normal; text-align: right; }
  .production-chip .production-note[hidden] { display: none; }
  .production-chip small { font-size: var(--fs-11); color: var(--text-3); font-weight: 600; }
  .live-dot {
    position: relative;
    align-self: center;
    flex: none;
    width: 7px;
    height: 7px;
    margin: 0 4px 0 2px;
    border-radius: 50%;
    background: var(--jade-300);
  }
  .live-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--jade-300);
    will-change: transform, opacity;
    animation: live-dot 1.8s ease-out infinite;
  }
  @keyframes live-dot { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(2.6); opacity: 0; } }

  /* Floor coverage: a jewel line along the top edge of the field frame. */
  .map-progress {
    position: relative;
    z-index: 6;
    flex: none;
    height: 4px;
    margin: 0 calc(var(--gutter) + 18px) -4px;
    border-radius: 0 0 4px 4px;
    background: rgb(0 0 0 / .5);
    overflow: hidden;
  }
  .map-progress > span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--jade-400), var(--gold-200));
    box-shadow: 0 0 8px rgb(245 200 105 / .7);
    transition: width .8s var(--ease-out);
  }

  /* ───────────── Field stage ───────────── */
  .stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 170px;
    margin: 0 var(--gutter);
    border-radius: 20px;
    overflow: hidden;
    background: #2b4c33;
    touch-action: none;
    box-shadow:
      0 0 0 1px rgb(0 0 0 / .7),
      0 0 0 3px #3b2a16,
      0 0 0 4px rgb(242 205 128 / .4),
      0 16px 30px -12px rgb(0 0 0 / .9);
  }
  .stage > canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
  .stage::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 36px rgb(0 0 0 / .42), inset 0 1px 0 rgb(255 255 255 / .12);
  }
  .stage-top {
    position: absolute;
    z-index: var(--z-stage-ui);
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
  }
  .layer-chip, #loot-ticker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    background: rgb(7 21 15 / .86);
    border: 1px solid rgb(242 205 128 / .3);
    box-shadow: 0 2px 6px rgb(0 0 0 / .35);
    font-size: var(--fs-12);
    font-weight: 700;
    color: var(--text-1);
    white-space: nowrap;
  }
  .layer-chip { min-width: 0; overflow: hidden; }
  #layer-label { overflow: hidden; text-overflow: ellipsis; }
  #progress-label { font: 700 13px/1 var(--font-display); color: var(--gold-200); padding-top: 1px; }
  #loot-ticker { padding: 0 10px 0 4px; }
  #loot-ticker:empty { display: none; }
  #loot-ticker img { width: 24px; height: 24px; object-fit: contain; animation: dm-pop .4s var(--ease-spring); }
  #loot-ticker b { font: 700 14px/1 var(--font-display); color: var(--gold-100); padding-top: 1px; animation: loot-rise .5s var(--ease-out); }
  @keyframes loot-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  #active-buffs:empty { display: none; }
  #active-buffs { position: absolute; z-index: var(--z-stage-ui); top: 48px; left: 10px; display: flex; gap: 6px; }

  /* Depth legend: one 22 px row of every layer, grouped by zone (mobile.mjs builds it from the snapshot; colours
     come from depth-content.mjs, the same as the depth-map cells). Reached layers carry their colour; layers not
     reached yet are dim numbered slots with no name or colour, so the legend never previews deeper content.
     The deepest layer reached has a gold outline; a thin bar above each reached zone shows its accent. */
  #depth-legend {
    position: absolute;
    z-index: var(--z-stage-ui);
    top: 44px;
    left: 10px;
    right: 10px;
    pointer-events: none;
  }
  .depth-ramp { display: flex; gap: 5px; height: 22px; }
  .depth-zone { position: relative; flex: var(--n, 1) 1 0; min-width: 0; display: flex; gap: 2px; }
  .depth-zone::before {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    top: -4px;
    height: 2px;
    border-radius: 2px;
    background: var(--zone-c, transparent);
    box-shadow: 0 0 6px var(--zone-c, transparent);
    opacity: .85;
  }
  .depth-seg {
    flex: 1 1 0;
    min-width: 0;
    display: grid;
    place-items: center;
    height: 22px;
    border-radius: 6px;
    font: 800 11px/1 var(--font-display);
    padding-top: 1px;
    color: #fffbea;
    text-shadow: 0 1px 1px rgb(0 0 0 / .7), 0 0 3px rgb(0 0 0 / .45);
    background: linear-gradient(180deg, color-mix(in srgb, var(--layer-c, #56635c) 78%, #fff 22%), var(--layer-c, #56635c) 55%, color-mix(in srgb, var(--layer-c, #56635c) 82%, #000 18%));
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .28), 0 1px 3px rgb(0 0 0 / .55);
    overflow: hidden;
  }
  .depth-seg.is-locked {
    color: var(--text-4);
    text-shadow: none;
    background: rgb(7 21 15 / .84);
    box-shadow: inset 0 0 0 1px var(--line-2);
  }
  .depth-seg.is-current {
    position: relative;
    z-index: 1;
    box-shadow: 0 0 0 2px var(--gold-200), 0 0 10px rgb(245 200 105 / .75), inset 0 1px 0 rgb(255 255 255 / .3);
  }
  /* The caption stays in the DOM for assistive tech; visually the ramp carries the meaning. */
  #depth-legend small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* The ramp owns the band under the layer chip while the depth map is shown. */
  .stage.is-depth-view #active-buffs { display: none; }
  @media (max-width: 359px) {
    .depth-ramp { gap: 4px; }
    .depth-zone { gap: 1px; }
    .depth-seg { font-size: 10px; border-radius: 5px; }
  }

  .scene-actions {
    position: absolute;
    z-index: var(--z-stage-ui);
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .scene-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 44px;
    padding: 0 11px 0 8px;
    border-radius: 13px;
    background: rgb(7 21 15 / .86);
    border: 1px solid rgb(206 228 196 / .2);
    box-shadow: 0 2px 0 rgb(0 0 0 / .45), inset 0 1px 0 rgb(255 255 255 / .06);
    color: var(--text-1);
    font-size: var(--fs-13);
    font-weight: 700;
    white-space: nowrap;
    transition: transform var(--dur-1), border-color var(--dur-2), background var(--dur-2);
  }
  .scene-actions button:active { transform: translateY(1px) scale(.97); }
  .scene-actions .gi { width: 24px; height: 24px; }
  #strategy-button, #depth-view-button { flex: 0 3 auto; min-width: 42px; }
  .scene-actions .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #depth-view-button[aria-pressed="true"] {
    color: var(--gold-100);
    border-color: var(--line-gold-strong);
    background: rgb(52 40 14 / .85);
    box-shadow: 0 2px 0 rgb(0 0 0 / .45), 0 0 14px -2px rgb(245 200 105 / .5);
  }
  .next-buy {
    flex: 1 1 auto;
    min-width: 92px;
    margin-left: auto;
  }
  .scene-actions .next-buy {
    color: var(--text-1);
    background: var(--grad-jade-plate);
    border-color: rgb(242 205 128 / .55) rgb(150 225 185 / .2) rgb(0 0 0 / .35);
    box-shadow: var(--sh-plate-jade), 0 0 14px -6px rgb(245 200 105 / .6);
    padding: 0 10px 0 6px;
  }
  .next-buy .nb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .next-buy .price { margin-left: 2px; font-size: 14px; color: var(--gold-100); }
  .next-buy .price .currency-icon { width: 16px; height: 16px; }
  .next-buy .gi { width: 20px; height: 20px; }
  .next-buy.is-idle { color: var(--text-1); background: rgb(7 21 15 / .8); border-color: rgb(206 228 196 / .2); text-shadow: none; box-shadow: 0 2px 0 rgb(0 0 0 / .45); }
  @media (max-width: 374px) {
    #strategy-button .label, #depth-view-button .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    #strategy-button, #depth-view-button { width: 42px; padding: 0; }
  }
  /* Latin and Cyrillic labels would squeeze all three buttons into ellipses: outside Chinese the strategy and
     strata buttons are icon-only at every width (the .label stays as their accessible name) and #next-buy gets the room. */
  :root:not(:lang(zh)) :is(#strategy-button, #depth-view-button) .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  :root:not(:lang(zh)) :is(#strategy-button, #depth-view-button) { width: 42px; padding: 0; }

  /* Boot splash: a direct child of #game-frame; its content and motion live in ui/onboarding.css. */
  #loading {
    position: fixed;
    z-index: var(--z-splash);
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    background:
      radial-gradient(70% 45% at 50% 42%, rgb(40 100 74 / .55), transparent 70%),
      linear-gradient(180deg, rgb(6 19 14 / .55), rgb(6 19 14 / .96) 78%),
      url(/art/premium/forest.jpg) center / cover no-repeat,
      var(--bg-0);
    opacity: 1;
    visibility: visible;
    transition: opacity .55s var(--ease-out), visibility 0s;
  }
  #loading[hidden] { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .55s var(--ease-out), visibility 0s .55s; }
  /* Splash content and the boot animation live in ui/onboarding.css. */

  /* ───────────── Assist strip ───────────── */
  .assist-strip {
    position: relative;
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px var(--gutter) 0;
    padding: 10px 10px 10px 14px;
    min-height: 74px;
    border-radius: 18px;
    background: var(--grad-panel), var(--surface-1);
    border: 1px solid var(--line-1);
    box-shadow: var(--hl-top), var(--sh-1);
  }
  .assist-info { flex: 1; min-width: 0; display: grid; gap: 3px; }
  #target-label { font-size: var(--fs-14); font-weight: 800; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #target-detail { font-size: var(--fs-11); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #target-meter {
    position: relative;
    height: 8px;
    margin-top: 3px;
    border-radius: 999px;
    background: var(--surface-inset);
    box-shadow: inset 0 1px 3px rgb(0 0 0 / .65), 0 1px 0 rgb(255 255 255 / .05);
    overflow: hidden;
  }
  #target-meter span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--jade-500), var(--jade-300));
    box-shadow: 0 0 10px rgb(80 200 140 / .5);
    transition: width .35s var(--ease-out);
  }
  #assist-button {
    position: relative;
    isolation: isolate;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 124px;
    height: 54px;
    padding: 0 16px 0 12px;
    border-radius: 16px;
    color: var(--text-on-gold);
    background: var(--grad-gold);
    border: 1px solid;
    border-color: #ffe9ad #e7ad48 #b7751e;
    font-size: var(--fs-15);
    font-weight: 800;
    text-shadow: 0 1px 0 rgb(255 246 215 / .6);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .8), inset 0 -3px 0 rgb(160 95 20 / .3), 0 4px 0 var(--gold-edge), 0 10px 22px -8px rgb(240 170 60 / .75);
    touch-action: none;
    transition: transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1), filter var(--dur-2);
  }
  #assist-button .gi { width: 30px; height: 30px; --gi-line: #4f320d; transform-origin: 30% 80%; }
  /* Outside Chinese the hold label ("Zum Helfen halten", "Зажать для помощи") would take the strip: the button is
     capped so the layer/HP lines keep ~110px, and the label wraps onto two balanced lines instead. */
  :root:not(:lang(zh)) #assist-button { max-width: calc(100% - 190px); line-height: 1.12; }
  /* v10.4: the 背包 button sits in the assist strip, right of 按住助力: a compact tile with the count under the icon */
  .assist-strip .bag-hud { flex: none; flex-direction: column; justify-content: center; gap: 1px; width: 58px; height: 54px; padding: 4px 6px; border-radius: 16px; }
  .assist-strip .bag-hud > div { justify-content: center; }
  .assist-strip .bag-hud strong { font-size: var(--fs-12); line-height: 1; }
  .assist-strip { gap: 10px; }
  :root:not(:lang(zh)) #assist-button > span { min-width: 0; text-align: center; text-wrap: balance; overflow-wrap: break-word; }
  #assist-button:active:not(:disabled), #assist-button.working {
    transform: translateY(3px);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), inset 0 -1px 0 rgb(160 95 20 / .3), 0 1px 0 var(--gold-edge), 0 4px 14px -4px rgb(255 200 90 / .9);
  }
  #assist-button.working { filter: brightness(1.07) saturate(1.1); }
  #assist-button.working .gi { animation: assist-swing .42s var(--ease-in-out) infinite; }
  #assist-button::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -2px;
    border-radius: 18px;
    border: 2px solid rgb(255 214 120 / .8);
    opacity: 0;
    pointer-events: none;
  }
  #assist-button.working::before { animation: assist-ring 1s ease-out infinite; }
  #assist-button:disabled {
    color: var(--text-3);
    background: var(--surface-disabled);
    border-color: var(--line-1);
    text-shadow: none;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .03);
    transform: none;
  }
  #assist-button:disabled .gi { filter: grayscale(1) brightness(.75); }
  @keyframes assist-swing { 0%, 100% { transform: rotate(8deg); } 45% { transform: rotate(-26deg); } }
  @keyframes assist-ring { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.12, 1.35); } }

  /* v10.1 D4-C: the permanent 离线挖矿 entry under the assist strip (shown once the permission is revealed, until owned).
     One slim 44px row so the field keeps its height on short phones. */
  .offline-strip { flex: none; margin: 6px var(--gutter) 0; }
  .offline-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 4px 8px 4px 10px;
    border-radius: 14px;
    text-align: left;
    color: var(--text-1);
    background: linear-gradient(90deg, rgb(120 170 230 / .12), rgb(120 170 230 / .02) 70%), var(--surface-inset);
    border: 1px solid rgb(160 200 240 / .22);
    box-shadow: 0 2px 0 rgb(0 0 0 / .35);
    transition: transform var(--dur-1), border-color var(--dur-2);
  }
  .offline-entry:active { transform: translateY(1px) scale(.99); }
  .offline-entry-icon { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: #cfe3ff; background: rgb(60 100 150 / .35); border: 1px solid rgb(160 200 240 / .25); }
  .offline-entry-icon svg { width: 18px; height: 18px; }
  .offline-entry-copy { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
  .offline-entry-copy strong { flex: none; font-size: var(--fs-13); font-weight: 800; }
  .offline-entry-copy small { min-width: 0; font-size: var(--fs-11); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .offline-entry-trail { flex: none; display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
  .offline-entry-trail svg { width: 16px; height: 16px; }
  .offline-entry-trail .chip { min-height: 22px; padding: 1px 8px; font-size: var(--fs-11); }
  @media (max-height: 640px) {
    .offline-strip { margin-top: 5px; }
    .offline-entry-copy small { display: none; }
  }

  /* v10.1: a one-off attention pulse for a note an error points at (MARKET_PROGRESS_REQUIRED → the market progress note). */
  .is-attention { animation: dm-attention 1.2s var(--ease-out) 1; }
  @keyframes dm-attention { 0%, 100% { box-shadow: 0 0 0 0 rgb(245 200 105 / 0); } 30% { box-shadow: 0 0 0 3px rgb(245 200 105 / .55), 0 0 18px rgb(245 200 105 / .35); } }
  html.reduce-motion .is-attention, html.low-quality .is-attention { animation: none; outline: 2px solid var(--gold-300); outline-offset: 2px; }

  /* Round payout teaser (tall screens only). */
  .quick-market { display: none; }
  @media (min-height: 760px) {
    .quick-market {
      flex: none;
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 8px var(--gutter) 0;
      padding: 0 4px 0 12px;
      min-height: 46px;
      border-radius: 14px;
      background: linear-gradient(90deg, rgb(245 200 105 / .1), rgb(245 200 105 / .02) 60%), var(--surface-inset);
      border: 1px solid rgb(242 205 128 / .18);
    }
    .quick-market > button:first-child { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; text-align: left; }
    /* The label wraps (two lines at most) so long translations stay whole; the countdown, the amount and its DMT icon never shrink. */
    .quick-market > button:first-child > span { min-width: 0; font-size: var(--fs-12); color: var(--text-3); font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
    /* Round countdown (m:ss to economy.pool.endAt, ticked by mobile.mjs while the strip is on screen). */
    .quick-market .sell-countdown {
      flex: none;
      margin-left: auto;
      padding: 2px 7px;
      border-radius: var(--r-pill);
      background: rgb(0 0 0 / .3);
      border: 1px solid var(--line-1);
      font: 700 12px/1.3 var(--font-display);
      font-variant-numeric: tabular-nums;
      color: var(--text-2);
      white-space: nowrap;
    }
    .quick-market .sell-countdown:empty { display: none; }
    .quick-market strong { flex: none; display: inline-flex; align-items: center; gap: 5px; font: 700 15px/1 var(--font-display); color: var(--gold-100); }
    #quick-market-icon, #quick-market-icon .currency-icon { flex: none; }
    #quick-market-icon .currency-icon { width: 18px; height: 18px; }
    /* Narrow phones: the countdown stacks under the amount (one right-hand column instead of two), so a long label
       (es/pt "Distribución estimada de la ronda") keeps the width it needs for two lines. */
    @media (max-width: 359px) {
      .quick-market > button:first-child { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center; column-gap: 6px; row-gap: 2px; }
      .quick-market > button:first-child > span { grid-row: 1 / span 2; align-self: center; }
      .quick-market strong { grid-column: 2; grid-row: 1; justify-self: end; }
      .quick-market > button:first-child:has(> .sell-countdown:empty) strong { grid-row: 1 / span 2; }
      .quick-market .sell-countdown { grid-column: 2; grid-row: 2; justify-self: end; margin-left: 0; padding: 0 5px; font-size: 11px; }
    }
    #sell-quick::before { content: ''; position: absolute; inset: -4px -2px; }
    #sell-quick {
      position: relative;
      flex: none;
      height: 36px;
      padding: 0 12px;
      border-radius: 10px;
      font-size: var(--fs-12);
      font-weight: 800;
      color: var(--gold-100);
      background: var(--grad-jade-plate);
      border: 1px solid rgb(242 205 128 / .28);
      box-shadow: 0 2px 0 rgb(0 0 0 / .45);
    }
  }

  /* ───────────── Dock ───────────── */
  /* Progressive unlocks hide locked buttons ([hidden]): every visible button keeps one fifth of the dock
     ((100% − 4 gaps) / 5) and the group stays centred — one button alone at t=0, then two, and so on. */
  #game-nav {
    position: relative;
    z-index: var(--z-dock);
    flex: none;
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - 8px) / 5);
    justify-content: center;
    gap: 2px;
    height: calc(var(--dock-h) + var(--safe-bottom));
    margin-top: 12px;
    padding: 5px 6px var(--safe-bottom);
    background: linear-gradient(180deg, #11301f 0%, #0a1d15 100%);
    border-top: 1px solid rgb(242 205 128 / .22);
    box-shadow: 0 -10px 24px -10px rgb(0 0 0 / .85), inset 0 1px 0 rgb(255 255 255 / .05);
  }
  #game-nav button {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    border-radius: 14px;
    color: var(--text-3);
    font-size: clamp(9.5px, 2.9vw, 11px);
    font-weight: 700;
    letter-spacing: .02em;
    transition: color var(--dur-2);
  }
  #game-nav button > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #game-nav .gi {
    width: 32px;
    height: 32px;
    filter: saturate(.3) brightness(.78);
    transition: transform var(--dur-3) var(--ease-spring), filter var(--dur-2);
  }
  /* v10.1 兑换: two existing coin icons (DMT in front, the swap coin behind) in the 32px glyph box. */
  #game-nav .nav-swap-glyph { position: relative; display: block; flex: none; }
  #game-nav .nav-swap-coin { position: absolute; width: 22px; height: 22px; filter: drop-shadow(0 1px 1px rgb(0 0 0 / .55)); }
  #game-nav .nav-swap-coin.is-ton { right: 0; top: 0; }
  #game-nav .nav-swap-coin.is-dmt { left: 0; bottom: 0; z-index: 1; }
  #game-nav button:active .gi { transform: scale(.9); }
  #game-nav button.active { color: var(--gold-100); }
  #game-nav button.active .gi { filter: drop-shadow(0 3px 4px rgb(0 0 0 / .5)); transform: translateY(-3px) scale(1.12); }
  #game-nav button.active::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 1px 4px 2px;
    border-radius: 14px;
    background:
      radial-gradient(80% 70% at 50% 25%, rgb(245 200 105 / .26), transparent 70%),
      linear-gradient(180deg, #24513e, #173a2c);
    border: 1px solid rgb(242 205 128 / .36);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .12), 0 4px 10px -4px rgb(0 0 0 / .7);
    animation: dm-pop .3s var(--ease-spring);
  }
  #game-nav button.active::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    width: 22px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--gold-200);
    box-shadow: 0 0 10px var(--gold-300);
    transform: translateX(-50%);
  }
  #game-nav i { position: absolute; top: 4px; left: calc(50% + 9px); }
  #game-nav i:not(.dot) { display: none; }
  #game-nav i.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffb3a1, #ef4f36 60%);
    box-shadow: 0 0 0 2px #0f2a1f;
    animation: nav-dot 1.6s ease-in-out 4;
  }
  @keyframes nav-dot { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18); } }

  /* ───────────── Panel sheet ───────────── */
  #sheet {
    position: absolute;
    z-index: var(--z-sheet);
    left: 0;
    right: 0;
    top: calc(var(--header-h) + var(--safe-top));
    bottom: calc(var(--dock-h) + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    background: var(--noise), linear-gradient(180deg, #0f2a20 0%, #0b2119 55%, #091b14 100%);
    opacity: 0;
    transform: translateY(22px);
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s var(--dur-3);
  }
  #sheet.open {
    opacity: 1;
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s;
  }
  .sheet-grip { display: none; }
  #sheet > header {
    position: relative;
    isolation: isolate;
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 76px;
    padding: 12px var(--gutter);
    overflow: hidden;
    border-bottom: 1px solid var(--line-gold);
    background: #0f2a20;
    box-shadow: 0 10px 20px -14px rgb(0 0 0 / .9);
  }
  #sheet > header::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    background:
      linear-gradient(90deg, #0f2a20 18%, rgb(15 42 32 / .78) 48%, rgb(15 42 32 / .25) 100%),
      linear-gradient(0deg, rgb(15 42 32 / .7), transparent 60%),
      var(--sheet-art, url(/art/premium/forest.jpg)) right 30% / cover no-repeat;
  }
  .sheet-heading { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
  .sheet-emblem {
    flex: none;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: radial-gradient(circle at 50% 30%, #2f6a50, #163b2c 75%);
    border: 1px solid var(--line-gold);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .14), 0 4px 10px -4px rgb(0 0 0 / .8);
  }
  .sheet-emblem .gi { width: 34px; height: 34px; filter: drop-shadow(0 2px 2px rgb(0 0 0 / .5)); }
  .sheet-emblem .icon, .sheet-emblem .currency-icon { width: 28px; height: 28px; color: var(--gold-200); }
  .sheet-heading-copy { min-width: 0; display: grid; gap: 1px; }
  .sheet-kicker { font: 700 11px/1.3 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--gold-300); opacity: .9; }
  #sheet-title { font-size: var(--fs-22); font-weight: 800; line-height: 1.15; color: var(--text-1); text-shadow: 0 2px 8px rgb(0 0 0 / .6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* A title that does not fit one line (mobile.mjs adds .is-long: "Historique des transactions") wraps onto two
     smaller lines instead of ending in an ellipsis; the header keeps its height. */
  #sheet-title.is-long { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: var(--fs-18); line-height: 1.1; white-space: normal; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; text-wrap: balance; }
  #sheet-title:focus { outline: none; }
  #sheet-subtitle { font-size: var(--fs-12); color: var(--text-3); line-height: 1.35; }
  #sheet-subtitle:empty { display: none; }
  #sheet > header [data-close] {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: rgb(6 19 14 / .72);
    border: 1px solid var(--line-2);
    color: var(--text-2);
    font-size: 0;
    box-shadow: 0 2px 0 rgb(0 0 0 / .4);
    transition: transform var(--dur-1), color var(--dur-2);
  }
  #sheet > header [data-close]:active { transform: scale(.92); color: var(--text-1); }
  #sheet > header [data-close] .gi { width: 22px; height: 22px; }
  #sheet-controls { flex: none; padding: 10px var(--gutter) 2px; }
  #sheet-controls:empty { display: none; }
  #sheet-body {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px var(--gutter) 28px;
  }
  #sheet-footer {
    position: relative;
    z-index: 2;
    flex: none;
    padding: 10px var(--gutter) 12px;
    background: linear-gradient(180deg, #153a2c, #0f2b21);
    border-top: 1px solid var(--line-gold);
    box-shadow: 0 -12px 24px -14px rgb(0 0 0 / .9);
  }
  /* Panel switch: content rises in once per open (never on poll re-renders). */
  #sheet.is-entering #sheet-body > *, #sheet.is-entering #sheet-controls > * { animation: dm-fade-up var(--dur-3) var(--ease-out) both; }
  #sheet.is-entering #sheet-body > :nth-child(2) { animation-delay: 30ms; }
  #sheet.is-entering #sheet-body > :nth-child(3) { animation-delay: 60ms; }
  #sheet.is-entering #sheet-body > :nth-child(4) { animation-delay: 90ms; }
  #sheet.is-entering #sheet-body > :nth-child(n+5) { animation-delay: 120ms; }

  /* Per-panel header art (art.css may override --sheet-art with generated banners). */
  #sheet[data-mode="shop"] { --sheet-art: url(/art/premium/workshop.jpg); }

  /* ───────────── Toast, connection ───────────── */
  /* Toast: a dark glass pill with a gold status mark — never mistaken for a control. */
  #toast {
    position: absolute;
    z-index: var(--z-toast);
    left: 50%;
    top: calc(var(--header-h) + var(--safe-top) + 10px);
    max-width: calc(100% - 32px);
    padding: 9px 16px 9px 30px;
    border-radius: 999px;
    background: rgb(5 15 11 / .94);
    border: 1px solid rgb(242 205 128 / .45);
    color: var(--text-1);
    font-size: var(--fs-13);
    font-weight: 700;
    line-height: 1.4;
    text-align: left;
    box-shadow: var(--sh-3), 0 0 0 1px rgb(0 0 0 / .5);
    opacity: 0;
    transform: translate(-50%, -14px) scale(.96);
    pointer-events: none;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-spring);
  }
  #toast::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gold-300);
    box-shadow: 0 0 8px var(--gold-300);
    transform: translateY(-50%);
  }
  #toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
  /* Inside panels the top is full of tabs and controls: rise from the bottom instead. */
  #game-frame.panel-open > #toast { top: auto; bottom: calc(var(--dock-h) + var(--safe-bottom) + var(--sheet-footer-h, 0px) + 16px); transform: translate(-50%, 14px) scale(.96); }
  #game-frame.panel-open > #toast.show { transform: translate(-50%, 0) scale(1); }
  /* v10: a toast with one action button (离线挖矿 / 调度 links) takes taps while it shows. */
  #toast.has-action { display: flex; align-items: center; gap: 10px; padding-right: 6px; }
  #toast.has-action.show { pointer-events: auto; }
  #toast .toast-action { flex: none; min-height: 32px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line-gold); background: var(--surface-2); color: var(--gold-200); font: inherit; font-size: var(--fs-12); white-space: nowrap; }
  #connection {
    position: absolute;
    z-index: var(--z-connection);
    top: calc(var(--header-h) + var(--safe-top));
    left: 0;
    right: 0;
    padding: 6px 12px;
    text-align: center;
    font-size: var(--fs-12);
    font-weight: 700;
    color: #2d1d05;
    background: linear-gradient(90deg, #e7b452, #ffd88a, #e7b452);
    box-shadow: 0 4px 12px rgb(0 0 0 / .4);
  }

  /* ───────────── Feedback banner ───────────── */
  #game-frame > #feedback-banner {
    position: absolute;
    z-index: var(--z-banner);
    left: var(--gutter);
    right: var(--gutter);
    bottom: calc(var(--dock-h) + var(--safe-bottom) + 14px);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 66px;
    padding: 9px 14px 9px 9px;
    border-radius: 18px;
    pointer-events: none;
    --fb-c: var(--gold-300);
    background:
      radial-gradient(90% 140% at 0% 50%, color-mix(in srgb, var(--fb-c) 26%, transparent), transparent 60%),
      linear-gradient(100deg, #1e4d3a, #133426);
    border: 1px solid color-mix(in srgb, var(--fb-c) 60%, transparent);
    box-shadow: var(--sh-3), 0 0 22px -6px color-mix(in srgb, var(--fb-c) 70%, transparent), inset 0 1px 0 rgb(255 255 255 / .1);
  }
  #game-frame.panel-open > #feedback-banner { bottom: calc(var(--dock-h) + var(--safe-bottom) + var(--sheet-footer-h, 0px) + 12px); }
  #game-frame:not(.panel-open) > #feedback-banner { bottom: auto; top: calc(var(--header-h) + var(--safe-top) + 122px); }
  #game-frame > #feedback-banner[data-kind="talent"] { --fb-c: var(--jade-300); }
  #game-frame > #feedback-banner[data-kind="layer"] { --fb-c: #ffae5a; }
  #game-frame > #feedback-banner[data-kind="rare"] { --fb-c: var(--rarity-rare); }
  #game-frame > #feedback-banner[data-kind="collection"] { --fb-c: var(--rarity-epic); }
  #game-frame > #feedback-banner[data-kind="payment"] { --fb-c: var(--ton); }
  #game-frame > #feedback-banner[data-kind="success"] { --fb-c: var(--jade-300); }
  #game-frame > #feedback-banner[data-kind="unlock"] { --fb-c: var(--gold-200); }
  /* New depth and new zone: the zone accent (depth-content.mjs ZONES) colours the banner; the emblem is a faceted
     gem carrying the layer number. */
  #game-frame > #feedback-banner[data-kind="depth"] { --fb-c: #ffae5a; }
  #game-frame > #feedback-banner:is([data-kind="depth"], [data-kind="zone"])[data-zone="surface"] { --fb-c: #9fd36a; }
  #game-frame > #feedback-banner:is([data-kind="depth"], [data-kind="zone"])[data-zone="geode"] { --fb-c: #72e4d8; --zone-art: url(/art/ui-v4/banners/zone-geode.webp); }
  #game-frame > #feedback-banner:is([data-kind="depth"], [data-kind="zone"])[data-zone="forge"] { --fb-c: #ff9a4d; --zone-art: url(/art/ui-v4/banners/zone-forge.webp); }
  #game-frame > #feedback-banner:is([data-kind="depth"], [data-kind="zone"])[data-zone="core"] { --fb-c: #ffe08a; --zone-art: url(/art/ui-v4/banners/zone-core.webp); }
  #feedback-banner:is([data-kind="depth"], [data-kind="zone"]) .feedback-emblem { isolation: isolate; background: none; border: 0; }
  #feedback-banner:is([data-kind="depth"], [data-kind="zone"]) .feedback-emblem::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 7px;
    transform: rotate(45deg);
    border-radius: 9px;
    background: linear-gradient(135deg, #fffdf0 0%, var(--fb-c) 34%, color-mix(in srgb, var(--fb-c) 42%, #06130e) 100%);
    border: 1.5px solid color-mix(in srgb, var(--fb-c) 60%, #fff);
    box-shadow: 0 0 0 3px rgb(0 0 0 / .35), 0 0 18px -2px var(--fb-c), inset 0 2px 0 rgb(255 255 255 / .45);
  }
  .feedback-mark { font: 800 20px/1 var(--font-display); color: #fffdf3; padding-top: 2px; text-shadow: 0 1px 0 rgb(0 0 0 / .55), 0 0 6px rgb(0 0 0 / .45); }
  .feedback-kicker { font: 700 11px/1.2 var(--font-display); letter-spacing: .14em; color: var(--fb-c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Zone celebration: a taller, full-width plate with one light sweep (none in reduced-motion or power saving). */
  #game-frame > #feedback-banner[data-kind="zone"] {
    overflow: hidden;
    min-height: 86px;
    gap: 14px;
    padding: 12px 16px 12px 12px;
    border-width: 1.5px;
    background:
      radial-gradient(70% 160% at 0% 50%, color-mix(in srgb, var(--fb-c) 36%, transparent), transparent 64%),
      radial-gradient(60% 120% at 100% 0%, color-mix(in srgb, var(--fb-c) 18%, transparent), transparent 70%),
      linear-gradient(100deg, color-mix(in srgb, var(--fb-c) 14%, #163d2e), #0c2419);
    box-shadow: var(--sh-3), 0 0 36px -4px color-mix(in srgb, var(--fb-c) 75%, transparent), inset 0 1px 0 rgb(255 255 255 / .14);
  }
  /* The painted zone banner (dark left third) sits behind the copy on the right. */
  #game-frame > #feedback-banner[data-kind="zone"]:is([data-zone="geode"], [data-zone="forge"], [data-zone="core"]) {
    background:
      linear-gradient(90deg, rgb(8 26 19 / .97) 0%, rgb(8 26 19 / .82) 40%, rgb(8 26 19 / .2) 78%, transparent 100%),
      var(--zone-art) right center / auto 100% no-repeat,
      linear-gradient(100deg, color-mix(in srgb, var(--fb-c) 14%, #163d2e), #0c2419);
  }
  #feedback-banner[data-kind="zone"] .feedback-emblem { width: 60px; height: 60px; }
  #feedback-banner[data-kind="zone"] .feedback-emblem::before { inset: 8px; border-radius: 11px; }
  #feedback-banner[data-kind="zone"] .feedback-mark { font-size: 24px; }
  #feedback-banner[data-kind="zone"] .feedback-title { font-size: var(--fs-20); line-height: 1.2; }
  #feedback-banner[data-kind="zone"] .feedback-detail { font-size: var(--fs-13); color: var(--text-1); }
  #game-frame > #feedback-banner[data-kind="zone"]::after {
    content: '';
    position: absolute;
    inset: -2px auto -2px 0;
    width: 34%;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / .22), transparent);
    transform: translateX(-120%) skewX(-18deg);
    pointer-events: none;
  }
  #game-frame > #feedback-banner.is-visible[data-motion="full"][data-kind="zone"]::after { animation: dm-shine 1.4s var(--ease-in-out) .35s 1 both; }
  #feedback-banner.is-visible[data-motion="full"][data-kind="zone"] .feedback-emblem::before { animation: zone-gem 1.2s var(--ease-out) .1s 1 both; }
  @keyframes zone-gem { 0% { box-shadow: 0 0 0 3px rgb(0 0 0 / .35), 0 0 0 0 var(--fb-c); } 45% { box-shadow: 0 0 0 3px rgb(0 0 0 / .35), 0 0 30px 6px var(--fb-c); } 100% { box-shadow: 0 0 0 3px rgb(0 0 0 / .35), 0 0 18px -2px var(--fb-c); } }
  html:is(.reduce-motion, .low-quality) #game-frame > #feedback-banner[data-kind="zone"]::after { display: none; animation: none; }
  html.low-quality #feedback-banner[data-kind="zone"] .feedback-emblem::before { animation: none; }
  .feedback-banner.is-visible[data-motion="full"] { animation: banner-in .5s var(--ease-spring) both; }
  .feedback-banner.is-visible[data-motion="full"] .feedback-emblem { animation: emblem-in .6s var(--ease-spring) .05s both; }
  @keyframes banner-in { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
  @keyframes emblem-in { 0% { transform: scale(.4) rotate(-20deg); } 70% { transform: scale(1.12) rotate(4deg); } 100% { transform: none; } }
  .feedback-emblem {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--fb-c) 40%, #1a4434), #0e271d 75%);
    border: 1px solid color-mix(in srgb, var(--fb-c) 55%, transparent);
    color: var(--fb-c);
    font: 800 22px/1 var(--font-display);
  }
  .feedback-emblem img { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 3px 4px rgb(0 0 0 / .5)); }
  .feedback-copy { min-width: 0; display: grid; gap: 1px; }
  .feedback-title { font-size: var(--fs-15); font-weight: 800; color: var(--text-1); line-height: 1.3; }
  .feedback-detail { font-size: var(--fs-12); color: var(--text-2); line-height: 1.4; }
  .feedback-detail:empty { display: none; }
  /* Rare/collection drops show as a compact "+N" pill. */
  #game-frame > #feedback-banner:is([data-kind="rare"], [data-kind="collection"]) { right: auto; min-height: 0; padding: 6px 14px 6px 6px; border-radius: 999px; }
  #feedback-banner:is([data-kind="rare"], [data-kind="collection"]) .feedback-emblem { width: 38px; height: 38px; border-radius: 50%; }
  #feedback-banner:is([data-kind="rare"], [data-kind="collection"]) .feedback-emblem img { width: 30px; height: 30px; }
  #feedback-banner:is([data-kind="rare"], [data-kind="collection"]) .feedback-title { font: 800 18px/1 var(--font-display); color: var(--fb-c); }

  #coins.feedback-pulse, #bag-count.feedback-pulse { animation: number-pulse .65s var(--ease-spring); }
  @keyframes number-pulse {
    0% { transform: scale(1); }
    35% { transform: scale(1.22); color: #fff; text-shadow: 0 0 12px rgb(255 214 120 / .9); }
    100% { transform: scale(1); }
  }

  /* ───────────── Welcome back (offline settlement) ─────────────
     <dialog id="welcome-back" class="welcome-dialog">, markup in public/welcome-back.mjs. Same material as the
     buyout dialog: gold rim, dark jade plate, near-opaque scrim (the canvas keeps repainting underneath). */
  .welcome-dialog {
    width: min(380px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    margin: auto;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: var(--text-1);
    text-align: left;
    border: 2px solid transparent;
    border-radius: var(--r-xl);
    background:
      radial-gradient(120% 50% at 50% 0%, rgb(245 200 105 / .14), transparent 60%) padding-box,
      var(--noise) padding-box,
      linear-gradient(180deg, #17402f 0%, #10301f 40%, #0b2219 100%) padding-box,
      linear-gradient(180deg, var(--gold-rim) 0%, var(--gold-400) 30%, var(--gold-700) 70%, var(--gold-900) 100%) border-box;
    box-shadow: 0 0 0 1px rgb(0 0 0 / .7), 0 0 44px -8px rgb(245 190 80 / .45), 0 30px 80px -12px rgb(0 0 0 / .95);
  }
  .welcome-dialog[open] { animation: welcome-in .42s var(--ease-spring) both; }
  .welcome-dialog::backdrop { background: radial-gradient(90% 70% at 50% 45%, rgb(10 36 26 / .88), rgb(2 9 6 / .95)); }
  .welcome-dialog[open]::backdrop { animation: welcome-fade .3s ease-out both; }
  @keyframes welcome-in { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
  @keyframes welcome-fade { from { opacity: 0; } to { opacity: 1; } }
  .welcome-dialog :is(h2, p, ul) { margin: 0; }
  .welcome-header {
    position: relative;
    isolation: isolate;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 14px 18px 16px;
    text-align: center;
    border-bottom: 1px solid rgb(242 205 128 / .24);
  }
  .welcome-header::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    border-radius: calc(var(--r-xl) - 2px) calc(var(--r-xl) - 2px) 0 0;
    background:
      linear-gradient(180deg, rgb(13 36 27 / .3) 0%, rgb(15 44 33 / .8) 62%, #12382a 100%),
      var(--welcome-art, url(/art/premium/forest.jpg)) center 40% / cover no-repeat;
  }
  /* A new zone reached while away: its painted banner replaces the forest. */
  .welcome-header[data-zone="geode"] { --welcome-art: url(/art/ui-v4/banners/zone-geode.webp); }
  .welcome-header[data-zone="forge"] { --welcome-art: url(/art/ui-v4/banners/zone-forge.webp); }
  .welcome-header[data-zone="core"] { --welcome-art: url(/art/ui-v4/banners/zone-core.webp); }
  .welcome-kicker {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 3px 11px 3px 9px;
    border-radius: var(--r-pill);
    background: rgb(6 19 14 / .72);
    border: 1px solid var(--line-gold);
    font: 700 11px/1.2 var(--font-display);
    letter-spacing: .12em;
    color: var(--gold-200);
    white-space: nowrap;
  }
  .welcome-kicker .icon { width: 14px; height: 14px; }
  .welcome-close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    background: rgb(6 19 14 / .72);
    border: 1px solid var(--line-2);
    color: var(--text-2);
    box-shadow: 0 2px 0 rgb(0 0 0 / .4);
  }
  .welcome-close:active { transform: scale(.92); }
  .welcome-close .gi { width: 22px; height: 22px; }
  .welcome-emblem {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 32%, #2f6a50, #163b2c 75%);
    border: 2px solid var(--gold-300);
    box-shadow: 0 0 0 4px rgb(245 200 105 / .14), 0 0 28px rgb(245 190 80 / .42), inset 0 2px 0 rgb(255 255 255 / .16);
  }
  .welcome-emblem .gi { width: 44px; height: 44px; filter: drop-shadow(0 2px 3px rgb(0 0 0 / .5)); }
  .welcome-header h2 { font-size: 26px; font-weight: 800; line-height: 1.15; color: var(--text-1); text-shadow: 0 2px 10px rgb(0 0 0 / .7); }
  .welcome-header p { font-size: var(--fs-13); line-height: 1.5; color: var(--text-2); text-wrap: balance; }
  .welcome-body { display: grid; gap: 12px; padding: 14px 14px 14px; }
  .welcome-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--r-lg);
    background: radial-gradient(120% 140% at 100% 50%, rgb(245 200 105 / .16), transparent 60%), rgb(0 0 0 / .24);
    border: 1px solid var(--line-gold);
  }
  .welcome-total-label { font-size: var(--fs-13); font-weight: 700; color: var(--text-2); }
  .welcome-total strong { display: inline-flex; align-items: baseline; gap: 2px; font: 800 30px/1 var(--font-display); color: var(--gold-100); white-space: nowrap; text-shadow: 0 2px 10px rgb(0 0 0 / .5); }
  .welcome-plus { font-size: 22px; color: var(--gold-300); }
  .welcome-total small { margin-left: 4px; font: 700 13px/1 var(--font-ui); color: var(--text-3); }
  .welcome-cap { margin: 0; }
  .welcome-items { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 6px; }
  .welcome-item { display: grid; justify-items: center; gap: 4px; min-width: 0; }
  .welcome-item .item-tile { width: 100%; max-width: 72px; }
  .welcome-item .item-count { right: 3px; bottom: 4px; min-width: 0; padding: 1px 5px; font-size: 11px; color: var(--gold-50); }
  .welcome-item small { max-width: 100%; font-size: var(--fs-11); font-weight: 700; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .welcome-item.is-more .item-tile b { font: 800 18px/1 var(--font-display); color: var(--text-2); }
  .welcome-facts { border-radius: var(--r-lg); background: rgb(4 14 10 / .38); border: 1px solid var(--line-1); overflow: hidden; }
  .welcome-fact { min-height: 50px; padding: 8px 12px; gap: 10px; }
  .welcome-fact .list-icon { width: 32px; height: 32px; border-radius: 10px; }
  .welcome-fact .list-icon .gi { width: 24px; height: 24px; }
  .welcome-fact .list-title { font-size: var(--fs-14); font-weight: 700; }
  .welcome-fact .list-title b { font-family: var(--font-display); color: var(--gold-100); }
  .welcome-fact .list-sub { font-size: var(--fs-12); color: var(--text-3); }
  .welcome-fact.is-zone .list-icon { background: radial-gradient(circle at 40% 30%, color-mix(in srgb, var(--zone-c) 55%, #1d4535), #12301f 80%); border-color: color-mix(in srgb, var(--zone-c) 60%, transparent); }
  .welcome-fact.is-zone .list-title { color: color-mix(in srgb, var(--zone-c) 60%, var(--text-1)); }
  .welcome-fact.is-gold .list-icon { border-color: var(--line-gold-strong); }
  .welcome-header h2:focus { outline: none; }
  /* The return button stays reachable while long summaries scroll. */
  .welcome-actions { position: sticky; bottom: 0; z-index: 2; display: grid; gap: 8px; margin: 0 -14px -14px; padding: 14px 14px 14px; background: linear-gradient(180deg, rgb(11 34 25 / 0), #0b2219 26%); }
  .welcome-links { display: flex; gap: 8px; }
  .welcome-links .btn { flex: 1 1 0; min-width: 0; }
  @media (max-height: 640px) {
    .welcome-header { padding-block: 10px 12px; gap: 4px; }
    .welcome-emblem { width: 52px; height: 52px; }
    .welcome-emblem .gi { width: 36px; height: 36px; }
    .welcome-header h2 { font-size: 22px; }
    .welcome-body { gap: 10px; padding-block: 12px; }
    .welcome-total strong { font-size: 26px; }
  }

  /* ───────────── Compact heights ───────────── */
  @media (max-height: 640px) {
    .stage-header { padding: 8px var(--gutter) 8px; }
    #objective-button { min-height: 46px; padding: 4px 10px 6px 6px; }
    .objective-icon { width: 32px; height: 32px; }
    .objective-icon .gi { width: 24px; height: 24px; }
    .production-chip { min-width: 84px; padding: 4px 10px; }
    .assist-strip { margin-top: 8px; min-height: 64px; padding: 8px 8px 8px 12px; }
    #assist-button { height: 48px; min-width: 112px; }
    #game-nav { margin-top: 8px; }
    #game-nav .gi { width: 28px; height: 28px; }
    #sheet > header { min-height: 64px; padding-block: 9px; }
    .sheet-emblem { width: 40px; height: 40px; }
    .sheet-emblem .gi { width: 30px; height: 30px; }
    #sheet-title { font-size: var(--fs-20); }
    .scene-actions button { height: 44px; }
  }
  @media (max-width: 399px) { .game-brand { display: none; } }
  @media (max-width: 359px) {
    .game-header { gap: 6px; }
    .header-actions button { width: 42px; }
    .header-actions .gi { width: 24px; height: 24px; }
    .production-chip { min-width: 64px; }
    .header-actions .gi { width: 25px; height: 25px; }
    #coins { font-size: 16px; }
    .bag-hud { padding-right: 9px; }
    .production-chip { min-width: 78px; padding-inline: 9px; }
    #assist-button { min-width: 104px; padding: 0 12px 0 8px; font-size: var(--fs-14); }
  }

  /* Decorative loops pause while a panel covers the field and stop in power-saving mode. */
  #game-frame.panel-open > section:not(#sheet) *,
  #game-frame.panel-open > section:not(#sheet) *::before,
  #game-frame.panel-open > section:not(#sheet) *::after { animation-play-state: paused; }
  html.low-quality .live-dot::after, html.low-quality .objective-icon .gi, html.low-quality #game-nav i.dot, html.low-quality .bag-hud.has-new::after { animation: none; }

  /* Focus rings inside clipped containers draw inward. */
  #mine-canvas:focus-visible { outline: 3px solid var(--gold-200); outline-offset: -3px; border-radius: 20px; }
  #game-nav button:focus-visible { outline-offset: -2px; }
}
