:root {
  color-scheme: dark;
  --bg: radial-gradient(circle at 20% -20%, rgba(93, 221, 255, 0.35), transparent 55%),
          radial-gradient(circle at 80% 20%, rgba(255, 156, 252, 0.3), transparent 60%),
          #070815;
  --panel: rgba(9, 12, 28, 0.78);
  --panel-border: rgba(113, 133, 255, 0.3);
  --text: #f6f8ff;
  --muted: rgba(243, 245, 255, 0.75);
  --accent: #8da2ff;
  --accent-strong: #5166ff;
  --surface: rgba(16, 22, 44, 0.8);
  --field: rgba(18, 24, 50, 0.7);
  --focus: rgba(129, 212, 250, 0.55);
  --shadow: 0 30px 60px rgba(5, 10, 30, 0.45);
  font-family: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 4vw, 3rem);
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: background 0.6s ease;
}

body.flashlight-active {
  overflow: hidden;
  cursor: none;
  background: #000;
}

body.flashlight-active .app {
  display: none;
}

body.pixel-mode-active {
  background: #000;
}

.app {
  width: min(780px, 100%);
  display: grid;
  gap: clamp(1.75rem, 4vw, 2.75rem);
}

.hero {
  background: rgba(10, 14, 34, 0.7);
  border: 1px solid var(--panel-border);
  border-radius: 26px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.95rem;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid rgba(140, 162, 255, 0.4);
  background: rgba(33, 50, 110, 0.35);
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.2rem, 5vw, 3.25rem);
  letter-spacing: -0.01em;
}

.hero__copy {
  margin: 0;
  line-height: 1.6;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.1rem);
}

.control-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  box-shadow: var(--shadow);
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem);
  backdrop-filter: blur(22px);
}

.preview {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  height: clamp(150px, 28vw, 220px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1rem;
  color: rgba(0, 0, 0, 0.65);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.preview__label {
  background: rgba(255, 255, 255, 0.8);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.preview--pulse {
  animation: previewPulse 0.6s ease;
}

@keyframes previewPulse {
  0% {
    box-shadow: inset 0 0 0 0 rgba(129, 212, 250, 0.45);
    transform: scale(1);
  }
  45% {
    box-shadow: inset 0 0 0 12px rgba(129, 212, 250, 0.25);
    transform: scale(1.01);
  }
  100% {
    box-shadow: inset 0 0 0 0 rgba(129, 212, 250, 0.45);
    transform: scale(1);
  }
}

.fields {
  display: grid;
  gap: clamp(1rem, 2vw, 1.5rem);
}

.field-group {
  display: grid;
  gap: 0.65rem;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

label {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.color-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

input[type="color"] {
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  cursor: pointer;
}

.color-text {
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--field);
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}

.color-text.invalid {
  border-color: rgba(248, 113, 113, 0.85);
  color: #fee2e2;
}


.color-text:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 0.6rem;
}

.swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 2px solid transparent;
  background: currentColor;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.swatch:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.swatch:hover {
  transform: translateY(-2px);
}

select, input[type="range"] {
  width: 100%;
}

select {
  appearance: none;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="12" height="8" viewBox="0 0 12 8" fill="none"%3E%3Cpath d="M1 1.5L6 6.5L11 1.5" stroke="white" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/%3E%3C/svg%3E') no-repeat right 1.1rem center / 12px 8px,
    var(--field);
  color: var(--text);
  font-size: 1rem;
}

select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 14px rgba(81, 102, 255, 0.45);
  border: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 14px rgba(81, 102, 255, 0.45);
  border: 0;
}

.speed-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.checkbox input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent-strong);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

button {
  border: none;
  border-radius: 18px;
  padding: 0.95rem 1.6rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 12px 22px rgba(81, 102, 255, 0.45);
}

button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 28px rgba(81, 102, 255, 0.45);
}

button.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.14);
}

.exit-hint {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(243, 245, 255, 0.6);
}

#pixelCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  pointer-events: none;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 0.4s ease;
}

body.pixel-mode-active #pixelCanvas {
  display: block;
  opacity: 1;
}

body.flashlight-active.pixel-mode-active {
  background: #000;
}

body.flashlight-active #pixelCanvas {
  z-index: 1;
}

body.flashlight-active.pixel-mode-active::after {
  content: "";
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 0;
}

@media (max-width: 720px) {
  body {
    padding: clamp(1.2rem, 4vw, 1.75rem);
  }

  .hero,
  .control-panel {
    border-radius: 22px;
  }

  .preview {
    height: clamp(130px, 40vw, 180px);
  }

  .actions {
    flex-direction: column;
  }

  button {
    width: 100%;
  }
}
