:root {
	--bg: #0f1419;
	--surface: #1a222d;
	--surface-2: #242e3c;
	--border: #2f3d4f;
	--text: #e8edf4;
	--text-muted: #8b9cb3;
	--accent: #f0a020;
	--accent-dim: #c47f12;
	--win: #34d399;
	--lose: #f87171;
	--radius: 12px;
	--space-xs: 4px;
	--space-sm: 8px;
	--space-md: 16px;
	--space-lg: 24px;
	--space-xl: 32px;
	--font-display: Georgia, 'Times New Roman', serif;
	--font-body: 'Segoe UI', system-ui, sans-serif;
	--tab-bar-h: 52px;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

[hidden] { display: none !important; }

html, body {
	height: 100%;
	margin: 0;
}

body {
	font-family: var(--font-body);
	font-size: 15px;
	line-height: 1.5;
	color: var(--text);
	background:
		radial-gradient(ellipse 80% 50% at 50% -20%, rgba(240, 160, 32, 0.12), transparent),
		var(--bg);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
	overflow: hidden;
}

h1, h2 {
	font-family: var(--font-display);
	font-weight: 700;
	margin: 0;
}

h1 {
	font-size: 28px;
	letter-spacing: -0.02em;
}

h2 {
	font-size: 20px;
	margin-bottom: var(--space-md);
}

/* ── HUD ────────────────────────────────────────── */
.hud {
	display: grid;
	grid-template-columns: 1fr auto auto;
	gap: var(--space-sm) var(--space-lg);
	align-items: center;
	padding: var(--space-md) var(--space-lg);
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
}

.hud__tagline {
	margin: 2px 0 0;
	font-size: 12px;
	color: var(--text-muted);
}

.hud__balance {
	text-align: right;
}

.hud__label {
	display: block;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--text-muted);
}

.hud__amount {
	font-family: var(--font-display);
	font-size: 28px;
	color: var(--accent);
}

.hud__timers {
	display: flex;
	gap: var(--space-sm);
}

.timer {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: var(--space-xs) var(--space-sm);
	background: var(--surface-2);
	border-radius: 8px;
	min-width: 60px;
}

.timer__label {
	font-size: 11px;
	color: var(--accent);
	font-weight: 600;
}

.timer__countdown {
	font-variant-numeric: tabular-nums;
	font-size: 13px;
	color: var(--text-muted);
}

.hud__boost {
	grid-column: 1 / -1;
	padding: var(--space-xs) var(--space-md);
	background: rgba(240, 160, 32, 0.12);
	border: 1px solid rgba(240, 160, 32, 0.3);
	border-radius: 8px;
	font-size: 13px;
}

.hud__boost-label {
	color: var(--accent);
	font-weight: 600;
	margin-right: var(--space-sm);
}

/* ── TAB CONTENT ─────────────────────────────────── */
.tab-content {
	flex: 1;
	overflow: hidden;
	position: relative;
	display: flex;
	flex-direction: column;
}

.tab-panel {
	padding: var(--space-lg);
	min-height: 100%;
	overflow-y: auto;
}

/* ── CARDS TAB ───────────────────────────────────── */
.cards-row {
	display: flex;
	flex-direction: row;
	align-items: flex-end;
	gap: var(--space-md);
	flex-wrap: nowrap;
	padding-bottom: var(--space-sm);
}

#tab-cards {
	display: flex;
	align-items: flex-end;
	min-height: 100%;
}

.card-option {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-xs);
	padding: var(--space-sm);
	background: var(--surface-2);
	border: 2px solid var(--border);
	border-radius: var(--radius);
	cursor: pointer;
	color: var(--text);
	font-family: inherit;
	transition: border-color 0.15s, transform 0.15s;
	width: 90px;
	flex-shrink: 0;
}

.card-option:hover:not(:disabled) {
	border-color: var(--accent);
	transform: translateY(-4px);
}

.card-option:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.card-option__visual {
	width: 100%;
	aspect-ratio: 3 / 4;
	border-radius: 6px;
	background: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.card-option__img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.card-option__name {
	font-weight: 600;
	font-size: 11px;
	text-align: center;
}

.card-option__cost {
	font-size: 11px;
	color: var(--accent);
}

.card-option__jackpot {
	font-size: 10px;
	color: var(--text-muted);
}

/* ── INVENTORY TAB ───────────────────────────────── */
.inventory-panel {
	max-width: 480px;
}

.inventory-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.inventory-list li {
	display: flex;
	justify-content: space-between;
	padding: var(--space-sm) 0;
	border-bottom: 1px solid var(--border);
	font-size: 14px;
}

.inventory-list li:last-child {
	border-bottom: none;
}

/* ── SHOP TAB ────────────────────────────────────── */
#tab-shop:not([hidden]) {
	display: flex;
	padding: 0;
	gap: 0;
	flex: 1;
	overflow: hidden;
	min-height: 100%;
}

.shopkeeper-col {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	gap: var(--space-xs);
	padding: var(--space-lg) var(--space-lg) var(--space-lg);
	flex-shrink: 0;
	width: 280px;
}

.shopkeeper-name {
	font-family: var(--font-display);
	font-size: 20px;
	font-weight: 700;
	color: var(--accent);
	letter-spacing: 0.04em;
}

.shopkeeper-img {
	width: 100%;
	max-height: 500px;
	object-fit: contain;
	object-position: bottom;
	animation: bob 3s ease-in-out infinite;
	filter: drop-shadow(0 8px 32px rgba(0,0,0,0.7));
}

@keyframes bob {
	0%, 100% { transform: translateY(0px); }
	50%       { transform: translateY(-10px); }
}

.shop-panel {
	flex: 1;
	min-width: 0;
	border-radius: 0;
	border: none;
	border-left: 1px solid var(--border);
	overflow-y: auto;
	height: 100%;
	padding: var(--space-lg);
}

.shop-panel__header {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: var(--space-md);
}

.shop-panel__header h2 {
	margin-bottom: 0;
}

.shop-rotation {
	font-size: 12px;
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
}

.shop-items {
	display: flex;
	flex-direction: column;
	gap: var(--space-sm);
}

.shop-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: var(--space-md);
	padding: var(--space-md);
	background: var(--surface-2);
	border-radius: 8px;
}

.shop-item__info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.shop-item__name {
	font-weight: 600;
	font-size: 14px;
}

.shop-item__desc {
	font-size: 12px;
	color: var(--text-muted);
}

/* ── SCRATCH OVERLAY ────────────────────────────── */
.scratch-overlay {
	position: fixed;
	inset: 0;
	bottom: var(--tab-bar-h);
	background: rgba(15, 20, 25, 0.92);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 200;
	padding: var(--space-lg);
}

.scratch-overlay__inner {
	width: 100%;
	max-width: 480px;
}

.scratch-panel__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: var(--space-lg);
}

.scratch-panel__header h2 {
	margin-bottom: 0;
}

.scratch-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--space-sm);
	max-width: 360px;
	margin: 0 auto var(--space-md);
}

.scratch-cell {
	aspect-ratio: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font-display);
	font-size: clamp(12px, 3vw, 18px);
	font-weight: 700;
	background: linear-gradient(135deg, #4a5568, #2d3748);
	border: 2px solid var(--border);
	border-radius: 8px;
	color: var(--text-muted);
	cursor: pointer;
	transition: background 0.2s, color 0.2s;
}

.scratch-cell:hover:not(:disabled) {
	background: linear-gradient(135deg, #5a6578, #3d4758);
	color: var(--text);
}

.scratch-cell--revealed {
	background: var(--surface);
	color: var(--accent);
	cursor: default;
}

.scratch-cell--muted {
	color: var(--text-muted);
	opacity: 0.6;
}

.scratch-hint {
	text-align: center;
	font-size: 13px;
	color: var(--text-muted);
	margin: 0;
}

.scratch-result {
	margin-top: var(--space-lg);
	padding: var(--space-md);
	border-radius: 8px;
	text-align: center;
	font-weight: 600;
}

.scratch-result--win {
	background: rgba(52, 211, 153, 0.15);
	color: var(--win);
	border: 1px solid rgba(52, 211, 153, 0.3);
}

.scratch-result--lose {
	background: rgba(248, 113, 113, 0.1);
	color: var(--lose);
	border: 1px solid rgba(248, 113, 113, 0.25);
}

/* ── PANEL ───────────────────────────────────────── */
.panel {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: var(--space-lg);
}

/* ── TAB BAR ─────────────────────────────────────── */
.tab-bar {
	display: flex;
	height: var(--tab-bar-h);
	border-top: 1px solid var(--border);
	background: var(--surface);
	flex-shrink: 0;
}

.tab-bar__btn {
	flex: 1;
	background: transparent;
	border: none;
	color: var(--text-muted);
	font-family: var(--font-body);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: color 0.15s, background 0.15s;
	letter-spacing: 0.02em;
	border-right: 1px solid var(--border);
}

.tab-bar__btn:last-child {
	border-right: none;
}

.tab-bar__btn:hover {
	color: var(--text);
	background: var(--surface-2);
}

.tab-bar__btn--active {
	color: var(--accent);
	background: var(--surface-2);
	border-top: 2px solid var(--accent);
}

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.15s, opacity 0.15s;
}

.btn--ghost {
	background: transparent;
	color: var(--text-muted);
	padding: var(--space-sm) var(--space-md);
}

.btn--ghost:hover {
	color: var(--text);
}

.btn--buy {
	padding: var(--space-sm) var(--space-md);
	background: var(--accent);
	color: var(--bg);
	white-space: nowrap;
}

.btn--buy:hover:not(:disabled) {
	background: var(--accent-dim);
}

.btn--buy:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 600px) {
	.hud {
		grid-template-columns: 1fr 1fr;
	}
	.hud__brand {
		grid-column: 1 / -1;
	}
	.hud__balance {
		text-align: left;
	}
	.shop-tab {
		flex-direction: column;
		align-items: center;
	}
	.shopkeeper-img {
		width: 120px;
	}
}
