:root {
  --bg: #0d0b1a; --bg2: #16132b; --card: #1d1937; --line: #2c2750; --ink: #f4f1ff; --dim: #9a94c4;
  --yellow: #ffd23f; --pink: #ff6bd6; --cyan: #3ec5ff; --green: #3ddc84; --red: #ff4d6d;
  --pix: 'Press Start 2P', monospace; --ui: 'Rubik', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px; }
body { min-height: 100vh; overscroll-behavior: none; }
body::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 100; background: repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0 1px, transparent 1px 3px); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }
h1 { font-family: var(--pix); font-size: 18px; line-height: 1.4; margin: 6px 0 14px; letter-spacing: .5px; }
.h2 { font-size: 15px; font-weight: 700; color: var(--dim); margin: 22px 0 10px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: rgba(13,11,26,.92); backdrop-filter: blur(8px); border-bottom: 2px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.logo { font-family: var(--ui); font-weight: 800; font-size: 15px; background: var(--yellow); color: var(--bg); padding: 2px 7px 3px; border-radius: 4px; box-shadow: 3px 3px 0 var(--pink); }
.brand-t { font-family: var(--pix); font-size: 12px; letter-spacing: 1px; }
.bal { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bal small { color: var(--yellow); font-weight: 700; }

main { padding: 14px 16px calc(86px + var(--safe-b)); max-width: 560px; margin: 0 auto; }
.screen { animation: in .28s var(--ease); }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

/* игры */
.hero-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.count { color: var(--dim); font-size: 13px; }
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); color: var(--ink); font: inherit; outline: none; margin-bottom: 14px; }
.search:focus { border-color: var(--cyan); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.gcard { position: relative; aspect-ratio: 1 / 1.08; border-radius: 14px; background: var(--card); border: 2px solid var(--line); overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0; transition: transform .12s var(--ease), border-color .2s; }
.gcard:active { transform: scale(.95); }
.gcard canvas { width: 100%; flex: 1; min-height: 0; object-fit: cover; object-position: center 40%; image-rendering: pixelated; display: block; background: var(--bg2); }
.gcard .gname { font-size: 12.5px; font-weight: 700; padding: 7px 8px 2px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gcard .gbest { font-size: 11px; color: var(--dim); padding: 0 8px 8px; font-variant-numeric: tabular-nums; }
.gcard .stripe { position: absolute; left: 0; top: 0; right: 0; height: 4px; }
.gcard.off { opacity: .4; }
.soon { text-align: center; color: var(--dim); font-size: 13px; margin: 22px 0 0; }
.announce { background: linear-gradient(90deg, #3a1d5e, #1d2a5e); border: 2px solid var(--purple, #b06bff); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-weight: 500; white-space: pre-wrap; }
.announce::before { content: '📢 '; }

/* кликер */
.click-bal { text-align: center; margin-top: 4px; }
.cb-label { color: var(--dim); font-size: 13px; }
.cb-num { font-size: clamp(30px, 9vw, 44px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; line-height: 1.15; }
.cb-num small { font-size: .45em; color: var(--yellow); }
.cb-rate { color: var(--dim); font-size: 13px; margin-top: 2px; }
.cb-rate span { color: var(--green); font-weight: 700; }
.stage { position: relative; height: min(64vw, 300px); display: grid; place-items: center; margin: 8px 0 4px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.glow { position: absolute; width: 74%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,210,63,.22), transparent 65%); }
.said { position: relative; width: min(60vw, 270px); aspect-ratio: 1; padding: 0; touch-action: manipulation; }
.said svg { width: 100%; height: 100%; display: block; transition: transform .09s var(--ease); filter: drop-shadow(0 8px 0 rgba(0,0,0,.35)); }
.said.hit svg { transform: scale(.92, .88) translateY(4%); }
.said .eyes-closed { display: none; }
.said.hit .eyes-open { display: none; }
.said.hit .eyes-closed { display: inline; }
.said.hit .mouth-n { display: none; }
.said .mouth-o { display: none; }
.said.hit .mouth-o { display: inline; }
.float { position: absolute; pointer-events: none; font-weight: 800; font-size: 18px; color: var(--yellow); text-shadow: 2px 2px 0 #000; animation: fl .8s var(--ease) forwards; white-space: nowrap; z-index: 3; }
@keyframes fl { to { transform: translateY(-70px); opacity: 0; } }
.coin { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--yellow); box-shadow: inset -2px -2px 0 #c99a10; pointer-events: none; z-index: 2; animation: cn .7s ease-out forwards; }
@keyframes cn { to { transform: translate(var(--dx), var(--dy)) rotate(200deg); opacity: 0; } }
.ups { display: grid; gap: 10px; }
.up { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.up .ic { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 22px; background: var(--bg2); }
.up .t { font-weight: 700; }
.up .d { color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.up .lv { font-family: var(--pix); font-size: 8px; color: var(--cyan); margin-left: 6px; }
.buy { background: var(--yellow); color: var(--bg); font-weight: 800; border-radius: 10px; padding: 10px 12px; min-width: 92px; font-size: 13px; font-variant-numeric: tabular-nums; box-shadow: 0 3px 0 #b8901a; transition: transform .1s; }
.buy:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8901a; }
.buy[disabled] { background: var(--line); color: var(--dim); box-shadow: none; }

/* топ */
.seg { display: flex; gap: 8px; margin-bottom: 14px; }
.seg button, .seg select { flex: 1; padding: 10px; border-radius: 10px; background: var(--card); border: 2px solid var(--line); color: var(--ink); font: inherit; font-weight: 600; }
.seg .on { border-color: var(--yellow); color: var(--yellow); }
.seg select.on { border-color: var(--yellow); }
.toplist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.toplist li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--card); border-radius: 12px; border: 2px solid transparent; }
.toplist li.me { border-color: var(--cyan); }
.toplist .pl { font-family: var(--pix); font-size: 10px; color: var(--dim); text-align: center; }
.toplist li:nth-child(1) .pl { color: var(--yellow); } .toplist li:nth-child(2) .pl { color: #d9d9e8; } .toplist li:nth-child(3) .pl { color: #e09a5a; }
.toplist .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.empty { color: var(--dim); text-align: center; padding: 30px 0; }

/* профиль */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.prof { display: flex; gap: 14px; align-items: center; }
.ava { width: 56px; height: 56px; border-radius: 14px; background: var(--bg2); overflow: hidden; flex: none; }
.ava svg { width: 100%; height: 100%; }
.p-name { font-weight: 800; font-size: 18px; }
.p-sub { color: var(--dim); font-size: 13px; margin-top: 2px; }
.list { padding: 4px 14px; }
.row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border: 0; }
.row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--yellow); }
.creator { text-align: center; background: linear-gradient(160deg, #2a1d55, #1d1937 60%); border-color: #4a3a8a; }
.cr-t { color: var(--dim); font-size: 13px; }
.cr-big { font-family: var(--pix); font-size: 17px; color: var(--yellow); margin: 12px 0 10px; text-shadow: 3px 3px 0 var(--pink); }
.cr-sub { font-size: 13px; color: var(--dim); }
.guest { color: var(--dim); font-size: 13px; text-align: center; }

/* панель */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.tile { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.tile b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--dim); font-size: 12px; }
.urow { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.urow .uh { display: flex; justify-content: space-between; gap: 8px; }
.urow .un { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow .um { color: var(--dim); font-size: 12px; margin-top: 2px; }
.urow .ua { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.urow.banned { opacity: .55; border-color: var(--red); }
.sbtn { background: var(--bg2); border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; }
.sbtn.red { color: var(--red); }
.form label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
.form input, .form textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg2); color: var(--ink); font: inherit; resize: vertical; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.toggles label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.toggles input { width: 18px; height: 18px; accent-color: var(--green); }
.btn { display: block; width: 100%; padding: 13px; border-radius: 12px; background: var(--yellow); color: var(--bg); font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 #b8901a; margin-top: 6px; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #b8901a; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--line); }

/* нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: rgba(13,11,26,.96); border-top: 2px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); }
.tabs button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; color: var(--dim); font-size: 11.5px; font-weight: 600; }
.tabs i { font-style: normal; font-size: 21px; filter: grayscale(1) brightness(.8); transition: transform .15s var(--ease); }
.tabs .on { color: var(--ink); }
.tabs .on i { filter: none; transform: translateY(-2px); }

/* игра */
.play { position: fixed; inset: 0; z-index: 50; background: #07061a; display: flex; flex-direction: column; padding-bottom: var(--safe-b); }
.play-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.back { width: 40px; height: 40px; border-radius: 10px; background: var(--card); font-size: 20px; }
.play-name { flex: 1; font-family: var(--pix); font-size: 11px; }
.play-score { font-family: var(--pix); font-size: 12px; color: var(--yellow); }
.screen-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 8px; }
#cv { height: 100%; max-height: 100%; max-width: 100%; aspect-ratio: 3 / 4; image-rendering: pixelated; border-radius: 6px; box-shadow: 0 0 0 3px var(--line); touch-action: none; }
.play.tapmode #cv { width: min(100%, calc((100vh - 120px) * .75)); height: auto; }
.play-hint { text-align: center; color: var(--dim); font-size: 12px; margin: 6px 16px; min-height: 15px; }
.pad { display: flex; justify-content: space-between; align-items: center; padding: 4px 22px 14px; user-select: none; -webkit-user-select: none; touch-action: none; }
.pad.lr .d-up, .pad.lr .d-down, .pad.lr .b-b { visibility: hidden; }
.dpad { position: relative; width: 138px; height: 138px; }
.dpad button { position: absolute; width: 46px; height: 46px; background: var(--card); border: 2px solid var(--line); border-radius: 10px; font-size: 16px; color: var(--dim); touch-action: none; }
.dpad button.on, .ab button.on { background: var(--line); color: var(--ink); transform: scale(.94); }
.d-up { left: 46px; top: 0; } .d-down { left: 46px; bottom: 0; } .d-left { left: 0; top: 46px; } .d-right { right: 0; top: 46px; }
.ab { display: flex; gap: 14px; align-items: flex-end; }
.ab button { width: 64px; height: 64px; border-radius: 50%; font-family: var(--pix); font-size: 14px; touch-action: none; }
.b-a { background: var(--red); box-shadow: 0 4px 0 #9a2238; margin-bottom: 26px; }
.b-b { background: var(--purple, #b06bff); box-shadow: 0 4px 0 #6a3aaa; }
.over { position: absolute; inset: 0; background: rgba(7,6,26,.8); display: grid; place-items: center; padding: 20px; animation: in .25s var(--ease); }
.over-box { width: min(320px, 100%); background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 20px; text-align: center; }
.over-t { font-family: var(--pix); font-size: 12px; color: var(--pink); }
.over-score { font-family: var(--pix); font-size: 30px; color: var(--yellow); margin: 16px 0 6px; }
.over-best { color: var(--dim); font-size: 14px; }
.over-reward { font-weight: 800; color: var(--green); font-size: 18px; margin: 12px 0 14px; min-height: 22px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s var(--ease); z-index: 200; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.form label.chk { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; }
.form label.chk input { width: 20px; height: 20px; margin: 0; accent-color: var(--yellow); flex: none; }
.form input[type=range] { padding: 0; accent-color: var(--yellow); border: 0; background: none; }
.note { color: var(--dim); font-size: 12px; margin: 0; }
