:root {
	color-scheme: dark;
	font-family:
		Inter,
		ui-sans-serif,
		system-ui,
		-apple-system,
		BlinkMacSystemFont,
		'Segoe UI',
		sans-serif;
	--gold: #ffd85a;
	--gold-strong: #ffbe35;
	--ink: #17090f;
	--wine: #681226;
	--green: #0f6045;
	--panel: rgba(8, 28, 24, 0.86);
	--panel-border: rgba(255, 216, 90, 0.3);
	background: #13070d;
	color: #fff7db;
}

html {
	min-height: 100%;
}

* {
	box-sizing: border-box;
}

body {
	display: flex;
	margin: 0;
	min-height: 100dvh;
	background:
		linear-gradient(
			180deg,
			rgba(255, 216, 90, 0.12) 0,
			rgba(255, 216, 90, 0) 132px
		),
		linear-gradient(
			145deg,
			#220814 0%,
			#681226 42%,
			#0e4b38 78%,
			#07080b 100%
		);
}

button {
	border: 0;
	font: inherit;
	cursor: pointer;
}

.app {
	display: flex;
	width: min(100%, 460px);
	min-height: 100dvh;
	flex-direction: column;
	margin: 0 auto;
	padding: 14px 12px 16px;
	align-items: stretch;
}

.view {
	animation: view-in 0.16s ease-out;
}

.topbar,
.section-title,
.hero,
.view-tabs,
.period-tabs,
.mode-switch {
	display: flex;
	align-items: center;
	gap: 10px;
}

.topbar,
.section-title,
.hero {
	justify-content: space-between;
}

.topbar {
	padding: 5px 2px 2px;
}

.brand {
	display: flex;
	align-items: center;
	min-width: 0;
	gap: 10px;
}

.brand-mark {
	display: grid;
	width: 42px;
	height: 42px;
	place-items: center;
	border: 2px solid var(--gold);
	border-radius: 50%;
	background: linear-gradient(145deg, #de2240, #841128);
	color: #fff16d;
	font-size: 14px;
	font-weight: 950;
	box-shadow:
		0 10px 22px rgba(0, 0, 0, 0.26),
		inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-name {
	overflow: hidden;
	color: #fff;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 21px;
	font-weight: 950;
	text-shadow: 0 2px 12px rgba(0, 0, 0, 0.36);
}

.muted {
	margin: 0;
	color: #f3d59d;
	font-size: 13px;
}

h2 {
	margin: 0;
	font-size: 18px;
	letter-spacing: 0;
}

.icon-button {
	width: 38px;
	height: 38px;
	border: 1px solid rgba(255, 214, 77, 0.58);
	border-radius: 50%;
	background: #0d3528;
	color: #ffd64d;
	font-size: 16px;
	font-weight: 950;
	text-align: center;
}

.view-tabs {
	position: sticky;
	top: 0;
	z-index: 2;
	margin-top: 13px;
	padding: 4px;
	border: 1px solid var(--panel-border);
	border-radius: 8px;
	background:
		linear-gradient(
			180deg,
			rgba(255, 255, 255, 0.07),
			rgba(255, 255, 255, 0.02)
		),
		rgba(9, 7, 12, 0.9);
	backdrop-filter: blur(14px);
	box-shadow:
		0 14px 32px rgba(0, 0, 0, 0.28),
		inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.view-tab,
.period-tab,
.mode {
	min-height: 42px;
	border-radius: 7px;
	color: #fff7db;
	font-weight: 900;
	transition:
		transform 0.14s ease,
		background 0.14s ease,
		box-shadow 0.14s ease;
}

.view-tab {
	flex: 1;
	background: transparent;
}

.view-tab:active,
.period-tab:active,
.mode:active {
	transform: translateY(1px);
}

.view-tab.active {
	background: linear-gradient(180deg, #fff087, var(--gold-strong));
	color: #23050b;
	box-shadow:
		inset 0 -3px 0 rgba(125, 37, 5, 0.24),
		0 6px 15px rgba(255, 190, 53, 0.16);
}

.view {
	display: none;
}

.view.active {
	display: flex;
	flex: 1;
	flex-direction: column;
}

.mode-switch {
	display: grid;
	grid-template-columns: 1fr 1fr;
	margin-top: 13px;
	padding: 5px;
	border: 1px solid var(--panel-border);
	border-radius: 8px;
	background:
		linear-gradient(
			180deg,
			rgba(255, 255, 255, 0.06),
			rgba(255, 255, 255, 0.02)
		),
		rgba(38, 7, 19, 0.82);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.mode {
	position: relative;
	padding: 11px 8px;
	border: 2px solid transparent;
	background: rgba(255, 255, 255, 0.08);
}

.mode[data-mode='street_dice'] {
	background: linear-gradient(
		180deg,
		rgba(28, 112, 78, 0.86),
		rgba(10, 58, 43, 0.88)
	);
}

.mode[data-mode='slot'] {
	background: linear-gradient(
		180deg,
		rgba(131, 22, 43, 0.86),
		rgba(67, 10, 28, 0.9)
	);
}

.mode span,
.mode small {
	display: block;
}

.mode small {
	margin-top: 2px;
	color: #e7c790;
	font-size: 11px;
	font-weight: 800;
}

.mode.active {
	border-color: #fff5a7;
	background: linear-gradient(180deg, #fff08a, var(--gold-strong));
	color: #21040a;
	box-shadow:
		0 0 0 2px rgba(255, 216, 90, 0.18),
		0 10px 20px rgba(0, 0, 0, 0.22);
}

.mode.active::after {
	content: '✓';
	position: absolute;
	top: 6px;
	right: 8px;
	display: grid;
	width: 20px;
	height: 20px;
	place-items: center;
	border-radius: 50%;
	background: #0f5c3d;
	color: #fff;
	font-size: 13px;
}

.mode.active small {
	color: #5a1600;
}

.rules-chip {
	width: 42px;
	min-height: 42px;
	border: 1px solid rgba(255, 216, 90, 0.38);
	border-radius: 8px;
	background: rgba(10, 7, 12, 0.62);
	color: var(--gold);
	font-weight: 900;
}

.mode-title {
	display: flex;
	align-items: center;
	gap: 10px;
}

.mode-title .rules-chip {
	width: 34px;
	min-height: 34px;
	border-color: rgba(83, 17, 22, 0.22);
	background: rgba(255, 255, 255, 0.5);
	color: #531116;
}

.panel {
	margin-top: 12px;
	padding: 15px;
	border: 1px solid var(--panel-border);
	border-radius: 8px;
	background:
		linear-gradient(
			180deg,
			rgba(255, 255, 255, 0.06),
			rgba(255, 255, 255, 0)
		),
		linear-gradient(180deg, rgba(16, 83, 55, 0.94), rgba(7, 36, 31, 0.96)),
		#123b2b;
	box-shadow:
		0 18px 38px rgba(0, 0, 0, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hero {
	align-items: stretch;
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 12px;
	color: #24050b;
}

body[data-mode='street_dice'] .hero {
	background:
		linear-gradient(135deg, #fff08a 0%, #78d87c 46%, #147a55 100%), #147a55;
}

body[data-mode='slot'] .hero {
	background:
		linear-gradient(135deg, #fff08a 0%, #ff9a38 42%, #a80d2c 100%), #a80d2c;
}

.hero .muted {
	color: #531116;
	font-weight: 850;
}

#currentModeLabel {
	display: block;
	margin-top: 4px;
	font-size: 31px;
	line-height: 1;
}

.attempt-box {
	min-width: 92px;
	padding: 9px 11px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.48);
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34);
	text-align: center;
}

#attemptsLeft {
	display: block;
	margin-top: 2px;
	font-size: 34px;
	font-weight: 950;
	line-height: 1;
}

#playButton {
	grid-column: 1 / -1;
	min-height: 54px;
	border: 2px solid rgba(255, 255, 255, 0.58);
	border-radius: 8px;
	background: linear-gradient(180deg, #fffbd1, #ffc13d 54%, #cf1b3b);
	color: #25050b;
	font-size: 18px;
	font-weight: 950;
	box-shadow:
		0 7px 0 rgba(91, 7, 22, 0.8),
		0 15px 24px rgba(91, 7, 22, 0.22);
}

#playButton:disabled {
	cursor: not-allowed;
	opacity: 0.72;
}

#playButton:active {
	transform: translateY(2px);
	box-shadow: 0 5px 0 rgba(91, 7, 22, 0.8);
}

.play-unavailable {
	grid-column: 1 / -1;
	margin: 0;
	padding: 10px 12px;
	border: 1px solid rgba(83, 17, 22, 0.18);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.42);
	color: #531116;
	font-size: 13px;
	font-weight: 900;
}

.game-notice {
	grid-column: 1 / -1;
	margin: 0;
	padding: 10px 12px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.34);
	color: #3d0b12;
	font-size: 13px;
	font-weight: 900;
}

.result {
	position: relative;
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
	overflow: hidden;
	border-color: rgba(255, 216, 90, 0.58);
}

.result > * {
	transition:
		filter 0.18s ease,
		opacity 0.18s ease,
		transform 0.18s ease;
}

.result.loading > * {
	filter: blur(2px);
	opacity: 0.34;
	transform: scale(0.985);
}

.result.loading::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 1;
	background:
		linear-gradient(
			90deg,
			transparent,
			rgba(255, 216, 90, 0.12),
			transparent
		),
		rgba(5, 18, 16, 0.42);
	animation: result-sweep 1.2s ease-in-out infinite;
}

.result.loading::after {
	content: 'Бросаем...';
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 2;
	padding: 9px 14px;
	border: 1px solid rgba(255, 216, 90, 0.42);
	border-radius: 999px;
	background: rgba(11, 36, 30, 0.92);
	box-shadow:
		0 12px 28px rgba(0, 0, 0, 0.32),
		inset 0 1px 0 rgba(255, 255, 255, 0.1);
	color: var(--gold);
	font-size: 13px;
	font-weight: 950;
	transform: translate(-50%, -50%);
	white-space: nowrap;
}

body[data-mode='street_dice'] .result {
	background:
		linear-gradient(180deg, rgba(7, 55, 38, 0.94), rgba(6, 34, 29, 0.96)),
		#06221d;
}

body[data-mode='slot'] .result {
	background:
		linear-gradient(180deg, rgba(54, 8, 28, 0.95), rgba(19, 7, 13, 0.96)),
		#13070d;
}

.ticket-panel {
	display: grid;
	gap: 14px;
}

.ticket-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.ticket-head strong {
	display: block;
	color: var(--gold);
	font-size: 42px;
	line-height: 1;
}

.ticket-badge {
	padding: 8px 10px;
	border-radius: 999px;
	background: rgba(255, 216, 90, 0.16);
	color: var(--gold);
	font-size: 12px;
	font-weight: 950;
}

.ticket-copy {
	margin: 0;
	color: #fff7db;
	font-size: 13px;
	font-weight: 750;
	line-height: 1.3;
}

.ticket-wheel {
	display: grid;
	width: min(100%, 220px);
	aspect-ratio: 1;
	place-items: center;
	justify-self: center;
	border: 10px solid var(--gold);
	border-radius: 50%;
	background: conic-gradient(
		#b31731 0deg 90deg,
		#09080c 90deg 180deg,
		#b31731 180deg 270deg,
		#09080c 270deg 360deg
	);
	box-shadow:
		inset 0 0 0 8px rgba(255, 255, 255, 0.12),
		0 16px 34px rgba(0, 0, 0, 0.34);
}

.ticket-wheel span {
	display: grid;
	width: 64px;
	height: 64px;
	place-items: center;
	border-radius: 50%;
	background: #fff7db;
	color: #25050b;
	font-size: 28px;
	font-weight: 950;
}

.ticket-wheel.spinning {
	animation: wheel-spin 0.32s linear infinite;
}

.ticket-wheel.settling {
	animation: wheel-settle 0.45s cubic-bezier(0.2, 0.85, 0.25, 1);
}

.ticket-wheel.red {
	background: radial-gradient(circle at 50% 50%, #e64761, #b31731 70%);
}

.ticket-wheel.black {
	background: radial-gradient(circle at 50% 50%, #24212a, #09080c 70%);
}

.ticket-actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 8px;
}

.ticket-choice {
	min-height: 38px;
	border: 2px solid rgba(255, 255, 255, 0.24);
	border-radius: 8px;
	color: #fff;
	font-weight: 950;
}

.ticket-choice.red {
	background: linear-gradient(180deg, #ff4965, #a80d27);
}

.ticket-choice.black {
	background: linear-gradient(180deg, #33313a, #08070a);
}

.ticket-choice:disabled {
	cursor: not-allowed;
	opacity: 0.48;
}

#ticketGameStatus {
	margin: 0;
	text-align: center;
}

.hidden {
	display: none;
}

.dice-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
	justify-content: center;
	gap: 8px;
}

.slot-row {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.die {
	display: grid;
	height: 58px;
	min-width: 0;
	place-items: center;
	border: 2px solid var(--gold);
	border-radius: 8px;
	background: linear-gradient(180deg, #fffdf3, #ffe4a0 54%, #f7bd43);
	color: #25050b;
	font-size: 23px;
	font-weight: 950;
	box-shadow: inset 0 -5px 0 rgba(129, 72, 4, 0.2);
}

.result-placeholder {
	background: linear-gradient(100deg, #fff1a8 0%, #ffd45b 45%, #fff1a8 90%);
	background-size: 220% 100%;
	animation: placeholder-shine 1s ease-in-out infinite;
}

.dice-summary {
	align-content: center;
	padding: 8px 5px;
	line-height: 1;
}

.dice-summary.point {
	border-color: #fff5a7;
	background: linear-gradient(180deg, #fff8be, #ffd64d 55%, #f0a92a);
	box-shadow:
		inset 0 -5px 0 rgba(129, 72, 4, 0.22),
		0 0 0 2px rgba(255, 245, 167, 0.2);
}

.dice-summary.win {
	border-color: #8df5be;
	background: linear-gradient(180deg, #effff2, #8ee59a 56%, #21a66c);
}

.dice-summary.lose {
	border-color: #ff8d8d;
	background: linear-gradient(180deg, #fff1e7, #ffb15f 52%, #d51d3e);
}

.die-value {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 21px;
	font-weight: 950;
}

.die-sum {
	display: none;
	color: #531116;
	font-size: 11px;
	font-weight: 950;
	text-transform: uppercase;
}

.reel {
	height: 66px;
	font-size: 28px;
}

.result-label {
	margin: 0 0 5px;
	color: #fff;
	font-size: 17px;
	font-weight: 950;
	line-height: 1.18;
}

.period-tabs {
	margin-top: 14px;
}

.period-tab {
	padding: 0 14px;
	background: rgba(255, 255, 255, 0.1);
}

.period-tab.active {
	background: linear-gradient(180deg, #fff087, var(--gold-strong));
	color: #23050b;
}

.leaderboard {
	display: grid;
	gap: 8px;
	margin: 14px 0 0;
	padding: 0;
	list-style: none;
	counter-reset: place;
}

.leaderboard li,
.history-item {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 10px;
	align-items: center;
	min-height: 50px;
	padding: 10px 12px;
	border: 1px solid rgba(255, 216, 90, 0.22);
	border-radius: 8px;
	background:
		linear-gradient(
			180deg,
			rgba(255, 255, 255, 0.06),
			rgba(255, 255, 255, 0.02)
		),
		rgba(4, 24, 19, 0.76);
}

.leaderboard li {
	counter-increment: place;
	grid-template-columns: 30px 44px minmax(0, 1fr) auto;
}

.leaderboard li::before {
	content: counter(place);
	display: grid;
	width: 28px;
	height: 28px;
	place-items: center;
	border-radius: 50%;
	background: #b31731;
	color: #fff;
	font-size: 13px;
	font-weight: 950;
}

.avatar {
	width: 42px;
	height: 42px;
	border: 2px solid rgba(255, 216, 90, 0.62);
	border-radius: 50%;
	object-fit: cover;
	background: #2a0d18;
}

.avatar-fallback {
	display: grid;
	place-items: center;
	color: var(--gold);
	font-weight: 950;
}

.leader-info,
.history-main {
	display: grid;
	min-width: 0;
	gap: 2px;
}

.leaderboard li.empty-row {
	grid-template-columns: 1fr !important;
	color: #f3d59d;
	text-align: center;
}

.leaderboard li.empty-row::before {
	display: none !important;
}

.name {
	min-width: 0;
	overflow: hidden;
	color: #fff7db;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 850;
}

.score {
	color: var(--gold);
	padding: 6px 9px;
	border-radius: 999px;
	background: rgba(255, 216, 90, 0.12);
	font-weight: 950;
}

.history {
	display: grid;
	gap: 8px;
	margin-top: 12px;
}

.history-rolls {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-top: 3px;
}

.history-rolls .die {
	width: auto;
	min-width: 52px;
	height: 36px;
	padding: 4px 6px;
	border-width: 1px;
	box-shadow: none;
}

.history-rolls .die-value {
	font-size: 13px;
}

.history-rolls .die-sum {
	font-size: 8px;
}

.disclaimer {
	margin-top: 12px;
	padding: 12px;
	border: 1px solid rgba(255, 216, 90, 0.18);
	border-radius: 8px;
	background:
		linear-gradient(
			180deg,
			rgba(255, 255, 255, 0.04),
			rgba(255, 255, 255, 0)
		),
		rgba(0, 0, 0, 0.3);
	color: #e7c790;
	font-size: 12px;
	line-height: 1.35;
	text-align: center;
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: grid;
	place-items: center;
	padding: 18px;
	background: rgba(0, 0, 0, 0.68);
}

.modal.hidden {
	display: none;
}

.modal-card {
	width: min(100%, 420px);
	padding: 16px;
	border: 1px solid rgba(255, 216, 90, 0.62);
	border-radius: 8px;
	background: linear-gradient(180deg, #240711, #103627);
	box-shadow: 0 22px 58px rgba(0, 0, 0, 0.5);
}

.modal-card .icon-button {
	background: rgba(255, 216, 90, 0.12);
	color: var(--gold);
}

.rules-text {
	display: grid;
	gap: 8px;
	margin-top: 14px;
}

.rules-text p {
	margin: 0;
	padding: 10px 12px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	color: #fff7db;
	font-weight: 750;
}

@media (max-width: 420px) {
	.brand-name {
		font-size: 20px;
	}

	.mode {
		min-height: 54px;
	}

	.hero {
		grid-template-columns: 1fr;
	}

	.attempt-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		text-align: left;
	}

	.ticket-wheel {
		width: min(100%, 180px);
	}

	#attemptsLeft {
		font-size: 30px;
	}
}

@keyframes wheel-spin {
	to {
		transform: rotate(360deg);
	}
}

@keyframes wheel-settle {
	0% {
		transform: rotate(0deg) scale(1);
	}

	55% {
		transform: rotate(22deg) scale(1.03);
	}

	100% {
		transform: rotate(0deg) scale(1);
	}
}

@keyframes view-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes result-sweep {
	0% {
		background-position:
			-140px 0,
			0 0;
	}

	100% {
		background-position:
			220px 0,
			0 0;
	}
}

@keyframes placeholder-shine {
	0% {
		background-position: 100% 0;
	}

	100% {
		background-position: -100% 0;
	}
}

@media (max-width: 360px) {
	.app {
		padding-right: 8px;
		padding-left: 8px;
	}

	.view-tab,
	.mode,
	.period-tab {
		font-size: 12px;
	}

	.view-tab {
		min-height: 38px;
		padding-right: 4px;
		padding-left: 4px;
	}

	.reel {
		font-size: 24px;
	}

	.mode-title .rules-chip {
		width: 32px;
		min-height: 32px;
	}
}
