/* Wyrd — app.css : layout and components, phone first */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--body); font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--display); text-wrap: balance; letter-spacing: .01em; }
a { color: var(--accent); }
small { font-size: 12px; }
.num, .tile .val, .amts, .amt { font-variant-numeric: tabular-nums; }

.screen {
  max-width: 560px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
body:not(.has-tabs) .screen { padding-bottom: 32px; }

/* header */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 6px 0 12px; }
.brand { font-size: 26px; font-weight: 700; }
.rank-line { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: none; border: 0; padding: 6px 0; font-size: 14px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tiles.two { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 9px; min-width: 0; }
.tile .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.tile .val { font-family: var(--display); font-size: 21px; font-weight: 700; margin-top: 3px; line-height: 1.1; overflow-wrap: anywhere; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tile.hero { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tile.hero .lbl, .tile.hero .sub { color: var(--accent-ink); opacity: .82; }
.tile.treasure { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-ink); }
.tile.treasure .lbl, .tile.treasure .sub { color: var(--gold-ink); opacity: .85; }
.tile.treasure.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.tile.treasure.bad .lbl, .tile.treasure.bad .sub { color: var(--bad); }

/* sections, cards, groups */
.section { margin-top: 20px; }
.section-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0 0 8px; font-family: var(--body); }
.section-title .right { float: right; font-weight: 500; text-transform: none; letter-spacing: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card.gold { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-ink); }
.card.soft { background: var(--surface-2); }
.card p { margin: 6px 0 0; }
.card h3 { font-size: 16px; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.group > * + * { border-top: 1px solid var(--line); }
.empty { padding: 16px 14px; color: var(--muted); }
.muted { color: var(--muted); }
.lead { font-size: 16px; }
.center { text-align: center; }

/* rows (envelopes, quests, lists) */
.row { display: flex; align-items: center; gap: 10px; }
.row.gap { gap: 8px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }

.env { }
.env-main { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 14px; color: inherit; }
.env.closed .env-main { opacity: .72; }
.line1 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.amts { white-space: nowrap; color: var(--muted); font-size: 13px; }
.amts b { color: var(--fg); font-weight: 600; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.good i, .env.paid .bar i, .env.closed .bar i { background: var(--good); }
.bar.gold i { background: var(--gold); }
.bar.bad i, .env.over .bar i { background: var(--bad); }
.bar.hp i { background: var(--bad); }
.env-form { padding: 4px 14px 14px; background: var(--surface-2); display: grid; gap: 8px; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill.rare { background: var(--rare-soft); color: var(--rare); }
.pill.muted { background: var(--surface-2); color: var(--muted); }

.quest { display: flex; gap: 12px; padding: 11px 14px; align-items: flex-start; }
.quest .chk { flex: 0 0 auto; width: 24px; height: 24px; border: 2px solid var(--line); border-radius: 7px; background: var(--surface); display: grid; place-items: center; font-size: 13px; color: #fff; margin-top: 1px; padding: 0; }
.quest.done .chk { background: var(--good); border-color: var(--good); }
.quest .q-main { flex: 1 1 auto; min-width: 0; text-align: left; background: none; border: 0; padding: 0; color: inherit; }
.quest .q-title { font-weight: 600; overflow-wrap: anywhere; }
.quest.done .q-title { text-decoration: line-through; color: var(--muted); }
.quest .q-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.quest.overdue .q-meta .when { color: var(--warn); font-weight: 600; }
.quest .q-money { flex: 0 0 auto; background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 999px; padding: 4px 10px; font-weight: 600; font-size: 13px; }

.item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; align-items: center; }
.item .what { min-width: 0; flex: 1; }
.item .what small { display: block; color: var(--muted); }
.item .amt { white-space: nowrap; font-weight: 600; }
.item .del { border: 0; background: none; color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 12px; }
.item .del.arm { color: var(--bad); font-weight: 600; }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--radius-sm); padding: 9px 13px; font-weight: 600; font-size: 14px; line-height: 1.2; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.gold { background: var(--gold-soft); color: var(--gold-ink); border-color: var(--gold); }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.wide { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 8px; font-size: 18px; line-height: 1; display: inline-grid; place-items: center; }
.icon-btn:focus-visible, .btn:focus-visible, .input:focus, .tab:focus-visible, .chip:focus-visible, .chk:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.input { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%; min-width: 0; }
.input.big { font-size: 28px; font-family: var(--display); font-weight: 700; padding: 10px 12px; }
.field { display: grid; gap: 5px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 11px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.chip small { color: var(--muted); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.on small { color: inherit; opacity: .8; }
.seg { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.seg .chip { justify-content: center; border-radius: var(--radius-sm); }
.banner { display: block; width: 100%; text-align: left; border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; }
.banner.gold { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-ink); }
.banner.warn { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tab { background: none; border: 0; color: var(--muted); display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; min-height: var(--tabs-h); }
.tab.active { color: var(--accent); }
.tab span { letter-spacing: .02em; }

/* floating log button */
.fab {
  position: fixed; z-index: 21;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--gold); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: var(--shadow); display: grid; place-items: center;
}

/* bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(5, 8, 12, 0); transition: background .22s ease; }
.sheet-backdrop.in { background: rgba(5, 8, 12, .5); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto;
  background: var(--surface); color: var(--fg); border-radius: 20px 20px 0 0;
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
  max-width: 600px; margin: 0 auto;
}
.sheet-backdrop.in .sheet { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { font-size: 18px; }
.sheet-body { display: grid; gap: 12px; }
.sheet-body form { display: grid; gap: 12px; }
.confirm p { margin: 0 0 6px; font-size: 16px; }

/* toasts */
#toasts { position: fixed; left: 0; right: 0; z-index: 28; display: grid; justify-items: center; gap: 6px; pointer-events: none;
  bottom: calc(var(--tabs-h) + 20px + env(safe-area-inset-bottom, 0px)); padding: 0 16px; }
.toast { background: var(--fg); color: var(--bg); border-radius: 999px; padding: 9px 15px; font-size: 14px; font-weight: 500; max-width: 100%; text-align: center;
  opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; box-shadow: var(--shadow); }
.toast.in { opacity: 1; transform: none; }
.toast.gold { background: var(--gold); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

/* oracle chart */
.chart { width: 100%; height: auto; display: block; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .fill { fill: var(--accent); opacity: .12; }
.chart .zero { stroke: var(--bad); stroke-dasharray: 4 4; stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .dot { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--body); }

/* achievements */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.badge { border: 1px solid var(--line); border-radius: 12px; padding: 10px 9px; background: var(--surface-2); min-width: 0; }
.badge .sig { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; background: var(--line); color: var(--muted); margin-bottom: 7px; }
.badge .bn { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
.badge .bh { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.badge.on { background: var(--surface); }
.badge.on.rarity-common { border-color: var(--accent); } .badge.on.rarity-common .sig { background: var(--accent); color: var(--accent-ink); }
.badge.on.rarity-uncommon { border-color: var(--good); } .badge.on.rarity-uncommon .sig { background: var(--good); color: #fff; }
.badge.on.rarity-rare { border-color: var(--rare); } .badge.on.rarity-rare .sig { background: var(--rare); color: #fff; }
.badge.on.rarity-legendary { border-color: var(--gold); background: var(--gold-soft); } .badge.on.rarity-legendary .sig { background: var(--gold); color: #fff; }
.badge-card { text-align: center; padding: 10px 4px 4px; display: grid; gap: 8px; justify-items: center; }
.badge-sigil { width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-size: 40px; font-weight: 700; color: #fff; background: var(--accent); }
.rarity-uncommon .badge-sigil { background: var(--good); } .rarity-rare .badge-sigil { background: var(--rare); } .rarity-legendary .badge-sigil { background: var(--gold); }
.badge-kicker { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.badge-name { font-size: 24px; }
.badge-how { margin: 0; color: var(--muted); }

/* xp float */
.xp-float { position: fixed; z-index: 45; right: max(22px, env(safe-area-inset-right, 0px)); top: calc(96px + env(safe-area-inset-top, 0px)); font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--gold); opacity: 0; transform: translateY(0); pointer-events: none; text-shadow: 0 1px 0 var(--surface); }
.xp-float.neg { color: var(--muted); }
.xp-float.go { opacity: 1; transform: translateY(-48px); transition: transform 1.4s cubic-bezier(.2, .7, .3, 1), opacity .3s; }

/* wizard */
.steps { display: flex; gap: 6px; margin: 4px 0 14px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--gold); }
.wizard h1 { font-size: 24px; margin-bottom: 6px; }
.wizard .lead { color: var(--muted); margin: 0 0 14px; }
.wizard .nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; }
.list-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; }
.list-row .input { padding: 7px 9px; }
.list-row .w-amt { width: 92px; flex: 0 0 92px; }
.list-row .w-day { width: 72px; flex: 0 0 72px; }

details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
hr.rune { border: 0; height: 1px; background: var(--line); margin: 18px 0; }
@media (min-width: 560px) { .tiles { gap: 10px; } }
