/* =====================================================================
   Hearthlight Ledger — see LOOKS.md. Tokens first; components read only tokens.
   ===================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  /* surfaces — walnut & umber */
  --bg: #15110d; --bg-2: #1f1913; --bg-3: #2a221a; --bg-4: #352b21;
  --line: #3b3026; --line-2: #54443a;
  /* ink — parchment */
  --ink: #f1e6d2; --ink-dim: #b9a98f; --ink-faint: #7f7160;
  /* accents */
  --brass: #d8aa5c; --brass-hi: #f3cf85; --brass-lo: #8a6a33;
  --ember: #e8793a; --ember-hi: #ffb067; --ember-lo: #a34a1c;
  --moss: #93c25c; --moss-lo: #4f7a2c;
  --blood: #df5a4e; --blood-lo: #7a2a22;
  --mana: #72a9e0; --violet: #b994ec; --amber: #e7a53a;
  /* type */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* shape */
  --r-sm: 7px; --r: 11px; --r-lg: 16px;
  --shadow: 0 1px 0 rgba(255, 230, 190, .04) inset, 0 6px 18px rgba(0, 0, 0, .35);
  --glow-ember: 0 0 0 1px var(--ember), 0 0 22px rgba(232, 121, 58, .35);
  /* day-cycle sky (body[data-phase] overrides) */
  --sky-a: #3a2430; --sky-b: #1f1913;
  /* legacy aliases used by inline styles in tab code */
  --text: var(--ink); --dim: var(--ink-dim); --border: var(--line);
  --green: var(--moss); --green-dark: var(--moss-lo); --red: var(--blood);
  --gold: var(--brass-hi); --accent: var(--mana); --blue: var(--mana); --bg2: var(--bg-2); --bg3: var(--bg-3);
}
body[data-phase="Morning"] { --sky-a: #4a2c3a; --sky-b: #2a1f1d; }
body[data-phase="Noon"]    { --sky-a: #4a3a1c; --sky-b: #2a2116; }
body[data-phase="Evening"] { --sky-a: #5a2e18; --sky-b: #2a1a12; }
body[data-phase="Night"]   { --sky-a: #1c2346; --sky-b: #14131c; }

html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(216, 170, 92, .06), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(232, 121, 58, .05), transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font-ui);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--brass-lo); color: var(--ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
#app { display: flex; height: 100vh; height: 100dvh; }

h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: .01em; color: var(--ink); }
h2 { font-size: 26px; line-height: 1.1; }
h3 { font-size: 17px; color: var(--brass-hi); }
h3.section {
  margin: 20px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-faint); display: flex; align-items: center; gap: 10px;
}
h3.section::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); }
.subtitle { color: var(--ink-dim); margin-bottom: 12px; font-size: 13px; }

/* ---------- Medallion: the one frame every icon sits in ---------- */
.medallion {
  --size: 40px;
  position: relative; flex: none; width: var(--size); height: var(--size); border-radius: 50%;
  display: grid; place-items: center; font-size: calc(var(--size) * .5); line-height: 1;
  background: radial-gradient(circle at 35% 30%, var(--bg-4), var(--bg) 75%);
  box-shadow: 0 0 0 1.5px var(--brass-lo), 0 0 0 3px var(--bg), 0 0 0 4px rgba(216, 170, 92, .25), 0 4px 10px rgba(0, 0, 0, .4);
}
.medallion > span { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }
.medallion.sm { --size: 26px; box-shadow: 0 0 0 1px var(--brass-lo); }
.medallion.lg { --size: 64px; }
.medallion.xl { --size: 96px; }
/* XP ring: any medallion inside an element carrying --frac */
.hero .medallion::before, .skill-card .medallion::before {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(var(--brass-hi) calc(var(--frac, 0) * 360deg), rgba(216, 170, 92, .12) 0);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 3px), #000 calc(50% - 2px));
          mask: radial-gradient(circle, transparent calc(50% - 3px), #000 calc(50% - 2px));
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 236px; min-width: 236px; overflow-y: auto; padding: 0 10px 28px;
  background: linear-gradient(180deg, #1c1611, #15110d);
  border-right: 1px solid var(--line);
  box-shadow: inset -1px 0 0 rgba(255, 230, 190, .03);
}
.brand {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center;
  padding: 18px 8px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2; background: #1c1611;
}
.brand-mark {
  grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-size: 20px; color: var(--bg); background: radial-gradient(circle at 35% 30%, var(--brass-hi), var(--brass-lo));
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--brass-lo);
}
.brand-name { font-family: var(--font-display); font-size: 19px; font-weight: 700; line-height: 1; }
.brand-sub { font-size: 10.5px; text-transform: uppercase; letter-spacing: .18em; color: var(--brass); }
.nav-group { margin-top: 14px; }
.nav-group-label {
  padding: 4px 10px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--ink-faint);
}
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 10px; margin: 1px 0; background: none; border: 0; border-radius: var(--r-sm);
  color: var(--ink-dim); font: inherit; font-size: 13.5px; cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-icon {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center; font-size: 15px; border-radius: 8px;
  background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line);
}
.nav-item:hover { background: rgba(255, 230, 190, .04); color: var(--ink); }
.nav-item.active { background: linear-gradient(90deg, rgba(216, 170, 92, .16), rgba(216, 170, 92, .03)); color: var(--ink); }
.nav-item.active .nav-icon { background: var(--bg-4); box-shadow: inset 0 0 0 1px var(--brass); }
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brass);
}
.nav-item .lvl {
  margin-left: auto; min-width: 26px; text-align: center; font-size: 11.5px; font-weight: 600;
  color: var(--brass-hi); background: rgba(216, 170, 92, .08); border-radius: 20px; padding: 1px 6px;
}
/* XP sliver under each skill entry */
.nav-item.skill::after {
  content: ''; position: absolute; left: 48px; right: 10px; bottom: 2px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--moss) calc(var(--frac, 0) * 100%), rgba(255, 230, 190, .05) 0);
  opacity: .7;
}
.nav-item.flare { animation: flare 1.4s ease-out; }
@keyframes flare {
  0% { background: rgba(243, 207, 133, .45); box-shadow: 0 0 24px rgba(243, 207, 133, .5); }
  100% { background: transparent; box-shadow: none; }
}
[data-tab="developer"] { opacity: .6; }

/* ---------- Topbar: sky band + the "now" bar ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar {
  position: relative; padding: 10px 20px 12px;
  background: linear-gradient(180deg, var(--sky-a), var(--sky-b));
  border-bottom: 1px solid var(--line);
  transition: background 2s;
}
#topbar::after { /* horizon line */
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass-lo), transparent);
}
#status { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.icon-btn {
  display: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line-2);
  background: rgba(0, 0, 0, .25); color: var(--ink); font-size: 17px; cursor: pointer;
}
.stat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 20px;
  background: rgba(10, 8, 6, .35); border: 1px solid rgba(255, 230, 190, .08); font-size: 13px; white-space: nowrap;
}
.stat-chip[hidden] { display: none; }
.stat-chip.gold b { color: var(--brass-hi); font-family: var(--font-display); font-size: 15px; }
.stat-chip.phase { color: var(--ink-dim); }
.stat-chip.bump { animation: bump .45s cubic-bezier(.3, 1.6, .5, 1); }
.stat-chip.dip { animation: dip .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.14); box-shadow: 0 0 18px rgba(243, 207, 133, .45); } }
@keyframes dip { 40% { transform: translateY(2px); filter: brightness(.8); } }
.dev-badge { margin-left: auto; background: var(--amber); color: var(--bg); font-weight: 700;
  border-radius: 20px; padding: 2px 10px; font-size: 12px; }
.dev-badge[hidden] { display: none; }
.mini-bar {
  display: inline-block; width: 84px; height: 7px; background: rgba(0, 0, 0, .55);
  border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 230, 190, .06);
}
.fill { display: block; height: 100%; width: 0; background: var(--moss); border-radius: inherit; transition: width .2s linear; }
.fill.red { background: linear-gradient(90deg, var(--blood-lo), var(--blood)); }
.fill.blue { background: linear-gradient(90deg, #355d8a, var(--mana)); }
.fill.warnfill { background: linear-gradient(90deg, var(--ember-lo), var(--amber)); }

#action-bar {
  position: relative; height: 40px; border-radius: 12px; overflow: hidden;
  background: rgba(8, 6, 4, .6); box-shadow: inset 0 0 0 1px rgba(255, 230, 190, .08), inset 0 2px 6px rgba(0, 0, 0, .5);
}
#action-fill {
  position: absolute; inset: 0; width: 0; transition: width .1s linear;
  background: linear-gradient(90deg, var(--ember-lo), var(--ember) 70%, var(--ember-hi));
  box-shadow: 0 0 18px rgba(232, 121, 58, .45);
}
#action-bar.running #action-fill::after { /* travelling sheen */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 240, 210, .28) 50%, transparent 70%);
  background-size: 220% 100%; animation: sheen 1.6s linear infinite;
}
@keyframes sheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }
#action-bar.pulse { animation: pulse .5s ease-out; }
@keyframes pulse { 0% { box-shadow: inset 0 0 0 1px var(--ember-hi), 0 0 0 0 rgba(255, 176, 103, .6); }
  100% { box-shadow: inset 0 0 0 1px rgba(255, 230, 190, .08), 0 0 0 10px rgba(255, 176, 103, 0); } }
#action-label-wrap {
  position: relative; display: flex; align-items: center; gap: 10px; height: 100%; padding: 0 8px;
  color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); font-size: 14px; font-weight: 600;
}
#action-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#action-bar:not(.running) #action-label { color: var(--ink-faint); font-weight: 400; }
#action-time { font-family: var(--font-display); font-size: 16px; color: var(--ink); }

/* ---------- Panel ---------- */
#panel { flex: 1; overflow-y: auto; padding: 22px 26px 40px; }
#panel > * { max-width: 1280px; }

/* Hero: medallion + title + XP */
.skill-head { margin-bottom: 16px; }
.hero { display: flex; align-items: center; gap: 18px; margin: 2px 0 12px; }
.hero .medallion.lg { margin: 6px; }
.hero-body { flex: 1; min-width: 0; max-width: 560px; }
.hero-title { display: flex; align-items: baseline; gap: 12px; }
.lvl-badge {
  font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--bg);
  background: linear-gradient(180deg, var(--brass-hi), var(--brass)); padding: 1px 10px; border-radius: 20px;
}
.xpbar {
  height: 9px; margin: 8px 0 5px; border-radius: 8px; overflow: hidden;
  background: rgba(0, 0, 0, .45); box-shadow: inset 0 0 0 1px rgba(255, 230, 190, .06);
}
.xpbar .fill { background: linear-gradient(90deg, var(--moss-lo), var(--moss)); box-shadow: 0 0 10px rgba(147, 194, 92, .4); }
.hero-meta { font-size: 12.5px; color: var(--ink-dim); }
/* Explanations: one line until clicked */
.about {
  max-width: 760px; font-size: 13px; color: var(--ink-dim); margin: 0 0 8px; padding-left: 12px; cursor: pointer;
  border-left: 2px solid var(--line-2);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden;
}
.about:hover { color: var(--ink); border-left-color: var(--brass-lo); }
.about.open { -webkit-line-clamp: unset; display: block; border-left-color: var(--brass); }
.skill-head > .subtitle { /* live status lines in the head */
  display: inline-block; margin: 0 6px 8px 0; padding: 4px 11px; border-radius: 20px; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line);
}

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
  padding: 14px 14px 16px; border-radius: var(--r); cursor: pointer;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s, box-shadow .2s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card:active { transform: translateY(0) scale(.99); }
.card.active { border-color: var(--ember); box-shadow: var(--glow-ember); }
.card.active::after { /* per-card progress, synced by the shell tick via --p */
  content: ''; position: absolute; left: 0; bottom: 0; height: 4px; width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, var(--ember), var(--ember-hi)); box-shadow: 0 0 10px var(--ember);
}
.card.locked { cursor: not-allowed; background: var(--bg-2); }
.card.locked:hover { transform: none; }
.card.locked > *:not(.req) { opacity: .45; }
.card.locked .icon { filter: grayscale(1); }
.card.locked::before { content: '🔒'; position: absolute; top: 10px; right: 12px; font-size: 13px; opacity: .8; }
.card .icon {
  width: 46px; height: 46px; margin-bottom: 6px; display: grid; place-items: center; font-size: 24px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bg-4), var(--bg) 75%);
  box-shadow: 0 0 0 1.5px var(--brass-lo), 0 0 0 3px var(--bg-2), 0 0 0 4px rgba(216, 170, 92, .2);
}
.card.active .icon { box-shadow: 0 0 0 1.5px var(--ember), 0 0 0 3px var(--bg-2), 0 0 14px rgba(232, 121, 58, .5); animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-2px); } }
.card .name { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin: 2px 0; color: var(--ink); }
.card .meta { font-size: 12.5px; color: var(--ink-dim); }
.card .req {
  align-self: flex-start; margin-top: 6px; font-size: 11.5px; color: var(--brass); padding: 1px 9px;
  border-radius: 20px; border: 1px solid var(--brass-lo); background: rgba(216, 170, 92, .06);
}
.card .meta.cta {
  order: 99; align-self: flex-start; margin-top: 10px; padding: 3px 11px; border-radius: 20px;
  font-size: 12px; color: var(--ink); background: var(--bg-4); border: 1px solid var(--line-2);
  opacity: .7; transition: opacity .15s;
}
.card:hover .meta.cta, .card.active .meta.cta { opacity: 1; }
.card.active .meta.cta { background: var(--ember-lo); border-color: var(--ember); }
.bar { height: 7px; background: rgba(0, 0, 0, .45); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.bar .fill { background: linear-gradient(90deg, var(--moss-lo), var(--moss)); }

/* Levels ledger */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 720px; margin-bottom: 4px; }
.stat {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; padding: 12px 16px;
  border-radius: var(--r); background: linear-gradient(180deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.stat-icon { grid-row: span 2; font-size: 24px; }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--brass-hi); line-height: 1.1; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-faint); }
.card-grid.skills { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.skill-card { flex-direction: row; align-items: center; gap: 14px; padding: 14px 16px; }
.skill-card .medallion { --size: 46px; margin: 4px; }
.skill-card-body { flex: 1; min-width: 0; }
.skill-card .name { margin: 0; }
.skill-card .bar { margin-top: 6px; }
.skill-card-lvl { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--brass-hi); min-width: 34px; text-align: right; }
.training-tag {
  position: absolute; top: 8px; right: 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ember-hi);
}

/* ---------- Rows, buttons, pills ---------- */
.item-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 8px;
  border-radius: var(--r); background: linear-gradient(180deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--line);
}
.item-row .icon {
  width: 38px; height: 38px; display: grid; place-items: center; font-size: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bg-4), var(--bg) 75%); box-shadow: 0 0 0 1.5px var(--brass-lo);
}
.item-row .qty { color: var(--brass-hi); font-weight: 700; }
.item-row .grow { flex: 1; min-width: 140px; }
.item-row .price { color: var(--ink-dim); font-size: 12px; }
button.btn {
  background: linear-gradient(180deg, var(--bg-4), var(--bg-3)); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 6px 12px; font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 230, 190, .05) inset, 0 2px 4px rgba(0, 0, 0, .3);
  transition: transform .08s, border-color .15s, filter .15s;
}
button.btn:hover { border-color: var(--brass-lo); filter: brightness(1.1); }
button.btn:active { transform: translateY(1px); }
button.btn.primary { background: linear-gradient(180deg, var(--ember), var(--ember-lo)); border-color: var(--ember); color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .4); }
button.btn.danger { background: linear-gradient(180deg, var(--blood), var(--blood-lo)); border-color: var(--blood); color: #fff; }
button.btn.active { background: linear-gradient(180deg, var(--moss), var(--moss-lo)); border-color: var(--moss); color: #fff; }
button.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; transform: none; }
input, select {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 9px; font: inherit; font-size: 13px;
}
input:focus, select:focus { outline: 2px solid var(--brass-lo); outline-offset: 1px; }
.dev-row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.pill { display: inline-block; background: var(--bg-3); border: 1px solid var(--line); border-radius: 20px; padding: 2px 11px; font-size: 12px; color: var(--ink-dim); }
.pill.warn { color: var(--amber); border-color: rgba(231, 165, 58, .5); background: rgba(231, 165, 58, .08); }
.help-badge { margin-left: 8px; font-size: 12px; color: var(--mana); cursor: help; border: 1px solid var(--line-2); border-radius: 20px; padding: 0 8px; }

/* ---------- Toasts: loot slips ---------- */
#toasts { position: fixed; left: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px; max-width: 380px;
  background: linear-gradient(180deg, var(--bg-4), var(--bg-3)); color: var(--ink);
  border: 1px solid var(--line-2); border-left: 3px solid var(--moss); border-radius: 10px; padding: 7px 12px;
  font-size: 13px; box-shadow: 0 8px 22px rgba(0, 0, 0, .5); animation: slip .28s cubic-bezier(.2, 1.4, .5, 1);
}
.toast b { color: var(--moss); }
.toast-icon { font-size: 18px; }
.toast.levelup { border-left-color: var(--brass-hi); }
.toast.warn { border-left-color: var(--blood); }
@keyframes slip { from { transform: translateX(-24px); opacity: 0; } }

/* ---------- FX layer ---------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 900; }
.floater {
  position: fixed; transform: translate(-50%, -50%); display: flex; gap: 8px; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: 17px; text-shadow: 0 2px 6px rgba(0, 0, 0, .8);
  animation: rise 1.25s ease-out forwards;
}
.floater.small { font-size: 14px; }
.gain.xp { color: var(--moss); }
.gain.item { color: var(--ink); }
.gain.gold { color: var(--brass-hi); }
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}
.levelup-seal {
  position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  animation: seal 2.2s cubic-bezier(.2, 1.3, .4, 1) forwards;
}
.levelup-seal .medallion.xl { font-size: 48px; box-shadow: 0 0 0 3px var(--brass-hi), 0 0 0 7px var(--bg), 0 0 0 9px var(--brass), 0 0 60px rgba(243, 207, 133, .6); }
.seal-rays {
  position: absolute; top: 48px; left: 50%; width: 320px; height: 320px; margin: -160px 0 0 -160px; border-radius: 50%;
  background: repeating-conic-gradient(rgba(243, 207, 133, .22) 0 8deg, transparent 8deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%); mask: radial-gradient(circle, #000 20%, transparent 68%);
  animation: spin 6s linear infinite;
}
.seal-text { text-align: center; padding: 8px 22px; border-radius: 12px; background: rgba(21, 17, 13, .85); border: 1px solid var(--brass-lo); }
.seal-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .3em; color: var(--brass); }
.seal-level { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--brass-hi); }
@keyframes seal {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(.5); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  22% { transform: translate(-50%, -50%) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(.96); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .levelup-seal { animation: none; }
}

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(8, 6, 4, .72); z-index: 100; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal {
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 24px; width: min(480px, 92vw); max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  animation: slip .25s ease-out;
}
.modal h3 { margin-bottom: 10px; font-size: 20px; }
.modal ul { margin: 10px 0 14px 18px; }

/* ---------- Misc components (kept from Phase 18–20, retokened) ---------- */
.level-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.item-tip {
  position: fixed; z-index: 1000; max-width: 270px; pointer-events: none;
  background: linear-gradient(180deg, var(--bg-4), var(--bg-3)); border: 1px solid var(--brass-lo); border-radius: 10px;
  padding: 9px 11px; font-size: 12px; color: var(--ink); box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
}
.item-tip[hidden] { display: none; }
.item-tip .tip-head { display: flex; align-items: center; gap: 6px; font-family: var(--font-display); font-size: 15px; margin-bottom: 4px; }
.item-tip .tip-icon { font-size: 18px; }
.item-tip .tip-desc { margin-bottom: 5px; }
.item-tip .tip-row { color: var(--ink-dim); margin-top: 2px; }
.item-tip .tip-k { color: var(--ink); }
.item-tip .tip-effect { margin-top: 5px; color: var(--moss); }
.tool-row { margin: 0 0 14px; font-size: 13px; }
.tool-row .tool-eq, .tool-row .tool-empty {
  display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 20px; padding: 3px 12px; cursor: help;
}
.tool-row .tool-eq { border-color: var(--brass-lo); }
.tool-row .tool-icon { font-size: 16px; }
.tool-row .tool-empty { color: var(--ink-faint); }
.hud-chips { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hud-chips .chip { background: rgba(10, 8, 6, .35); border: 1px solid rgba(255, 230, 190, .08); border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.hud-chips .chip.buff { border-color: var(--moss-lo); color: var(--moss); }
.hud-chips .chip.eta { display: none; } /* the action bar already shows the countdown */
.telegraph { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--amber); border-radius: var(--r); background: rgba(231, 165, 58, .07); }
.telegraph-label { font-weight: 600; margin-bottom: 6px; color: var(--amber); }
.bank-delta { font-size: 11px; opacity: .85; }
.thieve-log { display: flex; flex-direction: column; gap: 4px; max-width: 480px; }
.thieve-entry { font-size: 12px; padding: 5px 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.thieve-entry.ok { border-left: 3px solid var(--moss); }
.thieve-entry.fail { border-left: 3px solid var(--blood); }
.relic-list { display: flex; flex-direction: column; gap: 6px; }
.relic-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); }
.relic-row .relic-icon { font-size: 22px; }
.relic-row .relic-body { flex: 1; }
.relic-row .relic-where { font-size: 12px; color: var(--ink-dim); white-space: nowrap; }
.find-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.find-chip { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--bg); cursor: help; border: 1px solid var(--line); }
.rar.common, .find-chip.common { color: var(--ink-dim); }
.rar.uncommon, .find-chip.uncommon { color: var(--mana); }
.rar.rare, .find-chip.rare { color: var(--violet); }
.find-chip.uncommon { border-color: rgba(114, 169, 224, .5); }
.find-chip.rare { border-color: rgba(185, 148, 236, .6); }
.checklist { background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--brass); border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.checklist strong { display: block; margin-bottom: 6px; font-family: var(--font-display); font-size: 15px; }
.check-step { font-size: 13px; color: var(--ink-faint); padding: 1px 0; }
.check-step.done { color: var(--moss); }
.craft-tree { display: flex; flex-direction: column; gap: 10px; }
.craft-tree > .tree-node { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; }
.tree-line { font-size: 13px; cursor: help; }
.tree-kids { margin-left: 16px; border-left: 1px dashed var(--line-2); padding-left: 10px; margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.course-list { display: flex; flex-direction: column; gap: 4px; }
.course-step { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; }
.course-step.active { border-color: var(--ember); box-shadow: var(--glow-ember); }
.loadout-group { margin-bottom: 10px; }
.loadout { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; margin-top: 4px; }
.loadout-slot { display: flex; align-items: center; gap: 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; font-size: 13px; }
.loadout-slot.empty { opacity: .5; border-style: dashed; }
.loadout-slot .slot-name { text-transform: capitalize; color: var(--ink-faint); min-width: 58px; font-size: 12px; }
.loadout-slot .slot-icon { font-size: 16px; }
.loadout-slot .slot-empty { color: var(--ink-faint); }

@keyframes flash-red { 0%, 100% { outline-color: transparent; } 50% { outline-color: var(--blood); } }
.nav-item.alert, .item-row.alert { outline: 2px solid var(--blood); outline-offset: -2px; animation: flash-red 1s ease-in-out infinite; }

/* ---------- Bank grid ---------- */
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); grid-auto-rows: 150px; gap: 10px; margin-top: 12px; }
.bank-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; overflow: hidden; padding: 12px 8px 8px;
  border-radius: var(--r); background: linear-gradient(180deg, var(--bg-3), var(--bg-2)); border: 1px solid var(--line);
  cursor: grab; user-select: none; transition: border-color .15s, transform .15s;
}
.bank-cell:hover { border-color: var(--brass-lo); transform: translateY(-2px); }
.bank-cell:active { cursor: grabbing; }
.bank-cell.drop, .btn.drop { outline: 2px dashed var(--brass); outline-offset: -2px; }
.bank-icon {
  position: relative; width: 50px; height: 50px; display: grid; place-items: center; font-size: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--bg-4), var(--bg) 75%); box-shadow: 0 0 0 1.5px var(--brass-lo), 0 0 0 3px var(--bg-2), 0 0 0 4px rgba(216, 170, 92, .18);
}
.bank-qty {
  position: absolute; top: -6px; right: -18px; min-width: 22px; text-align: center;
  background: var(--bg); border: 1px solid var(--brass-lo); border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; color: var(--brass-hi);
}
.bank-cell > * { flex-shrink: 0; }
.bank-name { margin-top: 4px; font-size: 12px; text-align: center; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bank-price { font-size: 11px; color: var(--brass); }
.bank-actions { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin-top: auto; }
.bank-actions .btn { font-size: 10.5px; padding: 2px 7px; border-radius: 7px; }

/* ---------- Phone ---------- */
#scrim, #dock { display: none; }
@media (max-width: 760px) {
  body { font-size: 13.5px; }
  .icon-btn { display: grid; place-items: center; }
  #sidebar {
    position: fixed; z-index: 200; top: 0; bottom: 0; left: 0; width: 82vw; max-width: 300px;
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: 10px 0 40px rgba(0, 0, 0, .6);
  }
  body.drawer-open #sidebar { transform: none; }
  #scrim { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.drawer-open #scrim { opacity: 1; pointer-events: auto; }
  #topbar { padding: 8px 12px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  #status { gap: 6px; margin-bottom: 8px; }
  .stat-chip { padding: 3px 9px; font-size: 12px; }
  .stat-chip.phase #phase-val, .hud-chips { display: none; }
  .mini-bar { width: 48px; }
  #action-bar { height: 38px; }
  #panel { padding: 16px 12px calc(88px + env(safe-area-inset-bottom)); }
  h2 { font-size: 22px; }
  .hero { gap: 14px; }
  .medallion.lg { --size: 52px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .card-grid.skills { grid-template-columns: 1fr; }
  .card { padding: 11px 11px 13px; }
  .card .icon { width: 38px; height: 38px; font-size: 20px; }
  .card .name { font-size: 14.5px; }
  .card .meta { font-size: 11.5px; }
  .card .meta.cta { opacity: 1; font-size: 11px; }
  .stat-row { gap: 8px; }
  .stat { grid-template-columns: 1fr; padding: 10px; text-align: center; }
  .stat-icon { grid-row: auto; font-size: 18px; }
  .stat-value { font-size: 19px; }
  .stat-label { font-size: 9.5px; }
  .bank-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 158px; gap: 7px; }
  .bank-icon { width: 42px; height: 42px; font-size: 22px; }
  .bank-qty { right: -14px; }
  .item-row { padding: 9px 11px; }
  #dock {
    display: flex; position: fixed; z-index: 120; left: 0; right: 0; bottom: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(21, 17, 13, .94); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  }
  .dock-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 0; border: 0; border-radius: 10px;
    background: none; color: var(--ink-faint); font: inherit; font-size: 10.5px; cursor: pointer;
  }
  .dock-icon { font-size: 19px; }
  .dock-item.active { color: var(--brass-hi); background: rgba(216, 170, 92, .1); }
  #toasts { left: 10px; right: 10px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .levelup-seal { top: 38%; }
}
