:root {
  --navy: #010B16;
  --gold: #D8A847;
  --gold-soft: #F3ECDB;
  --bg: #F8F8F6;
  --card: #FFFFFF;
  --ink: #0D141B;
  --muted: #5E6570;
  --line: #E6E3DA;
  --D: #FA5656;
  --I: #FCC122;
  --S: #2CC929;
  --C: #4888F5;
  --D-ink: #C93434;
  --I-ink: #9A6E00;
  --S-ink: #15851A;
  --C-ink: #2A62C4;
  --accent: var(--gold);
  --accent-ink: #9C7424;
  --sans: "Georama", "Helvetica Neue", Arial, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #010B16;
    --card: #0B1826;
    --ink: #EEF0F2;
    --muted: #9AA3AE;
    --line: #1E2C3C;
    --gold-soft: #1B2330;
    --D-ink: #FF8A8A;
    --I-ink: #FCC122;
    --S-ink: #5FE05C;
    --C-ink: #8AB4FF;
    --accent-ink: #E9C27A;
  }
}

:root[data-theme="dark"] {
  --bg: #010B16;
  --card: #0B1826;
  --ink: #EEF0F2;
  --muted: #9AA3AE;
  --line: #1E2C3C;
  --gold-soft: #1B2330;
  --D-ink: #FF8A8A;
  --I-ink: #FCC122;
  --S-ink: #5FE05C;
  --C-ink: #8AB4FF;
  --accent-ink: #E9C27A;
}

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  font-variation-settings: "wdth" 100;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* top bar */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
}

.brand b {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  font-variation-settings: "wdth" 85;
}

.brand span {
  font-size: 13px;
  color: var(--muted);
}

.home-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}

/* progress segments */
.segs {
  display: grid;
  grid-template-columns: repeat(var(--pill-count, 8), 1fr);
  gap: 4px;
  margin-bottom: 14px;
}

.seg {
  height: 5px;
  border-radius: 3px;
  background: var(--line);
  border: 0;
  padding: 0;
}

.seg.done {
  background: var(--gold);
}

.seg.here {
  background: var(--ink);
}

/* card */
.card {
  background: var(--card);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.hero {
  position: relative;
  padding: 26px 22px 22px;
  background: var(--navy);
  color: #fff;
  overflow: hidden;
}

.hero .num {
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
}

.hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.02;
  font-weight: 850;
  letter-spacing: -0.02em;
  font-variation-settings: "wdth" 78;
  max-width: 15ch;
  position: relative;
}

.hero p {
  margin: 0;
  color: #C9CED4;
  max-width: 44ch;
  position: relative;
}

.hero .time {
  margin-top: 12px;
  font-size: 13px;
  color: #8C96A3;
  position: relative;
}

.watermark {
  position: absolute;
  right: -12px;
  bottom: -46px;
  font-size: 210px;
  font-weight: 900;
  line-height: 1;
  color: rgba(216, 168, 71, 0.13);
  font-variation-settings: "wdth" 70;
  pointer-events: none;
  user-select: none;
}

.body {
  padding: 22px;
}

.body h2 {
  font-size: 20px;
  line-height: 1.2;
  margin: 0 0 6px;
  font-weight: 800;
  font-variation-settings: "wdth" 85;
}

.body .hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 14px;
}

.block + .block {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px dashed var(--line);
}

/* factor picker */
.factors {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.fbtn {
  border: 2px solid var(--line);
  background: transparent;
  border-radius: 14px;
  padding: 10px 4px 8px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.fbtn .L {
  display: block;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  font-variation-settings: "wdth" 75;
  color: var(--fi);
}

.fbtn .n {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.fbtn[aria-pressed="true"] {
  border-color: var(--f);
  background: color-mix(in srgb, var(--f) 12%, transparent);
}

.fbtn:disabled {
  cursor: default;
}

.fbtn.right {
  border-color: var(--S);
  background: color-mix(in srgb, var(--S) 14%, transparent);
}

.fbtn.wrong {
  border-color: var(--D);
  background: color-mix(in srgb, var(--D) 12%, transparent);
}

.fD { --f: var(--D); --fi: var(--D-ink); }
.fI { --f: var(--I); --fi: var(--I-ink); }
.fS { --f: var(--S); --fi: var(--S-ink); }
.fC { --f: var(--C); --fi: var(--C-ink); }

.panel {
  border-left: 4px solid var(--f, var(--gold));
  padding: 2px 0 2px 16px;
}

.panel .tag {
  font-size: 13px;
  color: var(--fi, var(--accent-ink));
  font-weight: 700;
  margin-bottom: 4px;
}

.panel p {
  margin: 0 0 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
  padding: 0;
  list-style: none;
}

.chips li {
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 600;
}

.quote {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  margin: 14px 0 0;
  padding: 16px 18px;
  background: var(--gold-soft);
  border-radius: 4px 16px 16px 16px;
}

.quote small {
  display: block;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

/* true/false */
.tf {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.tf li {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.tf .q {
  font-weight: 600;
  margin-bottom: 10px;
}

.tf .opts {
  display: flex;
  gap: 8px;
}

.tf .opts button {
  flex: 1;
  border: 1.5px solid var(--line);
  background: transparent;
  border-radius: 10px;
  padding: 8px;
  font-weight: 700;
}

.tf .opts button.right {
  border-color: var(--S);
  background: color-mix(in srgb, var(--S) 14%, transparent);
}

.tf .opts button.wrong {
  border-color: var(--D);
  background: color-mix(in srgb, var(--D) 12%, transparent);
}

.tf .why {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

/* match game */
.need {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.15;
  margin: 4px 0 14px;
  font-variation-settings: "wdth" 82;
}

.score {
  font-size: 14px;
  color: var(--muted);
}

.feedback {
  min-height: 24px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

/* flip */
.flip {
  -webkit-perspective: 900px;
  perspective: 900px;
  border: 0;
  background: none;
  padding: 0;
  width: 100%;
  text-align: left;
}

.flip-spaced {
  margin-top: 14px;
}

.flip-inner {
  position: relative;
  display: grid;
  transition: transform 0.5s;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.flip.on .flip-inner {
  transform: rotateY(180deg);
}

.face {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 16px;
  padding: 18px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.face.front {
  background: color-mix(in srgb, var(--D) 10%, var(--card));
  border: 1.5px solid color-mix(in srgb, var(--D) 45%, transparent);
  transform: rotateY(0deg);
}

.face.back {
  background: color-mix(in srgb, var(--S) 10%, var(--card));
  border: 1.5px solid color-mix(in srgb, var(--S) 45%, transparent);
  transform: rotateY(180deg);
}

.face .lbl {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.face .txt {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  margin: 8px 0;
}

.face .tap {
  font-size: 13px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .flip-inner {
    transition: none;
  }
}

/* formula steps */
.formula {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 10px 0;
}

.formula span {
  border: 1.5px solid var(--f, var(--gold));
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 14px;
}

.formula i {
  color: var(--muted);
  font-style: normal;
}

/* combo */
.pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: start;
}

.pair .plus {
  font-size: 28px;
  font-weight: 300;
  padding-top: 14px;
  color: var(--muted);
}

.mini {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.mini .fbtn {
  padding: 8px 2px;
}

.mini .fbtn .L {
  font-size: 22px;
}

.meter {
  display: flex;
  gap: 5px;
  margin: 14px 0 6px;
}

.meter i {
  flex: 1;
  height: 10px;
  border-radius: 3px;
  background: var(--line);
}

.meter i.on {
  background: var(--gold);
}

.combo-title {
  font-size: 24px;
  font-weight: 850;
  line-height: 1.1;
  margin: 10px 0 4px;
  font-variation-settings: "wdth" 80;
}

.bridge {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--gold-soft);
}

.bridge b {
  display: block;
  font-size: 13px;
  color: var(--accent-ink);
  margin-bottom: 2px;
}

/* 5 steps */
.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: s;
}

.steps li {
  position: relative;
  padding: 0 0 18px 48px;
  counter-increment: s;
}

.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 38px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}

.steps b {
  display: block;
  font-size: 17px;
}

.steps span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 6px;
}

/* fields */
label.f {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin: 12px 0 5px;
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
}

textarea {
  min-height: 76px;
}

textarea:focus,
input:focus {
  border-color: var(--gold);
  outline: none;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  background: var(--navy);
  color: #fff;
}

:root[data-theme="dark"] .btn {
  background: var(--gold);
  color: var(--navy);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn {
    background: var(--gold);
    color: var(--navy);
  }
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.saved {
  font-size: 13px;
  color: var(--muted);
}

/* reflection */
.reflect {
  margin-top: 26px;
  background: var(--navy);
  color: #fff;
  border-radius: 18px;
  padding: 20px;
}

.reflect .k {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
}

.reflect .rq {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.5;
  margin: 6px 0 12px;
}

.reflect textarea {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.reflect .btn {
  background: var(--gold);
  color: var(--navy);
}

.reflect .btn.ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.reflect .saved {
  color: #9AA3AE;
}

/* nav */
.nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
}

.nav .btn {
  flex: 1;
}

/* home */
.cover {
  background: var(--navy);
  color: #fff;
  border-radius: 22px;
  padding: 30px 22px;
  position: relative;
  overflow: hidden;
}

.cover h1 {
  font-size: clamp(40px, 11vw, 58px);
  line-height: 0.95;
  margin: 0 0 12px;
  font-weight: 900;
  font-variation-settings: "wdth" 72;
  letter-spacing: -0.01em;
}

.cover h1 em {
  font-style: normal;
  color: var(--gold);
}

.cover p {
  color: #C9CED4;
  margin: 0 0 6px;
  max-width: 42ch;
}

.cover .cover-note {
  color: #8C96A3;
  font-size: 14px;
  margin-top: 12px;
}

.cover .cover-actions {
  margin-top: 18px;
}

.cover .cover-cta {
  background: var(--gold);
  color: var(--navy);
}

.cover .lines {
  position: absolute;
  right: -60px;
  top: -40px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(216, 168, 71, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 0 30px rgba(216, 168, 71, 0.04), 0 0 0 60px rgba(216, 168, 71, 0.03);
}

.list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.list button {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
}

.list .n {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gold-soft);
  display: grid;
  place-items: center;
  font-weight: 850;
  font-size: 18px;
  color: var(--accent-ink);
}

.list .t {
  font-weight: 700;
  line-height: 1.25;
}

.list .s {
  font-size: 13px;
  color: var(--muted);
}

.list .st {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.list .st.ok {
  color: var(--S-ink);
}

.foot {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
