/* ─── Block Builder — TSA tokens + mempool.space layout ─────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0909;   /* near-black, warm (thesatoshiarchive.com) */
  --surface:   #110f13;   /* panels / cards */
  --surface-2: rgba(255,255,255,0.03);
  --text:      #f2f2f2;
  --text-dim:  #9a9499;
  --accent:    #df6a1e;   /* Bitcoin burnt-orange */
  --accent-2:  #dc5046;   /* high heat / danger */
  --line:      rgba(255,255,255,0.08);

  --font-head: 'Orbitron', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  --radius: 12px;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(223,106,30,0.08), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  display: flex;
  justify-content: center;
  padding: 16px;
  min-height: 100vh;
}

.bb-app { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 14px; }

/* ─── HUD chips ──────────────────────────────────────────────────────────────── */
.bb-hud { display: flex; gap: 10px; align-items: stretch; }
.chip {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 10px 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chip-label { font-size: 10px; letter-spacing: 0.18em; color: var(--text-dim); text-transform: uppercase; }
.chip-val { font-family: var(--font-head); font-weight: 700; font-size: 22px; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1; }
.chip-unit { font-size: 10px; color: var(--text-dim); }
.chip-help {
  flex: 0 0 48px; cursor: pointer; color: var(--accent); font-family: var(--font-head);
  font-size: 20px; font-weight: 700;
}
.chip-help[disabled] { opacity: 0.3; cursor: default; }

/* ─── Block card (mempool.space mined-block feel) ───────────────────────────── */
.bb-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.block-bar { height: 14px; background: #060507; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.block-fill { height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease; }
.block-stats { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px;
  font-size: 13px; color: var(--text-dim); }
.block-stats strong { font-family: var(--font-head); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; }

.bb-goal { text-align: center; font-size: 14px; color: var(--text-dim); }
.bb-goal strong { color: var(--accent); }

/* ─── Mempool grid + transaction tiles ──────────────────────────────────────── */
.bb-mempool { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start;
  min-height: 240px; padding: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); }
.bb-tx {
  min-width: 72px; height: 66px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; cursor: pointer; border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.35); color: #0a0909; user-select: none;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.bb-tx .tx-rate { font-family: var(--font-head); font-weight: 800; font-size: 24px; line-height: 1;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 1px rgba(255,255,255,0.35); }
.bb-tx .tx-size { font-size: 11px; font-weight: 600; opacity: 0.78; }
.bb-tx:hover { box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.bb-tx.bounce { animation: bbBounce 0.25s ease; }
.bb-tx.hint { animation: bbHint 1s ease-in-out infinite; box-shadow: 0 0 0 3px var(--accent); }
@keyframes bbBounce { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes bbHint { 0%,100% { box-shadow: 0 0 0 3px rgba(223,106,30,0.4); } 50% { box-shadow: 0 0 0 5px rgba(223,106,30,0.9); } }

/* ─── Result + controls ─────────────────────────────────────────────────────── */
.bb-result { min-height: 24px; text-align: center; font-size: 14px; color: var(--text); letter-spacing: 0.02em; }
.bb-controls { display: flex; gap: 10px; }
.bb-btn {
  flex: 1; padding: 15px; min-height: 48px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #0a0909; font-family: var(--font-head); font-weight: 700;
  font-size: 16px; letter-spacing: 0.08em; cursor: pointer; transition: filter 0.15s ease;
}
.bb-btn:hover { filter: brightness(1.08); }
.bb-btn-icon { flex: 0 0 56px; background: var(--surface); color: var(--accent); border: 1px solid var(--line); }
.bb-best { text-align: center; font-size: 13px; color: var(--text-dim); }
.bb-best span { color: var(--text); font-variant-numeric: tabular-nums; }

/* ─── Rules overlay ─────────────────────────────────────────────────────────── */
.bb-rules { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(5,4,6,0.82); backdrop-filter: blur(4px); z-index: 50; }
.bb-rules[hidden] { display: none; }
.rules-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.rules-title { font-family: var(--font-head); font-weight: 800; font-size: 28px; letter-spacing: 0.04em;
  text-align: center; color: var(--text); }
.rules-sub { text-align: center; color: var(--text-dim); font-size: 14px; }
.rules-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.rules-list li { position: relative; padding-left: 22px; font-size: 15px; line-height: 1.5; color: var(--text); }
.rules-list li::before { content: ''; position: absolute; left: 0; top: 9px; width: 8px; height: 8px;
  border-radius: 2px; background: var(--accent); }
.rules-list strong { color: var(--accent); }
.rules-list em { color: var(--text); font-style: normal; font-weight: 700; }

/* Worked example inside the rules card */
.rules-example { display: flex; flex-direction: column; gap: 8px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.rules-ex-label { font-size: 12px; color: var(--text-dim); letter-spacing: 0.02em; }
.rules-ex-row { display: flex; align-items: center; gap: 12px; }
.ex-tile { flex: 0 0 auto; width: 64px; height: 52px; border-radius: 8px; color: #0a0909;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid rgba(0,0,0,0.35); }
.ex-tile b { font-family: var(--font-head); font-weight: 800; font-size: 20px; line-height: 1; }
.ex-tile small { font-size: 10px; font-weight: 600; opacity: 0.8; }
.ex-eq { font-size: 14px; color: var(--text); }
.ex-eq strong { color: var(--accent); }

/* End-of-run scorecard */
.sum-score { text-align: center; }
.sum-score span { font-family: var(--font-head); font-weight: 800; font-size: 40px; color: var(--accent);
  font-variant-numeric: tabular-nums; }
.sum-score small { display: block; font-size: 12px; color: var(--text-dim); letter-spacing: 0.16em;
  text-transform: uppercase; margin-top: 2px; }
.sum-eff { display: flex; flex-direction: column; gap: 6px; }
.sum-eff-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--text-dim); }
.sum-eff-row strong { font-family: var(--font-head); font-weight: 800; font-size: 22px; color: var(--text);
  font-variant-numeric: tabular-nums; }
.sum-bar { height: 10px; background: #060507; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.sum-bar i { display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.6s ease; }
.sum-eff-cap { font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.sum-verdict { font-size: 15px; line-height: 1.5; color: var(--text); }
.sum-learned { font-size: 12px; line-height: 1.5; color: var(--text-dim);
  border-left: 2px solid var(--accent); padding-left: 10px; }
.sum-actions { display: flex; gap: 10px; }

/* Leaderboard inside the scorecard */
.sum-board { display: flex; flex-direction: column; gap: 8px; }
.board-submit { display: flex; gap: 8px; }
.board-submit input { flex: 1; min-width: 0; padding: 12px; min-height: 44px; background: #060507;
  border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-family: var(--font-body);
  font-size: 15px; }
.board-submit input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.board-submit .bb-btn { flex: 0 0 auto; padding: 12px 16px; }
.board-list { list-style: none; display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  font-size: 14px; background: var(--surface-2); }
.board-list li.me { background: rgba(223,106,30,0.16); border: 1px solid var(--accent); }
.board-list .b-rank { flex: 0 0 24px; font-family: var(--font-head); font-weight: 700; color: var(--text-dim);
  font-variant-numeric: tabular-nums; }
.board-list .b-handle { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .b-fees { font-family: var(--font-head); font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; }
.board-note { font-size: 12px; color: var(--text-dim); text-align: center; min-height: 16px; }

/* ─── a11y ──────────────────────────────────────────────────────────────────── */
button:focus-visible, .bb-tx:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
