: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 calc(148px + env(safe-area-inset-bottom)); gap: 12px; flex-direction: column;
	position: absolute; inset: 0; overflow: hidden;
}
.page.active { display: flex; }
.page[data-page="stats"],
.page[data-page="profile"] { padding: 0; }
.page-scroll {
	flex: 1 1 auto;
	min-height: 0;
	width: 100%;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 16px 16px calc(148px + env(safe-area-inset-bottom));
	display: block;
}
/* Профиль: отступы между ПРОФИЛЬ / карточка аккаунта / ПРОФИТЫ */
.page[data-page="profile"] .page-scroll {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.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; }
.plate {
	text-align: center; text-transform: uppercase; letter-spacing: .08em;
	font-weight: 800; font-size: 13px; color: #e9e0ff;
	background: linear-gradient(180deg, #1c1629, #14101f);
	border: 1px solid var(--line); border-radius: 12px;
	padding: 10px 12px;
}
.brand-plate { font-size: 18px; letter-spacing: .12em; padding: 12px; }
.plate-in { margin: 0 0 14px; background: #1a1526; }
.plate-sec { margin: 16px 0 12px; }
.periods { display: flex; gap: 6px; overflow: hidden; align-items: stretch; flex-shrink: 0; margin-bottom: 4px; }
.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: 0 0 auto; gap: 0; margin-top: 14px; }
.dirs { flex: 0 0 auto; min-height: 80px; 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; margin: 12px 0 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:not([hidden]) { animation: modalFade .28s ease; }
.modal:not([hidden]) .modal-card { animation: modalUp .34s cubic-bezier(.22,.8,.32,1); }
.modal.closing { animation: modalFadeOut .26s ease forwards; pointer-events: none; }
.modal.closing .modal-card { animation: modalDown .28s cubic-bezier(.4,0,.2,1) forwards; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalUp {
	from { opacity: 0; transform: translateY(28px) scale(.96); }
	to { opacity: 1; transform: none; }
}
@keyframes modalDown {
	from { opacity: 1; transform: none; }
	to { opacity: 0; transform: translateY(22px) scale(.96); }
}
.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; }
.modal-actions {
	display: grid; grid-template-columns: 1fr 1.2fr; gap: 8px; margin-top: 4px;
}
.modal-actions .ghost {
	border: 1px solid rgba(255,255,255,.12); background: #1c1729; color: #fff;
	border-radius: 14px; padding: 14px 12px; font-weight: 700; font-size: 15px;
}
.modal-actions .join.danger {
	background: #fff; color: #9f1239; margin-top: 0;
}
.cond { padding: 6px 0; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

.page[data-page="raffle"] { padding: 0; overflow: hidden; }
.page[data-page="raffle"].active {
	overflow: hidden;
	justify-content: flex-start;
}
.raffle-scene {
	position: relative; overflow: hidden;
	flex: 1 1 auto; min-height: 0;
	background:
		radial-gradient(120% 70% at 50% 32%, #f0abfc 0%, #d946ef 18%, #a21caf 42%, #6b21a8 68%, #3b0764 100%);
	padding: 12px 16px 108px;
	display: flex; flex-direction: column; align-items: center;
	justify-content: center;
}
.raffle-scene .glow {
	position: absolute; left: 50%; top: 28%; width: 140%; height: 70%;
	transform: translate(-50%, -50%);
	background: radial-gradient(ellipse at center, rgba(255, 214, 255, .45) 0%, rgba(233, 121, 249, .18) 34%, transparent 62%);
	pointer-events: none; z-index: 0;
}

.raffle-head, .raffle-title, .raffle-sub { display: none !important; }

.wheel-hero {
	position: relative; z-index: 2;
	width: min(72vw, 270px, 46vh);
	max-width: 270px;
	margin: 0 auto 14px;
	aspect-ratio: 1;
	display: grid; place-items: center;
	flex: 0 0 auto;
	overflow: visible;
}
.wheel-img {
	width: 100%; height: 100%; object-fit: contain;
	object-position: center center;
	filter: drop-shadow(0 14px 28px rgba(24, 0, 48, .4));
	user-select: none; pointer-events: none;
	display: block;
}
.wheel-img[hidden] { display: none !important; }
.raffle-scene.off #wheel-open-img { display: none !important; }
.raffle-scene:not(.off) #wheel-locked-img { display: none !important; }

.float-prop {
	position: absolute; z-index: 1; pointer-events: none;
	animation: bob 5.4s ease-in-out infinite;
}
.float-prop.coin-tr,
.float-prop.coin-bl {
	width: 58px; height: 58px; border-radius: 50%;
	display: grid; place-items: center;
	background:
		radial-gradient(circle at 32% 28%, #fff7d1 0%, #f5d76e 28%, #d4a017 58%, #7a4e0b 100%);
	box-shadow:
		inset 0 0 0 5px #a16207,
		inset 0 0 0 8px rgba(255, 236, 160, .35),
		inset -4px -6px 12px rgba(80, 40, 0, .3),
		inset 4px 5px 10px rgba(255,255,255,.25),
		0 10px 18px rgba(0,0,0,.32);
}
.float-prop.coin-tr i,
.float-prop.coin-bl i {
	font-style: normal; font-weight: 900; font-size: 26px; color: #3f2a08;
	text-shadow: 0 1px 0 rgba(255,255,255,.35), 0 -1px 0 rgba(80,40,0,.35);
}
.float-prop.gem-tl,
.float-prop.gem-br {
	width: 36px; height: 36px;
	background: linear-gradient(145deg, #f5d0fe 0%, #c026d3 42%, #6b21a8 78%, #3b0764 100%);
	clip-path: polygon(50% 0, 100% 38%, 78% 100%, 22% 100%, 0 38%);
	filter: drop-shadow(0 8px 12px rgba(40, 0, 70, .4));
}
.float-prop.gem-tl::after,
.float-prop.gem-br::after {
	content: ""; position: absolute; inset: 18% 28% 40% 28%;
	background: linear-gradient(180deg, rgba(255,255,255,.55), transparent);
	clip-path: polygon(50% 0, 100% 100%, 0 100%);
	opacity: .7;
}
.float-prop.coin-tr { right: -10%; top: 6%; transform: rotate(16deg); }
.float-prop.gem-tl { left: -6%; top: 14%; transform: rotate(-18deg); width: 28px; height: 28px; animation-duration: 4.8s; opacity: .92; }
.float-prop.coin-bl { left: -12%; bottom: 4%; transform: rotate(-14deg); width: 54px; height: 54px; animation-duration: 6.2s; animation-direction: reverse; }
.float-prop.gem-br { right: -2%; bottom: 10%; transform: rotate(12deg); width: 24px; height: 24px; opacity: .85; }

@keyframes bob {
	0%, 100% { translate: 0 0; }
	50% { translate: 0 -8px; }
}

.ring-progress {
	position: absolute; inset: 2%; width: 96%; height: 96%;
	pointer-events: none; opacity: 0; z-index: 3;
}
.raffle-scene:not(.off) .ring-progress { opacity: 1; }
.ring-fg {
	transition: stroke-dashoffset 1s linear;
	filter: drop-shadow(0 0 8px rgba(232, 121, 249, .85));
}

.ring-core {
	position: absolute; inset: 26%;
	display: flex; flex-direction: column; align-items: center; justify-content: center;
	z-index: 4; pointer-events: none;
}
.ring-core[hidden] { display: none !important; }
.prize {
	font-size: clamp(28px, 8.5vw, 38px); font-weight: 800; color: #fff; letter-spacing: -.04em;
	text-align: center; line-height: 1;
	text-shadow: 0 10px 28px rgba(20, 0, 40, .55), 0 2px 0 rgba(255,255,255,.12);
}
.timer {
	margin-top: 10px; background: rgba(40, 8, 70, .55); color: #fff;
	border: 1px solid rgba(255,255,255,.16);
	border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; letter-spacing: .08em;
	backdrop-filter: blur(8px);
	box-shadow: 0 8px 18px rgba(0,0,0,.22);
}
.play {
	width: 100%; max-width: 420px; border: 0; border-radius: 18px; padding: 16px;
	background: #fff; color: #111; font-size: 17px; font-weight: 700;
	margin: 10px auto 0; box-shadow: 0 12px 28px rgba(0,0,0,.22);
	align-self: center; position: relative; z-index: 5; flex: 0 0 auto;
}
.play .join-label { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.play .join-check {
	display: inline-grid; place-items: center;
	width: 22px; height: 22px; border-radius: 50%;
	background: linear-gradient(145deg, #a855f7, #6d28d9);
	font-size: 12px; line-height: 1;
	box-shadow: 0 0 10px rgba(168, 85, 247, .55);
}
.play.joined {
	background: rgba(255,255,255,.22);
	color: #fff;
	border: 1px solid rgba(255,255,255,.28);
	backdrop-filter: blur(8px);
	box-shadow: none;
}
.play.joined:disabled { opacity: 1; }
.play:disabled:not(.joined) { opacity: .6; }
.cond-list { margin-top: 10px; text-align: left; }
.cond-list .cond { padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.cond-list .cond:last-child { border-bottom: 0; }
.admin-play, .admin-cancel { margin-top: 10px; }
.admin-cancel { background: #1c1729; color: #fff; border: 1px solid rgba(255,255,255,.12); }

.raffle-parts {
	width: 100%; max-width: 420px; align-self: center; flex: 0 0 auto;
	margin: 10px auto 0; z-index: 5;
	display: flex; flex-direction: column; gap: 6px;
	padding: 12px 16px; border-radius: 16px;
	background: rgba(20, 6, 40, .45);
	border: 1px solid rgba(255,255,255,.18);
	color: #fff; backdrop-filter: blur(8px);
	box-shadow: 0 10px 22px rgba(0,0,0,.18);
}
.raffle-parts[hidden] { display: none !important; }
.raffle-parts-row { display: flex; align-items: center; justify-content: space-between; }
.raffle-parts-label { font-size: 13px; font-weight: 700; opacity: .85; letter-spacing: .02em; }
.raffle-parts-num { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.raffle-parts-id {
	font-size: 11px; font-weight: 600; opacity: .72;
	font-variant-numeric: tabular-nums; word-break: break-all;
}
.raffle-parts-id[hidden] { display: none !important; }

.raffle-off {
	width: 100%; max-width: 420px; z-index: 5;
	margin: 10px auto 0; align-self: center; flex: 0 0 auto;
	display: flex; align-items: center; gap: 12px;
	background: linear-gradient(180deg, rgba(48, 12, 88, .78), rgba(28, 6, 56, .88));
	border: 1.5px solid rgba(192, 132, 252, .55);
	border-radius: 18px; padding: 14px 14px; color: #fff;
	box-shadow: 0 0 0 1px rgba(168, 85, 247, .18), 0 14px 30px rgba(20, 0, 40, .35), inset 0 1px 0 rgba(255,255,255,.08);
	backdrop-filter: blur(10px);
}
.raffle-off[hidden] { display: none !important; }
.off-ico {
	flex: 0 0 46px; width: 46px; height: 46px; border-radius: 14px;
	display: grid; place-items: center;
	background: linear-gradient(145deg, #a855f7, #6d28d9 55%, #4c1d95);
	border: 1px solid rgba(255,255,255,.22);
	box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 0 16px rgba(168, 85, 247, .45), 0 8px 16px rgba(0,0,0,.28);
}
.off-copy { min-width: 0; }
.off-title { font-weight: 800; font-size: 15px; margin-bottom: 3px; }
.off-text { opacity: .82; font-size: 12px; line-height: 1.35; }

.page[data-page="raffle"] .conds { margin: 0 16px 12px; width: calc(100% - 32px); }
.play.admin-play {
	margin-top: 10px;
	background: #4c1d95;
	color: #fff;
}
.play.admin-cancel {
	margin-top: 10px;
	background: #fff;
	color: #9f1239;
}
.raffle-admin-card {
	max-height: min(78dvh, 640px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 18px;
}
.raffle-admin-card .set-close {
	margin-left: 0; width: 100%;
}
.raffle-admin-card .ra-period-label { margin-top: 22px; }
.chip-row {
	display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.chip-row button {
	flex: 1 1 40%; border: 0; border-radius: 999px; padding: 8px 10px;
	background: #1c1729; color: var(--dim); font-weight: 700; font-size: 12px;
}
.chip-row button.on {
	background: linear-gradient(135deg, var(--acc2), var(--acc)); color: #fff;
}
.set-check {
	display: flex; align-items: center; gap: 8px;
	color: var(--dim); font-size: 13px; font-weight: 700; margin: 10px 0 6px;
}
.set-check input { width: 18px; height: 18px; }
.set-input:disabled { opacity: .45; }
.no-spin::-webkit-outer-spin-button,
.no-spin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.no-spin { -moz-appearance: textfield; appearance: textfield; }

.ra-tog {
	display: flex; align-items: center; gap: 12px;
	margin: 14px 0 8px; cursor: pointer; user-select: none;
}
.ra-tog-box {
	position: relative; width: 22px; height: 22px; flex: 0 0 22px;
}
.ra-tog-box input {
	position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer;
}
.ra-tog-box i {
	position: relative; display: block; width: 22px; height: 22px; border-radius: 7px;
	border: 1.5px solid rgba(196, 181, 253, .45);
	background: #0d0a16;
	box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
	transition: background .2s, border-color .2s, box-shadow .2s;
}
.ra-tog-box i::after {
	content: ""; position: absolute; left: 7px; top: 3px;
	width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0;
	transform: rotate(45deg) scale(.6); opacity: 0;
	transition: opacity .15s, transform .15s;
}
.ra-tog-box input:checked + i {
	border-color: transparent;
	background: linear-gradient(145deg, #a855f7, #6d28d9);
	box-shadow: 0 0 12px rgba(168, 85, 247, .45);
}
.ra-tog-box input:checked + i::after { opacity: 1; transform: rotate(45deg) scale(1); }
.ra-tog-text { color: var(--txt); font-size: 14px; font-weight: 700; }
.ra-tog-text em { color: var(--dim); font-style: normal; font-weight: 600; }

.ra-duration-row {
	display: grid; grid-template-columns: 1fr 1.2fr; gap: 8px; align-items: start;
	margin-bottom: 10px;
}
.ra-unit { margin-bottom: 0; }
.ra-unit button { flex: 1 1 40%; }

.ra-shares { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ra-share-row {
	display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: center;
}
.ra-share-row span {
	color: var(--dim); font-size: 12px; font-weight: 700;
}
.ra-shares-sum {
	margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--dim);
}
.ra-shares-sum.ok { color: var(--ok); }
.ra-shares-sum.bad { color: var(--bad); }

.settings-card { max-width: 400px; }
.set-block {
	padding: 14px 0;
	border-bottom: 1px solid var(--line);
}
.set-block:last-of-type { border-bottom: 0; }
.set-block + .set-block { margin-top: 8px; padding-top: 20px; }
.set-label { display: block; color: var(--dim); font-size: 12px; font-weight: 700; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.set-input {
	width: 100%; border: 1px solid var(--line); background: #0d0a16; color: var(--txt);
	border-radius: 12px; padding: 12px 14px; font-size: 15px; outline: none;
}
.set-input:focus { border-color: var(--acc); }
.set-btn {
	width: 100%; margin-top: 10px; border: 0; border-radius: 12px; padding: 12px;
	background: linear-gradient(135deg, var(--acc2), var(--acc)); color: #fff; font-weight: 700;
}
.set-close { width: 100%; margin-top: 16px; margin-left: 0; }
.toast {
	position: fixed; left: 50%; bottom: 108px; z-index: 90;
	transform: translateX(-50%) translateY(12px);
	min-width: 180px; max-width: calc(100% - 40px);
	padding: 12px 18px; border-radius: 14px; text-align: center;
	font-weight: 700; font-size: 14px; color: #fff;
	background: linear-gradient(135deg, #5b21b6, #a855f7);
	border: 1px solid rgba(255,255,255,.16);
	box-shadow: 0 12px 28px rgba(0,0,0,.35);
	opacity: 0; pointer-events: none;
	transition: opacity .28s ease, transform .28s ease;
}
.toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}
.toast[hidden] { display: none !important; }

[hidden] { display: none !important; }
