/* --- ROOT & GENERAL --- */
:root {
	--safe-top: env(safe-area-inset-top, 0px);
	--safe-bottom: env(safe-area-inset-bottom, 0px);
	--global-margin: 10px;
	--primary-glow: #667eea;
}
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}
::-webkit-scrollbar {
	display: none;
}
body {
	overflow: hidden;
	background: #0a0a0f;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	color: #fff;
	touch-action: none;
	position: fixed;
	width: 100%;
	height: 100%;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

/* --- CANVAS & UI LAYERS --- */
canvas {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
}
#effectsCanvas {
	z-index: 2;
	pointer-events: none;
}
.ui-container {
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 10;
}

/* --- HEADER & METERS --- */
.header {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	padding-top: var(--safe-top);
}
.header-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	padding: 0 var(--global-margin);
	margin-top: var(--global-margin);
}
.user-profile-area {
	display: flex;
	flex-direction: column;
	align-items: center;
	pointer-events: all;
	cursor: pointer;
}
.user-avatar-container {
	width: 52px;
	height: 52px;
	margin-bottom: 5px;
}
.user-avatar {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: linear-gradient(135deg, #667eea, #764ba2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	border: 2px solid rgba(255, 255, 255, 0.2);
}
.user-points {
	font-size: 13px;
	color: #a0a0b0;
}
.meters-container {
	display: flex;
	align-items: center;
	gap: 10px;
}
.circular-meter {
	width: 52px;
	height: 52px;
	position: relative;
}
.circular-meter svg {
	width: 100%;
	height: 100%;
	transform: rotate(-90deg);
}
.circular-meter-bg {
	fill: none;
	stroke: rgba(255, 255, 255, 0.1);
	stroke-width: 4;
}
.circular-meter-progress {
	fill: none;
	stroke-width: 4;
	stroke-linecap: round;
	transition: stroke-dasharray 0.1s linear, opacity 0.2s ease;
}
#chargeProgress { stroke: #00f2fe; }
#sharpnessProgress { stroke: #2ecc71; }
#quotaProgress { stroke: #ffd700; }
#hueRing { stroke-width: 4; }
.circular-meter-text {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	line-height: 1;
}
.circular-meter-value {
	font-size: 14px;
	font-weight: 700;
}
.circular-meter-icon {
	font-size: 18px;
}

/* --- BOTTOM UI & JOYSTICK --- */
.bottom-ui-container {
	position: absolute;
	bottom: calc(var(--safe-bottom) + 10px);
	left: 50%;
	transform: translateX(-50%);
	pointer-events: all;
}
.joystick {
	width: 80px;
	height: 80px;
	position: relative;
}
.joystick-outer {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background-color: #0a0a0a;
	box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.6), 0 3px 10px rgba(0, 0, 0, 0.5);
	border: 0.9375vw solid #1a1a1f;
}
.joystick-inner {
	width: 50px;
	height: 50px;
	border-radius: 50%;
	background-image: radial-gradient(circle at 35% 35%, #535490, #000000);
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transition: transform 0.1s ease-out;
}
.charm-collector {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	font-size: 24px;
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	position: absolute;
	bottom: 0;
	right: -54px;
}

/* --- DYNAMIC INDICATORS (BOTTOM) --- */
.bottom-indicators {
	position: fixed;
	bottom: calc(var(--safe-bottom) + 10px);
	left: var(--global-margin);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 3px;
	pointer-events: none;
}
.indicator {
	background: rgba(10, 10, 15, 0.7);
	backdrop-filter: blur(5px);
	padding: 4px 8px;
	border-radius: 6px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	font-size: 12px;
	color: #a0a0b0;
	transition: opacity 0.3s ease, transform 0.3s ease;
	white-space: nowrap;
}
.indicator-label {
	font-weight: 500;
}
.indicator-value {
	color: #fff;
	font-weight: 600;
	margin-left: 6px;
	min-width: 40px;
	display: inline-block;
	text-align: right;
}

/* --- MODALS & DRAWERS --- */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.6);
	z-index: 100;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}
.modal-overlay.active {
	opacity: 1;
	pointer-events: all;
}
.modal-card {
	position: fixed;
	left: 50%;
	top: 50%;
	background: rgba(30, 30, 40, 0.85);
	backdrop-filter: blur(10px);
	padding: 30px;
	border-radius: 20px;
	text-align: center;
	border: 1px solid rgba(255,255,255,0.1);
	width: 90%;
	max-width: 380px;
	z-index: 200;
	opacity: 0;
	transition: opacity 0.3s ease, transform 0.3s ease;
	transform: translate(-50%, -45%);
}
.modal-overlay.active .modal-card {
	opacity: 1;
	transform: translate(-50%, -50%);
}
.modal-card h2 { margin-bottom: 10px; }
.modal-card p { margin-bottom: 20px; color: #a0a0b0; }
.stats-summary { text-align: left; margin-top: 20px; }
.stat-line {
	display: flex;
	justify-content: space-between;
	padding: 8px 0;
	border-bottom: 1px solid rgba(255,255,255,0.1);
}
.stat-line:last-child { border-bottom: none; }
.action-btn {
	width: 100%;
	height: 45px;
	background: var(--primary-glow);
	border: none;
	border-radius: 10px;
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	margin-top: 20px;
	transition: background-color 0.2s;
}
.action-btn:disabled {
	background-color: #555;
	cursor: not-allowed;
	opacity: 0.6;
}



/* ... [All CSS up to the drawer section is identical to the previous version] ... */

/* --- MODALS & DRAWERS --- */
/* ... [Modal styles are identical] ... */
.drawer {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: #0D1117; /* Deeper, solid background */
	border-radius: 20px 20px 0 0;
	border-top: 1px solid #30363D;
	z-index: 101;
	transform: translateY(100%);
	transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
	pointer-events: all;
	max-height: 90vh;
	display: flex; /* CRITICAL for scrolling */
	flex-direction: column; /* CRITICAL for scrolling */
}
.drawer.active {
	transform: translateY(0);
}

/* --- DRAWER CONTENT (RE-ENGINEERED & POLISHED) --- */
.drawer-handle {
	flex-shrink: 0;
	width: 40px;
	height: 5px;
	background: #30363D;
	border-radius: 2.5px;
	margin: 10px auto;
	cursor: pointer;
}
.drawer-content {
	overflow-y: auto; /* CRITICAL for scrolling */
	padding: 0 15px 20px 15px;
}
.drawer-card {
	background-color: #161B22;
	border: 1px solid #30363D;
	border-radius: 12px;
	padding: 20px;
	margin-bottom: 15px;
}
.drawer-card h2 {
	font-size: 16px;
	font-weight: 600;
	margin: -5px 0 20px 0;
	color: #c9d1d9;
}
.purchase-item, .settings-item {
	margin-bottom: 20px;
}
.purchase-item:last-child, .settings-item:last-child {
	margin-bottom: 0;
}
.purchase-item label, .settings-item label {
	display: block;
	font-size: 14px;
	color: #8b949e;
	margin-bottom: 12px;
}
.purchase-summary {
	font-size: 13px;
	text-align: center;
	margin-top: 12px;
	color: #8b949e;
	height: 1.2em;
	transition: color 0.2s ease;
}
.purchase-error {
	color: #F85149 !important;
	font-weight: 600;
}

/* --- "LIGHTSABRE" SLIDER --- */
input[type="range"] {
	-webkit-appearance: none;
	width: 100%;
	height: 6px;
	background: #010409;
	border-radius: 3px;
	outline: none;
	border: 1px solid #30363D;
}
input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 22px;
	height: 22px;
	background: #f0f6fc;
	border-radius: 50%;
	border: 2px solid var(--primary-glow);
	cursor: pointer;
	box-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--primary-glow);
	margin-top: -9px; /* Vertically center thumb on track */
}

/* --- UI FEEDBACK ANIMATION --- */
@keyframes shake {
	10%, 90% { transform: translateX(-1px); }
	20%, 80% { transform: translateX(2px); }
	30%, 50%, 70% { transform: translateX(-4px); }
	40%, 60% { transform: translateX(4px); }
}
.shake {
	animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
}