@layer reset, base, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: dark; scroll-behavior: smooth; }
  body, h1, h2, h3, p { margin: 0; }
  button, input { font: inherit; }
  img, svg { max-width: 100%; }
}

@layer base {
  :root {
    --ink: #f8f5ff;
    --muted: #c8c2dc;
    --night: #100d24;
    --panel: #201a3d;
    --panel-2: #2a2250;
    --lime: #d4ff63;
    --pink: #ff74cf;
    --cyan: #65e8ff;
    --orange: #ffb45f;
    --line: #5a4d82;
    --shadow: 0 18px 55px rgb(0 0 0 / .25);
    --radius: 1.25rem;
    --max: 74rem;
  }
  body {
    min-width: 18rem;
    min-height: 100vh;
    color: var(--ink);
    background:
      radial-gradient(circle at 5% 8%, rgb(255 116 207 / .15), transparent 25rem),
      radial-gradient(circle at 94% 35%, rgb(101 232 255 / .11), transparent 28rem),
      var(--night);
    font-family: ui-rounded, "Trebuchet MS", system-ui, sans-serif;
    line-height: 1.55;
  }
  body.calm { background: var(--night); }
  a { color: inherit; text-decoration-thickness: .1em; text-underline-offset: .2em; }
  button { color: inherit; }
  button, a { -webkit-tap-highlight-color: transparent; }
  :focus-visible { outline: .2rem solid var(--lime); outline-offset: .25rem; }
  h1 { max-width: 18ch; font-size: clamp(2.25rem, 7vw, 5.75rem); line-height: .94; letter-spacing: -.055em; }
  h2 { font-size: clamp(1.65rem, 4vw, 2.75rem); line-height: 1.05; letter-spacing: -.035em; }
  h3 { font-size: 1.15rem; line-height: 1.2; }
  p { max-width: 68ch; }
}

@layer components {
  .skip-link {
    position: fixed;
    z-index: 20;
    top: .75rem;
    left: .75rem;
    padding: .65rem 1rem;
    color: var(--night);
    background: var(--lime);
    border-radius: .5rem;
    transform: translateY(-180%);
  }
  .skip-link:focus { transform: none; }
  .site-header, footer, main { width: min(100% - 2rem, var(--max)); margin-inline: auto; }
  .site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-block: 1.25rem;
  }
  .brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; font-weight: 800; line-height: 1; }
  .brand small { display: block; margin-top: .25rem; color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
  .brand-mark {
    display: grid;
    width: 3.2rem;
    aspect-ratio: 1;
    place-items: center;
    color: var(--night);
    background: var(--lime);
    border: .12rem solid var(--ink);
    border-radius: 35% 65% 58% 42%;
    box-shadow: .25rem .25rem 0 var(--pink);
    transform: rotate(-5deg);
  }
  nav { display: flex; align-items: center; gap: 1.15rem; font-size: .9rem; }
  nav a { text-decoration: none; }
  nav a:hover { text-decoration: underline; }
  .quiet-button, .tag, .filter-button {
    border: 1px solid var(--line);
    background: rgb(255 255 255 / .04);
    border-radius: 999px;
  }
  .quiet-button { padding: .45rem .75rem; cursor: pointer; }
  .support-nav { min-height: 2.75rem; color: var(--night); background: var(--lime); border-color: var(--ink); box-shadow: .2rem .2rem 0 var(--pink); font-weight: 850; }
  main { min-height: calc(100vh - 13rem); padding-block: clamp(2.5rem, 7vw, 6rem); }
  .hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(16rem, .65fr); align-items: center; gap: clamp(2rem, 7vw, 6rem); }
  .hero-copy > * + * { margin-top: 1.35rem; }
  .hero-copy .lead { max-width: 50ch; color: var(--muted); font-size: clamp(1.08rem, 2vw, 1.35rem); }
  .eyebrow { color: var(--lime); font-size: .78rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
  .hero-art {
    position: relative;
    display: grid;
    min-height: 23rem;
    place-items: center;
    isolation: isolate;
  }
  .hero-art::before, .hero-art::after { content: ""; position: absolute; border-radius: 50%; }
  .hero-art::before { z-index: -2; width: 20rem; aspect-ratio: 1; background: var(--pink); box-shadow: 0 0 0 1.5rem rgb(255 116 207 / .12); }
  .hero-art::after { z-index: -1; width: 15rem; aspect-ratio: 1; border: .18rem dashed var(--night); animation: orbit 18s linear infinite; }
  .hero-card { width: 12.5rem; padding: 1.4rem; color: var(--night); background: var(--lime); border: .2rem solid var(--ink); border-radius: 1rem; box-shadow: 1rem 1rem 0 var(--cyan); transform: rotate(4deg); }
  .hero-card strong { display: block; font-size: 3.8rem; line-height: 1; }
  .hero-card span { display: block; margin-top: .7rem; font-weight: 800; }
  @keyframes orbit { to { transform: rotate(1turn); } }
  .calm .hero-art::after { animation: none; }
  .button-row { display: flex; flex-wrap: wrap; gap: .75rem; }
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: .75rem 1.05rem;
    border: .12rem solid var(--ink);
    border-radius: .75rem;
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
  }
  .button.primary { color: var(--night); background: var(--lime); box-shadow: .3rem .3rem 0 var(--pink); }
  .button.secondary { background: var(--panel); }
  .button.support { color: var(--night); background: var(--cyan); box-shadow: .3rem .3rem 0 var(--pink); }
  .button:hover { transform: translateY(-.1rem); }
  .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-top: 2.2rem; }
  .stat { padding: 1rem; border-top: 1px solid var(--line); color: var(--muted); }
  .stat strong { display: block; color: var(--ink); font-size: 1.45rem; }
  .section-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
  .section-head > div > * + * { margin-top: .6rem; }
  .section-head p { color: var(--muted); }
  .filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: 1.5rem 2rem; }
  .filter-button { padding: .5rem .8rem; cursor: pointer; }
  .filter-button[aria-pressed="true"] { color: var(--night); background: var(--cyan); border-color: var(--cyan); font-weight: 850; }
  .mission-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
  .mission-card, .note-card, .panel {
    background: linear-gradient(145deg, rgb(255 255 255 / .06), transparent 70%), var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  .mission-card { position: relative; display: flex; min-height: 18rem; flex-direction: column; gap: .8rem; padding: 1.25rem; overflow: hidden; }
  .mission-card::after { content: attr(data-number); position: absolute; right: -.1rem; bottom: -1.8rem; color: rgb(255 255 255 / .045); font-size: 7rem; font-weight: 900; line-height: 1; }
  .mission-card p { color: var(--muted); font-size: .93rem; }
  .mission-card .kicker { color: var(--ink); font-weight: 700; }
  .mission-card .button { z-index: 1; align-self: flex-start; margin-top: auto; }
  .tag { align-self: flex-start; padding: .28rem .55rem; color: var(--cyan); font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  .tag.done { color: var(--lime); }
  .empty { padding: 2rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
  .mission-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(15rem, .7fr); gap: 1rem; align-items: start; }
  .panel { padding: clamp(1.25rem, 4vw, 2.5rem); }
  .panel > * + * { margin-top: 1.25rem; }
  .panel.narrow { max-width: 48rem; margin-inline: auto; }
  .mission-brief { color: var(--muted); font-size: 1.05rem; }
  .stakes { padding: .9rem 1rem; border-left: .25rem solid var(--orange); background: rgb(255 180 95 / .07); }
  .choice-list { display: grid; gap: .75rem; margin-top: 1.5rem; }
  .choice {
    width: 100%;
    padding: 1rem;
    text-align: left;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: .8rem;
    cursor: pointer;
  }
  .choice:hover { border-color: var(--cyan); background: #30275b; }
  .choice::before { content: "→"; margin-right: .6rem; color: var(--lime); font-weight: 900; }
  .progress { display: flex; gap: .4rem; padding: 0; list-style: none; }
  .progress li { width: 2.2rem; height: .35rem; background: var(--line); border-radius: 1rem; }
  .progress li.done { background: var(--lime); }
  .history { position: sticky; top: 1rem; }
  .history ol { padding-left: 1.25rem; color: var(--muted); font-size: .87rem; }
  .history li + li { margin-top: .75rem; }
  .history .button-row { margin-top: 1.25rem; }
  .history .button { min-height: 2.4rem; padding: .5rem .7rem; font-size: .83rem; }
  .result-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, .8fr); gap: 1.5rem; align-items: center; }
  .result-badge { font-size: clamp(4rem, 12vw, 8rem); filter: drop-shadow(.35rem .35rem 0 rgb(101 232 255 / .3)); }
  .result-line { color: var(--muted); font-size: 1.15rem; }
  .result-details { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
  .result-details div { padding: 1rem; background: rgb(255 255 255 / .04); border-radius: .75rem; }
  .result-details strong { display: block; color: var(--lime); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
  .score-bars { display: grid; gap: .5rem; }
  .score-row { display: grid; grid-template-columns: 7rem 1fr 2rem; align-items: center; gap: .5rem; font-size: .82rem; }
  .bar { height: .55rem; background: #0d0a1b; border-radius: 1rem; overflow: hidden; }
  .bar > span { display: block; height: 100%; background: var(--pink); }
  .notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; counter-reset: note; }
  .note-card { padding: 1.25rem; counter-increment: note; }
  .note-card h2 { font-size: 1.25rem; }
  .note-card h2::before { content: counter(note, decimal-leading-zero) " "; color: var(--pink); }
  .note-card p { margin-top: .8rem; color: var(--muted); }
  footer { display: flex; justify-content: space-between; gap: 1rem; padding-block: 2rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .83rem; }
  .ln-support-dialog { width: min(92vw, 26.5rem); padding: 1.75rem; color: var(--ink); background: var(--panel); border: 1px solid var(--cyan); border-radius: var(--radius); box-shadow: 0 2rem 6rem rgb(0 0 0 / .7); text-align: center; }
  .ln-support-dialog::backdrop { background: rgb(8 6 20 / .86); backdrop-filter: blur(.35rem); }
  .ln-support-dialog form { margin: 0; }
  .ln-support-close { position: absolute; top: .55rem; right: .8rem; border: 0; background: transparent; cursor: pointer; font-size: 1.8rem; }
  .ln-support-kicker { color: var(--lime); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
  .ln-support-dialog h2 { margin-top: .65rem; }
  .ln-support-dialog > p:not(.ln-support-kicker) { margin: .6rem auto 0; color: var(--muted); }
  .ln-support-dialog img { display: block; width: min(76vw, 20rem); height: auto; margin: 1rem auto; background: #fff; border-radius: .8rem; }
  .ln-support-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .65rem; }
  .ln-support-actions a, .ln-support-actions button { min-height: 2.7rem; padding: .65rem .9rem; color: var(--night); background: var(--lime); border: .1rem solid var(--ink); border-radius: .7rem; cursor: pointer; font-weight: 850; text-decoration: none; }
  .ln-support-actions button { color: var(--ink); background: transparent; border-color: var(--line); }
  .ln-support-status { min-height: 1.25rem; margin: .75rem auto 0!important; color: var(--muted); font-size: .78rem; }
  .toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 10; max-width: 20rem; padding: .75rem 1rem; color: var(--night); background: var(--lime); border-radius: .7rem; box-shadow: var(--shadow); font-weight: 750; }
}

@layer utilities {
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
}

@media (max-width: 52rem) {
  .site-header { align-items: flex-start; }
  nav { flex-wrap: wrap; justify-content: flex-end; }
  .hero, .mission-layout, .result-layout { grid-template-columns: 1fr; }
  .hero-art { min-height: 19rem; order: -1; }
  .mission-grid, .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history { position: static; }
}

@media (max-width: 36rem) {
  .site-header { display: block; }
  nav { justify-content: flex-start; margin-top: 1rem; gap: .75rem; }
  nav a { padding-block: .5rem; }
  main { padding-block: 2.5rem; }
  .mission-grid, .notes-grid { grid-template-columns: 1fr; }
  .section-head, footer { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  .stat { padding-inline: 0; }
  .result-details { grid-template-columns: 1fr; }
  .score-row { grid-template-columns: 6.5rem 1fr 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .site-header, footer, .button-row, .history { display: none; }
  body { color: #111; background: #fff; }
  main { width: 100%; padding: 0; }
  .panel { color: #111; background: #fff; border: 2px solid #111; box-shadow: none; }
  .result-line, .mission-brief { color: #333; }
}
