:root {
	--surface: #ffffff;
	--background: #f4f6fb;
	--primary: #2563eb;
	--primary-dark: #1d4ed8;
	--text: #172033;
	--muted: #64748b;
	--line: #dbe3ef;
	--shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	font-family: Arial, sans-serif;
	color: var(--text);
	background: var(--background);
}

body.display-page {
	min-height: 100vh;
	overflow: hidden;
}

body.fullscreen-display {
	background: #000000;
}

body.dot-display {
	background-color: #000000;
}

.app {
	min-height: 100vh;
	padding: 16px 12px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.panel {
	width: min(100%, 440px);
	padding: 22px 18px 0;
	border-radius: 8px;
	background: var(--surface);
	box-shadow: var(--shadow);
}

h1 {
	margin: 0 0 16px;
	font-size: 25px;
	font-weight: 700;
	letter-spacing: 0;
}

.control-form {
	display: grid;
	gap: 12px;
	padding-bottom: 84px;
}

.settings-section,
.details-content,
.gradient-controls {
	display: grid;
	gap: 12px;
}

.field {
	display: grid;
	gap: 6px;
	font-size: 14px;
	font-weight: 700;
	color: var(--muted);
}

.field strong {
	float: right;
	color: var(--primary);
	font-size: 13px;
}

input[type="text"],
select {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
	color: var(--text);
	font: inherit;
	outline: none;
	transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"] {
	height: 52px;
	padding: 0 14px;
	font-size: 18px;
	line-height: 52px;
}

select {
	height: 44px;
	padding: 0 12px;
}

input[type="text"]:focus,
select:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.char-counter {
	text-align: right;
	color: var(--muted);
	font-size: 12px;
	font-weight: 700;
}

.char-counter.is-limit {
	color: #dc2626;
}

input[type="range"] {
	width: 100%;
	accent-color: var(--primary);
}

.color-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.color-field {
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
}

.is-hidden {
	display: none !important;
}

input[type="color"] {
	width: 100%;
	height: 40px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
}

.checkbox-field {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-size: 15px;
}

.checkbox-field input {
	width: 18px;
	height: 18px;
	accent-color: var(--primary);
}

.choice-group {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
}

.choice-group legend {
	padding: 0 4px;
	color: var(--muted);
	font-size: 14px;
	font-weight: 800;
}

.choice-field {
	min-height: 36px;
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--text);
	font-size: 14px;
}

.choice-field input {
	width: 18px;
	height: 18px;
	accent-color: var(--primary);
}

.primary-button {
	width: 100%;
	height: 52px;
	border: 0;
	border-radius: 8px;
	background: var(--primary);
	color: #ffffff;
	font-size: 16px;
	font-weight: 700;
	box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
	cursor: pointer;
	transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.settings-details {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
	overflow: hidden;
}

.settings-details summary {
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 12px;
	color: var(--text);
	font-size: 15px;
	font-weight: 800;
	cursor: pointer;
	list-style: none;
}

.settings-details summary::-webkit-details-marker {
	display: none;
}

.settings-details summary::after {
	content: "+";
	color: var(--primary);
	font-size: 20px;
	line-height: 1;
}

.settings-details[open] summary {
	border-bottom: 1px solid var(--line);
}

.settings-details[open] summary::after {
	content: "-";
}

.details-content {
	padding: 12px;
}

.sticky-action {
	position: sticky;
	bottom: 0;
	z-index: 4;
	margin: 0 -18px;
	padding: 10px 18px 14px;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 22%);
}

.primary-button:hover {
	background: var(--primary-dark);
	box-shadow: 0 10px 22px rgba(37, 99, 235, 0.34);
}

.primary-button:active {
	transform: translateY(1px);
}

.display-stage {
	width: 100%;
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	position: relative;
}

.fullscreen-display .display-stage {
	min-height: 100dvh;
	padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
}

.display-message {
	position: relative;
	z-index: 1;
	margin: 0;
	padding: 0 26px;
	width: max-content;
	max-width: 100%;
	font-weight: 800;
	text-align: center;
	white-space: nowrap;
	word-break: normal;
}

.message-move {
	position: relative;
	z-index: 1;
	width: max-content;
	max-width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.marquee-viewport {
	position: relative;
	z-index: 1;
	width: 100%;
	overflow: hidden;
	white-space: nowrap;
}

.marquee-track {
	display: inline-flex;
	align-items: center;
	gap: clamp(40px, 8vw, 120px);
	width: max-content;
	max-width: none;
	will-change: transform;
}

.marquee-track.move-left {
	animation: marquee-left var(--marquee-duration, 8s) linear infinite;
}

.marquee-track.move-right {
	animation: marquee-right var(--marquee-duration, 8s) linear infinite;
}

.marquee-track .display-message {
	flex: 0 0 auto;
	max-width: none;
	padding: 0;
	white-space: nowrap;
}

.marquee-clone {
	margin-right: clamp(40px, 8vw, 120px);
}

.display-message.gradient,
.display-message.animated-gradient,
.display-message.rainbow {
	color: transparent !important;
	background: linear-gradient(var(--gradient-angle), var(--gradient-start), var(--gradient-end));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
}

.display-message.gradient {
	text-shadow:
		0 0 8px var(--gradient-start),
		0 0 18px var(--gradient-end);
}

.display-message.animated-gradient {
	background-size: 300% 300%;
	animation: gradientMove var(--gradient-duration) ease infinite;
	text-shadow:
		0 0 8px var(--gradient-start),
		0 0 20px var(--gradient-end);
}

.display-message.rainbow {
	background: linear-gradient(
		90deg,
		#ff1744,
		#ff9100,
		#ffea00,
		#00e676,
		#2979ff,
		#9c27b0,
		#ff1744
	);
	background-size: 300% 300%;
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	animation: gradientMove 6s linear infinite;
	text-shadow:
		0 0 8px rgba(255, 255, 255, 0.64),
		0 0 18px rgba(41, 121, 255, 0.52);
}

.display-message.neon {
	text-shadow:
		0 0 3px currentColor,
		0 0 8px currentColor,
		0 0 16px currentColor,
		0 0 30px currentColor,
		0 0 46px currentColor;
}

.dot-display .display-stage {
	background-color: #000000;
	background-image:
		radial-gradient(circle at center, transparent 0, rgba(0, 0, 0, 0.18) 46%, rgba(0, 0, 0, 0.82) 100%),
		radial-gradient(circle, rgba(255, 255, 255, 0.09) 1px, transparent 1.7px),
		linear-gradient(rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.025)),
		repeating-linear-gradient(
			to bottom,
			rgba(255, 255, 255, 0.045) 0,
			rgba(255, 255, 255, 0.045) 1px,
			transparent 1px,
			transparent 7px
		);
	background-size: 100% 100%, 8px 8px, 100% 100%, 100% 7px;
	box-shadow:
		inset 0 0 32px rgba(0, 0, 0, 0.92),
		inset 0 0 96px rgba(0, 0, 0, 0.88);
}

.dot-display .display-stage::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background:
		repeating-linear-gradient(
			to bottom,
			rgba(255, 255, 255, 0.035) 0,
			rgba(255, 255, 255, 0.035) 1px,
			transparent 1px,
			transparent 4px
		);
	mix-blend-mode: screen;
	opacity: 0.5;
}

.led-message {
	max-width: calc(100vw - 24px);
	padding: 0 12px;
	font-family: "Courier New", Consolas, monospace;
	font-weight: 900;
	letter-spacing: 0.12em;
	line-height: 1.2;
	text-transform: uppercase;
	color: var(--led-color);
	-webkit-text-stroke: 0.25px rgba(255, 255, 255, 0.24);
	text-stroke: 0.25px rgba(255, 255, 255, 0.24);
	text-shadow:
		0 0 1px var(--led-color),
		0 0 4px var(--led-color),
		0 0 9px var(--led-color),
		0 0 18px var(--led-color),
		0 0 32px rgba(255, 255, 255, 0.24);
	filter: brightness(1.25) contrast(1.25) saturate(1.4);
}

.led-message::before {
	content: attr(data-led-text);
	position: absolute;
	inset: 0 12px;
	z-index: 2;
	pointer-events: none;
	color: transparent;
	background-image: radial-gradient(circle, rgba(255, 255, 255, 0.72) 18%, transparent 22%);
	background-size: 0.18em 0.18em;
	background-position: center;
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	opacity: 0.22;
	text-shadow: none;
}

.led-message.solid {
	color: var(--led-color);
}

.led-message.gradient,
.led-message.animated-gradient,
.led-message.rainbow {
	background: linear-gradient(var(--gradient-angle), var(--gradient-start), var(--gradient-end));
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent !important;
	-webkit-text-fill-color: transparent;
}

.led-message.gradient,
.led-message.animated-gradient {
	text-shadow:
		0 0 2px var(--gradient-start),
		0 0 6px var(--gradient-start),
		0 0 12px var(--gradient-end),
		0 0 22px var(--gradient-end),
		0 0 34px rgba(255, 255, 255, 0.34);
}

.led-message.animated-gradient {
	background-size: 300% 300%;
}

.led-message.rainbow {
	background: linear-gradient(
		90deg,
		#ff1744,
		#ff9100,
		#ffea00,
		#00e676,
		#2979ff,
		#9c27b0,
		#ff1744
	);
	background-size: 300% 300%;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent !important;
	-webkit-text-fill-color: transparent;
	text-shadow:
		0 0 2px #ffffff,
		0 0 6px #ffea00,
		0 0 14px #2979ff,
		0 0 26px #9c27b0;
}

.led-message.neon {
	text-shadow:
		0 0 2px #ffffff,
		0 0 6px var(--led-color),
		0 0 14px var(--led-color),
		0 0 28px var(--led-color),
		0 0 46px var(--led-color),
		0 0 64px rgba(255, 255, 255, 0.32);
}

.marquee-track .led-message {
	max-width: none;
}

.display-message.blink {
	animation: blink 1s steps(2, start) infinite;
}

.display-message.animated-gradient.blink,
.display-message.rainbow.blink {
	animation:
		gradientMove var(--gradient-duration) ease infinite,
		blink 1s steps(2, start) infinite;
}

.back-settings-button {
	position: fixed;
	top: 12px;
	left: 12px;
	z-index: 6;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid rgba(255, 255, 255, 0.24);
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.28);
	color: rgba(255, 255, 255, 0.92);
	font-size: 15px;
	font-weight: 700;
	text-decoration: none;
	box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
	backdrop-filter: blur(8px);
}

.immersive-control {
	opacity: 1;
	transition: opacity 0.2s ease;
}

.fullscreen-ui-hidden .immersive-control {
	opacity: 0;
	pointer-events: none;
}

.back-settings-button:hover {
	background: rgba(0, 0, 0, 0.42);
	color: #ffffff;
}

.dot-display .back-settings-button {
	border-color: rgba(255, 255, 255, 0.3);
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
	text-shadow: 0 0 8px rgba(255, 255, 255, 0.72);
}

.fullscreen-actions {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 5;
	transform: translateX(-50%);
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: center;
}

.fullscreen-actions[hidden] {
	display: none;
}

.fullscreen-button,
.orientation-guide-button {
	min-width: 180px;
	height: 48px;
	padding: 0 18px;
	border: 0;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.92);
	color: #111827;
	font-size: 15px;
	font-weight: 700;
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
	cursor: pointer;
}

.orientation-guide-button {
	min-width: 140px;
	background: rgba(17, 24, 39, 0.74);
	color: #ffffff;
	border: 1px solid rgba(255, 255, 255, 0.24);
}

.fullscreen-button:hover,
.orientation-guide-button:hover {
	background: #ffffff;
	color: #111827;
}

.fullscreen-button.hidden {
	display: none;
}

.rotate-guide {
	position: fixed;
	inset: 0;
	z-index: 20;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.75);
	color: #ffffff;
	font-size: 22px;
	font-weight: 800;
	text-align: center;
	pointer-events: none;
}

.rotate-guide.show {
	display: flex;
}

.rotate-guide span {
	padding: 16px 20px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.14);
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}

@media (orientation: portrait) {
	body.fullscreen-display .rotate-guide.show {
		display: flex;
	}
}

@media (orientation: landscape) {
	.rotate-guide,
	.rotate-guide.show,
	body.fullscreen-display .rotate-guide.show {
		display: none;
	}

	.fullscreen-display .display-message {
		max-width: none;
	}

	.fullscreen-display .message-move:not(.move-left):not(.move-right) .display-message {
		font-size: min(var(--dot-font-size, 48px), 18vh);
	}
}

@keyframes marquee-left {
	from {
		transform: translateX(0);
	}

	to {
		transform: translateX(-50%);
	}
}

@keyframes marquee-right {
	from {
		transform: translateX(-50%);
	}

	to {
		transform: translateX(0);
	}
}

@keyframes blink {
	50% {
		opacity: 0;
	}
}

@keyframes gradientMove {
	0% {
		background-position: 0% 50%;
	}

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

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

@media (max-width: 360px) {
	.app {
		padding: 16px 12px;
	}

	.panel {
		padding: 24px 18px;
	}

	h1 {
		font-size: 25px;
	}

	.led-message {
		max-width: calc(100vw - 16px);
		padding: 0 8px;
		letter-spacing: 0.08em;
		line-height: 1.2;
	}
}

@media (max-width: 480px) {
	.led-message {
		font-size: min(var(--dot-font-size, 48px), 18vw);
		letter-spacing: 0.1em;
	}
}

@media (max-width: 360px) {
	.led-message {
		letter-spacing: 0.08em;
	}
}
