:root {
  --bg: #170d2b;
  --bg2: #24123f;
  --card: #2d1a4d;
  --card2: #3a2263;
  --line: rgba(255, 255, 255, .08);
  --gas: #8be33f;
  --gas2: #5fbf1f;
  --gold: #ffc62b;
  --gold2: #e89a00;
  --text: #fff7e6;
  --muted: #b9a8d6;
  --red: #ff5f6d;
  --orange: #ff9f43;
  --r: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Nunito', system-ui, sans-serif; overscroll-behavior: none; }
body { user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
.hidden { display: none !important; }
h2 { font-family: 'Lilita One', sans-serif; font-weight: 400; margin: 0; font-size: 20px; letter-spacing: .5px; }
small, .muted { color: var(--muted); }
.small { font-size: 12px; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 520px; margin: 0 auto;
  background: radial-gradient(120% 60% at 50% 30%, #3b1d66 0%, var(--bg) 70%); }

/* Header */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 0; gap: 8px; }
.me-chip { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  padding: 4px 12px 4px 4px; max-width: 60%; }
.me-chip .lvl { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #3a2000; font-weight: 900; border-radius: 50%;
  width: 28px; height: 28px; display: grid; place-items: center; font-size: 14px; flex: none; }
.me-name { font-weight: 900; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-right { display: flex; gap: 6px; align-items: center; }
.rp-chip { background: rgba(255, 198, 43, .14); border: 1px solid rgba(255, 198, 43, .4); color: var(--gold); font-weight: 900;
  border-radius: 99px; padding: 6px 11px; font-size: 14px; font-variant-numeric: tabular-nums; }
.shield { background: var(--card2); border-radius: 50%; width: 34px; height: 34px; font-size: 17px; }
.gasrow { text-align: center; padding: 6px 16px 2px; }
.gas { font-family: 'Lilita One', sans-serif; font-size: 38px; line-height: 1.05; text-shadow: 0 0 18px rgba(139, 227, 63, .35);
  font-variant-numeric: tabular-nums; }
.gas::before { content: '💨 '; font-size: 28px; }
.pph { font-size: 13px; color: var(--gas); font-weight: 900; }
.mult { background: var(--gold); color: #3a2000; border-radius: 99px; padding: 1px 7px; margin-left: 4px; font-size: 11px; }
.boostbar { display: flex; gap: 6px; padding: 4px 16px 0; flex-wrap: wrap; justify-content: center; min-height: 4px; }
.bchip { font-size: 12px; font-weight: 800; background: rgba(139, 227, 63, .15); border: 1px solid rgba(139, 227, 63, .4);
  color: var(--gas); padding: 3px 9px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.bchip.gold { background: rgba(255, 198, 43, .12); border-color: rgba(255, 198, 43, .45); color: var(--gold); }

main { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }
.view { display: none; padding: 8px 16px 24px; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* Throne */
.levelbar { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; text-align: left; }
.lb-top { display: flex; justify-content: space-between; font-weight: 900; font-size: 13px; gap: 8px; }
.stage { position: relative; height: min(40vh, 320px); display: grid; place-items: center; }
.aura { position: absolute; width: 74%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 227, 63, .35) 0%, rgba(139, 227, 63, .08) 45%, transparent 70%);
  animation: pulse 3s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .75; } }
.king { position: relative; background: none; padding: 0; width: min(58vw, 250px); touch-action: manipulation; }
.king img { width: 100%; display: block; pointer-events: none; filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .45)); animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-1.5deg); } }
.king.squish img { animation: squish .18s ease; }
@keyframes squish { 40% { transform: scale(.92, 1.06); } 100% { transform: scale(1); } }
.king.tired img { filter: grayscale(.6) drop-shadow(0 12px 18px rgba(0, 0, 0, .45)); }
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.puff { position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c6ff8f, #79d12f 55%, rgba(95, 191, 31, 0) 72%); animation: puff .9s ease-out forwards; }
@keyframes puff { 0% { transform: translate(0, 0) scale(.3); opacity: .95; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.9); opacity: 0; } }
.float { position: absolute; font-family: 'Lilita One', sans-serif; font-size: 22px; color: var(--gold);
  text-shadow: 0 2px 0 #6b3d00, 0 0 10px rgba(0, 0, 0, .4); white-space: nowrap; animation: floatup 1s ease-out forwards; }
.float small { display: block; font-size: 14px; color: var(--gas); text-align: center; }
@keyframes floatup { to { transform: translateY(-90px); opacity: 0; } }

.energy { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
.energy-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; color: var(--muted); }
.energy-top b { color: var(--text); }
.bar { height: 12px; background: #1a0f2e; border-radius: 99px; margin: 7px 0 5px; overflow: hidden; }
.bar.thin { height: 7px; margin: 6px 0 0; }
.fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--gas2), var(--gas)); border-radius: 99px; transition: width .25s; }
.fill.gold { background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.tapinfo { font-size: 12px; color: var(--gas); font-weight: 800; text-align: center; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.qbtn { background: var(--card2); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 4px; font-weight: 900; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.qbtn b { font-size: 20px; }
.qbtn.ready { background: linear-gradient(180deg, var(--gas), var(--gas2)); color: #10260a; box-shadow: 0 4px 0 #3a7a10; animation: wiggle 2s ease-in-out infinite; }
@keyframes wiggle { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-3deg); } 97% { transform: rotate(3deg); } }

/* Generic */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 10px; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 10px; }
.item { display: flex; align-items: center; gap: 12px; }
.icon { font-size: 28px; width: 46px; height: 46px; display: grid; place-items: center; background: var(--bg2); border-radius: 12px; flex: none; }
.info { flex: 1; min-width: 0; }
.name { font-weight: 900; font-size: 15px; }
.desc { font-size: 12px; color: var(--muted); font-weight: 700; }
.buy { background: linear-gradient(180deg, var(--gas), var(--gas2)); color: #10260a; font-weight: 900; font-size: 14px;
  padding: 9px 12px; border-radius: 12px; box-shadow: 0 3px 0 #3a7a10; min-width: 80px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.buy:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #3a7a10; }
.buy.poor, .buy:disabled { background: #4a3470; color: #9b88bf; box-shadow: 0 3px 0 #2a1a45; }
.buy.star { background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #3a2000; box-shadow: 0 3px 0 #a86a00; }
.buy.red { background: linear-gradient(180deg, #ff7b86, #e04352); color: #fff; box-shadow: 0 3px 0 #8f1f2b; }
.buy.wide { flex: 1; width: 100%; }
.ghost { background: var(--card2); padding: 9px 14px; border-radius: 12px; font-weight: 900; }
.ghost.sm { padding: 6px 12px; font-size: 13px; margin-top: 8px; }
.hint { font-size: 12px; color: var(--muted); text-align: center; margin: 12px 6px; }
.stars-tag { font-size: 12px; font-weight: 900; color: var(--gold); }
.label { font-weight: 900; margin-bottom: 8px; }
.row2 { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: 700 14px 'Nunito', system-ui, sans-serif; user-select: text; -webkit-user-select: text; }
input#wallet { font: 700 13px ui-monospace, monospace; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { background: var(--card); border: 1px solid var(--line); padding: 7px 12px; border-radius: 99px; font-weight: 900; font-size: 13px;
  color: var(--muted); white-space: nowrap; flex: none; }
.chips button.on { background: var(--gold); color: #3a2000; border-color: var(--gold); }

/* Cards */
.combo { display: flex; align-items: center; gap: 10px; border-color: rgba(255, 198, 43, .35); background: linear-gradient(135deg, #3c2410, #2d1a4d); }
.combo .ct { flex: 1; font-weight: 900; font-size: 14px; }
.combo .ct small { display: block; font-weight: 700; }
.slot { width: 42px; height: 42px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 22px;
  border: 1px dashed rgba(255, 198, 43, .4); }
.slot.on { border: 1px solid var(--gold); background: rgba(255, 198, 43, .15); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gcard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: left; display: flex;
  flex-direction: column; gap: 6px; position: relative; min-height: 132px; }
.gcard .top { display: flex; gap: 8px; align-items: center; }
.gcard .em { font-size: 26px; width: 40px; height: 40px; display: grid; place-items: center; background: var(--bg2); border-radius: 10px; flex: none; }
.gcard .nm { font-weight: 900; font-size: 13px; line-height: 1.15; }
.gcard .pr { font-size: 11px; color: var(--muted); font-weight: 800; }
.gcard .pr b { color: var(--gas); }
.gcard .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 7px; font-size: 12px; font-weight: 900; }
.gcard .cost { color: var(--gas); font-variant-numeric: tabular-nums; }
.gcard .cost.poor { color: #9b88bf; }
.gcard.locked { opacity: .55; }
.gcard.locked .em { filter: grayscale(1); }
.gcard .lock { color: var(--orange); font-size: 11px; }
.gcard .cd { color: var(--muted); font-variant-numeric: tabular-nums; }
.gcard .lv { color: var(--gold); }
.gcard.combo-hit::after { content: '🎯'; position: absolute; top: 6px; right: 8px; font-size: 14px; }

/* Earn */
.rp-hero { text-align: center; border-color: rgba(255, 198, 43, .4); background: linear-gradient(160deg, #4a2a00, #2d1a4d 70%); }
.rp-big { font-family: 'Lilita One', sans-serif; font-size: 44px; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.duty { display: flex; align-items: center; gap: 12px; }
.duty .info .bar { height: 7px; margin: 6px 0 2px; }
.duty .rp { font-weight: 900; color: var(--gold); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.duty.done { border-color: rgba(139, 227, 63, .45); }
.bonusrp { font-size: 13px; font-weight: 800; }
.bonusrp div { display: flex; justify-content: space-between; padding: 3px 0; }
.bonusrp b { color: var(--gold); }
.how summary { font-weight: 900; cursor: pointer; }
.how p { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.how b { color: var(--text); }

/* Ranks */
.prizehead { display: flex; justify-content: space-between; align-items: center; font-weight: 800;
  background: linear-gradient(135deg, #4a2a00, #2d1a4d); border-color: rgba(255, 198, 43, .35); }
.countdown { font-size: 13px; color: var(--muted); }
.countdown b { color: var(--gold); }
.myrank { display: flex; justify-content: space-between; flex-wrap: wrap; font-weight: 900; border-color: rgba(139, 227, 63, .4); }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 800; }
.board li:nth-child(odd) { background: rgba(255, 255, 255, .03); }
.board li.me { background: rgba(139, 227, 63, .15); }
.board .pos { width: 30px; text-align: center; font-family: 'Lilita One', sans-serif; font-size: 18px; color: var(--muted); }
.board .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pname small { margin-left: 4px; }
.board .pscore { font-variant-numeric: tabular-nums; color: var(--gold); }
.board .prize { font-size: 11px; color: var(--gold); display: block; }
.lastweek h3 { font-size: 14px; color: var(--muted); margin: 16px 0 6px; }

/* Me */
.ladder { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; font-weight: 800; color: var(--muted); }
.ladder.cur { color: var(--gold); }
.ladder.done { color: var(--text); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.stats div b { display: block; font-size: 16px; }
.card.row { display: flex; justify-content: space-between; align-items: center; font-weight: 900; }

/* Tabs */
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); background: #120a22; border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { background: none; display: flex; flex-direction: column; align-items: center; gap: 1px; position: relative;
  font-size: 11px; font-weight: 800; color: var(--muted); padding: 4px 0; border-radius: 12px; }
.tabs button span { font-size: 21px; filter: grayscale(.6); }
.tabs button.on { color: var(--text); background: var(--card); }
.tabs button.on span { filter: none; }
.tabs button.dot::after { content: ''; width: 8px; height: 8px; background: var(--red); border-radius: 50%; position: absolute; top: 4px; right: 22%; }

/* Sheet / modal / toast / loading */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 4, 20, .7); z-index: 25; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg2); border-top: 2px solid var(--gold); border-radius: 22px 22px 0 0; width: 100%; max-width: 520px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; animation: up .2s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .big-em { font-size: 64px; text-align: center; }
.sheet h3 { font-family: 'Lilita One', sans-serif; font-weight: 400; font-size: 24px; text-align: center; margin: 4px 0; }
.sheet .sub { text-align: center; color: var(--muted); font-weight: 700; font-size: 14px; margin-bottom: 14px; }
.sheet .kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 800; gap: 10px; }
.sheet .kv span:last-child { text-align: right; word-break: break-all; }
.sheet .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.sheet .acts button { flex: 1; min-width: 40%; }
.modal { position: fixed; inset: 0; background: rgba(10, 4, 20, .75); display: grid; place-items: center; z-index: 30; padding: 24px; }
.modal-card { background: var(--bg2); border: 2px solid var(--gold); border-radius: 22px; padding: 22px; max-width: 340px; width: 100%; text-align: center; animation: pop .25s ease; }
.modal-card h3 { font-family: 'Lilita One', sans-serif; font-weight: 400; font-size: 24px; margin: 4px 0 8px; color: var(--gold); }
.modal-card .big { font-family: 'Lilita One', sans-serif; font-size: 30px; color: var(--gas); margin: 6px 0 12px; }
.modal-card input { width: 100%; margin: 8px 0; }
.modal-card .skip { background: none; color: var(--muted); font-weight: 800; margin-top: 10px; font-size: 13px; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); background: #120a22; border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px; font-weight: 800; font-size: 14px; z-index: 40; max-width: 90%; text-align: center; }
.toast.err { border-color: var(--red); }
.loading { position: fixed; inset: 0; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 12px;
  z-index: 50; font-weight: 800; color: var(--muted); text-align: center; padding: 24px; }
.loading img { width: 120px; animation: bob 1.2s ease-in-out infinite; }

/* Admin */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.tile .t { font-size: 11px; color: var(--muted); font-weight: 900; letter-spacing: .5px; text-transform: uppercase; }
.tile .v { font-family: 'Lilita One', sans-serif; font-size: 24px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); font-weight: 700; }
.tile.alert { border-color: rgba(255, 95, 109, .6); }
.tile.alert .v { color: var(--red); }
.tile.goldt .v { color: var(--gold); }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl td, .tbl th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl th { color: var(--muted); font-weight: 900; }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.ev { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.ev .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex: none; background: var(--muted); }
.ev .dot.s2 { background: var(--orange); }
.ev .dot.s3 { background: var(--red); }
.ev .body { flex: 1; min-width: 0; }
.ev .ty { font-weight: 900; }
.ev .who { color: var(--gold); font-weight: 800; }
.ev .det { color: var(--muted); word-break: break-word; }
.ev .tm { color: var(--muted); font-size: 11px; white-space: nowrap; }
.prow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.prow .pi { flex: 1; min-width: 0; }
.prow .pn { font-weight: 900; }
.prow .ps { color: var(--muted); font-size: 11px; font-weight: 700; }
.tag { display: inline-block; font-size: 10px; font-weight: 900; padding: 2px 6px; border-radius: 6px; margin-left: 4px; background: var(--card2); color: var(--muted); }
.tag.red { background: rgba(255, 95, 109, .2); color: var(--red); }
.tag.orange { background: rgba(255, 159, 67, .2); color: var(--orange); }
.tag.green { background: rgba(139, 227, 63, .18); color: var(--gas); }
.adm-search { display: flex; gap: 8px; margin-bottom: 10px; }
.mini { font-size: 12px; padding: 6px 10px; min-width: 0; }
body.admin-mode .gasrow, body.admin-mode .boostbar { display: none; }
.prow .ps, .ev .det { word-break: break-all; }
