:root {
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.18);
  --grad-a: #a78bfa;
  --grad-b: #f472b6;
  --grad-c: #38bdf8;
  --text: #f5f3ff;
  --muted: rgba(245, 243, 255, 0.72);
  --term-green: #4ade80;
  --term-amber: #fbbf24;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #4c1d95 45%, #86198f 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

#app {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px;
}

.loading {
  margin: 0;
  text-align: center;
  color: var(--muted);
}

.loading[hidden] {
  display: none;
}

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(15, 10, 40, 0.35);
}

.hdr {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
}

.hdr-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hdr-title {
  margin: 0;
  font-size: 2.4rem;
  line-height: 1.1;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hdr-subtitle {
  margin: 0;
  font-size: 1.05rem;
}

.hdr-tagline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.hdr-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hdr-version {
  font-size: 0.8rem;
  color: var(--muted);
}

.section {
  margin: 0 0 12px;
  font-size: 1.15rem;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pill {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b));
  transition:
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

.pill:hover {
  box-shadow: 0 0 18px rgba(244, 114, 182, 0.55);
}

.pill:active {
  transform: scale(0.97);
}

.pill:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.pill.ghost {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 16px;
  align-items: start;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.card {
  padding: 16px;
}

.counters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.counter {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

#tokens {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
}

#tps {
  font-size: 1.15rem;
  color: var(--text);
}

.prompt {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 20px;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
}

.click-value {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.85;
}

.buy-qty-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

#buy-qty {
  display: flex;
  gap: 6px;
}

.qty {
  padding: 4px 12px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.qty.active {
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b));
  border-color: transparent;
}

#generators {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gen-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gen-row.mystery {
  border-style: dashed;
  opacity: 0.8;
}

.gen-emoji {
  width: 2rem;
  font-size: 1.5rem;
  text-align: center;
}

.gen-body {
  flex: 1;
  min-width: 0;
}

.gen-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
}

.gen-owned {
  font-size: 0.8rem;
  color: var(--muted);
}

.gen-flavor,
.gen-tps {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.gen-buy {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.9rem;
  white-space: nowrap;
}

#multipliers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mult-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.8rem;
}

.mult-value {
  font-weight: 600;
}

#buffs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#buffs:empty {
  display: none;
}

.buff-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(244, 114, 182, 0.4);
  font-size: 0.8rem;
}

.prompt-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.45);
}

.prompt-title {
  margin: 0;
  font-weight: 600;
}

.prompt-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.prompt-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.prompt-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--term-amber), var(--grad-b));
}

.prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-approve,
.prompt-approve-always {
  padding: 8px 14px;
  font-size: 0.9rem;
}

#gpu-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gpu-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gpu-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gpu-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gpu-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.gpu-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--term-green), var(--grad-c));
  transition: width 0.4s ease;
}

.gpu-row-text {
  font-size: 0.8rem;
  color: var(--muted);
}

.gpu-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.gpu-note[hidden] {
  display: none;
}

#repo-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.repo-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.repo-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.repo-commit {
  font-size: 0.8rem;
  color: var(--muted);
}

.repo-commit[hidden] {
  display: none;
}

.repo-none {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.repo-none[hidden] {
  display: none;
}

#upgrades {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.up-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.up-name {
  font-weight: 600;
}

.up-desc {
  margin: 0;
  font-size: 0.85rem;
}

.up-flavor {
  margin: 0;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
}

.up-buy {
  align-self: flex-start;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.upgrades-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

#achievements {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ach-count {
  grid-column:
    1 / -1;
  margin: 0 0 2px;
  font-size: 0.9rem;
  color: var(--muted);
}

.ach-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0.7;
}

.ach-tile.unlocked {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(244, 114, 182, 0.5);
}

.ach-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.ach-real {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--term-amber);
}

.ach-desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.ach-locked {
  font-size: 0.72rem;
  color: var(--muted);
}

.ach-locked[hidden],
.ach-real[hidden] {
  display: none;
}

#feed {
  background: #000;
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--term-green);
  max-height: 320px;
  overflow-y: auto;
}

#feed .line {
  margin: 0 0 4px;
}

#feed .line.real {
  color: var(--term-amber);
}

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  font-size: 0.9rem;
  color: var(--muted);
}

#modal-root:empty,
#boot:empty {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 8, 30, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(540px, 100%);
  padding: 24px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.modal-title {
  margin: 0;
  font-size: 1.3rem;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.modal-line {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 4, 16, 0.85);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.boot-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px;
  background: #000;
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.boot-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--term-green);
}

.boot-cmd {
  color: var(--term-amber);
}

.boot-done {
  color: var(--term-amber);
  font-weight: 700;
}

.boot-origin[hidden],
.boot-actions[hidden] {
  display: none;
}

.boot-actions {
  display: flex;
  justify-content: flex-end;
}

.origin-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
}

.origin-line {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 85%;
}

.origin-dev {
  align-self: flex-start;
}

.origin-client {
  align-self: flex-end;
  align-items: flex-end;
}

.origin-speaker {
  font-size: 0.72rem;
  color: var(--muted);
}

.origin-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
}

.receipts-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow-y: auto;
  padding: 24px;
  background: rgba(10, 8, 30, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.receipts-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px;
  background: rgba(20, 14, 52, 0.92);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.receipts-title {
  margin: 0;
  font-size: 1.6rem;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.receipts-intro {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.receipts-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.receipts-caption {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b), var(--grad-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.receipts-missing {
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--muted);
}

.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

.stat-label {
  color: var(--muted);
}

.stat-value {
  font-weight: 600;
}

.stat-footnote {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.team-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
}

.team-head {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.team-subject {
  font-weight: 600;
}

.team-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.75rem;
  color: var(--muted);
}

.diary-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diary-entry {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
}

.diary-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
}

.diary-ticket {
  font-size: 0.75rem;
  color: var(--grad-b);
}

.diary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.75rem;
  color: var(--muted);
}

.diary-note,
.diary-worry {
  margin: 0;
  font-size: 0.82rem;
}

.diary-worry {
  color: var(--muted);
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.source-chars {
  font-size: 0.72rem;
  color: var(--muted);
}

.receipts-source-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.receipts-source-view:empty {
  display: none;
}

.receipts-source-banner {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--term-amber);
}

.receipts-source-text {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  background: #000;
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--term-green);
  white-space: pre;
}

.receipts-close {
  align-self: flex-end;
}

#toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 8, 30, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.9rem;
  animation: toast-in 0.18s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Leaderboard (T20, SPEC 16.2). */
.lb-sub {
  margin: -6px 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.lb-table th,
.lb-table td {
  padding: 4px 6px;
  text-align: left;
  white-space: nowrap;
}

.lb-table th {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--glass-border);
}

.lb-table th.lb-rank,
.lb-table td.lb-rank,
.lb-table th.lb-tokens,
.lb-table td.lb-tokens,
.lb-table th.lb-tps,
.lb-table td.lb-tps,
.lb-table th.lb-vibes,
.lb-table td.lb-vibes {
  text-align: right;
}

.lb-row + .lb-row td {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.lb-row.you {
  background: rgba(56, 189, 248, 0.14);
}

.lb-row.you td {
  font-weight: 600;
}

.lb-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.lb-handle-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.lb-handle-input {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
}

.lb-handle-input:focus {
  outline: none;
  border-color: var(--grad-c);
}

.lb-handle-save {
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, var(--grad-a), var(--grad-b));
}

/* Mini mode (T19, SPEC 16.5): the compact 380 x 560 pop-out layout. */
body.mini #app {
  gap: 10px;
  max-width: 380px;
  padding: 10px;
}

body.mini .cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

body.mini .hdr,
body.mini .foot,
body.mini .cols > .col:nth-child(n + 2),
body.mini .card:has(#multipliers),
body.mini #gpu-panel,
body.mini .card:has(#repo-panel),
body.mini .card:has(#prompt-slot) > .section,
body.mini .card:has(#feed) > .section {
  display: none;
}

body.mini .card:has(#prompt-slot:empty) {
  display: none;
}

body.mini #feed {
  max-height: none;
}

body.mini #feed .line {
  display: none;
}

body.mini #feed .line:nth-last-child(-n + 3) {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
