@font-face {
  font-family: "Special Elite";
  src: url("assets/fonts/SpecialElite-Regular.ttf") format("truetype");
  font-display: swap;
}

/* ---------- colours ----------
   Brand palette stays fixed; the "role" colours below switch between light and
   dark mode automatically, following each phone's own setting. */
:root {
  --plum-dark: #3D214D;
  --plum: #714278;
  --indigo: #616798;
  --teal: #63C0C3;
  --butter: #FCDF7E;
  --blush: #FFBBB5;
  --ink: #141414;
  --cream: #FFF3DB;

  /* light mode */
  --bg: #FFFFFF;
  --surface: #F8F3F9;          /* cards, option buttons */
  --text: #2A1736;
  --muted: #6E5F78;
  --heading: #3D214D;
  --accent: #714278;           /* links, selected states */
  --dot-fill: #FFFFFF;         /* inside of an unselected Likert circle */
  --track: #E6D9E4;            /* empty progress segments, borders */
  --divider: #EEE3EC;
  --error: #C62828;
  --btn-bg: #714278;
  --btn-shadow: #3D214D;
  --bar-bg: rgba(255, 255, 255, .94);
  --shadow: rgba(61, 33, 77, .12);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Special Elite", "Courier New", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16101A;
    --surface: #251B2C;
    --text: #F4ECF6;
    --muted: #B8A8C2;
    --heading: #EBD9EF;
    --accent: #D3A6DB;
    --dot-fill: #16101A;
    --track: #3E3046;
    --divider: #3E3046;
    --error: #FF8A80;
    --btn-bg: #8A5492;
    --btn-shadow: #0B070D;
    --bar-bg: rgba(22, 16, 26, .94);
    --shadow: rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
}
button { font: inherit; color: inherit; }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 20px calc(32px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
.screen { display: flex; flex-direction: column; }

h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 12px; color: var(--heading); }
h2 { font-size: 18px; margin: 28px 0 12px; color: var(--heading); }
p { margin: 0 0 14px; }
.lead { font-size: 18px; }
.muted { opacity: .45; }

/* ---------- buttons (all button text in Special Elite) ---------- */
.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  margin-top: 16px;
  border: 0;
  border-radius: 999px;
  background: var(--btn-bg);
  color: #fff;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--btn-shadow);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--btn-shadow); }
.btn:disabled { opacity: .6; }
.btn:focus-visible, .link:focus-visible, .likert-opt:focus-visible, .seg:focus-visible,
.color-sq:focus-visible, .pat:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.link {
  background: none;
  border: 0;
  padding: 12px 4px;
  color: var(--accent);
  font-family: var(--display);
  font-size: 18px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link.small { font-size: 15px; color: var(--muted); align-self: center; margin-top: 24px; }

.error { color: var(--error); font-weight: 600; margin: 12px 0 0; }

/* ---------- welcome ---------- */
.welcome { text-align: center; padding-top: 16px; }
.welcome .logo { width: 100%; max-width: 360px; margin: 0 auto 16px; display: block; }
.welcome h1 { font-size: 30px; }

/* ---------- quiz ---------- */
.progress { margin-bottom: 28px; }
.progress-text { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.segs { display: flex; gap: 4px; }
.seg {
  flex: 1;
  height: 28px;           /* tall tap target … */
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  position: relative;
}
.seg::after {             /* … thin visible bar */
  content: "";
  position: absolute; left: 0; right: 0; top: 10px;
  height: 8px;
  border-radius: 4px;
  background: var(--track);
}
.seg.done::after { background: var(--teal); }
.seg.current::after { box-shadow: 0 0 0 2px var(--accent); }

.question { font-size: 22px; line-height: 1.4; font-weight: 600; min-height: 7.5em; margin-bottom: 20px; }

.likert { display: flex; justify-content: space-between; gap: 4px; }
.likert-opt {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
  padding: 6px 0;
  background: none; border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.likert-opt .dot {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: var(--dot-fill);
  transition: background .15s, transform .15s;
}
.likert-opt.on .dot { background: var(--accent); transform: scale(1.08); box-shadow: inset 0 0 0 4px var(--dot-fill); }
.likert-opt .lbl { font-size: 14.5px; line-height: 1.25; text-align: center; color: var(--muted); }
.likert-opt.on .lbl { color: var(--heading); font-weight: 700; }

.quiz-nav { margin-top: 32px; display: flex; flex-direction: column; }
.quiz-nav .link { align-self: flex-start; }

/* ---------- result ---------- */
.result { text-align: center; padding-top: 24px; }
.fabric-name { font-family: var(--display); font-weight: 400; color: var(--heading); letter-spacing: .01em; }
.fabric-name.xl { font-size: 56px; line-height: 1.05; margin: 4px 0 8px; }
.fabric-name.lg { font-size: 40px; line-height: 1.1; margin: 0 0 4px; }
.fabric-name.sm { font-size: 22px; line-height: 1.1; }
.nickname { font-size: 20px; font-weight: 700; margin: 0; color: var(--accent); }
.epithet { font-size: 16px; color: var(--muted); font-style: italic; margin: 2px 0 16px; }
.fabric-img { width: 100%; aspect-ratio: 5 / 3; object-fit: cover; border-radius: 16px; box-shadow: 0 6px 20px var(--shadow); margin-bottom: 8px; }

/* ---------- customize ---------- */
.preview-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  margin: -20px -20px 16px;
  padding: 12px 20px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--divider);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.preview, .final-swatch {
  flex: none;
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow), 0 0 0 1px var(--divider);
}
.preview svg, .final-swatch svg { width: 100%; height: 100%; display: block; }
.preview-label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

.colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.color-sq {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .35);
}
.color-sq.on { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.color-sq.on::after {
  content: "✓";
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.color-sq.light.on::after { color: var(--plum-dark); text-shadow: none; }

.picker {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  min-height: 60px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 2px solid var(--track);
  cursor: pointer;
  font-weight: 600;
}
.picker.on { border-color: var(--accent); }
.picker.disabled { opacity: .4; cursor: not-allowed; }
.picker .chip { width: 36px; height: 36px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .4); }
.picker input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.picker input[type="color"]:disabled { cursor: not-allowed; }

.patterns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 12px; }
.pat {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none;
  cursor: pointer;
}
.pat-art {
  width: 100%; aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;                         /* pattern choices are always black on white */
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, .35);
}
.pat-art svg { width: 100%; height: 100%; display: block; }
.pat.on .pat-art { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.pat-name { font-size: 14px; font-weight: 600; line-height: 1.2; text-align: center; min-height: 2.4em; }
.pat.on .pat-name { color: var(--accent); font-weight: 800; }

.submit-area { margin-top: 28px; display: flex; flex-direction: column; }
.submit-area .link { align-self: center; }

/* ---------- details ---------- */
.details { text-align: left; }
.congrats { text-align: center; font-size: 26px; margin-top: 16px; }
.emoji { text-align: center; font-size: 34px; letter-spacing: 4px; margin: 0 0 16px; }
.final-swatch { width: 120px; height: 120px; margin: 0 auto 24px; border-radius: 14px; }
.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
}
.card .epithet { margin-bottom: 14px; }
.core { color: var(--heading); }
.motto { font-family: var(--display); font-size: 20px; line-height: 1.35; color: var(--accent); margin: 18px 0; }
details { border-top: 1px solid var(--divider); padding-top: 12px; }
summary { font-weight: 700; color: var(--accent); cursor: pointer; padding: 6px 0; }
dl { margin: 8px 0 0; }
dt { font-weight: 700; margin-top: 12px; }
dd { margin: 2px 0 0; }
.backing img { width: 100%; aspect-ratio: 5 / 2; object-fit: cover; border-radius: 12px; margin-bottom: 14px; }
.fabric-inline { font-family: var(--display); font-weight: 400; font-size: 1.1em; line-height: 1; color: var(--heading); }
.next ol { margin: 4px 0 0; padding-left: 22px; }
.next li { margin: 6px 0; font-weight: 600; }
.test-banner { background: var(--butter); color: var(--plum-dark); border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 600; }

@media (max-width: 360px) {
  .likert-opt .dot { width: 34px; height: 34px; }
  .likert-opt .lbl { font-size: 13px; }
  .fabric-name.xl { font-size: 46px; }
  .btn { font-size: 19px; }
}
