:root {
	--bg1: #06283d;
	--bg2: #0a4d68;
	--accent: #00b4d8;
	--danger: #ff4d6d;
}

body {
	margin: 0;
	font-family: "Inter", sans-serif;
	background: linear-gradient(135deg, var(--bg1), var(--bg2));
	color: white;

	min-height: 100vh;
	display: flex;
	justify-content: center;

	overflow-x: hidden;
	overflow-y: auto;

	padding: 12px;
	box-sizing: border-box;
}

.container {
	text-align: center;
	width: 100%;
	max-width: 700px;

	padding: 12px;
	box-sizing: border-box;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: center; /* UBAH INI (kunci utama) */
	gap: 14px;
	flex-wrap: wrap;

	padding: 10px 14px;
	border-radius: 999px;

	background: rgba(255, 255, 255, 0.06);
	backdrop-filter: blur(12px);
}

.mode-switch {
	display: flex;
	gap: 6px;
	background: rgba(255, 255, 255, 0.08);
	padding: 4px;
	border-radius: 999px;
}

.mode-btn {
	padding: 10px 14px;
	border: none;
	border-radius: 999px;
	cursor: pointer;
	background: transparent;
	color: white;
	font-weight: 600;
	transition: all 0.3s ease;

	min-width: 90px;
	min-height: 42px;
	flex: unset;
}

.mode-btn.active {
	background: var(--accent);
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.mode-btn:hover {
	opacity: 0.8;
}

.timer {
	font-size: clamp(32px, 10vw, 70px);
	font-weight: 700;
	display: flex;
	justify-content: center;
	gap: 10px;
}

.color-btn {
	position: relative;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	background: var(--color);
	transition: 0.25s ease;
}

.color-btn.active {
	box-shadow:
		0 0 0 2px white,
		0 0 12px var(--color);
}

.color-btn:hover {
	transform: scale(1.15);
	box-shadow: 0 0 15px var(--color);
}

.color-btn::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	box-shadow: 0 0 0 3px white;
	opacity: 0;
	transition: 0.3s;
}

.color-btn.active::after {
	opacity: 1;
}

.flip {
	min-width: clamp(60px, 18vw, 90px);
}

.flip.animate {
	transform: rotateX(360deg);
}

.inputs {
	display: flex;
	gap: 8px;
	align-items: center;
}

.clear-btn:hover {
	background: rgba(255, 255, 255, 0.18);
}

.clear-btn.hidden {
	display: none;
}

.config-wrapper {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 30px;
	margin-top: 25px;
	flex-wrap: wrap;
}

.app-footer.floating {
	bottom: calc(18px + env(safe-area-inset-bottom));
}

.config-item {
	display: flex;
	align-items: center;
	gap: 10px;
	background: rgba(255, 255, 255, 0.05);
	padding: 12px 18px;
	border-radius: 14px;
	backdrop-filter: blur(8px);
}

.config-label {
	font-size: 14px;
	font-weight: 500;
	opacity: 0.8;
}

.config-item input[type="range"] {
	width: 140px;
	accent-color: var(--accent);
	cursor: pointer;
}

.config-item input[type="number"] {
	width: 60px;
	height: 36px;
	text-align: center;
	border-radius: 8px;
	border: none;
	outline: none;
	background: rgba(255, 255, 255, 0.1);
	color: white;
	transition: 0.2s ease;
}

.config-item input[type="number"]:focus {
	box-shadow: 0 0 0 2px var(--accent);
}

.config-suffix {
	font-size: 13px;
	opacity: 0.6;
}

.controls {
	display: flex;
	justify-content: center; /* center horizontal */
	gap: 8px; /* jarak antar tombol */
	flex-wrap: wrap; /* jika layar kecil, tombol pindah ke baris baru */
	margin-top: 20px;
}

.controls button {
	flex: 1;
	padding: 10px 18px;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
	background: var(--accent);
	color: white;
}

.time-input-wrapper {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	margin-top: 20px;
}

.time-inputs {
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(255, 255, 255, 0.05);
	padding: 10px 18px;
	border-radius: 14px;
	backdrop-filter: blur(8px);
}

.time-inputs span {
	font-size: 20px;
	font-weight: 600;
	opacity: 0.6;
}

.time-inputs input {
	width: 60px;
	height: 40px;
	text-align: center;
	font-size: 16px;
	border-radius: 10px;
	border: none;
	outline: none;
	background: rgba(255, 255, 255, 0.08);
	color: white;
	transition: 0.2s ease;
}

.time-inputs input:focus {
	background: rgba(255, 255, 255, 0.15);
	box-shadow: 0 0 0 2px var(--accent);
}

.time-inputs input::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

.clear-btn {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	font-size: 18px;
	background: rgba(255, 255, 255, 0.08);
	color: white;
	transition: 0.2s ease;
}

.clear-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	transform: scale(1.1);
}

.controls .danger {
	background: var(--danger);
}

.progress {
	width: min(65vw, 220px);
	height: min(65vw, 220px);
	margin: 20px auto;
	position: relative;
}

.inner-anim {
	position: absolute;
	width: 120px;
	height: 120px;
	border-radius: 50%;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(255, 255, 255, 0.05);
	backdrop-filter: blur(8px);
	transition: all 0.3s ease;
}

.lap-container {
	margin-top: 20px;
	width: 100%;
	max-width: 350px;
}

.lap-container h3 {
	font-size: 14px;
	opacity: 0.7;
	margin-bottom: 10px;
	letter-spacing: 1px;
}

.lap-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-height: 200px;
	overflow-y: auto;
	padding-right: 5px;
}

.lap-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: rgba(255, 255, 255, 0.05);
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px;
	backdrop-filter: blur(10px);
	transition: 0.2s ease;
}

.lap-item:hover {
	background: rgba(255, 255, 255, 0.08);
}

.lap-left {
	display: flex;
	gap: 8px;
	opacity: 0.7;
}

.lap-diff {
	font-size: 12px;
	opacity: 0.6;
}

.lap-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
}

.clear-laps {
	background: transparent;
	border: 1px solid rgba(255, 255, 255, 0.2);
	color: white;
	font-size: 12px;
	padding: 5px 12px;
	border-radius: 8px;
	cursor: pointer;
	transition: 0.2s ease;
}

.clear-laps:hover {
	background: rgba(255, 255, 255, 0.1);
}

.hidden {
	display: none;
}

.fastest {
	color: #4ade80;
}

.slowest {
	color: #f87171;
}

/* CALM MODE */
.inner-anim.calm {
	animation: calmPulse 3s infinite ease-in-out;
}

@keyframes calmPulse {
	0% {
		transform: translate(-50%, -50%) scale(1);
		opacity: 0.6;
	}
	50% {
		transform: translate(-50%, -50%) scale(1.05);
		opacity: 0.8;
	}
	100% {
		transform: translate(-50%, -50%) scale(1);
		opacity: 0.6;
	}
}

/* PANIC MODE */
.inner-anim.panic {
	animation: panicPulse 0.5s infinite;
	background: rgba(255, 77, 109, 0.2);
}

@keyframes panicPulse {
	0% {
		transform: translate(-50%, -50%) scale(1);
	}
	25% {
		transform: translate(-48%, -52%) scale(1.08);
	}
	50% {
		transform: translate(-52%, -48%) scale(1.05);
	}
	75% {
		transform: translate(-50%, -50%) scale(1.1);
	}
	100% {
		transform: translate(-50%, -50%) scale(1);
	}
}

svg {
	transform: rotate(-90deg);
}

circle {
	fill: none;
	stroke-width: 10;
}

circle.bg {
	stroke: rgba(255, 255, 255, 0.1);
}

circle.bar {
	stroke: var(--accent);
	stroke-linecap: round;
	transition: stroke 0.4s ease;
}

circle.bar.panic {
	stroke: var(--danger);
}

.config {
	margin-top: 10px;
}

.laps {
	margin-top: 10px;
	max-height: 120px;
	overflow: auto;
	font-size: 14px;
	opacity: 0.85;
}

.app-footer.floating {
	position: fixed;
	bottom: 18px;
	left: 50%;
	transform: translateX(-50%);

	padding: 10px 20px;
	font-size: 12px;
	border-radius: 999px;

	background: rgba(255, 255, 255, 0.06);
	backdrop-filter: blur(14px);
	-webkit-backdrop-filter: blur(14px);

	border: 1px solid var(--accent);
	color: var(--accent);

	box-shadow:
		0 0 20px rgba(0, 0, 0, 0.25),
		0 0 12px var(--accent);

	opacity: 0;
	transition:
		opacity 0.6s ease,
		transform 0.6s ease;

	z-index: 50;
	pointer-events: none;
}

.app-footer.floating.show {
	opacity: 1;
	transform: translateX(-50%) translateY(-4px);
}

@keyframes softFloat {
	0% {
		transform: translateX(-50%) translateY(0);
	}
	50% {
		transform: translateX(-50%) translateY(-6px);
	}
	100% {
		transform: translateX(-50%) translateY(0);
	}
}

.app-footer.floating.show {
	animation: softFloat 6s ease-in-out infinite;
}

.time-display {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.time {
	font-size: 64px;
	font-weight: 600;
	letter-spacing: 2px;
}

.clock-date {
	margin-top: 10px;
	font-size: 14px;
	letter-spacing: 0.5px;
	color: var(--accent);
	opacity: 0;
	transform: translateY(6px);
	transition: 0.4s ease;
}

.clock-date.show {
	opacity: 0.9;
	transform: translateY(0);
}

.theme-wrapper {
	position: relative;
	display: flex;
	justify-content: center;
	margin-top: 10px;
}

.theme-toggle {
	border: none;
	border-radius: 50%;
	width: 42px;
	height: 42px;
	font-size: 20px;
	cursor: pointer;
	background: rgba(255, 255, 255, 0.15);
	color: white;
	backdrop-filter: blur(10px);
}

.theme-picker {
	position: absolute;
	left: calc(100% + 10px);
	top: 50%;
	transform: translateY(-50%);

	display: flex;
	gap: 10px;
	padding: 10px 14px;
	border-radius: 50px;

	background: rgba(0, 0, 0, 0.35);
	backdrop-filter: blur(12px);

	opacity: 1;
	transition: 0.25s ease;
	white-space: nowrap;
}

.theme-picker.hidden {
	opacity: 0;
	transform: translateY(-50%) scale(0.95);
	pointer-events: none;
}

.warning-modal {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.35);
	backdrop-filter: blur(6px);
	z-index: 9999;
	transition: 0.2s ease;
}

.warning-modal.hidden {
	opacity: 0;
	pointer-events: none;
}

.warning-box {
	background: #0f172a;
	color: white;
	padding: 20px 24px;
	border-radius: 16px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
	text-align: center;
	min-width: 260px;
}

.warning-text {
	font-size: 15px;
	margin-bottom: 16px;
	opacity: 0.9;
}

.warning-box button {
	border: none;
	padding: 8px 18px;
	border-radius: 10px;
	cursor: pointer;
	font-weight: 600;
}

@media (max-width: 480px) {
	.topbar {
		flex-direction: column;
		border-radius: 18px;
	}

	.mode-switch {
		display: flex;
		gap: 6px;
		background: rgba(255, 255, 255, 0.08);
		padding: 4px;
		border-radius: 999px;
	}

	.theme-picker {
		left: 50%;
		top: calc(100% + 8px);
		transform: translateX(-50%);
	}
}
