/* layout — app shell, wallet HUD, page head, dock, bottom nav */
@layer layout {
  .app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100dvh; width: 100%; max-width: 520px; margin: 0 auto; overflow: hidden; }
  .board { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .tab-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 12px 16px; -webkit-overflow-scrolling: touch; }
  .tab-pane { display: none; }
  .tab-pane.active { display: block; }

  /* wallet HUD */
  .hud { position: relative; z-index: 8; flex: none; display: flex; align-items: center; gap: 8px; min-height: var(--hud-h); padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 6px; }
  .wallet { position: relative; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 999px; background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge); }
  .coin { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; color: #5a3d00; background: radial-gradient(circle at 35% 30%, #fff6c4, var(--dust) 55%, #e0a82a); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18), 0 0 14px rgba(255, 226, 122, .45); }
  .wallet-main { min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
  .dust-value { font-size: 24px; font-weight: 900; letter-spacing: -.01em; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
  .breakdown-wrap { position: static; }
  .wallet .rate { display: inline-flex; align-items: center; gap: 3px; margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--info-ink); position: relative; }
  .wallet .rate::after { content: ""; position: absolute; inset: -14px -10px; }
  .wallet .rate b { font-weight: 900; }
  .wallet .rate svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; transition: transform .2s var(--ease); }
  .breakdown-wrap.open .rate svg { transform: rotate(180deg); }
  .core-chip { flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px 0 8px; border-radius: 999px; font-size: 15px; font-weight: 900; color: var(--core-text); background: rgba(167, 139, 255, .16); box-shadow: inset 0 0 0 1.5px rgba(167, 139, 255, .45); }
  .core-chip svg { width: 16px; height: 16px; fill: currentColor; }

  /* page head */
  .page-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 2px 14px 8px; }
  .page-title { font-size: 20px; font-weight: 900; line-height: 1.1; }
  .page-kicker { display: block; font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--ink-3); }
  .page-ctx { margin-left: auto; display: flex; gap: 6px; }
  .ctx-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--ink-2); background: rgba(255, 255, 255, .07); }
  .ctx-chip svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
  .page-index { display: none; }

  /* action dock: the two verbs of the game, within thumb reach */
  .dock { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 12px 8px; }

  /* bottom navigation sits in normal flow, so it can never cover content */
  .tabs { position: relative; z-index: 7; flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px); background: linear-gradient(180deg, var(--plate), var(--plate-lo)); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(0, 0, 0, .25); }
  .tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 5px; border-radius: 14px; font-size: 12px; font-weight: 800; color: var(--ink-3); transition: color .15s, background .15s; }
  .tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .tab.active { color: var(--ink); background: rgba(255, 255, 255, .08); box-shadow: inset 0 -3px 0 var(--info); }
  .tab.active svg { stroke: var(--info-ink); filter: drop-shadow(0 0 6px rgba(92, 200, 255, .55)); }
  .badge { position: absolute; top: 2px; left: 50%; margin-left: 8px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; font-size: 11px; font-weight: 900; color: #fff; background: var(--bad); box-shadow: 0 0 0 2px var(--plate); }

  @media (min-width: 700px) {
    body { display: grid; place-items: center; }
    .app { height: min(920px, 95dvh); border-radius: 28px; background: rgba(11, 16, 32, .6); box-shadow: 0 0 0 1px var(--line), 0 40px 90px -30px rgba(0, 0, 0, .9); }
  }
}
