:root {
  --bg: #0b0a08;
  --panel: rgba(255, 250, 240, .035);
  --line: rgba(255, 245, 230, .09);
  --ink: #f4efe6;
  --ink-muted: #b5ab99;
  --ink-dim: #776f60;
  --acid: #d4a843;      /* ember gold — the realm's one accent */
  --acid-hot: #e2b44d;
  --cyan: #d4a843;
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  --common: #98928a;    /* footman iron */
  --rare: #6f9bd1;      /* knight steel-blue */
  --epic: #a678d4;      /* highlord amethyst */
  --legendary: #e0a63c; /* sovereign gold */
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1000px 640px at 85% -12%, rgba(212, 168, 67, .05), transparent 62%),
    radial-gradient(820px 520px at -8% 108%, rgba(212, 168, 67, .035), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: 'Outfit', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.mono { font-family: 'Fragment Mono', ui-monospace, monospace; }

.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .3;
  background-image:
    linear-gradient(rgba(212, 168, 67, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 168, 67, .045) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse at center, #000 25%, transparent 75%);
}
.glow { position: fixed; z-index: 0; pointer-events: none; filter: blur(90px); border-radius: 50%; }
.glow.a { top: -140px; left: -100px; width: 420px; height: 420px; background: #1a140c; opacity: .75; }
.glow.b { bottom: -180px; right: -140px; width: 480px; height: 480px; background: #33230f; opacity: .28; }

main { position: relative; z-index: 1; max-width: 1020px; margin: 0 auto; padding: 34px 26px 90px; }

/* header */
header.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand .mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  filter: drop-shadow(0 6px 18px rgba(212, 168, 67, .35));
}
.wordmark { font-family: 'Cinzel', serif; font-size: 21px; letter-spacing: .12em; }
.netline { font-size: 11.5px; color: var(--ink-dim); letter-spacing: .04em; margin-top: 2px; }
.wallet-chip {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 8px 16px; font-family: 'Fragment Mono', monospace; font-size: 12.5px; color: var(--ink-muted);
}
.wallet-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acid-hot); box-shadow: 0 0 10px var(--acid-hot); }
.wallet-chip .htr { color: var(--acid); font-weight: 600; }

/* machine panel */
.machine-panel {
  margin-top: 46px; display: grid; grid-template-columns: 280px 1fr; gap: 36px; align-items: center;
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-lg); padding: 40px 36px 44px;
}
@media (max-width: 760px) { .machine-panel { grid-template-columns: 1fr; text-align: center; } .machine { margin: 0 auto; } }
.machine { width: 100%; max-width: 300px; position: relative; }
.machine img {
  display: block; width: 100%; height: 440px; object-fit: cover; object-position: center 74%;
  border-radius: var(--r-md);
  border: 1px solid rgba(212, 168, 67, .22);
}
.machine::after {
  content: ''; position: absolute; inset: 0; border-radius: var(--r-md);
  pointer-events: none;
  background: radial-gradient(120% 90% at 62% 40%, transparent 45%, rgba(11, 10, 8, .55) 100%);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 67, .12), inset 0 -40px 60px -30px rgba(11, 10, 8, .8);
}
.machine.shaking { animation: shake .5s ease-in-out infinite; }
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2.4deg); }
  75% { transform: rotate(2.4deg); }
}
.cap { opacity: .95; }
.cap.c0 { fill: var(--common); } .cap.c0b { fill: #c3cad4; }
.cap.c1 { fill: var(--rare); } .cap.c1b { fill: #7fb0ff; }
.cap.c2 { fill: var(--epic); }
.cap.c3 { fill: var(--legendary); }
#capsules circle { animation: bob 3.4s ease-in-out infinite; transform-origin: center; }
#capsules circle:nth-child(2) { animation-delay: .6s; }
#capsules circle:nth-child(3) { animation-delay: 1.2s; }
#capsules circle:nth-child(4) { animation-delay: 1.8s; }
#capsules circle:nth-child(5) { animation-delay: 2.4s; }
#capsules circle:nth-child(6) { animation-delay: 3s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.pull-col h1 { font-size: 42px; line-height: 1.04; margin: 0 0 14px; font-weight: 800; letter-spacing: -.03em; text-wrap: balance; }
.pull-col .accent { color: var(--acid); text-shadow: 0 0 30px rgba(212, 168, 67, .32); }
.sub { color: var(--ink-muted); font-size: 14.5px; line-height: 1.7; margin: 0 0 22px; max-width: 56ch; text-wrap: pretty; }

.odds { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 24px; }
.odd {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 13px;
  font-size: 12px; display: flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, .25);
}
.odd b { font-size: 13px; }
.odd .pct { color: var(--ink-dim); }
.odd .left { font-family: 'Fragment Mono', monospace; font-size: 11px; color: var(--ink-dim); }
.odd .swatch { width: 9px; height: 9px; border-radius: 3px; }

.pull-btn {
  display: inline-flex; align-items: baseline; gap: 14px; cursor: pointer;
  font-family: 'Cinzel', serif; font-size: 26px; letter-spacing: .14em;
  color: #241703; background: linear-gradient(135deg, #caa03f, #e6bd5e);
  border: none; border-radius: 14px; padding: 18px 40px;
  box-shadow: 0 14px 45px -12px rgba(212, 168, 67, .5);
  transition: transform .12s ease, box-shadow .12s ease, filter .2s;
}
.pull-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 20px 55px -12px rgba(226, 180, 77, .6); }
.pull-btn:active:not(:disabled) { transform: translateY(1px); }
.pull-btn:disabled { filter: grayscale(.75) brightness(.6); cursor: not-allowed; box-shadow: none; }
.pull-cost { font-family: 'Fragment Mono', monospace; font-size: 14px; letter-spacing: 0; opacity: .8; }
.pull-note { margin-top: 12px; font-size: 12.5px; color: var(--ink-dim); }
.pull-note a { color: var(--cyan); }

/* stats */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0;
  margin-top: 18px; border: 1px solid var(--line); background: var(--panel);
  border-radius: var(--r-md); overflow: hidden;
}
.stats-row .stat { border: none; border-left: 1px solid var(--line); border-radius: 0; padding: 16px 18px; background: none; }
.stats-row .stat:first-child { border-left: none; }
.farm-summary .stat { border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-md); padding: 16px 18px; }
.stat .k { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
.stat .v { font-family: 'Fragment Mono', monospace; font-variant-numeric: tabular-nums; font-size: 22px; margin-top: 6px; color: var(--ink); }
.stat .v small { font-size: 12px; color: var(--ink-dim); }

/* shelves */
.shelf { margin-top: 44px; }
.shelf h2 { font-size: 16px; letter-spacing: .06em; margin: 0 0 16px; color: var(--ink-muted); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.empty { color: var(--ink-dim); font-size: 14px; border: 1px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center; }

.card {
  position: relative; border-radius: var(--r-md); padding: 20px 18px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .015));
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 18px 44px -18px var(--rc, rgba(0,0,0,.6)); }
.card .row-btns, .card .claim-mini { margin-top: auto; }
.card .row-btns { padding-top: 12px; }
.card .claim-mini { margin-top: auto; }
.card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--rc, var(--common));
}
.card .emoji { font-size: 40px; line-height: 1; filter: drop-shadow(0 0 14px var(--rc)); }
.card .name { font-weight: 700; font-size: 15.5px; margin-top: 12px; }
.card .tier { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--rc); margin-top: 3px; font-weight: 700; }
.card .uid { font-family: 'Fragment Mono', monospace; font-size: 10px; color: var(--ink-dim); margin: 10px 0 12px; word-break: break-all; }
.card .claim-mini {
  margin-top: auto; width: 100%; cursor: pointer;
  font-family: 'Cinzel', serif; letter-spacing: .1em; font-size: 13px;
  color: #241703; background: linear-gradient(135deg, #caa03f, #e6bd5e);
  border: none; border-radius: 9px; padding: 9px 0;
}
.card .claim-mini:disabled { filter: grayscale(.7) brightness(.65); cursor: wait; }

footer { margin-top: 60px; font-size: 11px; color: var(--ink-dim); }
footer a { color: var(--cyan); text-decoration: none; }

/* overlay */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(2, 5, 18, .88); backdrop-filter: blur(8px);
}
.overlay[hidden], .stage[hidden] { display: none; }
.overlay-inner { text-align: center; padding: 24px; }

.capsule-drop { animation: drop-bounce 1.6s ease-in-out infinite; margin-bottom: 30px; }
.capsule { width: 92px; height: 92px; margin: 0 auto; position: relative; }
.capsule-top, .capsule-bottom { position: absolute; left: 0; width: 92px; height: 46px; }
.capsule-top { top: 0; border-radius: 92px 92px 0 0; background: linear-gradient(180deg, #ff5977, #d63c5e); }
.capsule-bottom { bottom: 0; border-radius: 0 0 92px 92px; background: linear-gradient(180deg, #eef2f7, #c6cede); }
@keyframes drop-bounce { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-16px) rotate(4deg); } }
.wait-title { font-family: 'Cinzel', serif; font-size: 21px; letter-spacing: .05em; }
.wait-sub { color: var(--ink-muted); font-size: 13.5px; margin-top: 8px; }
.wait-timer { color: var(--ink-dim); font-size: 12px; margin-top: 16px; }

.prize-card {
  width: 270px; margin: 0 auto 24px; border-radius: 20px; padding: 34px 24px 26px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
  border: 1.5px solid var(--rc, var(--common));
  box-shadow: 0 0 70px -12px var(--rc, var(--common));
  animation: card-in .55s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes card-in { 0% { transform: scale(.35) rotateY(90deg); opacity: 0; } 100% { transform: scale(1) rotateY(0); opacity: 1; } }
.prize-emoji { font-size: 74px; line-height: 1; filter: drop-shadow(0 0 26px var(--rc)); }
.prize-tier { margin-top: 16px; font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--rc); font-weight: 800; }
.prize-name { font-size: 24px; font-weight: 800; margin-top: 6px; }
.prize-uid { font-size: 10px; color: var(--ink-dim); margin-top: 12px; word-break: break-all; }

.claim-btn {
  display: block; margin: 0 auto; cursor: pointer;
  font-family: 'Cinzel', serif; font-size: 16px; letter-spacing: .12em;
  color: #241703; background: linear-gradient(135deg, #caa03f, #e6bd5e);
  border: none; border-radius: 12px; padding: 14px 34px;
  box-shadow: 0 12px 40px -10px rgba(212, 168, 67, .45);
}
.ghost-btn {
  display: block; margin: 14px auto 0; cursor: pointer; background: none;
  border: none; color: var(--ink-dim); font-size: 13px; text-decoration: underline;
}
.err-emoji { font-size: 54px; margin-bottom: 18px; }

/* v2: tabs, arena, farm, connect */
.wallet-chip.as-btn { cursor: pointer; transition: border-color .15s; }
.wallet-chip.as-btn:hover { border-color: var(--acid); }
.wallet-chip .dot.off { background: var(--ink-dim); box-shadow: none; }

.tabs { display: flex; gap: 8px; margin-top: 44px; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; cursor: pointer; color: var(--ink-dim);
  font-family: 'Cinzel', serif; font-size: 14px; letter-spacing: .1em;
  padding: 12px 18px; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--acid); border-bottom-color: var(--acid); }
.tabpane { margin-top: 26px; }
.mt { margin-top: 34px !important; }

.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.mini-btn {
  cursor: pointer; font-family: 'Cinzel', serif; letter-spacing: .08em; font-size: 12px;
  color: #241703; background: linear-gradient(135deg, #caa03f, #e6bd5e);
  border: none; border-radius: 8px; padding: 8px 14px;
}
.mini-btn.alt { background: none; color: var(--ink-muted); border: 1px solid var(--line); }
.mini-btn:disabled { filter: grayscale(.75) brightness(.6); cursor: not-allowed; }
.row-btns { display: flex; gap: 8px; margin-top: 12px; }
.row-btns .mini-btn { flex: 1; }

.card.selected { outline: 2px solid var(--acid); outline-offset: 2px; }
.fuse-bar { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-muted); }
.pending-gems { margin-top: 10px; font-family: 'Fragment Mono', monospace; font-size: 12px; color: var(--acid); }

.farm-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 26px; }
.farm-summary .row-btns { margin-top: 12px; }

.duels { display: flex; flex-direction: column; gap: 12px; }
.duel {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-md); padding: 14px 18px;
}
.duel.closed { opacity: .45; }
.duel-emoji { font-size: 30px; }
.duel-info { flex: 1; font-size: 14px; }
.duel-meta { font-size: 11.5px; color: var(--ink-dim); margin-top: 3px; }
.duel-done { font-size: 11px; letter-spacing: .12em; color: var(--ink-dim); text-transform: uppercase; }

.connect-list { display: flex; flex-direction: column; gap: 10px; margin: 22px auto 14px; max-width: 360px; }
.connect-opt {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start; text-align: left;
  cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  border-radius: 12px; padding: 13px 16px; color: var(--ink); font-family: 'Outfit', sans-serif;
}
.connect-opt:hover { border-color: var(--acid); }
.connect-opt b { font-size: 15px; }
.connect-opt span { font-size: 12px; color: var(--ink-dim); }
.wc-pair { margin-top: 14px; }
.wc-pair canvas { background: #fff; border-radius: 12px; padding: 6px; }
.wc-pair textarea {
  width: 100%; max-width: 360px; margin-top: 8px; background: rgba(0,0,0,.4);
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink-muted);
  font-family: 'Fragment Mono', monospace; font-size: 10px; padding: 8px;
}
.pick-cards { max-width: 640px; margin: 22px auto; max-height: 46vh; overflow-y: auto; }
.pick-wager { color: var(--ink-muted); font-size: 14px; }
.pick-wager input {
  width: 90px; background: rgba(0,0,0,.4); border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); font-family: 'Fragment Mono', monospace; padding: 6px 9px; margin-left: 8px;
}
.prize-power { margin-top: 8px; font-family: 'Fragment Mono', monospace; font-size: 15px; color: var(--ink); }
.duel-banner { font-family: 'Cinzel', serif; font-size: 40px; letter-spacing: .1em; margin-bottom: 14px; }
.duel-banner.win { color: var(--acid); text-shadow: 0 0 40px rgba(212,168,67,.5); }
.duel-banner.lose { color: var(--danger, #ff6b8a); }

/* background tx toasts */
.toasts {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  display: flex; flex-direction: column-reverse; gap: 10px; max-width: 340px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: #0d1430; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; box-shadow: 0 14px 40px -12px rgba(0,0,0,.7);
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast .t-body { flex: 1; min-width: 0; }
.toast b { font-size: 13px; display: block; }
.toast .t-sub { font-size: 11px; color: var(--ink-dim); display: block; word-break: break-word; }
.toast .t-time { font-size: 11px; color: var(--ink-dim); }
.toast .t-spin {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  border: 2px solid rgba(212,168,67,.25); border-top-color: var(--acid);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast.ok { border-color: rgba(212,168,67,.5); }
.toast.ok .t-spin { animation: none; border-color: var(--acid); background: var(--acid); }
.toast.fail { border-color: rgba(255,107,138,.6); }
.toast.fail .t-spin { animation: none; border-color: #ff6b8a; background: #ff6b8a; }
.toast .t-x { background: none; border: none; color: var(--ink-dim); cursor: pointer; font-size: 13px; }

/* taste pass: states, texture, focus */
button { transition: transform .18s ease, filter .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease; }
button:active:not(:disabled) { transform: scale(.98); }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; border-radius: 4px; }
html { scroll-behavior: smooth; }

.mini-btn:hover:not(:disabled) { filter: brightness(1.1); }
.mini-btn.alt:hover:not(:disabled) { border-color: var(--acid); color: var(--ink); filter: none; }
.tab:hover { color: var(--ink-muted); }
.tab.active:hover { color: var(--acid); }
.claim-mini:hover:not(:disabled) { filter: brightness(1.08); }
.connect-opt:active { transform: scale(.99); }

/* fixed grain overlay: breaks digital flatness (pointer-events: none) */
body::after {
  content: ''; position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* tinted shadows on primary actions (match background hue, not black) */
.pull-btn { box-shadow: 0 14px 45px -12px rgba(212, 168, 67, .38), 0 4px 14px -6px rgba(5, 8, 23, .8); }
.toast { box-shadow: 0 14px 40px -12px rgba(5, 8, 23, .85); }

/* learn page */
.guide { list-style: none; margin: 0; padding: 0; counter-reset: step; max-width: 64ch; }
.guide li { counter-increment: step; position: relative; padding: 0 0 30px 58px; }
.guide li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 1px;
  font-family: 'Fragment Mono', monospace; font-size: 13px; color: var(--acid);
  border: 1px solid rgba(212, 168, 67, .3); border-radius: var(--r-sm);
  padding: 6px 8px; background: rgba(212, 168, 67, .06);
}
.guide li:not(:last-child)::after {
  content: ''; position: absolute; left: 16px; top: 40px; bottom: 8px;
  width: 1px; background: var(--line);
}
.guide h3 { margin: 2px 0 7px; font-size: 16.5px; font-weight: 700; letter-spacing: -.01em; }
.guide p { margin: 0; color: var(--ink-muted); font-size: 14px; line-height: 1.7; text-wrap: pretty; }
.guide a, .faq a { color: var(--acid); text-decoration-color: rgba(212, 168, 67, .4); }

.faq { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 26px 34px; }
.faq .qa h4 { margin: 0 0 7px; font-size: 14.5px; font-weight: 700; letter-spacing: -.005em; }
.faq .qa p { margin: 0; color: var(--ink-muted); font-size: 13.5px; line-height: 1.65; text-wrap: pretty; }
@media (max-width: 700px) { .faq { grid-template-columns: 1fr; } }

/* codex chronicle */
.lore { max-width: 64ch; border-left: 2px solid rgba(212, 168, 67, .35); padding-left: 22px; margin-bottom: 8px; }
.lore p { color: var(--ink-muted); font-size: 14.5px; line-height: 1.75; margin: 0 0 14px; text-wrap: pretty; }
.lore b { color: var(--ink); font-weight: 600; }
