:root {
  --bg: #120b24;
  --bar: #1c1238;
  --bar-line: #8b5cf6;
  --panel: #221640;
  --panel2: #2e1f55;
  --text: #f3eeff;
  --muted: #a99cc9;
  --gold: #ffc233;
  --gold-dark: #b37a00;
  --cyan: #2fd3e8;
  --pixel: "Press Start 2P", monospace;
  --ui: "Jersey 10", "Segoe UI", sans-serif; /* pixelated and easy to read (similar to the damage numbers) */
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 21px;
  /* the pixel fonts have no bold face: never fake one (synthetic bold smears the letters) */
  font-synthesis: none;
}
b, strong, .hero-name { font-weight: 400; }
[hidden] { display: none !important; }
canvas { image-rendering: auto; }

/* ---------- Buttons ---------- */
.btn {
  background: var(--panel2); color: var(--text); border: 2px solid #4c3a85; border-radius: 6px;
  padding: 8px 14px; font: 600 18px var(--ui); cursor: pointer;
}
.btn:hover { background: #3b2a6b; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 17px; }
.btn.primary, .btn-gold {
  background: linear-gradient(180deg, #ffd65a, #f0a800); color: #2a1a00; border: 3px solid #1a1030;
  box-shadow: inset 0 -4px 0 #c27f00, 0 4px 0 #1a1030; border-radius: 6px;
}
.btn-gold { font: 12px var(--pixel); padding: 14px 22px; cursor: pointer; letter-spacing: 1px; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-gold:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #c27f00, 0 2px 0 #1a1030; }
.btn-gold.big { font-size: 18px; padding: 18px 34px; min-width: 320px; display: flex; justify-content: space-between; gap: 24px; }
.btn.danger { border-color: #a8324a; background: #4a1525; }

/* ---------- Wallet connection ---------- */
.connect {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 30%, #3a1d7a, #120b24 70%);
}
.connect-card {
  width: 100%; max-width: 560px; background: #1c1238; border: 4px solid #0d0820; border-radius: 0;
  padding: 22px; text-align: center;
  box-shadow: 0 0 0 4px var(--bar-line), 0 0 0 8px #0d0820, 0 0 48px #8b5cf666;
}
.connect-card canvas { width: 100%; height: auto; max-width: 520px; }
#connect-scene { image-rendering: pixelated; margin-top: -4px; }
.online-pill {
  display: inline-flex; align-items: center; gap: 8px; font: 9px var(--pixel); color: #b6ffcf; background: #0f2a1d;
  border: 3px solid #0d0820; padding: 7px 12px; margin-top: 10px; box-shadow: 0 3px 0 #0d0820;
}
.online-pill i { width: 8px; height: 8px; background: #3cff7a; box-shadow: 0 0 6px #3cff7a; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.connect-tag { font: 12px var(--pixel); color: var(--gold); margin: 16px 0 8px; line-height: 1.6; text-shadow: 2px 2px 0 #0d0820; }
.connect-text { color: #d9cffa; font-size: 20px; margin: 0 0 16px; line-height: 1.15; }
.wallet-list { display: flex; flex-direction: column; gap: 12px; }
.wallet-btn {
  display: flex; align-items: center; gap: 14px; background: #2e1f55; border: 3px solid #0d0820; border-radius: 0;
  color: var(--text); padding: 10px 14px; font: 13px var(--pixel); cursor: pointer; text-align: left;
  box-shadow: inset 0 -5px 0 #1f1440, inset 0 3px 0 #4c3a85, 0 4px 0 #0d0820;
}
.wallet-btn:hover { background: #3d2a78; box-shadow: inset 0 -5px 0 #2a1c52, inset 0 3px 0 var(--gold), 0 4px 0 #0d0820; }
.wallet-btn:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 #1f1440, 0 1px 0 #0d0820; }
.wallet-btn canvas { width: 40px; height: 40px; flex: none; image-rendering: pixelated; }
.wallet-btn small { margin-left: auto; color: var(--muted); font: 8px var(--pixel); }
.wallet-btn small.found { color: #3cff7a; }
.connect-note { color: var(--muted); font-size: 17px; margin-top: 16px; }
.connect-invite { font: 9px var(--pixel); color: var(--gold); line-height: 1.7; margin: 8px 0 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--bar); border-bottom: 2px solid var(--bar-line); padding: 8px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 6px; }
.brand img { width: 36px; height: 36px; image-rendering: pixelated; }
.brand b { display: block; font: 14px var(--pixel); letter-spacing: 1px; }
.brand small { display: block; font: 7px var(--pixel); color: var(--muted); margin-top: 4px; letter-spacing: 1px; }
.pill {
  font: 9px var(--pixel); padding: 8px 12px; border-radius: 5px; border: 2px solid #0d0820; text-decoration: none;
  color: #fff; cursor: pointer; white-space: nowrap; line-height: 1.2;
}
.pill-x { background: #000; display: inline-flex; align-items: center; justify-content: center; padding: 6px 14px; }
.pill-x svg { width: 16px; height: 16px; fill: #fff; display: block; }
.pill-x:hover { background: #222; }
.pill-buy { background: var(--gold); color: #2a1a00; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill-balance { background: #120b24; border-color: #4c3a85; color: var(--gold); }
.pill-wallet { background: #120b24; border-color: #4c3a85; color: #fff; }

/* ---------- Stage ---------- */
.stage { max-width: 1400px; margin: 0 auto; padding-bottom: 96px; min-height: calc(100vh - 60px); }
.screen { display: none; }
.screen.active { display: block; }
.page { padding: 16px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font: 16px var(--pixel); margin: 0; color: var(--gold); }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 17px; line-height: 1.4; }

/* ---------- Home scene ---------- */
.scene { position: relative; overflow: hidden; background: #0b0a24; border-left: 2px solid #2e1f55; border-right: 2px solid #2e1f55; }
.sky {
  position: relative; min-height: 470px; padding: 40px 16px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: #0b0a24;
}
#sky { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sky > *:not(#sky) { position: relative; z-index: 1; }
.sun {
  position: absolute; right: 9%; top: 40px; width: 120px; height: 120px; border-radius: 50%;
  background: #ffe36b; box-shadow: 0 0 0 16px #ffe36b55, 0 0 0 32px #ffe36b22;
}
.cloud { position: absolute; background: #fff; border-radius: 40px; opacity: .95; animation: drift 60s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 55%; height: 140%; left: 15%; top: -60%; }
.cloud::after { width: 40%; height: 110%; right: 12%; top: -40%; }
.c1 { width: 120px; height: 36px; left: 8%; top: 120px; }
.c2 { width: 90px; height: 28px; left: 58%; top: 70px; animation-duration: 80s; }
.c3 { width: 140px; height: 40px; left: 78%; top: 210px; animation-duration: 70s; }
.c4 { width: 100px; height: 30px; left: 30%; top: 300px; animation-duration: 90s; }
@keyframes drift { from { transform: translateX(-30px); } 50% { transform: translateX(30px); } to { transform: translateX(-30px); } }
#banner {
  position: relative; width: 100%; max-width: 640px; height: auto; border-radius: 14px;
  box-shadow: 0 0 0 4px #1a1030, 0 10px 30px #1a103088;
}
.home-stats { position: relative; font: 10px var(--pixel); color: #e9e2ff; text-shadow: 0 2px 0 #0b0a24; }
#field { display: block; width: 100%; height: 260px; }

/* ---------- Heroes ---------- */
.hero-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.hero-card {
  background: var(--panel); border-radius: 10px; padding: 12px; border: 2px solid var(--rc);
  display: flex; flex-direction: column; gap: 8px;
}
.hero-card.selected { box-shadow: 0 0 18px color-mix(in srgb, var(--rc) 55%, transparent); }
.hero-card.r4, .hero-card.r5 { background: linear-gradient(160deg, color-mix(in srgb, var(--rc) 20%, var(--panel)), var(--panel) 60%); }
.hero-top { display: flex; gap: 10px; align-items: center; }
.hero-top canvas { width: 84px; height: 84px; border-radius: 8px; background: #0005; flex: none; }
.rarity { font: 8px var(--pixel); text-transform: uppercase; color: var(--rc); letter-spacing: 1px; }
.rarity.big { font-size: 13px; margin-top: 6px; }
.hero-name { font-size: 22px; }
.hero-title { font-size: 17px; color: var(--muted); }
.tags { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.tag-pill { font-size: 14px; background: #ffffff1a; padding: 2px 8px; border-radius: 999px; }
.tag-pill.work { background: #4cc36b33; color: #8af0a5; }
.stats { display: grid; grid-template-columns: auto 1fr auto; gap: 3px 8px; font-size: 17px; align-items: center; text-align: left; }
.stat-bar, .energy-bar { height: 6px; background: #0006; border-radius: 3px; overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: var(--rc); }
.energy { font-size: 16px; color: var(--muted); }
.energy-bar { height: 8px; margin-top: 3px; }
.energy-bar i { display: block; height: 100%; background: linear-gradient(90deg, #4cc36b, #b6f36b); }
.skills { display: flex; flex-wrap: wrap; gap: 4px; }
.skill-chip {
  font-size: 16px; background: #0004; border: 1px solid color-mix(in srgb, var(--rc) 60%, transparent);
  border-radius: 5px; padding: 2px 6px; cursor: help; white-space: nowrap;
}
.hero-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: auto; }
/* the three hero buttons always have the same size and shape */
.hero-actions .btn { height: 40px; padding: 0 4px; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Shop, chests, settings ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.shop-card, .chest-box, .settings-box {
  background: var(--panel); border: 2px solid #4c3a85; border-radius: 12px; padding: 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.shop-card h3 { font: 13px var(--pixel); color: var(--gold); margin: 4px 0; }
.odds { align-items: stretch; text-align: left; }
.odds-row { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid #ffffff12; }
.chest-box { max-width: 520px; margin: 0 auto; }
.chest-count { font: 14px var(--pixel); color: var(--gold); }
.settings-box { max-width: 520px; margin: 0 auto; align-items: stretch; }
.settings-box b { word-break: break-all; }

/* ---------- Match ---------- */
#hud { flex: 1; font-weight: 600; font-size: 20px; min-width: 200px; }
.game-area { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.game-wrap { position: relative; flex: 1 1 520px; max-width: 720px; }
#game { width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 10px 40px #0008; background: #000; }
#side-panel { flex: 1 1 260px; max-width: 720px; }
.overlay {
  position: absolute; inset: 0; background: #0b0d1acc; border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
}
.overlay h2 { margin: 0; font: 16px var(--pixel); color: var(--gold); line-height: 1.5; }
.panel-card { background: var(--panel); border-radius: 10px; padding: 14px; }
.panel-card h3 { margin: 0 0 10px; font: 11px var(--pixel); color: var(--gold); }
.panel-actions { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
#agent-list { max-height: 360px; overflow: auto; padding-right: 4px; }
.agent { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; align-items: center; margin-bottom: 8px; font-size: 18px; }
.agent .energy-bar { grid-column: 1 / -1; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.vault-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.vault-count { font-size: 16px; padding: 3px 8px; border-radius: 999px; background: #0004; }
.vault-wood { color: #d9a066; } .vault-silver { color: #dfe6ee; } .vault-gold { color: #ffd23f; }
.vault-diamond { color: #7df9ff; } .vault-cage { color: #ff7ad9; }

/* ---------- Treasure Hunt: segmented bar, map on the left, heroes on the right ---------- */
#hud { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px; background: #120b24; border: 2px solid #4c3a85; border-radius: 5px;
  padding: 6px 10px; font: 9px var(--pixel); color: #fff; white-space: nowrap;
}
.hud-pill.gold { color: var(--gold); }
.hud-pill.cage { color: #fff; }
.pot-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid #0008; }
.pot-wood { background: #8a5a2e; } .pot-silver { background: #b8c2cc; } .pot-gold { background: #e8b923; } .pot-diamond { background: #5fe3ff; }

.game-area:has(#side-panel.treasure) { flex-wrap: nowrap; align-items: flex-start; }
.game-wrap.big { flex: 1 1 auto; max-width: none; min-width: 0; }
#side-panel.treasure {
  flex: 0 0 360px; max-width: 360px; position: sticky; top: 64px;
  max-height: calc(100vh - 150px); display: flex; flex-direction: column;
}
#side-panel.treasure.collapsed { flex-basis: auto; max-width: none; }
#side-panel.treasure.collapsed .tw-panel { display: none; }
.tw-show { display: none; }
#side-panel.treasure.collapsed .tw-show { display: block; }
.tw-panel {
  background: #1c1238; border: 2px solid var(--cyan); border-radius: 10px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; min-height: 0; max-height: 100%;
}
.tw-head { display: flex; align-items: center; gap: 8px; }
.tw-head b { font: 11px var(--pixel); color: var(--cyan); }
.tw-head span { flex: 1; font: 8px var(--pixel); color: #fff; line-height: 1.5; }
.tw-actions { display: flex; gap: 8px; }
.small-gold { font-size: 9px; padding: 8px 12px; }
.tw-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; min-height: 0; flex: 1; }
.tw-hero {
  display: flex; align-items: center; gap: 8px; background: #241a48; border: 2px solid #3b2d6b; border-radius: 8px; padding: 6px;
}
.tw-hero.working { border-color: color-mix(in srgb, var(--rc) 70%, #4cc36b); }
.tw-hero canvas { width: 48px; height: 48px; flex: none; border-radius: 6px; background: #0004; }
.tw-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tw-top { display: flex; align-items: center; gap: 6px; }
.tw-top b { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-rar { margin-left: auto; font: 7px var(--pixel); color: #120b24; background: var(--rc); padding: 3px 5px; border-radius: 3px; white-space: nowrap; }
.tw-meta { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-hero .btn { flex: none; font: 8px var(--pixel); padding: 8px; }
@media (max-width: 900px) {
  .game-area:has(#side-panel.treasure) { flex-wrap: wrap; }
  #side-panel.treasure { flex: 1 1 100%; max-width: none; position: static; max-height: none; }
}

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 8px;
  background: var(--bar); border-top: 2px solid var(--cyan); padding: 8px; overflow-x: auto;
}
.bottom-nav button {
  position: relative; width: 74px; flex: none; background: #2a1c52; border: 2px solid #0d0820; border-radius: 6px;
  color: #fff; font: 8px var(--pixel); padding: 6px 2px 7px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 5px;
}
.bottom-nav button:hover, .bottom-nav button.active { background: #3d2a78; border-color: var(--gold); }
.bottom-nav i { font-style: normal; font-size: 29px; line-height: 1; height: 28px; display: flex; align-items: center; }
.bottom-nav i { height: 32px; }
.bottom-nav i canvas { width: 32px; height: 32px; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 #0d0820); }
.bottom-nav em {
  position: absolute; top: -6px; right: -6px; background: #ff3d6e; color: #fff; font: 8px var(--pixel); font-style: normal;
  padding: 4px 5px; border-radius: 999px; border: 2px solid #0d0820;
}

/* ---------- Modal and notices ---------- */
.modal { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-box {
  background: var(--panel); border-radius: 14px; padding: 20px; max-width: 360px; width: 100%; text-align: center;
  display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--rc, #fff3); animation: pop .35s cubic-bezier(.2, 1.4, .5, 1);
}
.modal-box > canvas { margin: 0 auto; width: 180px; height: 180px; }
.modal-box p { margin: 0; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translate(-50%, 20px); background: #000d; color: #fff;
  padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; z-index: 60; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Touch ---------- */
.touch { display: none; }
@media (pointer: coarse) {
  .touch { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; user-select: none; touch-action: none; }
}
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 4px; }
.dpad button { background: var(--panel2); color: var(--text); border: 1px solid #ffffff22; border-radius: 10px; font-size: 26px; touch-action: none; }
.bomb-btn { width: 88px; height: 88px; border-radius: 50%; font-size: 39px; touch-action: none; }

@media (max-width: 700px) {
  .pill-x, .pill-buy { display: none; }
  .brand small { display: none; }
  .btn-gold.big { min-width: 0; width: 100%; font-size: 13px; }
  .sun { width: 70px; height: 70px; }
}
/* close (X) buttons are red everywhere so they are easy to find */
.btn-close {
  padding: 6px 12px; font-size: 18px; line-height: 1; color: #fff; background: #d6243c; border: 3px solid #0d0820;
  border-radius: 6px; box-shadow: inset 0 -4px 0 #9b1b30, 0 3px 0 #0d0820;
}
.btn-close:hover { background: #ff3d55; }
.btn-close:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #9b1b30, 0 1px 0 #0d0820; }
.brand { cursor: pointer; }

/* Treasure Hunt fits entirely on screen: the map shrinks to the available height, the hero panel sits on the right
   at the same height and scrolls only internally — the page never gets a scrollbar */
html:has(#screen-game.active .game-wrap.big), body:has(#screen-game.active .game-wrap.big) { overflow: hidden; height: 100%; }
.stage:has(#screen-game.active .game-wrap.big) { padding-bottom: 0; min-height: 0; }
#screen-game.active:has(.game-wrap.big) { padding-top: 10px; padding-bottom: 0; }
#screen-game.active:has(.game-wrap.big) .page-head { margin-bottom: 10px; }
.game-area:has(.game-wrap.big) { justify-content: center; }
.game-wrap.big { flex: 0 1 auto; }
.game-wrap.big #game { width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 210px); }
#side-panel.treasure { position: static; max-height: calc(100vh - 210px); }
.pot-ico { width: 22px; height: 22px; margin: -6px -2px -6px -4px; image-rendering: auto; }

/* List scrollbar: thin and purple, no white track or arrows */
/* (in Chrome, ::-webkit-scrollbar rules only apply without scrollbar-color, so the standard rule is Firefox-only) */
@supports not selector(::-webkit-scrollbar) { .tw-list, #agent-list { scrollbar-width: thin; scrollbar-color: #7b5cff transparent; } }
.tw-list::-webkit-scrollbar, #agent-list::-webkit-scrollbar { width: 6px; }
.tw-list::-webkit-scrollbar-track, #agent-list::-webkit-scrollbar-track { background: transparent; }
.tw-list::-webkit-scrollbar-thumb, #agent-list::-webkit-scrollbar-thumb { background: #7b5cff; border-radius: 6px; }
.tw-list::-webkit-scrollbar-button, #agent-list::-webkit-scrollbar-button { display: none; height: 0; }

/* ---------- Shop: summon 1, 5 or 10 ---------- */
.summon-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.summon-btns .btn-gold { font-size: 11px; padding: 10px 12px; }

/* ---------- Houses ---------- */
.house-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.house-card {
  background: var(--panel); border: 2px solid #4c3a85; border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.house-card.owned { border-color: #4cc36b; }
.house-card canvas { width: 192px; height: 160px; image-rendering: pixelated; border-radius: 6px; }
.house-card h3 { margin: 0; font: 12px var(--pixel); color: var(--gold); }
.house-card p { margin: 0; min-height: 34px; }
.house-stats { display: flex; gap: 10px; font-size: 17px; flex-wrap: wrap; justify-content: center; }
.house-owned { font: 9px var(--pixel); color: #4cc36b; padding: 10px 0; }

/* ---------- Reveal: black scroll rises closed, unrolls top to bottom and glows in the rarity color ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 60; background: #000c; display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow: hidden;
}
.reveal-scroll { position: relative; width: min(560px, 94vw); animation: reveal-rise .8s cubic-bezier(.2,.9,.3,1.1) both; }
.reveal-rod {
  position: relative; z-index: 2; height: 18px; margin: 0 -18px; border-radius: 9px;
  background: linear-gradient(#3a3a46, #0b0b10 55%, #26262f); border: 2px solid #000;
  box-shadow: 0 0 0 2px #c9a227 inset;
}
.reveal-rod::before, .reveal-rod::after { content: ''; position: absolute; top: -4px; width: 12px; height: 26px; border-radius: 4px; background: #c9a227; border: 2px solid #000; }
.reveal-rod::before { left: -8px; } .reveal-rod::after { right: -8px; }
.reveal-rod.bottom { transform: translateY(calc(-1 * var(--h, 300px))); animation: reveal-rod 1.2s 1.1s ease-in-out forwards; }
.reveal-paper {
  background: radial-gradient(circle at 50% 35%, #1d1d26, #050507 75%); border-left: 3px solid #c9a227; border-right: 3px solid #c9a227;
  clip-path: inset(0 0 100% 0); animation: reveal-unroll 1.2s 1.1s ease-in-out forwards, reveal-glow 1.8s 2.3s ease-in-out infinite;
  max-height: calc(100vh - 90px); overflow-y: auto;
}
.reveal-inner { padding: 18px 16px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.reveal-inner h2 { margin: 0; font: 13px var(--pixel); color: var(--glow); text-shadow: 0 0 10px var(--glow); }
.reveal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; width: 100%; }
.reveal-grid.single { grid-template-columns: 1fr; max-width: 340px; }
.reveal-hero { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 16px; }
.reveal-hero b { font-size: 17px; }
.reveal-grid.single .reveal-hero b { font-size: 23px; }
.reveal-hero canvas { position: relative; z-index: 1; }
.reveal-glow {
  position: absolute; top: 0; left: 50%; width: 120px; height: 120px; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle, var(--rc) 0%, transparent 70%); opacity: 0; animation: reveal-burst 1.4s 2.1s ease-out forwards;
}
.reveal-grid.single .reveal-glow { width: 220px; height: 220px; }
.reveal-hero .stats, .reveal-hero .skills { width: 100%; justify-content: center; }
.reveal-inner .btn-gold { opacity: 0; animation: reveal-fade .4s 2.3s forwards; }
@keyframes reveal-rise { from { transform: translateY(110vh); } to { transform: translateY(0); } }
@keyframes reveal-unroll { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes reveal-rod { to { transform: translateY(0); } }
@keyframes reveal-glow { 0%, 100% { box-shadow: 0 0 24px 4px var(--glow); } 50% { box-shadow: 0 0 48px 12px var(--glow); } }
@keyframes reveal-burst { 0% { opacity: 0; transform: translateX(-50%) scale(.3); } 40% { opacity: .95; } 100% { opacity: .55; transform: translateX(-50%) scale(1); } }
@keyframes reveal-fade { to { opacity: 1; } }

/* HOUSE button: sends the hero to rest in a house; gray when energy is full */
.btn-house { background: #2e5a3d; border-color: #4cc36b; }
.btn-house.inside { background: #4cc36b; color: #0d2418; }
.btn-house:disabled { background: #3a3a46; border-color: #55555f; color: #8a8a96; cursor: not-allowed; }
.tag-pill.house { background: #4cc36b; color: #0d2418; }
.tw-btns { display: flex; flex-direction: column; gap: 4px; flex: none; }
.tw-btns .btn { width: 100%; }
.helper-row { margin-top: 12px; }
.helper-list { margin: 0; padding-left: 18px; text-align: left; font-size: 15px; line-height: 1.35; display: flex; flex-direction: column; gap: 4px; }
.helper-list b { color: var(--gold); }

/* ---------- Referrals ---------- */
.referral { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.ref-banner {
  display: flex; align-items: center; gap: 16px; background: var(--panel); border: 3px solid #0d0820; padding: 16px;
  box-shadow: 0 0 0 3px #4c3a85; flex-wrap: wrap; justify-content: center;
}
.ref-banner canvas { width: 48px; height: 48px; image-rendering: pixelated; flex: none; }
.ref-banner p { margin: 0; flex: 1; min-width: 220px; line-height: 1.2; }
.ref-banner b { color: var(--gold); }
.ref-notice { margin: 0; font: 9px var(--pixel); line-height: 1.8; color: #ffd8a8; background: #3a2410; border: 3px solid #0d0820; padding: 10px 12px; }
.ref-link { display: flex; gap: 10px; flex-wrap: wrap; }
.ref-link input {
  flex: 1; min-width: 200px; background: #120b24; color: var(--cyan); border: 3px solid #0d0820; box-shadow: 0 0 0 2px #4c3a85;
  font: 20px var(--ui); padding: 8px 12px;
}
.ref-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ref-stats div { background: var(--panel); border: 3px solid #0d0820; box-shadow: 0 0 0 2px #4c3a85; padding: 12px 6px; text-align: center; }
.ref-stats b { display: block; font: 18px var(--pixel); color: var(--gold); }
.ref-stats small { display: block; color: var(--muted); font-size: 18px; margin-top: 6px; }
.ref-by { margin: 0; text-align: center; }
.ref-table { width: 100%; border-collapse: collapse; background: var(--panel); border: 3px solid #0d0820; }
.ref-table th { font: 8px var(--pixel); color: var(--muted); text-align: left; padding: 10px 8px; border-bottom: 2px solid #4c3a85; }
.ref-table td { padding: 8px; border-bottom: 1px solid #ffffff12; font-size: 20px; }
.ref-table td:last-child { text-align: right; }
.ref-ok { color: #3cff7a; font: 8px var(--pixel); }
.btn-gold.small { font-size: 9px; padding: 8px 12px; }
.btn-gold:disabled { filter: grayscale(1) brightness(.7); cursor: default; }
.ref-loading { text-align: center; }

/* ---------- Market ---------- */
.market-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.market-tabs { display: flex; gap: 6px; }
.mtab {
  font: 10px var(--pixel); color: var(--muted); background: #2a1c52; border: 3px solid #0d0820; padding: 10px 14px; cursor: pointer;
  box-shadow: inset 0 -4px 0 #1f1440, 0 3px 0 #0d0820;
}
.mtab.active { color: #2a1a00; background: linear-gradient(180deg, #ffd65a, #f0a800); box-shadow: inset 0 -4px 0 #c27f00, 0 3px 0 #0d0820; }
.market-bar select {
  font: 18px var(--ui); color: var(--text); background: #2a1c52; border: 3px solid #0d0820; padding: 6px 8px; box-shadow: 0 3px 0 #0d0820;
}
.market-note { margin: 0 0 14px; font: 8px var(--pixel); line-height: 1.8; color: #ffd8a8; background: #3a2410; border: 3px solid #0d0820; padding: 8px 12px; }
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.market-card {
  background: linear-gradient(160deg, color-mix(in srgb, var(--rc) 22%, var(--panel)), var(--panel) 60%);
  border: 3px solid #0d0820; box-shadow: 0 0 0 3px var(--rc), 0 6px 0 #0d0820; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.market-card .hero-top canvas { border-radius: 0; image-rendering: auto; }
.market-seller { font-size: 16px; color: var(--muted); margin-top: 4px; }
.market-buy { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; border-top: 2px dashed #ffffff22; padding-top: 10px; }
.market-price { font: 11px var(--pixel); color: var(--gold); text-shadow: 2px 2px 0 #0d0820; }
.market-empty { grid-column: 1 / -1; text-align: center; padding: 30px 0; }
.btn-gold.btn-red { background: linear-gradient(180deg, #ff6b7d, #d6243c); color: #fff; box-shadow: inset 0 -4px 0 #9b1b30, 0 4px 0 #1a1030; }
.btn-list { background: #3a2410; border-color: var(--gold); color: var(--gold); }
.btn-list:hover { background: #5a3818; }
.modal-title { font: 12px var(--pixel); color: var(--gold); margin: 4px 0; line-height: 1.6; }
.modal-btns { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.price-input {
  font: 14px var(--pixel); color: var(--gold); background: #120b24; border: 3px solid #0d0820; box-shadow: 0 0 0 2px #4c3a85;
  padding: 10px; text-align: center; width: 100%;
}
.small-note { font-size: 16px; }

/* Treasure Hunt speed button (centered above the heroes panel) with its padlock on the right */
.speed-row { display: flex; justify-content: center; align-items: center; gap: 8px; }
#side-panel .speed-row { margin: 0 auto 10px; }
.speed-row[hidden] { display: none; }
#speed-row #btn-speed {
  min-width: 140px; font: 14px var(--pixel); padding: 12px 22px; letter-spacing: 1px;
  background: linear-gradient(180deg, #ffd65a, #f0a800); color: #2a1a00; border: 3px solid #0d0820; border-radius: 6px;
  box-shadow: inset 0 -4px 0 #c27f00, 0 4px 0 #0d0820;
}
#speed-row #btn-speed:hover { filter: brightness(1.08); }
#speed-row #btn-speed:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 #c27f00, 0 2px 0 #0d0820; }
#speed-row #btn-speed:disabled {
  background: #4a4a56; color: #9a9aa6; box-shadow: inset 0 -4px 0 #34343e, 0 4px 0 #0d0820; cursor: not-allowed; filter: none; transform: none;
}
.speed-lock {
  width: 48px; height: 46px; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: #2a1c52; border: 3px solid #0d0820; border-radius: 6px; box-shadow: inset 0 -4px 0 #1f1440, 0 4px 0 #0d0820;
}
.speed-lock:hover { background: #3d2a78; }
.speed-lock.open { background: #173a26; cursor: default; }
.speed-lock canvas { width: 32px; height: 32px; image-rendering: pixelated; }
.modal-box canvas.modal-icon { width: 96px; height: 96px; image-rendering: pixelated; }
.unlock-price { font: 13px var(--pixel); color: var(--gold); margin: 6px 0; }

/* Story hero picker */
.modal-box.picker { position: relative; max-width: 920px; max-height: 88vh; overflow-y: auto; padding-top: 18px; }
.modal-x { position: absolute; top: 10px; right: 10px; z-index: 2; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 6px; }
.pick-card {
  background: linear-gradient(160deg, color-mix(in srgb, var(--rc) 18%, var(--panel2)), var(--panel2) 70%);
  border: 3px solid #0d0820; box-shadow: 0 0 0 2px var(--rc); padding: 10px 8px; display: flex; flex-direction: column;
  align-items: center; gap: 4px;
}
.modal-box .pick-card canvas { width: 80px; height: 80px; margin: 0; }
.pick-card .rarity { color: var(--rc); }
.pick-stats { font-size: 15px; color: var(--muted); }
.pick-card .btn-gold { margin-top: 4px; width: 100%; }

.btn-list:disabled { background: #3a3a46; border-color: #55555f; color: #8a8a96; cursor: not-allowed; }

/* ---------- Upgrade ---------- */
.btn-upgrade { font-size: 11px; padding: 10px 16px; }
.tag-pill.lv { background: #0d0820; color: var(--gold); border: 1px solid var(--gold); }
.upg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .upg-layout { grid-template-columns: 1fr; } }
.upg-batch { background: var(--panel); border: 3px solid #0d0820; box-shadow: 0 0 0 2px #4c3a85; padding: 12px; }
.upg-slots { display: flex; flex-direction: column; gap: 6px; }
.upg-pair {
  display: grid; grid-template-columns: 56px 1fr auto auto auto; align-items: center; gap: 10px; padding: 6px 8px;
  background: #160e2e; border: 2px solid var(--rc); min-height: 68px;
}
.upg-pair.empty { display: flex; justify-content: center; border: 2px dashed #4c3a85; color: var(--muted); font-size: 18px; }
.upg-pair canvas { width: 56px; height: 56px; }
.upg-keep b { display: block; color: var(--rc); }
.upg-keep span { font: 9px var(--pixel); color: #3cff7a; }
.upg-burn { display: flex; align-items: center; gap: 6px; color: #ff8a9a; font-size: 16px; }
.upg-burn small { font: 7px var(--pixel); color: #ff3d55; }
.upg-burn canvas { width: 40px; height: 40px; opacity: .8; filter: grayscale(.4); }
.upg-cost { font: 9px var(--pixel); color: var(--gold); white-space: nowrap; }
.upg-pair .btn-close.small { padding: 4px 8px; font-size: 14px; }
.upg-total { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.upg-total span { font: 9px var(--pixel); color: var(--muted); }
.upg-total b { font: 13px var(--pixel); color: var(--gold); flex: 1; }
.upg-hint { margin: 12px 0; font-size: 19px; color: #d9cffa; }
.upg-hint b { color: var(--gold); }
.upg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.upg-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; cursor: pointer;
  background: linear-gradient(160deg, color-mix(in srgb, var(--rc) 18%, var(--panel2)), var(--panel2) 70%);
  border: 3px solid #0d0820; box-shadow: 0 0 0 2px var(--rc); color: var(--text); font: 18px var(--ui);
}
.upg-card:hover { filter: brightness(1.12); }
.upg-card.pending { box-shadow: 0 0 0 3px var(--gold), 0 0 18px var(--gold); transform: translateY(-2px); }
.upg-card.dim { opacity: .35; }
.upg-card canvas { width: 64px; height: 64px; }
.upg-card .rarity { color: var(--rc); }
.upg-card small { font-size: 14px; color: var(--muted); }
.lv-badge { position: absolute; top: 6px; left: 6px; font: 8px var(--pixel); color: var(--gold); background: #0d0820; padding: 4px 5px; border: 1px solid var(--gold); }
.upg-results { background: #0f2a1d; border: 3px solid #0d0820; box-shadow: 0 0 0 2px #3cff7a; padding: 12px; margin-bottom: 14px; }
.upg-results h3 { font: 11px var(--pixel); color: #3cff7a; margin: 0 0 8px; }
.upg-result { padding: 4px 0; font-size: 19px; }
.upg-result b { color: var(--rc); }
.upg-result span { color: var(--gold); margin-left: 8px; }
.upg-rules { background: var(--panel); border: 3px solid #0d0820; box-shadow: 0 0 0 2px #4c3a85; padding: 14px; font-size: 18px; }
.upg-rules h3 { font: 11px var(--pixel); color: var(--gold); margin: 0 0 8px; }
.upg-rules ul { margin: 0 0 12px; padding-left: 18px; line-height: 1.15; }
.upg-rules li { margin-bottom: 6px; }
.upg-rules b { color: #fff; }
.upg-table { width: 100%; border-collapse: collapse; font-size: 17px; }
.upg-table th { font: 7px var(--pixel); color: var(--muted); text-align: right; padding: 6px 4px; border-bottom: 2px solid #4c3a85; }
.upg-table th:first-child, .upg-table td:first-child { text-align: left; }
.upg-table td { text-align: right; padding: 5px 4px; border-bottom: 1px solid #ffffff12; }
.rar-pill { font: 7px var(--pixel); color: #0d0820; background: var(--rc); padding: 3px 5px; white-space: nowrap; }

/* houses in the Market and the LIST button on owned houses */
.market-card.house-listing { align-items: center; text-align: center; }
.market-card.house-listing canvas { width: 192px; height: 160px; image-rendering: pixelated; }
.market-card.house-listing .rarity { color: #4cc36b; }
.market-card.house-listing .market-buy { width: 100%; }
.house-list-btn { width: 100%; height: 40px; margin-top: 8px; }
.house-owned.listed { color: var(--gold); }
.modal-box canvas.modal-house { width: 192px; height: 160px; image-rendering: pixelated; }

/* fixed Market fee, shown to everyone next to the tabs */
.market-tabs { align-items: center; }
.market-fee { font: 9px var(--pixel); color: #ffd8a8; background: #3a2410; border: 3px solid #0d0820; box-shadow: 0 0 0 2px #c27f00; padding: 9px 12px; margin-left: 6px; white-space: nowrap; }

/* CAGES button (Hero Chests) next to UPGRADE, with the number of chests waiting */
.btn-cages { position: relative; }
.btn-cages em { position: absolute; top: -8px; right: -8px; background: #ff3d6e; color: #fff; font: 8px var(--pixel); font-style: normal; padding: 4px 5px; border-radius: 999px; border: 2px solid #0d0820; }

/* ---------- Claim (withdraw Chakra to the wallet) ---------- */
.claim { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.claim-card { background: var(--panel); border: 3px solid #0d0820; box-shadow: 0 0 0 3px var(--cyan); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.claim-card canvas { width: 64px; height: 64px; image-rendering: pixelated; }
.claim-balance { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.claim-balance small { font: 8px var(--pixel); color: var(--muted); }
.claim-balance b { font: 20px var(--pixel); color: var(--gold); text-shadow: 2px 2px 0 #0d0820; }
.claim-label { font: 9px var(--pixel); color: var(--cyan); margin-top: 6px; }
.claim-input { display: flex; gap: 8px; width: 100%; max-width: 380px; }
.claim-input input { flex: 1; font: 14px var(--pixel); color: var(--gold); background: #120b24; border: 3px solid #0d0820; box-shadow: 0 0 0 2px #4c3a85; padding: 10px; text-align: center; min-width: 0; }
.claim-input .btn { height: auto; }
.claim-breakdown { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; width: 100%; max-width: 380px; font-size: 19px; text-align: left; }
.claim-breakdown b { text-align: right; color: #ff8a9a; }
.claim-breakdown b.net { color: #3cff7a; }
.claim-rules { font-size: 17px; margin: 0; }
.claim-warn { margin: 0; font: 9px var(--pixel); color: #ffd8a8; line-height: 1.7; }
.claim-title { font: 11px var(--pixel); color: var(--gold); margin: 6px 0 0; }
.claim-pending { color: var(--gold); font: 8px var(--pixel); }

/* on-chain payment progress */
.pay-step { font: 9px var(--pixel); color: var(--cyan); line-height: 1.8; margin-top: 6px; }

/* payment window: picture of what is being bought */
.modal-box canvas.pay-art { width: auto; height: auto; max-width: 192px; margin: 0 auto; image-rendering: pixelated; }
.pay-price { font: 13px var(--pixel); color: var(--gold); margin: 4px 0; }

/* summon buttons: always one under the other */
.summon-btns { display: flex; flex-direction: column; align-items: center; gap: 12px; }
