@charset "utf-8";

:root {
	--bg:#0b0d14;
	--glass:rgba(18, 21, 32, 0.72);
	--panel:#141824;
	--line:rgba(255, 255, 255, 0.09);
	--text:#e7eaee;
	--muted:#8a929e;
	--accent:#4fd1c5;
}

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

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

body {
	background:radial-gradient(120% 90% at 50% 30%, #1a1f33 0%, var(--bg) 70%);
	color:var(--text);
	font-family:'Space Grotesk', system-ui, sans-serif;
	font-size:14px;
	-webkit-font-smoothing:antialiased;
	-webkit-user-select:none;
	user-select:none;
	-webkit-touch-callout:none;
}

.hide {
	display:none !important;
}

#scene, #scene canvas {
	position:fixed;
	inset:0;
	display:block;
	touch-action:none;
}

/* Hold and Next, placed beside the tower by script */

.side_box {
	position:fixed;
	left:0;
	top:0;
	display:flex;
	flex-direction:column;
	align-items:center;
	gap:4px;
	width:112px;
	padding:10px 12px;
	background:var(--glass);
	-webkit-backdrop-filter:blur(12px);
	backdrop-filter:blur(12px);
	border:1px solid var(--line);
	border-radius:14px;
}

.side_box.idle {
	visibility:hidden;
}

.hold_box {
	cursor:pointer;
}

.box_label {
	display:flex;
	flex-wrap:wrap;          /* "Flick Up" drops under the label on narrow phones */
	justify-content:center;
	align-items:center;
	gap:2px 6px;
	color:var(--muted);
	font-size:11px;
	text-transform:uppercase;
	letter-spacing:0.06em;
}

.box_label kbd {
	font-size:9px;
	text-transform:none;
	letter-spacing:0;
}

.stats {
	display:grid;
	grid-template-columns:auto auto;
	gap:2px 10px;
	width:100%;
	margin:6px 0 0;
	padding-top:8px;
	border-top:1px solid var(--line);
}

.stats dt {
	color:var(--muted);
	font-size:11px;
	text-transform:uppercase;
	letter-spacing:0.05em;
}

.stats dd {
	margin:0;
	text-align:right;
	font-weight:700;
	font-variant-numeric:tabular-nums;
}


/* Corner buttons */

.corner {
	position:fixed;
	top:16px;
	right:16px;
	display:flex;
	gap:8px;
	z-index:6; /* above the pause screen, so Settings and Resume are always reachable */
}

.icon {
	display:flex;
	align-items:center;
	justify-content:center;
	width:38px;
	height:38px;
	padding:0;
	background:var(--glass);
	-webkit-backdrop-filter:blur(12px);
	backdrop-filter:blur(12px);
	border:1px solid var(--line);
	border-radius:10px;
	color:var(--text);
	cursor:pointer;
}

.icon:hover {
	background:rgba(255, 255, 255, 0.1);
}

.icon svg {
	width:18px;
	height:18px;
	fill:none;
	stroke:currentColor;
	stroke-width:2;
	stroke-linecap:round;
	stroke-linejoin:round;
}

.icon svg .fill {
	fill:currentColor;
}


/* Clear popups */

.popups {
	position:fixed;
	inset:0;
	overflow:hidden;
	pointer-events:none;
}

/* Placed by script just above the piece that landed */
.popup_group {
	position:absolute;
	left:0;
	top:0;
	display:flex;
	flex-direction:column;
	align-items:center;
	gap:2px;
	white-space:nowrap;
	will-change:transform;
}

.popup {
	font-weight:700;
	font-size:22px;
	letter-spacing:0.04em;
	text-shadow:0 2px 12px rgba(0, 0, 0, 0.6);
	animation:pop 1.3s ease-out forwards;
}

.popup.clear2 { font-size:26px; color:#9fe8e0; }
.popup.clear3 { font-size:32px; color:#f6c453; }
.popup.clear4 { font-size:42px; color:#ff8a6b; text-shadow:0 0 18px rgba(255, 138, 107, 0.7), 0 2px 12px rgba(0, 0, 0, 0.6); }
.popup.b2b    { font-size:16px; color:#ff8a6b; }
.popup.chain  { font-size:18px; color:#b07cf0; }
.popup.points { font-size:15px; color:var(--muted); }
.popup.level  { font-size:20px; color:var(--accent); }
.popup.spin   { color:#d6a8ff; text-shadow:0 0 16px rgba(176, 124, 240, 0.7), 0 2px 12px rgba(0, 0, 0, 0.6); }

@keyframes pop {
	0%   { opacity:0; transform:translateY(10px) scale(0.85); }
	12%  { opacity:1; transform:translateY(0) scale(1.08); }
	22%  { transform:scale(1); }
	75%  { opacity:1; }
	100% { opacity:0; transform:translateY(-24px); }
}

@media (prefers-reduced-motion:reduce) {
	.popup { animation-name:fade; }
	@keyframes fade { 0%, 75% { opacity:1; } 100% { opacity:0; } }
}


/* Overlay */

.overlay {
	position:fixed;
	inset:0;
	z-index:5;
	display:flex;
	align-items:center;
	justify-content:center;
	padding:16px;
	background:rgba(5, 6, 10, 0.55);
	overflow:auto;
}

.card {
	width:min(100%, 380px);
	padding:24px;
	background:var(--glass);
	-webkit-backdrop-filter:blur(16px);
	backdrop-filter:blur(16px);
	border:1px solid var(--line);
	border-radius:18px;
	text-align:center;
}

.card h2 {
	margin:0 0 6px;
	font-size:26px;
	letter-spacing:0.04em;
}

.card p {
	margin:0 0 18px;
	color:var(--muted);
	line-height:1.5;
}

.card p b {
	color:var(--text);
}

.start {
	width:100%;
	height:44px;
	background:var(--accent);
	border:0;
	border-radius:11px;
	color:#08201d;
	font:700 16px 'Space Grotesk', system-ui, sans-serif;
	cursor:pointer;
}

.start:hover {
	filter:brightness(1.08);
}

.overlay_new {
	width:100%;
	margin-top:8px;
}

.scores table {
	width:100%;
	margin-top:18px;
	border-collapse:collapse;
	font-size:12px;
	font-variant-numeric:tabular-nums;
}

.scores th {
	color:var(--muted);
	font-weight:500;
	text-transform:uppercase;
	letter-spacing:0.05em;
	font-size:10px;
	padding:0 6px 4px;
}

.scores td {
	padding:3px 6px;
	border-top:1px solid var(--line);
}

.scores td:first-child {
	color:var(--muted);
}

.scores tr.new td {
	color:var(--accent);
	font-weight:700;
}

.keys {
	display:flex;
	flex-direction:column;
	gap:6px;
	margin-top:18px;
	color:var(--muted);
	font-size:12px;
	line-height:1.8;
}

kbd {
	display:inline-block;
	min-width:22px;
	margin:0 2px;
	padding:1px 6px;
	border:1px solid var(--line);
	border-bottom-width:2px;
	border-radius:5px;
	background:rgba(255, 255, 255, 0.05);
	color:var(--text);
	font:500 11px 'Space Grotesk', system-ui, sans-serif;
	line-height:1.5;
}

.touch_keys {
	display:none;
}

@media (pointer:coarse) {
	.touch_keys { display:block; }
}


/* Settings drawer */

.settings {
	position:fixed;
	top:0;
	right:0;
	bottom:0;
	width:min(100%, 340px);
	display:flex;
	flex-direction:column;
	background:var(--panel);
	border-left:1px solid var(--line);
	box-shadow:-20px 0 40px rgba(0, 0, 0, 0.4);
	z-index:10;
}

.settings_head, .settings_foot {
	display:flex;
	align-items:center;
	gap:8px;
	padding:14px 16px;
}

.settings_head {
	justify-content:space-between;
	border-bottom:1px solid var(--line);
}

.settings_head h2 {
	margin:0;
	font-size:17px;
}

.settings_foot {
	border-top:1px solid var(--line);
}

.settings_body {
	flex:1;
	overflow:auto;
	padding:4px 16px 16px;
	scrollbar-gutter:stable;
}

/* A plain fixed-width bar on the drawer's own color: no arrows, no shrinking overlay */
.settings_body::-webkit-scrollbar {
	width:18px;
}

.settings_body::-webkit-scrollbar-track {
	margin:6px 0;
	background:var(--panel);
}

/* Transparent borders inset the 9px thumb, leaving 6px clear of the drawer's right edge */
.settings_body::-webkit-scrollbar-thumb {
	background:rgba(255, 255, 255, 0.14) padding-box;
	border:solid transparent;
	border-width:0 6px 0 3px;
	/* Per-side radii so the visible 9px pill gets an even 4.5px curve despite the uneven borders */
	border-radius:7.5px 10.5px 10.5px 7.5px / 4.5px;
}

.settings_body::-webkit-scrollbar-thumb:hover {
	background-color:rgba(255, 255, 255, 0.26);
}

.settings_body::-webkit-scrollbar-button {
	display:none;
}

/* Firefox only (Chrome would let these override the rules above and bring its arrows back) */
@supports (-moz-appearance:none) {
	.settings_body {
		scrollbar-color:rgba(255, 255, 255, 0.18) var(--panel);
	}
}

/* Each section is a softly tinted card in its own pastel, carried into its heading, sliders and toggles */
.settings_body section {
	--hue:#aab4c4;
	margin-top:12px;
	padding:10px 14px 12px;
	background:color-mix(in srgb, var(--hue) 6%, transparent);
	border-left:3px solid color-mix(in srgb, var(--hue) 70%, transparent);
	border-radius:10px;
	/* Hairline top, right and bottom as offset shadows, so they taper into the left bar instead of butting against it.
	   Mixed with the drawer's color rather than transparent: the two overlap on the right, and an opaque color doesn't double up. */
	box-shadow:
		1px 1px color-mix(in srgb, var(--hue) 32%, var(--panel)),
		1px -1px color-mix(in srgb, var(--hue) 32%, var(--panel));
}

.settings_body .sec_board_setup { --hue:#8fe3c8; }
.settings_body .sec_gameplay    { --hue:#f2e08f; }
.settings_body .sec_view     { --hue:#9cc8ff; }
.settings_body .sec_handling { --hue:#c6b0ff; }
.settings_body .sec_sound    { --hue:#ffc59e; }
.settings_body .sec_keys     { --hue:#ffadc8; }

.settings_body h3 {
	margin:4px 0 8px;
	color:var(--hue);
	font-size:11px;
	text-transform:uppercase;
	letter-spacing:0.08em;
}

.settings_body .hint {
	margin:-4px 0 8px;
	color:var(--muted);
	font-size:12px;
}

.setting {
	display:grid;
	grid-template-columns:1fr auto;
	align-items:center;
	gap:2px 10px;
	padding:6px 0;
	font-size:13px;
}

.setting b {
	font-weight:500;
	font-variant-numeric:tabular-nums;
	color:var(--text);
}

.setting input[type="range"] {
	grid-column:1 / -1;
}

.setting .note {
	grid-column:1 / -1;
	color:var(--muted);
	font-size:11px;
	line-height:1.4;
}

.tag {
	margin-left:4px;
	padding:1px 5px;
	border-radius:4px;
	background:rgba(255, 255, 255, 0.06);
	color:var(--muted);
	font-size:10px;
	font-style:normal;
}

.setting.toggle {
	cursor:pointer;
}

.setting.toggle input {
	accent-color:var(--hue, var(--accent));
	width:16px;
	height:16px;
	margin:0;
}

.segmented {
	display:flex;
	padding:3px;
	background:rgba(0, 0, 0, 0.3);
	border-radius:9px;
}

.segmented button {
	padding:5px 12px;
	background:none;
	border:0;
	border-radius:7px;
	color:var(--muted);
	font:500 13px 'Space Grotesk', system-ui, sans-serif;
	cursor:pointer;
}

.segmented button.active {
	background:rgba(255, 255, 255, 0.1);
	color:var(--text);
}

.key_btn {
	min-width:96px;
	height:30px;
	padding:0 10px;
	background:rgba(255, 255, 255, 0.05);
	border:1px solid var(--line);
	border-bottom-width:2px;
	border-radius:7px;
	color:var(--text);
	font:500 12px 'Space Grotesk', system-ui, sans-serif;
	cursor:pointer;
}

.key_btn.listening {
	border-color:var(--hue, var(--accent));
	color:var(--hue, var(--accent));
}

.text_btn {
	flex:1;
	height:34px;
	padding:0 12px;
	background:rgba(255, 255, 255, 0.05);
	border:1px solid var(--line);
	border-radius:9px;
	color:var(--text);
	font:500 13px 'Space Grotesk', system-ui, sans-serif;
	cursor:pointer;
}

.text_btn:hover {
	background:rgba(255, 255, 255, 0.1);
}

.reset_keys {
	width:100%;
	margin-top:8px;
}

input[type="range"] {
	-webkit-appearance:none;
	appearance:none;
	width:100%;
	height:22px;
	margin:0;
	background:transparent;
	cursor:pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
	height:4px;
	border-radius:2px;
	background:rgba(255, 255, 255, 0.14);
}

input[type="range"]::-moz-range-track {
	height:4px;
	border-radius:2px;
	background:rgba(255, 255, 255, 0.14);
}

/* Below a raised minimum the track turns dotted (the thumb stops at its end).
   The thumb's center travels from 8px to 100% - 8px, so --lock (0-1) maps onto that span. */
input[type="range"].locked::-webkit-slider-runnable-track {
	background:
		linear-gradient(rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14)) right / calc(100% - 8px - (100% - 16px) * var(--lock)) 100% no-repeat,
		repeating-linear-gradient(to right, rgba(255, 255, 255, 0.2) 0 2px, transparent 2px 5px) left / calc(8px + (100% - 16px) * var(--lock)) 100% no-repeat;
}

input[type="range"].locked::-moz-range-track {
	background:
		linear-gradient(rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14)) right / calc(100% - 8px - (100% - 16px) * var(--lock)) 100% no-repeat,
		repeating-linear-gradient(to right, rgba(255, 255, 255, 0.2) 0 2px, transparent 2px 5px) left / calc(8px + (100% - 16px) * var(--lock)) 100% no-repeat;
}

input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance:none;
	appearance:none;
	width:16px;
	height:16px;
	margin-top:-6px;
	border-radius:50%;
	background:var(--hue, var(--text));
}

input[type="range"]::-moz-range-thumb {
	width:16px;
	height:16px;
	border:0;
	border-radius:50%;
	background:var(--hue, var(--text));
}


@media (min-width:900px) and (min-height:600px) {
	.side_box { width:196px; padding:14px 18px; gap:8px; border-radius:18px; }
	.box_label { font-size:14px; }
	.box_label kbd { font-size:11px; }
	.stats { gap:4px 14px; margin-top:10px; padding-top:12px; }
	.stats dt { font-size:13px; }
	.stats dd { font-size:20px; }
}

@media (max-width:600px) {
	.side_box { width:100px; padding:8px 6px; }
	.corner { top:10px; right:10px; }
}
