:root {
  --bg: #2a1638;
  --bg2: #3d1f52;
  --panel: #fff7e6;
  --ink: #2b1a12;
  --text: #fff7e6;
  --muted: #e6d3f0;
  --gold: #ffcc33;
  --red: #e0453a;
  --blue: #45b4ff;
  --green: #3fbf6a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 70% at 50% 0%, #6a2f86 0%, var(--bg) 70%) fixed;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; height: 100%; overscroll-behavior: none; overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
.note { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 6px 0; }

/* ---------- umumiy */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 2px solid rgba(255, 255, 255, 0.18); font-size: 17px; font-weight: 800; }
.pill.sm { padding: 3px 10px; font-size: 15px; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2a8, var(--gold) 55%, #c98a12); border: 2px solid var(--ink); }
.skull { width: 15px; height: 15px; border-radius: 50% 50% 40% 40%; background: #fff; border: 2px solid var(--ink); }
.sq { width: 44px; height: 44px; border-radius: 14px; font-size: 18px; font-weight: 900; display: grid; place-items: center; }
.ghost { background: rgba(0, 0, 0, 0.3); border: 2px solid rgba(255, 255, 255, 0.2); }
.primary, .play {
  background: linear-gradient(#ffd84a, #ff9f1c); color: var(--ink); font-weight: 900; border: 3px solid var(--ink);
  border-radius: 16px; box-shadow: 0 5px 0 var(--ink); padding: 12px 18px;
}
.primary:active, .play:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }

/* ---------- menyu */
.screen { width: 100%; max-width: 520px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); min-height: 100dvh; }
.top { display: flex; justify-content: space-between; align-items: center; }
.hero-box { text-align: center; padding: 8px 0 18px; }
.hero-box h1 {
  font-size: 46px; letter-spacing: 2px; font-weight: 900; color: var(--gold);
  -webkit-text-stroke: 2px var(--ink); text-shadow: 0 4px 0 var(--ink), 0 0 24px rgba(255, 180, 60, 0.45);
}
.sub { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
#heroImg { display: block; margin: 6px auto; width: 168px; height: 168px; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.3)); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.play { font-size: 26px; padding: 14px 54px; letter-spacing: 1px; }
.mgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 10px 0 18px; }
.mcard { background: rgba(0, 0, 0, 0.28); border: 2px solid rgba(255, 255, 255, 0.15); border-radius: 16px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.mcard .mt { display: flex; align-items: center; gap: 8px; }
.mcard img { width: 40px; height: 40px; }
.mcard b { font-size: 16px; }
.mcard small { color: var(--muted); font-size: 13px; line-height: 1.3; min-height: 34px; }
.dots { display: flex; gap: 3px; }
.dots i { flex: 1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); }
.dots i.on { background: var(--gold); }
.buy { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px; border-radius: 12px; font-weight: 900; background: var(--green); color: #fff; border: 2px solid var(--ink); }
.buy[disabled] { background: rgba(255, 255, 255, 0.12); color: var(--muted); border-color: transparent; cursor: default; }
.howto { margin-top: 6px; }

/* ---------- jang */
#game { position: fixed; inset: 0; overflow: hidden; touch-action: none; background: #e9c88a; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: max(6px, env(safe-area-inset-top)) 10px 0; pointer-events: none; }
.hud button { pointer-events: auto; }
.xp { position: relative; height: 18px; border-radius: 9px; background: rgba(43, 26, 18, 0.75); border: 2px solid var(--ink); overflow: hidden; }
.xp i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(#7fd4ff, #2f8fe0); }
.xp b { position: absolute; right: 8px; top: -1px; font-size: 13px; text-shadow: 0 1px 2px #000; }
.hrow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.hrow .time { flex: 1; text-align: center; font-size: 24px; font-weight: 900; color: #fff; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 2px 0 var(--ink); }
.hud .pill { color: #fff; background: rgba(43, 26, 18, 0.6); }
.hud .sq { width: 40px; height: 40px; background: rgba(43, 26, 18, 0.6); color: #fff; }
.wrow { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.wrow span { position: relative; width: 30px; height: 30px; border-radius: 8px; background: rgba(43, 26, 18, 0.55); border: 2px solid rgba(43, 26, 18, 0.8); }
.wrow img { width: 100%; height: 100%; }
.wrow em { position: absolute; right: -3px; bottom: -4px; font-style: normal; font-size: 11px; font-weight: 900; color: #fff; background: var(--ink); border-radius: 6px; padding: 0 3px; }
.boss { position: relative; margin: 8px auto 0; max-width: 340px; height: 20px; border-radius: 10px; background: rgba(43, 26, 18, 0.8); border: 2px solid var(--ink); overflow: hidden; }
.boss i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(#ff7a5a, #c4262e); }
.boss span { position: relative; z-index: 1; display: block; text-align: center; font-size: 12px; font-weight: 900; line-height: 16px; text-shadow: 0 1px 2px #000; }
.toast {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); margin: 0; pointer-events: none;
  font-size: 20px; font-weight: 900; color: #fff; text-align: center; -webkit-text-stroke: 1px var(--ink); text-shadow: 0 3px 0 var(--ink);
  opacity: 0; transition: opacity 0.25s; width: 90%;
}
.toast.on { opacity: 1; }

/* ---------- oynalar */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(20, 8, 30, 0.72); }
.panel { width: 100%; max-width: 420px; background: var(--panel); color: var(--ink); border: 3px solid var(--ink); border-radius: 22px; padding: 18px 16px; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.35); text-align: center; }
.panel .note { color: #6b5a4a; }
.panel h2 { font-size: 26px; font-weight: 900; }
.glow { color: var(--gold); -webkit-text-stroke: 1.5px var(--ink); text-shadow: 0 3px 0 var(--ink); }
.cards { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.card { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border-radius: 16px; background: #fff; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); animation: pop 0.25s ease-out backwards; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } }
.card img { width: 54px; height: 54px; flex: none; background: #ffeec2; border-radius: 12px; border: 2px solid var(--ink); }
.card div { display: flex; flex-direction: column; gap: 2px; }
.card b { font-size: 18px; }
.card small { font-size: 14px; color: #5b4a3a; line-height: 1.3; }
.card .tag { align-self: flex-start; font-size: 11px; font-weight: 900; padding: 1px 7px; border-radius: 8px; background: var(--green); color: #fff; }
.card .tag.up { background: var(--blue); }
.card.w { background: #fff6dc; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row button { flex: 1; padding: 12px; border-radius: 14px; font-weight: 900; }
.panel .ghost { background: #eadfcf; border: 2px solid var(--ink); color: var(--ink); }
.build { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.build span { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 4px; border-radius: 10px; background: #fff; border: 2px solid var(--ink); font-weight: 800; font-size: 14px; }
.build img { width: 28px; height: 28px; }
.rstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.rstats div { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 4px; }
.rstats b { display: block; font-size: 22px; }
.rstats small { color: #6b5a4a; font-size: 12px; }
.rgold { font-size: 20px; font-weight: 900; margin: 14px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* ---------- 2-bosqich: bo'limlar, joylar, qahramonlar, kunlik, kitob */
#menu.screen { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.tbtn { display: flex; gap: 8px; }
.sq.off { opacity: 0.45; }
.tab h2 { margin: 18px 0 8px; font-size: 20px; }
.tab h2 small { font-size: 14px; color: var(--muted); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center; gap: 4px;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: rgba(30, 14, 42, 0.94); border-top: 2px solid rgba(255, 255, 255, 0.12);
}
.tabs button { position: relative; flex: 1; max-width: 104px; padding: 10px 0; border-radius: 12px; font-weight: 800; font-size: 13px; background: transparent; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: rgba(255, 204, 51, 0.16); color: var(--gold); }
.badge { position: absolute; top: 4px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--red); border: 2px solid var(--ink); }
.wide { width: 100%; }
.mapgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mapc { text-align: left; padding: 10px; border-radius: 16px; border: 3px solid rgba(255, 255, 255, 0.15); min-height: 104px; display: flex; flex-direction: column; gap: 4px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.mapc b { font-size: 16px; }
.mapc small { font-size: 12px; line-height: 1.3; opacity: 0.95; }
.mapc .st { margin-top: auto; font-size: 12px; font-weight: 800; }
.mapc[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--ink), 0 0 16px rgba(255, 204, 51, 0.45); }
.mapc.lock { filter: grayscale(0.85) brightness(0.6); }
.m0 { background: linear-gradient(160deg, #e9c88a, #b8803a); }
.m1 { background: linear-gradient(160deg, #a7b4a0, #5a6a5a); }
.m2 { background: linear-gradient(160deg, #b8aa94, #6a5a48); }
.m3 { background: linear-gradient(160deg, #8fd86a, #3f8a3a); }
.m4 { background: linear-gradient(160deg, #cfe6f4, #5a8ab0); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px; border-radius: 12px; font-weight: 800; background: rgba(0, 0, 0, 0.28); border: 2px solid rgba(255, 255, 255, 0.15); }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--ink); border-color: var(--ink); }
.heroes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.hcard { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border-radius: 16px; background: rgba(0, 0, 0, 0.28); border: 2px solid rgba(255, 255, 255, 0.15); text-align: center; }
.hcard[aria-pressed="true"] { border-color: var(--gold); background: rgba(255, 204, 51, 0.12); }
.hcard img { width: 84px; height: 84px; }
.hcard b { font-size: 16px; }
.hcard small { font-size: 12px; color: var(--muted); line-height: 1.3; min-height: 48px; }
.hcard .buy { width: 100%; }
.skins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skin { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 14px; background: rgba(0, 0, 0, 0.28); border: 2px solid rgba(255, 255, 255, 0.15); font-size: 12px; font-weight: 800; }
.skin[aria-pressed="true"] { border-color: var(--gold); }
.skin img { width: 64px; height: 64px; }
.daily { background: linear-gradient(160deg, #5a2a8a, #2a1638); border: 2px solid rgba(255, 204, 51, 0.5); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.daily b { font-size: 18px; color: var(--gold); }
.daily .primary { margin-top: 6px; }
.chestbtn { margin-top: 12px; padding: 14px; border-radius: 16px; font-weight: 900; font-size: 16px; background: linear-gradient(#c98a3a, #8a5a2a); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.chestbtn[disabled] { background: rgba(255, 255, 255, 0.1); box-shadow: none; border-color: transparent; color: var(--muted); }
.tasks { display: flex; flex-direction: column; gap: 8px; }
.task { padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.28); border: 2px solid rgba(255, 255, 255, 0.15); display: flex; flex-direction: column; gap: 6px; }
.task.done { border-color: var(--green); }
.task .tt { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 14px; }
.bar2 { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.bar2 i { display: block; height: 100%; background: var(--green); }
.achs { display: flex; flex-direction: column; gap: 6px; }
.ach { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); font-size: 14px; opacity: 0.55; }
.ach.on { opacity: 1; border: 2px solid rgba(255, 204, 51, 0.6); }
.ach .ai { font-size: 20px; }
.ach div { flex: 1; display: flex; flex-direction: column; }
.ach small { color: var(--muted); font-size: 12px; }
.ach em { font-style: normal; font-weight: 900; color: var(--gold); white-space: nowrap; }
.bestiary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.beast { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); text-align: center; font-size: 12px; font-weight: 700; gap: 2px; }
.beast img { width: 56px; height: 56px; }
.beast small { color: var(--muted); font-weight: 600; }
.row.small { margin-top: 10px; }
.row.small button { padding: 9px; font-size: 14px; }
.row.small button[disabled] { opacity: 0.4; }
.card.evo { background: linear-gradient(135deg, #fff1b8, #ffd27a); }
.card .tag.evo { background: #e0453a; }
.panel.scroll { max-height: 92dvh; overflow-y: auto; }
.news { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.news p { margin: 0; padding: 7px 10px; border-radius: 10px; background: #fff3cf; border: 2px solid var(--ink); font-weight: 800; font-size: 14px; }
.dstats { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; text-align: left; }
.dstats .dr { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; }
.dstats img { width: 26px; height: 26px; }
.dstats .db { height: 8px; border-radius: 4px; background: #eadfcf; overflow: hidden; }
.dstats .db i { display: block; height: 100%; background: linear-gradient(90deg, #ff9f1c, #e0453a); }
.dstats .dn { grid-column: 2; font-size: 12px; color: #5b4a3a; margin-bottom: -3px; }
.skin .pr { display: flex; align-items: center; gap: 4px; }

/* ---------- 3-bosqich: sarguzasht, do'stlar jadvali */
.stages { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-bottom: 8px; }
.stages .land { margin: 10px 0 0; font-size: 15px; color: var(--gold); }
.stage { display: flex; align-items: center; gap: 10px; width: 78%; padding: 10px 12px; border-radius: 16px; border: 3px solid rgba(255, 255, 255, 0.15); color: #fff; text-align: left; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.stage.z0 { align-self: flex-start; }
.stage.z1 { align-self: center; }
.stage.z2 { align-self: flex-end; }
.stage.m0 { background: linear-gradient(135deg, #c9933f, #8a5a22); }
.stage.m1 { background: linear-gradient(135deg, #5a7aa8, #2f4468); }
.stage.m2 { background: linear-gradient(135deg, #7a6a8a, #3f3550); }
.stage.m3 { background: linear-gradient(135deg, #3f9a5a, #1f5a3a); }
.stage.m4 { background: linear-gradient(135deg, #6aa8d8, #2f5a88); }
.stage[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 204, 51, 0.35); }
.stage.lock { filter: grayscale(0.85) brightness(0.6); }
.stage .sn { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(0, 0, 0, 0.35); font-weight: 900; }
.stage .sname { flex: 1; font-weight: 800; font-size: 15px; }
.stage .ss { color: var(--gold); font-size: 15px; letter-spacing: 1px; }
.friendbox { display: flex; flex-direction: column; gap: 10px; }
.namel { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.namel input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.3); color: #fff; font: inherit; font-size: 16px; }
.ftable { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 13px; }
.fr { display: grid; grid-template-columns: minmax(0, 1.5fr) 0.5fr repeat(5, 1fr) 24px; font-size: 12px; gap: 4px; align-items: center; padding: 7px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); }
.fr.head { background: none; color: var(--muted); font-weight: 700; font-size: 12px; }
.fr.me { background: rgba(255, 204, 51, 0.12); }
.fr .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.fr .top { color: var(--gold); font-weight: 900; }
.fr .del { width: 26px; height: 26px; padding: 0; border-radius: 8px; background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 16px; }

/* ---------- 4-bosqich: ertak sahnasi, haftalik */
.story .pics { display: flex; align-items: center; justify-content: center; gap: 10px; }
.story .pics img { width: 110px; height: 110px; image-rendering: auto; }
.story .pics span { font-weight: 900; font-size: 22px; color: var(--gold); }
.story p { font-size: 16px; line-height: 1.45; margin: 6px 0 14px; }
.tiers { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
