/* overlays — static bottom sheets, programmatic modals, toast, banner, flash, coin */
@layer overlays {
  .sheet-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: end center; background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
  .sheet { display: flex; flex-direction: column; width: 100%; max-width: 520px; max-height: 90dvh; padding: 8px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); border-radius: 26px 26px 0 0; background: linear-gradient(180deg, var(--plate-hi), var(--plate) 40%, var(--plate-lo)); box-shadow: inset 0 1px 0 var(--rim), var(--shadow-pop); overflow-y: auto; }
  .grabber { flex: none; width: 44px; height: 5px; margin: 2px auto 8px; border-radius: 999px; background: rgba(255, 255, 255, .22); }
  .sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 0 10px; }
  .sheet-head h2 { font-size: 20px; font-weight: 900; }
  .sheet-close { width: 40px; height: 40px; }
  @media (min-width: 700px) {
    .sheet-overlay { place-items: center; padding: 24px; }
    .sheet { border-radius: 26px; max-height: 84dvh; }
  }

  /* programmatic modal (protocol / relic / event / confirm / offline / import-export) */
  .overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); opacity: 0; transition: opacity .2s; }
  .overlay.show { opacity: 1; }
  .modal { width: 100%; max-width: 420px; max-height: 88dvh; overflow-y: auto; padding: 18px 16px 16px; border-radius: 24px; background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 var(--depth) 0 var(--edge), var(--shadow-pop); transform: translateY(14px) scale(.97); transition: transform .24s var(--ease); }
  .overlay.show .modal { transform: none; }
  .modal h2 { font-size: 20px; font-weight: 900; margin-bottom: 8px; }
  .modal-body { font-size: 14px; line-height: 1.65; color: var(--ink-2); }
  .modal-body p { margin: 0 0 8px; }
  .modal-body b { color: var(--ink); }
  .modal-actions { display: flex; gap: 10px; margin-top: 16px; }
  .modal-actions .btn { flex: 1; }
  .big-gain { font-size: 32px; font-weight: 900; text-align: center; color: var(--dust-ink); text-shadow: 0 2px 0 rgba(0, 0, 0, .4); }
  .save-area { display: block; width: 100%; min-height: 120px; margin-top: 8px; padding: 10px; border-radius: var(--r-md); border: 0; resize: vertical; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 1.5px var(--line); -webkit-user-select: text; user-select: text; }
  .import-error { margin-top: 6px; font-size: 13px; color: var(--bad-ink); }

  /* toast + unlock banner */
  .toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--dock-h) + env(safe-area-inset-bottom, 0px) + 20px); z-index: 95; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
  .toast { display: flex; align-items: center; gap: 10px; max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 16px; background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge), var(--shadow-pop); opacity: 0; transform: translateY(10px); transition: opacity .22s, transform .22s; }
  .toast.show { opacity: 1; transform: none; }
  .toast-icon { font-size: 22px; }
  .toast-main { min-width: 0; display: flex; flex-direction: column; }
  .toast-main b { font-size: 14px; font-weight: 900; }
  .toast-main small { font-size: 12px; line-height: 1.4; color: var(--ink-3); }
  .unlock-banner { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 50%; z-index: 96; display: flex; align-items: center; gap: 12px; width: min(92vw, 440px); padding: 10px 14px; border-radius: 18px; color: var(--hot-ink); background: linear-gradient(180deg, #ffd0a3, var(--hot)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 4px 0 var(--hot-edge), var(--shadow-pop); transform: translate(-50%, -150%); transition: transform .3s var(--ease); pointer-events: none; }
  .unlock-banner.show { transform: translate(-50%, 0); }
  .ub-icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; font-size: 24px; background: rgba(255, 255, 255, .45); }
  .ub-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
  .ub-main b { font-size: 15px; font-weight: 900; }
  .ub-main span { font-size: 12px; font-weight: 700; opacity: .8; }
  .ub-tier { flex: none; font-size: 22px; font-weight: 900; }
  .flash { position: fixed; inset: 0; z-index: 99; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 45%, rgba(255, 190, 120, .55), rgba(255, 138, 61, .15) 45%, transparent 70%); }
  .flash.go { animation: flash 1s ease-out; }
  .fly-coin { position: fixed; z-index: 98; pointer-events: none; font-size: 16px; color: var(--dust); text-shadow: 0 0 10px rgba(255, 226, 122, .9); }
  body.modal-open { overflow: hidden; }

  /* archive */
  .archive-summary { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
  .asum { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-radius: var(--r-md); text-align: center; background: rgba(255, 255, 255, .07); }
  .asum span { font-size: 12px; color: var(--ink-3); }
  .asum b { font-size: 15px; font-weight: 900; }
  .archive-tabs { flex: none; margin-bottom: 10px; }
  .archive-panes { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .archive-pane { display: none; }
  .archive-pane.active { display: block; }
  .seg-filter { margin-top: 8px; }
  .ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ach { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-md); background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1.5px var(--line); opacity: .55; }
  .ach.unlocked { opacity: 1; background: rgba(255, 226, 122, .1); box-shadow: inset 0 0 0 1.5px rgba(255, 226, 122, .5); }
  .ach-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; font-size: 18px; background: rgba(255, 255, 255, .1); }
  .ach-main { min-width: 0; display: flex; flex-direction: column; }
  .ach-main b { font-size: 13px; font-weight: 800; }
  .ach-main small { font-size: 12px; line-height: 1.35; color: var(--ink-3); }
  .stat-groups { display: grid; gap: 10px; }
  .stat-group { padding: 10px 12px; border-radius: var(--r-md); background: rgba(255, 255, 255, .05); }
  .stat-group h4, .archive-codex h3 { margin: 0 0 6px; font-size: 13px; font-weight: 900; letter-spacing: .06em; color: var(--info-ink); }
  .archive-codex h3 { margin-top: 14px; } .archive-codex h3:first-child { margin-top: 0; }
  .stat-list { display: grid; gap: 5px; }
  .stat-list li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink-3); }
  .stat-list li > span { flex: none; max-width: 52%; }
  .stat-list li b { min-width: 0; text-align: right; font-weight: 700; overflow-wrap: anywhere; color: var(--ink); }
  .archive-codex .stat-list li { flex-direction: column; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
  .archive-codex .stat-list li > span { max-width: none; font-weight: 800; color: var(--ink-2); }
  .archive-codex .stat-list li b { text-align: left; font-weight: 600; color: var(--ink-3); }
  /* prestige */
  .prestige-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
  .prestige-hero p { font-size: 13px; line-height: 1.6; color: var(--ink-2); }
  .prestige-orb { flex: none; width: 56px; height: 56px; border-radius: 50%; background: radial-gradient(circle at 34% 28%, #efe8ff, var(--core) 55%, #4a2fb0); box-shadow: 0 0 22px rgba(167, 139, 255, .65), inset -6px -8px 12px rgba(40, 10, 110, .5); }
  .prestige-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .pstat { display: flex; flex-direction: column; gap: 2px; padding: 10px 6px; border-radius: var(--r-md); text-align: center; background: rgba(255, 255, 255, .07); }
  .pstat span { font-size: 12px; color: var(--ink-3); }
  .pstat b { font-size: 18px; font-weight: 900; }

  /* help */
  .help-body, .settings-body { overflow-y: auto; }
  .help-body h3 { margin: 14px 0 4px; font-size: 14px; font-weight: 900; color: var(--info-ink); }
  .help-body h3:first-child { margin-top: 0; }
  .help-body p { font-size: 13px; line-height: 1.7; color: var(--ink-2); }
  .help-body b { color: var(--dust-ink); }
  .key-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
  .key-grid span { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-2); }

  /* settings */
  .set-group { margin-top: 14px; }
  .set-group:first-child { margin-top: 0; }
  .set-group h3 { margin-bottom: 6px; font-size: 12px; font-weight: 800; letter-spacing: .12em; color: var(--ink-3); }
  .set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; margin-bottom: 8px; padding: 0 14px; border-radius: var(--r-md); font-size: 15px; font-weight: 700; background: linear-gradient(180deg, var(--plate-hi), var(--plate)); box-shadow: inset 0 1px 0 var(--rim), 0 3px 0 var(--edge); }
  .set-row:active { transform: translateY(3px); box-shadow: inset 0 1px 0 var(--rim), 0 0 0 var(--edge); }
  .set-row b { font-weight: 800; color: var(--info-ink); }
  .save-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
}
