:root {
  --bg: #0d0b08;
  --bg2: #15120d;
  --card: #1a1610;
  --line: #2c2518;
  --text: #f4ede0;
  --muted: #9b8f7a;
  --gold: #f5b82e;
  --gold2: #ffd76a;
  --gold-dark: #a46a07;
  --ok: #4fd18b;
  --bad: #ff6b5e;
  --radius: 16px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --content-top: var(--tg-content-safe-area-inset-top, 0px);
  --vh: var(--tg-viewport-stable-height, 100vh);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow-x: hidden; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; }
h2, h3 { margin: 0 0 8px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 6px 0; }
[hidden] { display: none !important; }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
b, .num { font-variant-numeric: tabular-nums; }

.app {
  min-height: var(--vh);
  display: flex; flex-direction: column;
  padding-top: calc(var(--safe-top) + var(--content-top));
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(245, 184, 46, .14), transparent 60%),
    var(--bg);
}

/* ---------- splash ---------- */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; }
.splash-logo { width: 84px; height: 84px; animation: pulse 1.6s ease-in-out infinite; }
.splash-title { font-weight: 800; letter-spacing: .12em; color: var(--gold); }
.splash-msg { color: var(--muted); max-width: 300px; }
@keyframes pulse { 50% { transform: scale(1.06); filter: drop-shadow(0 0 18px rgba(245,184,46,.5)); } }

/* ---------- header ---------- */
.top { padding: 10px 16px 4px; }
.top-row { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .1em; font-size: 14px; color: var(--gold2); }
.brand img { width: 26px; height: 26px; }
.chip { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: 5px 10px; font-size: 12px; }
.balance-card {
  margin-top: 10px; padding: 12px 14px; border-radius: var(--radius);
  background: linear-gradient(135deg, #241c0f, #15110b); border: 1px solid #3a2e17;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.balance { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold2); word-break: break-all; }
.balance small { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- views ---------- */
main { flex: 1; padding: 8px 16px calc(88px + var(--safe-bottom)); }
.view { display: flex; flex-direction: column; gap: 12px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.row-card { display: flex; align-items: center; gap: 12px; }
.box-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 22px; background: #241d12; border-radius: 12px; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-align: center; min-width: 0; }
.stat b { display: block; font-size: 13px; color: var(--gold2); overflow: hidden; text-overflow: ellipsis; }
.note { background: #1a160f; border-left: 3px solid var(--gold-dark); padding: 8px 10px; border-radius: 8px; }
.disclaimer { color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 700; color: #1b1205; cursor: pointer;
  transition: transform .08s ease, opacity .15s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-gold { background: linear-gradient(180deg, var(--gold2), var(--gold)); box-shadow: 0 4px 14px rgba(245,184,46,.25); }
.btn-outline { background: transparent; color: var(--gold2); border: 1px solid #5a4620; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.wide { width: 100%; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.col-btns { display: flex; flex-direction: column; gap: 6px; }

/* ---------- mine ---------- */
.forge-wrap { position: relative; display: grid; place-items: center; padding: 6px 0; }
.forge {
  width: min(62vw, 250px); aspect-ratio: 1; border: 0; padding: 0; background: none; border-radius: 50%;
  touch-action: manipulation; cursor: pointer; transition: transform .07s ease;
}
.forge img { width: 100%; height: 100%; pointer-events: none; filter: drop-shadow(0 10px 30px rgba(245,184,46,.25)); }
.forge.hit { transform: scale(.94) rotate(-2deg); }
.forge.empty { filter: grayscale(.7) brightness(.7); }
.fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.fx span {
  position: absolute; font-weight: 800; color: var(--gold2); text-shadow: 0 2px 6px #000; font-size: 15px;
  animation: rise .8s ease-out forwards; white-space: nowrap;
}
@keyframes rise { to { transform: translate(-50%, -90px); opacity: 0; } }
.boost-pill { align-self: center; background: linear-gradient(90deg, #ff7a18, #ffb627); color: #1b1205; font-weight: 800; padding: 4px 12px; border-radius: 99px; font-size: 12px; }
.energy-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.bar { height: 12px; border-radius: 99px; background: #241d12; overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #d38b10, var(--gold2)); border-radius: 99px; transition: width .3s; }

/* ---------- rewards ---------- */
.streak { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 8px 0 12px; }
.streak div { background: #221b10; border: 1px solid var(--line); border-radius: 10px; padding: 7px 2px; text-align: center; font-size: 11px; color: var(--muted); }
.streak div b { display: block; color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.streak .done { background: linear-gradient(180deg, #3d2d0c, #2a1f0b); border-color: var(--gold-dark); }
.streak .done b { color: var(--gold2); }
.streak .next { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.code-form { display: flex; gap: 8px; margin-top: 8px; }
.code-form input {
  flex: 1; min-width: 0; background: #0f0c08; border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  padding: 11px 12px; font: inherit; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.code-form input:focus, .sheet input:focus { outline: none; border-color: var(--gold); }
.board { list-style: none; padding: 0; margin: 4px 0 0; max-height: 360px; overflow: auto; }
.board li { display: flex; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 13px; }
.board li:last-child { border: 0; }
.board .rk { width: 28px; color: var(--muted); }
.board .me { color: var(--gold2); font-weight: 700; }
.board .nm { flex: 1; }

/* ---------- lists (tasks / upgrades / friends) ---------- */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px; }
.item .t { font-weight: 600; }
.item .sub { font-size: 12px; color: var(--muted); }
.item .rw { font-size: 12px; color: var(--gold); font-weight: 700; }
.item.claimed { opacity: .55; }
.pbar { height: 5px; background: #241d12; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--gold); }
.lvl { font-size: 12px; color: var(--gold2); font-weight: 700; }
.master { border-color: #5a4620; }
.link-box { background: #0f0c08; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; word-break: break-all; margin-top: 4px; user-select: text; -webkit-user-select: text; }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: rgba(16, 13, 9, .94); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabs button {
  position: relative; background: none; border: 0; color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px;
}
.tabs .ti { width: 22px; height: 22px; }
.tabs .ti svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs .active { color: var(--gold2); background: #1f190f; }
.tabs .dot { position: absolute; top: 4px; right: 22%; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

/* ---------- sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow: auto;
  background: var(--bg2); border-top: 1px solid #3a2e17; border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(18px + var(--safe-bottom)); animation: up .2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: #3a2e17; margin: 4px auto 12px; }
.sheet .field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.sheet input {
  background: #0f0c08; border: 1px solid var(--line); border-radius: 12px; color: var(--text); padding: 11px 12px; font: inherit; width: 100%;
}
.rules { list-style: none; padding: 0; margin: 6px 0; font-size: 13px; }
.rules li { padding: 3px 0; }
.rules .y::before { content: "✓ "; color: var(--ok); font-weight: 800; }
.rules .n::before { content: "✗ "; color: var(--bad); font-weight: 800; }
.hist { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.hist li { padding: 6px 0; border-bottom: 1px solid var(--line); word-break: break-all; }
.st-pending { color: var(--gold); } .st-approved { color: var(--ok); } .st-rejected { color: var(--bad); }
.lang-list { display: flex; flex-direction: column; gap: 8px; }
.mock-ad { text-align: center; padding: 20px 0; }
.mock-ad .count { font-size: 48px; font-weight: 800; color: var(--gold2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); z-index: 30;
  background: #2a2112; color: var(--text); border: 1px solid #5a4620; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.toast.err { border-color: #7a2c25; background: #2a1411; }

@media (max-width: 360px) {
  .balance { font-size: 20px; }
  .tabs button { font-size: 9.5px; }
}
