:root {
  --bg: #0b0f14;
  --card: #141b24;
  --card2: #1b2430;
  --line: #263243;
  --text: #e8eef5;
  --muted: #7d8a9a;
  --green: #3ee07a;
  --gold: #ffcc33;
  --red: #ff5a5a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: Rubik, system-ui, -apple-system, sans-serif; user-select: none; -webkit-user-select: none;
  touch-action: none;
}
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

/* ---------- menu ---------- */
.screen {
  position: fixed; inset: 0; overflow-y: auto; touch-action: pan-y;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: radial-gradient(1200px 600px at 50% -10%, rgba(62, 224, 122, .14), transparent 60%), rgba(11, 15, 20, .82);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  max-width: 560px; margin: 0 auto; overflow-x: hidden; overscroll-behavior-x: none;
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; min-width: 0; }
.logo { font-weight: 900; font-size: 26px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 0 18px rgba(255, 204, 51, .35); }
.logo span { color: var(--green); margin-left: 6px; text-shadow: 0 0 18px rgba(62, 224, 122, .35); }
.logo { display: flex; align-items: center; flex: 0 0 auto; white-space: nowrap; font-size: clamp(16px, 5vw, 26px); }
.logo img { width: 1.3em; height: 1.3em; margin-right: 7px; border-radius: 9px; box-shadow: 0 0 14px rgba(62, 224, 122, .3); }
.hero { display: block; width: 100%; height: auto; aspect-ratio: 1120 / 400; border-radius: 16px; border: 1px solid var(--line); margin-bottom: 14px; background: var(--card); }
.user { color: var(--muted); font-size: 14px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.balance { display: flex; flex-direction: column; gap: 14px; }
.label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.label.pad { margin: 22px 2px 10px; }
.muted { text-transform: none; letter-spacing: 0; }
.big { font-size: 38px; font-weight: 900; color: var(--gold); }
.row { display: flex; gap: 10px; }
.btn { flex: 1; padding: 13px 14px; border-radius: 14px; font-weight: 700; font-size: 15px; background: var(--card2); transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn.green { background: var(--green); color: #05210f; }
.btn.gold { background: var(--gold); color: #2a1f00; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:disabled { opacity: .45; }

.rooms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.room { text-align: left; padding: 14px; border-radius: 16px; background: var(--card); border: 2px solid var(--line); }
.room:not(.paid) { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.room:not(.paid) .s { margin-top: 0; }
.room.sel { border-color: var(--green); box-shadow: 0 0 0 4px rgba(62, 224, 122, .12); }
.room .t { font-size: 22px; font-weight: 900; }
.room.paid .t { color: var(--gold); }
.room .s { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.45; }

.skins { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; touch-action: pan-x; }
.skin { flex: 0 0 auto; width: 92px; padding: 10px 8px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); text-align: center; font-size: 12.5px; }
.skin.sel { border-color: var(--green); }
.skin .chip { height: 26px; border-radius: 13px; margin-bottom: 8px; }
.skin .p { color: var(--gold); font-weight: 700; margin-top: 3px; }
.skin .p.own { color: var(--green); }

.play { display: block; width: 100%; margin-top: 24px; padding: 18px; font-size: 22px; font-weight: 900; letter-spacing: 2px; background: linear-gradient(135deg, var(--green), #19b45a); color: #04210e; box-shadow: 0 10px 30px rgba(62, 224, 122, .25); }
.note { color: var(--muted); font-size: 12.5px; line-height: 1.5; text-align: center; margin-top: 14px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-tl { position: absolute; left: 12px; top: max(12px, env(safe-area-inset-top)); }
.hud-value { font-size: 30px; font-weight: 900; color: var(--gold); text-shadow: 0 2px 8px #000; }
.hud-sub { font-size: 13px; color: #cfd8e3; text-shadow: 0 1px 4px #000; }
#minimap { position: static; display: block; width: 96px; height: 96px; margin-top: 8px; }
#joy { position: absolute; left: 0; top: 0; width: 100px; height: 100px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .05); opacity: 0; transition: opacity .15s; }
#joy.on { opacity: 1; }
#joy i { position: absolute; left: 30px; top: 30px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .35); }
.hud-tr { position: absolute; right: 10px; top: max(10px, env(safe-area-inset-top)); width: 168px; background: rgba(0, 0, 0, .35); border-radius: 12px; padding: 8px 10px; font-size: 12.5px; }
.lb-title { font-weight: 700; color: var(--muted); margin-bottom: 4px; }
#lb { margin: 0; padding-left: 18px; }
#lb li { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; }
#lb li span:first-child { overflow: hidden; text-overflow: ellipsis; }
#lb li.me { color: var(--green); font-weight: 700; }
#lb li b { color: var(--gold); font-weight: 500; }
.hud-btn { position: absolute; pointer-events: auto; bottom: max(18px, env(safe-area-inset-bottom)); border-radius: 18px; font-weight: 900; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
.cashout { left: 12px; padding: 16px 18px; background: var(--gold); color: #2a1f00; overflow: hidden; font-size: 15px; }
.cashout i { position: absolute; left: 0; bottom: 0; height: 5px; background: #2a1f00; width: 0; }
.cashout span { position: relative; }
.boost { right: 14px; width: 76px; height: 76px; border-radius: 50%; font-size: 30px; background: rgba(62, 224, 122, .2); border: 2px solid var(--green); }
.boost.on { background: rgba(62, 224, 122, .55); }
@media (hover: hover) and (pointer: fine) { .boost { display: none; } }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { position: relative; width: 100%; max-width: 560px; background: var(--card); border-radius: 22px 22px 0 0; padding: 22px 16px max(22px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); animation: up .2s ease-out;
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.sheet p b { color: var(--text); }
.terms-link { color: var(--gold); text-decoration: underline; }
.dep-tabs { margin: 4px 0 6px; }
[data-stars] small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 6px; font-size: 22px; }
.sheet p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 6px 0 14px; }
.close { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 50%; background: var(--card2); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.grid3 .btn { padding: 14px 6px; font-size: 17px; }
.input { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 18px; margin-bottom: 12px; }
.coins { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.coins span { font-size: 12px; padding: 4px 8px; border-radius: 8px; background: var(--card2); color: #b9c4d0; }
.result { text-align: center; }
.result .em { font-size: 54px; }
.result .amt { font-size: 40px; font-weight: 900; margin: 6px 0 4px; }
.hist { font-size: 13px; color: var(--muted); margin-top: 12px; }
.hist div { display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%); background: #222c39; border: 1px solid var(--line); padding: 12px 16px; border-radius: 14px; z-index: 20; font-size: 14px; max-width: 90vw; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }

/* ---------- admin ---------- */
.top-r { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; flex: 1 1 auto; }
.adm-btn { flex: 0 0 auto; padding: 7px 9px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.adm-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; touch-action: pan-x; }
.adm-tabs button { flex: 0 0 auto; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 13px; }
.adm-tabs button.on { background: var(--green); color: #05210f; border-color: var(--green); font-weight: 700; }
#admBody h3 { margin: 18px 2px 8px; font-size: 15px; }
#admBody .muted { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 6px 2px; }
#admBody .err { color: var(--red); font-size: 14px; }
#admBody .tag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--card2); color: var(--gold); vertical-align: middle; }
#admBody small { color: var(--muted); }
#admBody a { color: var(--green); text-decoration: underline; cursor: pointer; }
.kv { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 12px; }
.kv div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv div:first-child { border-top: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.item .input { margin: 0; font-size: 15px; padding: 10px 12px; }
.row-sb { display: flex; justify-content: space-between; gap: 10px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.line.click { cursor: pointer; }
.line b.pos { color: var(--green); }
.line b.neg { color: var(--red); }
.btn.red { background: var(--red); color: #fff; }
.btn.wide { display: block; width: 100%; margin: 8px 0; }
.set { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
label.set { flex-direction: row; justify-content: space-between; align-items: center; }
.set .input { margin: 0; }
.set input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); }
textarea.input { resize: vertical; font-size: 15px; }

/* ---------- profile & leaderboard ---------- */
.prof-btn { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 20px; background: var(--card); border: 1px solid var(--line); flex: 0 0 auto; }
.prof-btn .user { max-width: none; min-width: 0; color: var(--text); font-size: 13.5px; font-weight: 500; }
.ava { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #05210f; background: linear-gradient(135deg, var(--green), var(--gold)); }
.ava.big { width: 64px; height: 64px; font-size: 28px; }
.prof-head { display: flex; align-items: center; gap: 14px; }
.prof-head h2 { margin: 0; font-size: 20px; }
.prof-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.prof-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.prof-big div { background: var(--card2); border-radius: 12px; padding: 10px 8px; text-align: center; }
.prof-big b { display: block; font-size: 18px; font-weight: 900; }
.prof-big span { font-size: 11.5px; color: var(--muted); }
#profBody h3 { margin: 20px 2px 8px; font-size: 15px; }
#profBody .muted { color: var(--muted); font-size: 13px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; touch-action: pan-x; }
.chips button { flex: 0 0 auto; padding: 7px 11px; border-radius: 10px; background: var(--card2); font-size: 13px; }
.chips button.on { background: var(--green); color: #05210f; font-weight: 700; }
.top-card { padding: 12px; }
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--line); font-size: 14px; }
.top-list li:first-child { border-top: 0; }
.top-list .pl { flex: 0 0 28px; text-align: center; font-weight: 700; color: var(--muted); }
.top-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .vl { font-weight: 700; color: var(--gold); }
.top-list li.me { background: rgba(62, 224, 122, .1); border-radius: 10px; }
.top-list li.me .nm { color: var(--green); font-weight: 700; }
.top-list li.gap { justify-content: center; color: var(--muted); padding: 2px; border: 0; }
.top-list .empty { color: var(--muted); justify-content: center; }

/* shop */
.skin .icon { font-size: 26px; height: 26px; line-height: 26px; margin-bottom: 8px; }
.skin .chip.glow { box-shadow: 0 0 12px var(--glow); }
.skin .chip.rainbow { background-size: 300% 100% !important; animation: rb 3s linear infinite; }
@keyframes rb { to { background-position: 300% 0; } }

.row.extra { margin-top: 10px; }
.row.extra .btn { padding: 11px 10px; font-size: 14px; }

.fld { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 12.5px; color: var(--muted); }
.fld .input { margin-bottom: 10px; }
.lim-head { margin: 4px 0 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.lim-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.lim-row .fld { min-width: 0; }

/* quests & tournament */
.quests { padding: 6px 14px; }
.quest { padding: 10px 0; border-top: 1px solid var(--line); }
.quest:first-child { border-top: 0; }
.quest.claimed { opacity: .55; }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }
.q-claim { flex: 0 0 auto; padding: 7px 12px; font-size: 13px; }
.bar { height: 6px; border-radius: 3px; background: var(--card2); margin: 8px 0 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); border-radius: 3px; }
.tour .t-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tour .t-head b { font-size: 17px; }
.t-prize { font-weight: 900; font-size: 20px; color: var(--gold); }
.tour .muted { color: var(--muted); font-size: 12.5px; margin: 6px 0 4px; line-height: 1.45; }
.top-list small.pos { font-size: 11px; }

/* admin charts */
.chart { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 10px 4px; }
.chart svg { display: block; width: 100%; height: 170px; }
.chart svg text { fill: var(--muted); font-size: 13px; font-family: Rubik, sans-serif; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

#admBody a.flag { color: var(--red); font-size: 13px; text-decoration: none; }

/* support chat */
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow-y: auto; margin: 10px 0; touch-action: pan-y; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.msg small { display: block; margin-top: 4px; font-size: 11px; opacity: .6; }
.msg.in { align-self: flex-start; background: var(--card2); }
.msg.out { align-self: flex-end; background: rgba(62, 224, 122, .18); }

/* live feed */
.feed { display: flex; align-items: center; gap: 8px; padding: 9px 12px; margin-bottom: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 13px; overflow: hidden; }
.feed .f-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed small { color: var(--muted); flex: 0 0 auto; font-size: 11px; }
.feed .gold { color: var(--gold); }
.f-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.feed.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(255, 204, 51, .25); border-color: var(--gold); } }
/* achievements */
.achs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ach { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 3px; opacity: .45; filter: grayscale(1); }
.ach.got { opacity: 1; filter: none; border-color: rgba(62, 224, 122, .5); }
.ach .ai { font-size: 26px; }
.ach b { font-size: 13.5px; }
.ach small { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

.rg .muted { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 6px 0 10px; }
.rg .row .btn { padding: 10px 6px; font-size: 13.5px; }
.excl { color: var(--red); font-size: 13.5px; line-height: 1.45; }

.item.off { opacity: .6; }

/* login streak */
.streak { padding: 12px; }
.sdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 10px; }
.sd { background: var(--card2); border-radius: 10px; padding: 6px 2px; text-align: center; border: 1px solid transparent; }
.sd small { display: block; font-size: 10px; color: var(--muted); }
.sd b { font-size: 12.5px; }
.sd.got { background: rgba(255, 145, 0, .22); border-color: rgba(255, 145, 0, .5); }
.sd.now { border-color: var(--gold); box-shadow: 0 0 10px rgba(255, 204, 51, .35); }
.streak .muted { color: var(--muted); font-size: 12px; line-height: 1.4; margin: 8px 2px 0; }

.invite { display: block; pointer-events: auto; margin-top: 8px; padding: 6px 11px; border-radius: 14px; font-size: 12.5px; font-weight: 700; background: rgba(0, 0, 0, .45); color: #fff; border: 1px solid var(--line); }

/* account level */
.lvl { margin-top: 12px; }
.lvl .bar { margin: 6px 0; }
.lv-rewards { display: flex; gap: 6px; margin: 8px 0 4px; }
.lv-rewards span { flex: 1; text-align: center; padding: 6px 0; border-radius: 10px; background: var(--card2); font-size: 18px; opacity: .4; filter: grayscale(1); }
.lv-rewards span.got { opacity: 1; filter: none; background: rgba(255, 204, 51, .15); }
.lv-rewards small { display: block; font-size: 10px; color: var(--muted); }
.lvl .muted { color: var(--muted); font-size: 11.5px; }

.row.extra .btn { padding: 11px 6px; font-size: 13px; }
.hist a.join, .hist a.kick { color: var(--green); cursor: pointer; text-decoration: underline; font-size: 13px; }
.hist a.kick { color: var(--red); margin-left: 6px; }

/* spectator bar */
.spec-bar { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; pointer-events: auto; background: rgba(0, 0, 0, .6); padding: 8px 10px; border-radius: 16px; max-width: 94vw; }
.spec-bar span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spec-bar .btn { flex: 0 0 auto; padding: 8px 12px; font-size: 13px; }
.ava { overflow: hidden; }
.ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-prize { font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.q-prize.money { color: var(--gold); }
.q-prize.xp { color: var(--green); }
.q-note { margin-top: 8px; }
.howto { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-size: 13.5px; }
.howto summary { cursor: pointer; font-weight: 700; color: var(--text); }
.howto ol { margin: 8px 0 4px; padding-left: 20px; color: var(--muted); line-height: 1.5; }
.howto .btn { margin-top: 6px; }
.ton-box { display: grid; gap: 6px; padding: 12px; border-radius: 14px; background: var(--card2); border: 1px solid var(--line); margin-bottom: 10px; }
.ton-box small { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ton-val { font-size: 14px; word-break: break-all; color: var(--text); }
.ton-val.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.ton-val.memo { font-size: 22px; font-weight: 900; letter-spacing: 1px; color: var(--gold); }
.ton-warn { color: var(--gold) !important; font-weight: 600; }
.faq { display: grid; gap: 6px; margin: 4px 0 14px; }
.faq details { border: 1px solid var(--line); border-radius: 12px; background: var(--card2); padding: 9px 12px; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text); }
.faq p { margin: 8px 0 2px !important; font-size: 13.5px; }
.menu-support { margin-top: 16px; }
.clan-prize { display: grid; gap: 6px; margin: 6px 0 12px; padding: 12px 14px; }
.cp-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-row span { padding: 6px 10px; border-radius: 10px; background: var(--card2); font-weight: 700; color: var(--gold); }
