/* ============================================================
   Koinos Crusaders — Koinos edition
   Retro dark-fantasy pixel theme
   ============================================================ */

:root {
  --bg-deep:    #0d0a14;
  --bg-stone:   #1a1426;
  --bg-panel:   #241b36;
  --bg-card:    #2e2344;
  --border-stone: #4a3b66;
  --gold:       #f2c94c;
  --gold-dark:  #b8901f;
  --rupee:      #34d399;
  --blood:      #e0455a;
  --mana:       #7f9cf5;
  --pi:         #8a3ffc;
  --pi-light:   #b07df7;
  --tg:         #2aabee;   /* Telegram brand blue — deliberately outside the game palette */
  --tg-deep:    #17313f;
  --text:       #e8e2f4;
  --text-dim:   #9b8fb5;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body:  'VT323', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 20px;
  -webkit-font-smoothing: none;
  overscroll-behavior: none;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; position: relative; }

/* ---------- screens ---------- */
.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--text);
  background: var(--bg-card);
  border: 3px solid var(--border-stone);
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: transform .06s, filter .15s;
  touch-action: manipulation;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold  { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: #241b00; border-color: #7c6011; }
.btn-pi    { background: linear-gradient(180deg, var(--pi-light), var(--pi)); color: #fff; border-color: #5b21b6; }
.btn-blood { background: linear-gradient(180deg, #f47187, var(--blood)); color: #2d060d; border-color: #8f1f30; }
.btn-stone { background: var(--bg-card); }
.btn-big   { font-size: 14px; padding: 18px 24px; }
.btn-small { font-size: 9px; padding: 8px 10px; }

/* ---------- title screen ---------- */
#screen-title {
  align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 20%, #2c1f4d 0%, transparent 55%),
    repeating-linear-gradient(0deg, #131020 0 42px, #171126 42px 44px),
    var(--bg-deep);
}
.title-wrap { text-align: center; padding: 24px; position: relative; width: 100%; }
.pixel-logo {
  image-rendering: pixelated;
  width: 96px; height: 96px;
  margin-bottom: 10px;
  filter: drop-shadow(0 6px 12px rgba(138, 63, 252, .4));
}
.game-logo { font-family: var(--font-pixel); line-height: 1.5; margin-bottom: 18px; }
.logo-line1 {
  display: block; font-size: clamp(16px, 5vw, 26px); color: var(--pi-light);
  text-shadow: 0 3px 0 #3c1a78, 0 6px 14px rgba(138, 63, 252, .45);
  letter-spacing: 6px;
}
.logo-line2 {
  display: block; font-size: clamp(26px, 8vw, 42px); color: var(--gold);
  text-shadow: 0 4px 0 #6b4e00, 0 8px 18px rgba(242, 201, 76, .35);
}
.tagline { color: var(--text-dim); font-size: 22px; margin-bottom: 34px; }
.title-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.title-buttons .btn { width: min(320px, 80vw); }
.title-status { margin-top: 16px; color: var(--rupee); min-height: 24px; font-size: 18px; }
.version-tag { margin-top: 26px; color: var(--text-dim); opacity: .6; font-size: 16px; }
.title-torch {
  position: absolute; top: -10px; width: 22px; height: 34px; border-radius: 40% 40% 30% 30%;
  background: radial-gradient(circle at 50% 30%, #ffe08a 0 30%, #ff9d2e 55%, #d43d0c 100%);
  animation: flicker 480ms infinite alternate; filter: blur(.4px);
}
.title-torch.left  { left: 8%; }
.title-torch.right { right: 8%; }
@keyframes flicker {
  from { transform: scale(1) rotate(-2deg); opacity: .92; }
  to   { transform: scale(1.12) rotate(2deg); opacity: 1; }
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px;
  background: var(--bg-stone);
  border-bottom: 3px solid var(--border-stone);
  position: sticky; top: 0; z-index: 5;
}
.player-chip { display: flex; align-items: center; gap: 10px; }
.player-name { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); }
.rupee-chip { font-size: 20px; color: var(--rupee); white-space: nowrap; }
.avatar-btn {
  width: 42px; height: 42px; font-size: 22px; line-height: 1; cursor: pointer;
  background: var(--bg-card); border: 2px solid var(--border-stone); border-radius: 10px;
  flex: 0 0 auto;
}
.avatar-btn:active { transform: scale(.94); }
.hud-balances { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; overflow: hidden; }
.bal-chip { font-size: 18px; color: var(--rupee); white-space: nowrap; }
.bal-chip:nth-child(2) { color: var(--gold); }
.bal-pi { color: var(--pi-light); cursor: pointer; }
.sub-title { font-family: var(--font-pixel); font-size: 12px; color: var(--gold); text-align: center; flex: 1; }

/* ---------- main menu ---------- */
#screen-menu { background: var(--bg-deep); }
.menu-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  /* extra bottom room so the floating Telegram badge never parks on a card */
  padding: 16px 16px 76px; flex: 1; align-content: start;
}
.menu-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-panel));
  border: 3px solid var(--border-stone); border-radius: 10px;
  padding: 18px 10px; cursor: pointer; color: var(--text);
  font-family: var(--font-body);
  transition: border-color .15s, transform .06s;
}
.menu-card:active { transform: scale(.97); }
.menu-card:hover { border-color: var(--gold); }
.menu-emoji { font-size: 34px; }
.menu-card-wide { grid-column: 1 / -1; }
.menu-title { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); }
.menu-sub { color: var(--text-dim); font-size: 16px; text-align: center; line-height: 1.15; }
.menu-footer { padding: 10px 16px 18px; color: var(--text-dim); font-size: 16px; text-align: center; }
.menu-footer .docs-link { display: block; margin-top: 6px; color: var(--gold); text-decoration: none; }
.menu-footer .docs-link:hover { text-decoration: underline; }

/* profile accomplishments */
.pf-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 6px 2px; }
.pf-badge {
  background: var(--bg-panel); border: 2px solid var(--border-stone); border-radius: 8px;
  padding: 6px 10px; font-size: 17px; white-space: nowrap;
}
.pf-badge.locked { opacity: .38; filter: grayscale(.7); }

/* ---------- sub screens ---------- */
.sub-content { padding: 14px; flex: 1; overflow-y: auto; }
.card-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--bg-panel); border: 2px solid var(--border-stone);
  border-radius: 8px; padding: 10px 12px;
}
.item-card .ic-emoji { font-size: 30px; width: 42px; text-align: center; flex-shrink: 0; }
.item-card .ic-body { flex: 1; min-width: 0; }
.item-card .ic-name { font-family: var(--font-pixel); font-size: 10px; margin-bottom: 4px; }
.item-card .ic-desc { color: var(--text-dim); font-size: 17px; line-height: 1.2; }
.item-card .ic-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.price-tag { color: var(--rupee); font-size: 18px; white-space: nowrap; }
.price-tag.pi { color: var(--pi-light); }

.rarity-common    { color: #cbd5e1; }
.rarity-uncommon  { color: #4ade80; }
.rarity-rare      { color: #60a5fa; }
.rarity-epic      { color: #c084fc; }
.rarity-legendary { color: var(--gold); }

.section-head {
  font-family: var(--font-pixel); font-size: 11px; color: var(--pi-light);
  margin: 18px 0 10px; letter-spacing: 1px;
}
.section-head:first-child { margin-top: 0; }

/* hero picker */
.hero-card { border-width: 3px; }
.hero-card.selected { border-color: var(--gold); box-shadow: 0 0 14px rgba(242, 201, 76, .25); }
.stat-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.stat-pill {
  font-size: 15px; background: var(--bg-stone); border: 1px solid var(--border-stone);
  padding: 2px 8px; border-radius: 20px; color: var(--text-dim);
}
.stat-pill b { color: var(--text); }

/* equipment grid */
.equip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.equip-slot {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-panel); border: 2px dashed var(--border-stone); border-radius: 8px;
  font-size: 24px; cursor: pointer; gap: 2px;
}
.equip-slot.filled { border-style: solid; border-color: var(--gold-dark); }
.equip-slot .slot-label { font-size: 12px; color: var(--text-dim); }
.slot-icon { width: 24px; height: 24px; image-rendering: pixelated; opacity: .75; object-fit: contain; }

/* ---------- dungeon crawler ---------- */
#screen-dungeon { background: #151019; }
.crawl-wrap {
  position: relative; flex: 1; display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden; touch-action: none;
}
#crawl-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
  background: #151019;
}

.crawl-hud {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 4;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
}
.hud-heart { font-size: 26px; filter: drop-shadow(0 2px 2px #000); }
.hud-heart img { width: 30px; height: 28px; image-rendering: pixelated; display: block; }
.pedia-icon { width: 42px; height: 42px; image-rendering: pixelated; object-fit: contain; }
.crawl-hpbar {
  position: relative; width: min(40vw, 178px); height: 18px;
  border: 2px solid #0d0a14; border-radius: 3px;
  background: #3a0a12; overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,.6), inset 0 0 0 1px #6b4a2a;
}
.crawl-hpfill {
  height: 100%; width: 100%;
  /* red recolor of the original bar art — full HP reads bright red, and
     refreshRunHud dims it toward dark dried-blood as HP drains */
  background: url('../assets/sprites/hpbar_fill_red.png') repeat-x, linear-gradient(180deg, #ff4d5e, #c11226);
  background-size: auto 100%;
  image-rendering: pixelated;
  transition: width .25s;
}
.rupee-icon { width: 18px; height: 18px; image-rendering: pixelated; vertical-align: -3px; }
.crawl-hpbar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000; font-family: var(--font-pixel); font-size: 8px;
}
.crawl-floor { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); text-shadow: 0 2px 2px #000; margin-left: auto; }
.crawl-hud .rupee-chip { text-shadow: 0 2px 2px #000; }

.crawl-status {
  position: absolute; top: 40px; left: 12px; z-index: 4;
  font-size: 15px; color: var(--text); text-shadow: 0 1px 2px #000; pointer-events: none;
}

.crawl-side {
  position: absolute; right: 10px; bottom: 24%; z-index: 4;
  display: flex; flex-direction: column; gap: 10px;
}
.side-btn {
  width: 48px; height: 48px; font-size: 20px; cursor: pointer;
  background: url('../assets/sprites/btn_wood.png') no-repeat center / 100% 100%,
              linear-gradient(180deg, #7c5a34, #55381c);
  image-rendering: pixelated;
  border: none; border-radius: 6px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.5));
  transition: transform .06s;
}
.side-btn:active { transform: scale(.92); }

.crawl-log {
  position: absolute; left: 10px; bottom: calc(24% + 4px); z-index: 3;
  max-width: 62vw; font-size: 15px; line-height: 1.25;
  text-shadow: 0 1px 2px #000, 0 0 4px #000; pointer-events: none;
}
.crawl-log p { margin: 0 0 2px; }
.log-hero { color: #7ce8a8; }
.log-foe  { color: #ff8a97; }
.log-gold { color: var(--gold); }
.log-sys  { color: #c9bfdd; }
.log-crit { color: var(--gold); font-weight: bold; }

/* full log overlay panel (original "COMBAT LOG" window) */
.log-overlay {
  max-height: 50dvh; overflow-y: auto; font-size: 17px; line-height: 1.3;
  background: rgba(10, 8, 16, .92); border: 2px solid var(--border-stone);
  border-radius: 6px; padding: 10px;
}

/* D-pad (original cross-shaped pad, bottom center) */
.dpad {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid; z-index: 4;
  grid-template-areas: ". up ." "left wait right" ". down .";
  gap: 0;
  background: url('../assets/sprites/dpad.png') no-repeat center / contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.55));
  padding: 2px;
}
.dpad { touch-action: none; user-select: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
/* Physical press: the pad tilts like a real d-pad rocker — the edge you
   push dips into the screen. (transform must keep the translateX centering.) */
.dpad { transition: transform .07s ease-out; will-change: transform; }
.dpad.tilt-up    { transform: translateX(-50%) perspective(260px) rotateX(17deg); }
.dpad.tilt-down  { transform: translateX(-50%) perspective(260px) rotateX(-17deg); }
.dpad.tilt-left  { transform: translateX(-50%) perspective(260px) rotateY(-17deg); }
.dpad.tilt-right { transform: translateX(-50%) perspective(260px) rotateY(17deg); }
/* Arms are visual only — the pad itself is the touch surface, and every
   tap resolves to the nearest arrow (no accidental turn-wasting center). */
.dpad-btn {
  width: 56px; height: 56px; font-size: 20px; color: transparent;
  background: transparent; border: none;
  pointer-events: none; user-select: none;
}
.dpad-btn.pressed { background: radial-gradient(circle, rgba(255,220,150,.35) 0%, transparent 70%); }
.dpad-up { grid-area: up; } .dpad-left { grid-area: left; }
.dpad-right { grid-area: right; } .dpad-down { grid-area: down; }

@media (min-width: 700px) {
  .dpad { opacity: .45; }
  .dpad:hover { opacity: 1; }
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(6, 4, 12, .82);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: min(440px, 100%); max-height: 84dvh; overflow-y: auto;
  background: var(--bg-panel); border: 3px solid var(--gold-dark);
  border-radius: 12px; padding: 20px;
}
.modal h3 { font-family: var(--font-pixel); font-size: 13px; color: var(--gold); margin-bottom: 14px; text-align: center; }
.modal p { margin-bottom: 10px; line-height: 1.3; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.modal .big-emoji { font-size: 56px; text-align: center; display: block; margin-bottom: 10px; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 90; width: min(420px, 92vw);
}
.toast {
  background: var(--bg-card); border: 2px solid var(--gold-dark); border-radius: 8px;
  padding: 10px 14px; font-size: 18px; text-align: center;
  animation: toastin .25s;
}
@keyframes toastin { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; } }

/* ---------- collection (Pokédex) ---------- */
.col-head { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); margin: 18px 0 10px; line-height: 1.7;
  display: flex; justify-content: space-between; align-items: baseline; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.col-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-panel); border: 2px solid var(--border-stone); border-radius: 8px;
  padding: 10px 6px 8px; min-height: 86px; justify-content: center;
}
.col-icon { height: 40px; display: flex; align-items: center; justify-content: center; }
.col-emoji { font-size: 30px; line-height: 1; }
.col-sprite { width: 40px; height: 40px; image-rendering: pixelated; }
.col-name { font-size: 15px; text-align: center; line-height: 1.1; word-break: break-word; }
.col-count {
  position: absolute; top: 4px; right: 6px;
  font-family: var(--font-pixel); font-size: 9px; color: var(--gold);
}
/* Undiscovered: a dark silhouette, the shape visible but nothing else. */
.col-locked .col-icon { filter: grayscale(1) brightness(0.22); opacity: .9; }
.col-locked .col-name { color: var(--text-dim); opacity: .55; }
.col-locked { border-style: dashed; opacity: .8; }

/* Stack size on inventory rows, sell lists and export buttons (×N). */
.stack-count {
  font-family: var(--font-pixel); font-size: 9px; color: var(--gold);
  background: rgba(0, 0, 0, .35); border-radius: 6px; padding: 1px 4px;
  vertical-align: middle;
}

/* ---------- Dice Duel (Knucklebones) ---------- */
.duel-grid { display: flex; justify-content: center; gap: 8px; margin: 6px 0; }
.duel-col {
  display: flex; flex-direction: column; gap: 4px; padding: 5px;
  background: rgba(0, 0, 0, .3); border: 2px solid var(--border-stone);
  border-radius: 8px; min-width: 52px; align-items: center;
}
.duel-col.duel-open { border-color: var(--gold); cursor: pointer; }
.duel-col.duel-open:hover { background: rgba(255, 200, 80, .12); }
.duel-cell {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 40px; line-height: 1; color: #f2ead9;
  background: rgba(255, 255, 255, .05); border-radius: 6px;
}
.duel-colscore { font-family: var(--font-pixel); font-size: 10px; color: var(--gold); min-height: 12px; }
.duel-mid { text-align: center; margin: 8px 0; min-height: 40px; }
.duel-die { font-size: 40px; vertical-align: middle; line-height: 1; }
.duel-side { text-align: center; font-family: var(--font-pixel); font-size: 11px; }

/* ---------- game stats ---------- */
.gs-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 5px 0; border-bottom: 1px solid rgba(74, 59, 102, .35);
}
.gs-row:last-child { border-bottom: none; }
.gs-label { color: var(--text-dim); font-size: 18px; }
.gs-value { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- settings ---------- */
.set-head { font-family: var(--font-pixel); font-size: 11px; color: var(--gold); margin-bottom: 14px; line-height: 1.7; }
#sub-content .card + .card { margin-top: 16px; }
.set-row { margin-bottom: 14px; }
.set-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.set-val { font-family: var(--font-pixel); font-size: 10px; color: var(--gold); font-variant-numeric: tabular-nums; }
.set-hint { font-size: 16px; margin: 4px 0 0; line-height: 1.2; }
.set-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.set-toggle input { width: 20px; height: 20px; accent-color: var(--gold); cursor: pointer; flex: none; }
.set-previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.set-previews .btn { padding: 8px 10px; font-size: 9px; }
/* Muted: the mixer stays readable but clearly inert. */
.set-off { opacity: .4; pointer-events: none; }

.set-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 10px; border-radius: 5px; cursor: pointer;
  background: var(--bg-stone);   /* JS paints the filled portion */
  border: 2px solid var(--border-stone);
}
.set-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 4px;
  background: var(--bg-card); border: 3px solid var(--gold); cursor: pointer;
}
.set-range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--bg-card); border: 3px solid var(--gold); cursor: pointer;
}
.set-range:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- testnet notice ----------
   A setup sheet, not a warning banner: numbered steps, and every value the
   wallet's "Add network" form asks for sitting on its own copyable row. */
.testnet-link {
  color: var(--pi-light); text-decoration: none; font-size: 17px;
  border-bottom: 1px dotted var(--pi-light); padding-bottom: 1px;
}
.testnet-link:hover, .testnet-link:focus-visible { color: var(--gold); border-bottom-color: var(--gold); }
/* Denser than a normal dialog: this one is a reference sheet, and the whole
   of step 1 should be reachable on a phone without hunting. */
.tn-body { font-size: 18px; }
.tn-body p { margin-bottom: 8px; line-height: 1.25; }
.modal h4.tn-step {
  font-family: var(--font-pixel); font-size: 10px; color: var(--gold);
  margin: 18px 0 8px; padding-top: 12px; border-top: 2px solid var(--border-stone);
  line-height: 1.7;
}
.tn-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 10px; }
.tn-faucets { margin: 0 0 4px 20px; }
.tn-faucets li { margin-bottom: 6px; line-height: 1.25; }
.tn-faucets a { color: var(--pi-light); }
.tn-faucets a:hover { color: var(--gold); }

/* A value can be long (RPC URLs are), so it scrolls inside its own box
   rather than shoving the Copy button off the edge of a phone. */
.cp-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 8px;
  align-items: center; margin-bottom: 8px;
}
.cp-label { grid-column: 1 / -1; font-size: 16px; color: var(--text-dim); }
.cp-value {
  font-family: monospace; font-size: 13px; color: var(--text);
  background: var(--bg-stone); border: 1px solid var(--border-stone);
  border-radius: 5px; padding: 6px 8px;
  overflow-x: auto; white-space: nowrap; min-width: 0;
}
.cp-btn { padding: 7px 10px; font-size: 9px; white-space: nowrap; }
.cp-btn.cp-ok { border-color: var(--rupee); color: var(--rupee); }
.tn-hide {
  display: flex; align-items: center; gap: 8px; margin-top: 18px;
  padding-top: 12px; border-top: 2px solid var(--border-stone);
  cursor: pointer; color: var(--text-dim);
}
.tn-hide input { width: 18px; height: 18px; accent-color: var(--gold); cursor: pointer; }

/* ---------- floating Telegram badge ----------
   Only on the title screen and the Keep (body.show-tg, set by UI.show), so it
   never sits over the d-pad during a run or over a menu you're reading.
   Below the modal (50) and toasts (90), above the sticky topbar (5). */
.tg-link {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 6;
  display: none;
  align-items: center; gap: 8px;
  padding: 9px 13px;
  font-family: var(--font-pixel); font-size: 10px; line-height: 1;
  color: var(--text); text-decoration: none;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-panel));
  border: 3px solid var(--tg); border-radius: 10px;
  box-shadow: 0 3px 0 var(--tg-deep), 0 0 12px rgba(42, 171, 238, .28);
  transition: transform .12s, box-shadow .12s;
}
body.show-tg .tg-link { display: flex; }
.tg-link svg { width: 18px; height: 18px; flex: none; fill: var(--tg); }
.tg-link:hover, .tg-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--tg-deep), 0 0 16px rgba(42, 171, 238, .45);
}
.tg-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tg-link:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--tg-deep); }
@media (prefers-reduced-motion: reduce) { .tg-link { transition: none; } }
/* Only on genuinely tiny screens drop to the icon alone — on a normal phone
   the word is what makes the badge legible, and the corner has room for it. */
@media (max-width: 340px) {
  .tg-link { gap: 0; padding: 10px; }
  .tg-label { display: none; }
}

/* ---------- leaderboard ---------- */
.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lb-tabs .btn { flex: 1; }
.lb-tabs .btn.active { border-color: var(--gold); color: var(--gold); }
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--bg-panel); border: 2px solid var(--border-stone); border-radius: 8px;
}
.lb-rank { font-family: var(--font-pixel); font-size: 11px; color: var(--text-dim); width: 34px; }
.lb-row:nth-child(1) .lb-rank { color: var(--gold); }
.lb-row:nth-child(2) .lb-rank { color: #cbd5e1; }
.lb-row:nth-child(3) .lb-rank { color: #d97706; }
.lb-name { flex: 1; font-size: 20px; }
.lb-score { color: var(--rupee); font-size: 20px; }

/* ---------- NFT Market inputs ---------- */
.mk-input {
  background: rgba(0, 0, 0, .35);
  border: 2px solid var(--border-stone);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  padding: 8px 10px;
  width: 130px;
  margin: 4px;
}
.mk-input:focus { outline: none; border-color: var(--gold); }

/* ---------- misc ---------- */
.dim { color: var(--text-dim); }
.gold { color: var(--gold); }
.center { text-align: center; }
.mt { margin-top: 14px; }
.hr { border: none; border-top: 2px solid var(--border-stone); margin: 14px 0; }

@media (min-width: 561px) {
  #app { border-left: 3px solid var(--border-stone); border-right: 3px solid var(--border-stone); }
}
