:root {
	--bg: #07040f;
	--card: #14101f;
	--line: rgba(255,255,255,.08);
	--txt: #f4efff;
	--dim: #9b90b3;
	--acc: #c084fc;
	--acc2: #7c3aed;
	--ok: #4ade80;
	--bad: #fb7185;
	--bar: #0d0a16;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--txt); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow: hidden; }
body { min-height: 100dvh; }
#app { position: relative; height: 100dvh; overflow: hidden; }
.page {
	display: none; padding: 16px 16px 96px; gap: 12px; flex-direction: column;
	position: absolute; inset: 0; overflow: hidden;
}
.page.active { display: flex; }
.page[data-page="profile"].active { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page.anim-in { animation: pageIn .32s cubic-bezier(.22,.8,.32,1); }
.page.anim-back { animation: pageBack .32s cubic-bezier(.22,.8,.32,1); }
@keyframes pageIn { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes pageBack { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
.sec-body.swap { animation: fadeSwap .28s ease; }
@keyframes fadeSwap { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.top { display: flex; flex-direction: column; gap: 10px; }
.brand { font-weight: 700; font-size: 22px; letter-spacing: -.02em; }
.periods { display: flex; gap: 6px; overflow: hidden; align-items: stretch; flex-shrink: 0; }
.periods button, .tabs button, .ghost, .join {
	border: 0; border-radius: 999px; padding: 7px 8px; font-weight: 600; font-size: 12px;
	background: #1c1729; color: var(--dim); transition: background .2s ease, color .2s ease;
	white-space: nowrap;
}
.periods button { flex: 1 1 0; min-width: 0; }
.periods button.on, .tabs button.on { background: linear-gradient(135deg, var(--acc2), var(--acc)); color: #fff; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.hero-k, .card-h { color: var(--dim); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.sec-title { color: var(--dim); font-size: 13px; font-weight: 600; margin: 18px 0 12px; }
#stats-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dirs { flex: 1; min-height: 120px; position: relative; }
.empty-hint {
	position: absolute; inset: 0; display: grid; place-items: center;
	color: rgba(155, 144, 179, .55); font-size: 14px; text-align: center; padding: 12px 24px; pointer-events: none;
}
.hero-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; text-align: center; }
.hero-row span { display: block; font-size: 26px; font-weight: 800; }
.hero-row small { color: var(--dim); }
.hero-row .accent span { color: var(--ok); }
.dir { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.dir:last-child { margin-bottom: 0; }
.dir b { font-size: 16px; }
.dir .meta { color: var(--dim); font-size: 13px; margin-top: 4px; }
.dir .conv { color: var(--ok); font-weight: 800; font-size: 18px; }
.join { width: 100%; padding: 14px; font-size: 16px; background: linear-gradient(135deg, var(--acc2), var(--acc)); color: #fff; }
.join:disabled { opacity: .55; }
.user { display: flex; align-items: center; gap: 12px; }
.ava-wrap { width: 56px; height: 56px; flex: 0 0 56px; }
.ava { width: 56px; height: 56px; border-radius: 18px; object-fit: cover; background: #2a203c; display: block; }
.ava-fb { display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #fff; }
.u-name { font-weight: 800; }
.u-sub, .u-id { color: var(--dim); font-size: 13px; }
.ghost { margin-left: auto; }
.grid { display: flex; flex-direction: column; gap: 10px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 8px; }
.item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item .row { display: flex; justify-content: space-between; font-weight: 700; }
.item .sub { color: var(--dim); font-size: 13px; margin-top: 4px; }
.empty { color: var(--dim); text-align: center; padding: 28px 8px; }
.bar {
	position: fixed; left: 12px; right: 12px; bottom: 12px;
	display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
	background: var(--bar); border: 1px solid var(--line); border-radius: 20px; padding: 8px;
	padding-bottom: calc(8px + env(safe-area-inset-bottom));
	z-index: 5;
}
.bar button { background: transparent; color: var(--dim); border: 0; padding: 10px 6px; font-weight: 700; border-radius: 14px; transition: background .2s, color .2s, transform .2s; }
.bar button.on { background: #241b38; color: #fff; }
.modal {
	position: fixed; inset: 0; background: rgba(0,0,0,.62);
	display: grid; place-items: center; padding: 20px 20px 110px;
	z-index: 80; pointer-events: auto;
}
.modal[hidden] { display: none !important; }
.modal-card { background: var(--card); border-radius: 18px; padding: 22px 18px 18px; width: 100%; max-width: 380px; position: relative; z-index: 81; }
.modal-title { font-weight: 800; font-size: 18px; margin-bottom: 12px; }
.modal-body { color: var(--dim); line-height: 1.45; margin-bottom: 18px; }
.modal-card .join { margin-top: 4px; position: relative; z-index: 82; }
.cond { padding: 6px 0; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

.page[data-page="raffle"] { padding: 0; overflow: hidden; }
.raffle-scene {
	position: relative; overflow: hidden; flex: 1; min-height: 0;
	border-radius: 0 0 28px 28px;
	background: radial-gradient(120% 90% at 50% 20%, #e879f9 0%, #c026d3 28%, #a21caf 52%, #7e22ce 100%);
	padding: 18px 16px 96px;
	display: flex; flex-direction: column;
}
.raffle-scene.off { filter: saturate(.85); }
.raffle-head { display: flex; justify-content: space-between; align-items: center; z-index: 3; }
.raffle-title { font-size: 28px; font-weight: 800; color: #fff; letter-spacing: -.03em; }
.raffle-x { width: 36px; height: 36px; border: 0; background: transparent; color: #fff; font-size: 28px; line-height: 1; }
.ring-box { position: relative; width: 250px; height: 250px; margin: 28px auto 0; z-index: 2; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.28); stroke-width: 10; }
.ring-fg { fill: none; stroke: #fff; stroke-width: 10; stroke-linecap: round; stroke-dasharray: 528; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.dot {
	position: absolute; left: 50%; top: 8px; width: 18px; height: 18px; margin-left: -9px;
	border-radius: 50%; background: #fff; box-shadow: 0 0 12px #fff;
}
.ring-core { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.prize {
	font-size: 40px; font-weight: 800; color: #fff; letter-spacing: -.03em;
	text-shadow: 0 8px 24px rgba(88, 28, 135, .35);
}
.timer {
	margin-top: 10px; background: rgba(255,255,255,.22); color: #fff;
	border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; letter-spacing: .08em;
}
.play {
	margin-top: auto; width: 100%; border: 0; border-radius: 18px; padding: 16px;
	background: #fff; color: #111; font-size: 17px; font-weight: 700;
	box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.play:disabled { opacity: .6; }
.raffle-off {
	position: absolute; left: 16px; right: 16px; top: auto; bottom: 118px; z-index: 4;
	background: rgba(40, 10, 70, .72); border-radius: 16px; padding: 14px 16px; text-align: center; color: #fff;
}
.raffle-off[hidden] { display: none !important; }
.off-title { font-weight: 800; margin-bottom: 6px; }
.off-text { opacity: .85; font-size: 14px; }
.float { position: absolute; pointer-events: none; z-index: 1; }
.gem {
	left: 18px; top: 86px; width: 42px; height: 42px;
	background: linear-gradient(135deg, #f5d0fe, #a21caf 55%, #4c1d95);
	clip-path: polygon(50% 0, 100% 35%, 78% 100%, 22% 100%, 0 35%);
	filter: drop-shadow(0 8px 10px rgba(0,0,0,.25));
	animation: floaty 4.2s ease-in-out infinite;
}
.coin {
	width: 78px; height: 78px; border-radius: 50%;
	background: radial-gradient(circle at 35% 30%, #f5e6a8, #c9a227 45%, #5b3b09 100%);
	box-shadow: inset 0 0 0 8px #7a5410, 0 12px 18px rgba(0,0,0,.28);
	display: grid; place-items: center; color: #3f2a08; font-weight: 900; font-size: 34px;
}
.coin::after { content: "$"; }
.coin-tr { right: 18px; top: 58px; transform: rotate(18deg); animation: floaty 5s ease-in-out infinite reverse; }
.coin-bl { left: -10px; bottom: 78px; transform: rotate(-18deg) scale(.92); animation: floaty 6s ease-in-out infinite; }
.reel {
	right: -18px; bottom: 92px; width: 92px; height: 150px;
	border-radius: 18px; transform: rotate(28deg);
	background: linear-gradient(180deg, #3b0764, #1e1b4b);
	border: 4px solid #c4b5fd; overflow: hidden;
	box-shadow: 0 16px 24px rgba(0,0,0,.3);
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
	animation: reelspin 3.6s linear infinite;
}
.reel span { color: #ddd6fe; font-size: 46px; font-weight: 900; line-height: .9; text-shadow: 0 2px 0 #0f172a; }
@keyframes floaty { 50% { transform: translateY(-8px); } }
@keyframes reelspin { to { filter: hue-rotate(18deg); } }
.page[data-page="raffle"] .conds { margin: 0 16px 12px; }

[hidden] { display: none !important; }
