:root {
  --bg: #14151a;
  --surface: #1e2027;
  --surface-2: #262933;
  --text: #f4f5f7;
  --muted: #9aa0ac;
  --accent: #ffd24d;
  --radius: 16px;
  --ring: rgba(255, 255, 255, 0.08);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.app {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* --- Screen switching --- */
.screen {
  display: none;
  width: 100%;
  max-width: 520px;
  animation: fade 0.35s ease;
}
.screen.is-active {
  display: block;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.stack {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* --- Typography --- */
.title {
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.05;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(
    100deg,
    #ff4d6d,
    #ffd24d 35%,
    #4dabff 70%,
    #7cffb2
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title span {
  font-weight: 400;
}
.title.small {
  font-size: clamp(1.5rem, 5vw, 2rem);
}
.lede {
  color: var(--muted);
  margin: 0;
}
.date {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  margin: 0;
}
.fine {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

/* --- Buttons --- */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.2s ease;
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.btn-primary {
  background: var(--accent);
  color: #201a00;
}
.btn-primary:hover {
  filter: brightness(1.06);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--ring);
}

/* --- Study screen --- */
#screen-study.is-active {
  display: grid;
  place-items: center;
  max-width: none;
  position: fixed;
  inset: 0;
}
.study-colour {
  position: fixed;
  inset: 0;
  background: #000;
}
.study-overlay {
  position: relative;
  text-align: center;
  z-index: 1;
  mix-blend-mode: difference;
  color: #fff;
  pointer-events: none;
}
.study-label {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0 0 8px;
}
.countdown {
  font-size: clamp(5rem, 20vw, 9rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* --- Recreate screen --- */
.recreate {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.step {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}
.prompt {
  margin: 0;
  font-size: 1.35rem;
}
.preview {
  height: 120px;
  border-radius: 12px;
  border: 1px solid var(--ring);
  background: rgb(128, 128, 128);
  transition: background 0.05s linear;
}
.preview-hex {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.slider {
  display: grid;
  grid-template-columns: 56px 1fr 44px;
  align-items: center;
  gap: 12px;
}
.slider-name {
  font-size: 0.9rem;
  font-weight: 600;
}
.slider output {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Range track colouring per channel */
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  outline: none;
}
.slider-r input {
  background: linear-gradient(to right, #000, #ff2d2d);
}
.slider-g input {
  background: linear-gradient(to right, #000, #2dff2d);
}
.slider-b input {
  background: linear-gradient(to right, #000, #2d6bff);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #14151a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #14151a;
  cursor: pointer;
}

/* --- Results screen --- */
.score-ring {
  width: 150px;
  height: 150px;
  margin: 4px auto;
  border-radius: 50%;
  display: grid;
  place-content: center;
  background: var(--surface-2);
  border: 6px solid var(--accent);
}
.score-value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}
.score-max {
  color: var(--muted);
  font-size: 0.9rem;
}
.verdict {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px;
}
.result-swatches {
  display: flex;
  gap: 6px;
  align-items: center;
}
.result-chip {
  flex: 1;
  height: 46px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-size: 0.65rem;
  font-family: ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.result-chip small {
  opacity: 0.75;
}
.result-arrow {
  color: var(--muted);
  font-size: 1.1rem;
}
.result-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: center;
}
