/* Bloodline: dark terrarium glass. Lime for action, magenta for rare. Tokens first, then layout, then components. */
:root {
  --bg: #121416; --surface: #1b1e22; --surface-2: #262a30; --ink: #eef1f4; --ink-soft: #9aa3ad;
  --accent: #c6f432; --accent-ink: #14180a; --accent-text: #c6f432; --hot: #ff3da8; --hot-ink: #fff;
  --ok: #4fd1a5; --warn: #ffb547; --line: rgba(255,255,255,.09);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 28px -16px rgba(0,0,0,.9);
  --scrim: rgba(4,6,8,.66);
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --sans: Figtree, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 16px; --gut: 16px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2,.8,.2,1);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef0f2; --surface: #ffffff; --surface-2: #e2e6ea; --ink: #15191d; --ink-soft: #5b6570;
    --accent: #c6f432; --accent-ink: #14180a; --accent-text: #4d6b00; --hot: #d81b7d; --hot-ink: #fff;
    --ok: #0f8f66; --warn: #a65f00; --line: rgba(10,20,30,.12);
    --shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 8px 22px -14px rgba(20,30,40,.35); --scrim: rgba(10,14,18,.45);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #eef0f2; --surface: #ffffff; --surface-2: #e2e6ea; --ink: #15191d; --ink-soft: #5b6570;
  --accent: #c6f432; --accent-ink: #14180a; --accent-text: #4d6b00; --hot: #d81b7d; --hot-ink: #fff;
  --ok: #0f8f66; --warn: #a65f00; --line: rgba(10,20,30,.12);
  --shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 8px 22px -14px rgba(20,30,40,.35); --scrim: rgba(10,14,18,.45);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
  background-image: radial-gradient(90% 60% at 50% -10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#app { position: fixed; inset: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-weight: 800; letter-spacing: .005em; text-decoration: none;
  transition: transform .12s var(--ease), background .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-hot { background: var(--hot); color: var(--hot-ink); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-lg { min-height: 54px; padding: 0 30px; font-size: 17px; border-radius: 14px; }
.btn-sm { min-height: 44px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; flex: none;
}
.icon-btn svg, .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ico.cash { color: var(--accent-text); }
.ico.rep { color: var(--hot); }
.keepico { width: 16px; height: 16px; fill: var(--accent); stroke: none; }

/* ---------- title ---------- */
.title {
  position: absolute; inset: 0; display: grid; place-items: center; overflow-y: auto;
  padding: calc(var(--sat) + 24px) calc(var(--gut) + var(--sar)) calc(var(--sab) + 24px) calc(var(--gut) + var(--sal));
}
.title-plate { width: min(520px, 100%); text-align: center; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-soft); font-weight: 800; }
.wordmark { font: 800 clamp(56px, 17vw, 96px)/.95 var(--display); margin: 8px 0 0; letter-spacing: -.035em; }
.wordmark span { color: var(--accent-text); }
.title-stage { position: relative; margin: 6px 0 4px; border-radius: 22px; background: radial-gradient(60% 55% at 50% 60%, var(--surface-2), transparent 75%); }
.title-art { width: 100%; height: clamp(170px, 34vh, 290px); display: block; }
.title-cast { position: absolute; left: 0; right: 0; bottom: 4px; margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.tagline { font: 700 20px/1.3 var(--display); margin: 6px 0 22px; letter-spacing: -.01em; }
.title-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.title-meta { font-size: 13px; color: var(--ink-soft); margin: 18px 0 0; }
.title.leaving { animation: fadeOut .35s var(--ease) forwards; }
@keyframes fadeOut { to { opacity: 0; transform: scale(1.02); } }

/* ---------- game frame ---------- */
.game { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--sat) + 8px) calc(var(--gut) + var(--sar)) 8px calc(var(--gut) + var(--sal));
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
}
.purse { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.coin { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.coin .ico { width: 18px; height: 18px; }
.rate { font-size: 12px; color: var(--accent-text); font-weight: 800; font-variant-numeric: tabular-nums; }
.view { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 14px calc(var(--gut) + var(--sar)) 28px calc(var(--gut) + var(--sal)); outline: none; }
.view > * { max-width: 920px; margin-left: auto; margin-right: auto; }
.tabs {
  display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line);
  background: var(--surface); padding: 4px calc(4px + var(--sar)) calc(4px + var(--sab)) calc(4px + var(--sal));
}
.tab {
  position: relative; min-height: 56px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 800; color: var(--ink-soft); border-radius: 12px; padding: 0 2px; min-width: 0;
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent-ink); }
.tab[aria-current="page"]::before { content: ''; position: absolute; inset: 6px 10%; border-radius: 12px; background: var(--accent); z-index: -1; }
.tab { isolation: isolate; }
.dot { position: absolute; top: 8px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--hot); box-shadow: 0 0 0 2px var(--surface); }

@media (orientation: landscape) and (max-height: 520px) {
  .game { grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; }
  .top { grid-column: 2; grid-row: 1; padding-top: calc(var(--sat) + 4px); padding-bottom: 4px; }
  .view { grid-column: 2; grid-row: 2; }
  .tabs { grid-column: 1; grid-row: 1 / 3; grid-template-columns: 1fr; grid-auto-rows: 1fr; width: calc(84px + var(--sal)); border-top: 0; border-right: 1px solid var(--line);
    padding: calc(var(--sat) + 4px) 4px calc(var(--sab) + 4px) calc(4px + var(--sal)); }
  .tab { min-height: 44px; }
  .tab[aria-current="page"]::before { inset: 3px 6px; }
  .title-art { height: 120px; }
  .wordmark { font-size: 52px; }
  .tagline { margin-bottom: 12px; }
  .title-actions { flex-direction: row; justify-content: center; }
  .scene { max-height: 52vh; }
}

/* ---------- common blocks ---------- */
.h2 { font: 800 28px/1.05 var(--display); margin: 4px 0 4px; letter-spacing: -.02em; }
.view-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px; }
.sub { color: var(--ink-soft); font-size: 13px; margin: 0 0 12px; }
.sub b { color: var(--ink); }
.small { font-size: 12px; }
.strong { font-weight: 800; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 0 8px; }
.section-h h3 { font: 800 19px/1.2 var(--display); margin: 0; letter-spacing: -.01em; }
.section-h small { color: var(--ink-soft); font-weight: 700; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.seg { gap: 6px; }
.chip {
  flex: none; min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lock { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; vertical-align: -2px; flex: none; }
.chip small { font-weight: 700; opacity: .65; font-variant-numeric: tabular-nums; }
.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 800; background: var(--surface-2); color: var(--ink); }
.tag.hot { background: color-mix(in srgb, var(--hot) 18%, transparent); color: var(--hot); }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); display: flex; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags.center { justify-content: center; margin: 8px 0; }
.tags.pad { padding: 6px 10px 0; }
.muted { color: var(--ink-soft); }
.num { font-variant-numeric: tabular-nums; }
.price { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.price .ico { width: 15px; height: 15px; }
.btn-primary .ico.cash, .btn-hot .ico { color: inherit; }
.price + .price { margin-left: 6px; }

/* ---------- animals ---------- */
.scene-wrap { position: relative; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); margin-top: 4px; }
.scene { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 38vh; min-height: 170px; }
.scene-cap { position: absolute; left: 10px; bottom: 10px; right: 10px; display: flex; justify-content: space-between; align-items: end; gap: 8px; pointer-events: none; }
.scene-cap .plaque { background: color-mix(in srgb, var(--bg) 78%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 11px; font-weight: 800; color: var(--ink-soft); backdrop-filter: blur(6px); }
.scene-cap .plaque b { font: 800 17px/1 var(--display); display: block; color: var(--ink); font-variant-numeric: tabular-nums; }
.capbar { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; }
.meter { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.stat .meter { margin-top: 6px; height: 6px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 860px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card {
  text-align: left; padding: 0 0 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative;
}
.card canvas { width: 100%; aspect-ratio: 4 / 3; display: block; background: radial-gradient(70% 60% at 50% 60%, var(--surface-2), transparent 80%); }
.card .nm { font: 800 16px/1.15 var(--display); padding: 4px 10px 0; display: flex; gap: 6px; align-items: center; min-width: 0; }
.card .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .ph { font-size: 12px; color: var(--ink-soft); padding: 2px 10px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.card .ap { font-size: 12px; font-weight: 800; padding: 4px 10px 0; color: var(--accent-text); display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.card .ap .ico { width: 14px; height: 14px; }
.sex { font: 800 14px/1 var(--sans); flex: none; }
.sex.m { color: #5bb8ff; } .sex.f { color: #ff8ac6; }
.card .badge { position: absolute; top: 8px; left: 8px; background: color-mix(in srgb, var(--bg) 80%, transparent); }
.card .keep { position: absolute; top: 8px; right: 8px; }
.card.rare { border-color: color-mix(in srgb, var(--hot) 55%, var(--line)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--hot) 30%, transparent), var(--shadow); }
.card.rare .ph { color: var(--hot); }
.more { margin: 14px auto 0; display: flex; }

/* ---------- breeding ---------- */
.pen { padding: 14px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; margin-bottom: 10px; }
.ring { width: 76px; height: 76px; position: relative; }
.ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 12px/1 var(--sans); font-variant-numeric: tabular-nums; text-align: center; }
.pen-who { min-width: 0; }
.pen .who { font: 800 17px/1.15 var(--display); overflow: hidden; text-overflow: ellipsis; }
.pen .muted.small { overflow: hidden; text-overflow: ellipsis; }
.pen .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.pen.empty { grid-template-columns: 1fr; justify-items: center; text-align: center; border-style: dashed; background: transparent; box-shadow: none; }
.pen.locked { opacity: .75; }
.pick { display: grid; grid-auto-flow: column; grid-auto-columns: 118px; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: thin; }
.pick button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 0 0 6px; text-align: center; min-height: 44px; min-width: 0; }
.pick button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.pick button[disabled] { opacity: .4; }
.pick canvas { width: 100%; aspect-ratio: 4/3; display: block; }
.pick b { display: block; font: 800 14px/1.15 var(--display); padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { font-size: 11px; color: var(--ink-soft); display: block; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odds { width: 100%; border-collapse: collapse; font-size: 13px; }
.odds td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.odds td:last-child { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.odds .new { color: var(--hot); font-weight: 800; font-size: 10px; letter-spacing: .06em; margin-left: 6px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch.inline { gap: 8px; font-weight: 700; font-size: 13px; }
.switch input { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; border-radius: 99px; background: var(--surface-2); position: relative; border: 1px solid var(--line); flex: none; margin: 8px 0; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink-soft); transition: transform .2s var(--ease), background .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: var(--accent-ink); }

/* ---------- list rows (upgrades, settings) ---------- */
.rows { display: flex; flex-direction: column; }
.rowi { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.rowi:last-child { border-bottom: 0; }
.rowi.one { grid-template-columns: 1fr; }
.rowi.one > b { display: block; margin-bottom: 6px; }
.rowi h4 { margin: 0; font: 800 16px/1.2 var(--display); }
.rowi p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
.rowi .lvl { font-size: 12px; font-weight: 800; color: var(--accent-text); }
.sprow { grid-template-columns: 64px 1fr auto; }
.sprow canvas { width: 64px; height: 48px; display: block; }
.sprow.next { background: color-mix(in srgb, var(--accent) 6%, transparent); }
@media (max-width: 400px) {
  .sprow { grid-template-columns: 56px 1fr; }
  .sprow canvas { width: 56px; height: 42px; }
  .sprow > :last-child { grid-column: 1 / -1; justify-self: end; }
}

/* ---------- orders ---------- */
.comm { padding: 14px; margin-bottom: 12px; position: relative; overflow: hidden; }
.comm::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--hot); }
.comm-top { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.comm-top canvas { width: 96px; height: 72px; display: block; border-radius: 10px; background: var(--surface-2); }
.eyebrow-s { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.comm h4 { margin: 2px 0 6px; font: 800 19px/1.15 var(--display); }
.comm .reward { display: flex; gap: 14px; font-weight: 800; margin: 10px 0 8px; }
.comm .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.comm.waiting { opacity: .8; }
.comm.waiting::before { background: var(--surface-2); }
.comm.waiting h4 { font-size: 16px; }

/* ---------- morphs ---------- */
.progress { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.progress .num { font-size: 13px; }
.mgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 520px) { .mgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 760px) { .mgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.cell { border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 0 6px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 44px; }
.cell canvas { width: 100%; aspect-ratio: 4 / 3; display: block; }
.cell span { font-size: 11px; font-weight: 800; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.cell.none { background: transparent; border-style: dashed; }
.cell.none span { color: var(--ink-soft); }
.recipe { margin: 0; padding-left: 20px; }
.recipe li { margin: 4px 0; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fadeIn .2s var(--ease); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: min(560px, 100%); max-height: calc(100% - var(--sat) - 24px); background: var(--bg); border-radius: 22px 22px 0 0;
  border: 1px solid var(--line); border-bottom: 0; box-shadow: 0 -12px 40px rgba(0,0,0,.35);
  display: flex; flex-direction: column; animation: up .26s var(--ease);
}
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 6px 18px; flex: none; }
.sheet-h h2 { font: 800 22px/1.1 var(--display); margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -.01em; }
.sheet-b { overflow-y: auto; overscroll-behavior: contain; padding: 4px 18px calc(18px + var(--sab)); }
.grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 0; flex: none; }
.center-modal { align-items: center; padding: 16px; }
.center-modal .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); max-height: calc(100% - 32px); }
.center-modal .grabber { display: none; }
@media (orientation: landscape) and (max-height: 520px) { .scrim { align-items: center; padding: 8px; } .sheet { border-radius: 18px; border-bottom: 1px solid var(--line); max-height: calc(100% - 16px); } .grabber { display: none; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
.big-art { width: 100%; aspect-ratio: 4 / 3; max-height: 34vh; display: block; margin: 0 auto; border-radius: 16px; background: radial-gradient(60% 55% at 50% 60%, var(--surface-2), transparent 80%); }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 8px; }
.stat { padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.stat.wide { grid-column: 1 / -1; }
.stat small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.stat b { font: 800 18px/1.25 var(--display); font-variant-numeric: tabular-nums; }
.geno { font: 700 14px/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: .03em; word-spacing: .3em; margin-top: 4px; overflow-wrap: anywhere; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions-row .btn { flex: 1 1 auto; }
.lbl { display: block; margin: 12px 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.name-input { width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font: 800 18px var(--display); }
.name-input.area { font: 13px/1.4 ui-monospace, Menlo, Consolas, monospace; padding: 10px 12px; resize: vertical; }
.tree { display: flex; flex-direction: column; gap: 12px; }
.gen { display: grid; gap: 6px; }
.gen h5 { margin: 0; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.gen .row { display: grid; gap: 6px; }
.anc { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 6px 8px; text-align: left; min-width: 0; }
.anc b { display: block; font: 800 14px/1.15 var(--display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anc small { display: block; font-size: 11px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anc.gone { opacity: .7; border-style: dashed; }
.anc.unknown { opacity: .45; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.help h3 { font: 800 17px/1.2 var(--display); margin: 16px 0 4px; }
.help h3:first-child { margin-top: 4px; }
.help p { margin: 0 0 8px; }
.litter { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.reveal { animation: flip .5s var(--ease) both; }
.reveal:nth-child(2) { animation-delay: .12s; } .reveal:nth-child(3) { animation-delay: .24s; } .reveal:nth-child(4) { animation-delay: .36s; }
.reveal:nth-child(n+5) { animation-delay: .48s; }
@keyframes flip { from { transform: perspective(600px) rotateY(80deg); opacity: 0; } }
.welcome-sum { text-align: center; padding: 8px 0; }
.welcome-sum b { font: 800 44px/1 var(--display); color: var(--accent-text); display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.welcome-sum b .ico { width: 34px; height: 34px; }

/* ---------- save codes (LoopSync panel) ---------- */
.sync-wrap .lp-sync { display: flex; flex-direction: column; gap: 10px; }
.sync-wrap .lp-sync-p, .sync-wrap .lp-sync-s { margin: 0; font-size: 13px; color: var(--ink-soft); }
.sync-wrap .lp-sync-row, .sync-wrap .lp-sync-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sync-wrap .lp-sync-k { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.sync-wrap .lp-sync-code { font: 800 22px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--accent-text); user-select: all; overflow-wrap: anywhere; }
.sync-wrap .lp-sync-btn { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 800; }
.sync-wrap .lp-sync-in { flex: 1 1 160px; min-width: 0; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font: 700 16px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--sab)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 14px; z-index: 60;
  transition: opacity .2s, transform .2s var(--ease); max-width: calc(100% - 32px); text-align: center;
}
.toast.bad { background: var(--hot); color: var(--hot-ink); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.reduced *, .reduced *::before, .reduced *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }

/* ---------- trophies ---------- */
.top-btns { display: flex; gap: 8px; flex: none; }
.top-btns .icon-btn { position: relative; }
.top-btns .dot { top: 5px; right: 5px; }
.trophy { grid-template-columns: 40px minmax(0, 1fr) auto; align-items: start; --tc: #c98a4a; }
.trophy.t2 { --tc: #aeb8c4; } .trophy.t3 { --tc: #f2c443; } .trophy.t4 { --tc: #6fd6ff; } .trophy.t5 { --tc: var(--hot); }
.trophy .medal { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--tc);
  background: color-mix(in srgb, var(--tc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--tc) 40%, transparent); }
.trophy .medal svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trophy .tier { font-size: 10px; font-weight: 800; line-height: 1; letter-spacing: .08em; text-transform: uppercase; color: var(--tc); margin-left: 4px; vertical-align: 2px; }
.trophy .progress { margin: 6px 0 2px; }
.trophy .reward { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.trophy .btn { align-self: center; }
.trophy.ready { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.trophy.ready .medal { background: var(--tc); color: var(--bg); }
.trophy.done .medal { background: var(--tc); color: var(--bg); border-color: transparent; }
.trophy.done h4, .trophy.done > .tbody > p { opacity: .75; }
.trophy.t5.ready .medal, .trophy.t5.done .medal { box-shadow: 0 0 14px color-mix(in srgb, var(--hot) 60%, transparent); }

/* ---------- base map (Clash style home) ---------- */
.goal { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px; margin-bottom: 10px; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.goal.done { border-color: var(--hot); }
.goal-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font: 800 22px/1 var(--display); background: var(--accent); color: var(--accent-ink); }
.goal.done .goal-ico { background: var(--hot); color: var(--hot-ink); animation: bob 1.2s var(--ease) infinite; }
.goal-t { min-width: 0; }
.goal-t small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.goal-t b { display: block; font: 800 16px/1.2 var(--display); }
.goal-r { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.basebar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.builders { font-size: 13px; color: var(--ink-soft); }
.builders b { color: var(--ink); }
.base { border-radius: 20px; padding: 10px; background: linear-gradient(180deg, #7dc95a, #5fae44); box-shadow: inset 0 2px 0 rgba(255,255,255,.25), var(--shadow); }
:root[data-theme="dark"] .base { background: linear-gradient(180deg, #2c4a2a, #1f361f); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .base { background: linear-gradient(180deg, #2c4a2a, #1f361f); } }
.base .section-h { margin: 14px 4px 8px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.base .section-h small { color: rgba(255,255,255,.85); }
.plots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.plot { position: relative; display: block; aspect-ratio: 4 / 3; border: 0; padding: 0; border-radius: 16px; overflow: hidden; background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), 0 6px 14px -8px rgba(0,0,0,.5); text-align: left; transition: transform .12s var(--ease); }
.plot.wide { grid-column: 1 / -1; aspect-ratio: 16 / 8; }
.plot:active, .plot.hab:active { transform: scale(.98); }
.plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plot-hit { position: absolute; inset: 0; z-index: 1; background: transparent; border: 0; border-radius: 16px; }
.plot-name, .plot-lv, .plot-price, .plot-time { position: absolute; z-index: 2; pointer-events: none; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.plot-name { left: 8px; bottom: 6px; font: 800 14px/1.1 var(--display); max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot-lv { left: 6px; top: 6px; font-size: 11px; padding: 3px 7px; border-radius: 8px; background: rgba(0,0,0,.45); text-shadow: none; }
.plot-price { right: 6px; top: 6px; font-size: 11px; padding: 3px 7px; border-radius: 8px; background: rgba(0,0,0,.5); display: inline-flex; gap: 6px; text-shadow: none; }
.plot-price .price { color: #fff; }
.plot-up { position: absolute; z-index: 2; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 6px rgba(0,0,0,.4); animation: bob 1.4s var(--ease) infinite; pointer-events: none; }
.plot-bar { position: absolute; z-index: 2; left: 8px; right: 8px; bottom: 26px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.5); overflow: hidden; pointer-events: none; }
.plot-bar i { display: block; height: 100%; background: #f2c443; border-radius: 4px; transition: width 1s linear; }
.plot-time { right: 8px; bottom: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.plot.new { background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.plot.locked { opacity: .7; }
.coinb { position: absolute; z-index: 3; right: 6px; top: 6px; min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 22px; border: 2px solid #fff; display: inline-flex; align-items: center; gap: 4px; background: #f2c443; color: #3a2a00; font-weight: 800; font-size: 13px; box-shadow: 0 4px 10px rgba(0,0,0,.35); animation: bob 1.6s var(--ease) infinite; }
.coinb .ico { width: 16px; height: 16px; }
.coinb.full { background: #ff8a3c; color: #fff; }
.plot.pointed { box-shadow: inset 0 0 0 3px var(--accent), 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent), 0 6px 14px -8px rgba(0,0,0,.5); }
.arrow { position: absolute; z-index: 4; left: 50%; top: 4px; width: 0; height: 0; margin-left: -12px; border: 12px solid transparent; border-top: 16px solid var(--accent); filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); animation: point 0.9s ease-in-out infinite; pointer-events: none; }
.plot.flash { animation: flash 1s var(--ease) 2; }
@keyframes bob { 50% { transform: translateY(-3px); } }
@keyframes point { 50% { transform: translateY(8px); } }
@keyframes flash { 50% { transform: scale(1.04); filter: brightness(1.25); } }
.reduced .coinb, .reduced .arrow, .reduced .plot-up, .reduced .goal-ico { animation: none; }
@media (prefers-reduced-motion: reduce) { .coinb, .arrow, .plot-up, .goal-ico, .plot.flash { animation: none; } }
.bld-art { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 200px; border-radius: 14px; background: color-mix(in srgb, #7dc95a 40%, var(--surface-2)); margin-bottom: 6px; }
.up { padding: 12px; margin: 10px 0; }
.up-h { display: flex; justify-content: space-between; gap: 10px; align-items: start; margin-bottom: 10px; }
.up-h h4 { margin: 0; font: 800 16px/1.2 var(--display); }
.up-h p { margin: 2px 0 0; font-size: 13px; color: var(--ink-soft); }
.up-busy .meter { margin-bottom: 6px; }
.up-busy .meter i { transition: width 1s linear; }
.btn-block { width: 100%; }
.center { text-align: center; }
.opens { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.opens li { margin: 4px 0; }
.steps { margin: 0 0 12px; padding-left: 22px; }
.steps li { margin: 0 0 10px; }
details.help summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
details.help summary::after { content: "+"; margin-left: auto; font-size: 20px; color: var(--ink-soft); }
details.help[open] summary::after { content: "−"; }
.up-h .lvl { white-space: nowrap; }
