:root {
    --bg: #F3E9D5;
    --surface: #FBF5E8;
    --text: #2A1B3D;
    --muted: #6C5C7E;
    --border: #D6C6A6;
    --accent: #5A3A86;
    --accent-text: #FBF5E8;
    --pick: #F0B93A;
    --pick-text: #2A1B3D;

    /* The result card keeps one palette in both themes so screenshots match. */
    --card-night: #241733;
    --card-dusk: #3A2856;
    --card-parch: #F0E4CC;
    --card-dim: #A99BBD;
    --card-track: #4A3768;
    --card-candle: #F0B93A;

    --display: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "SimSun", Georgia, serif;
    --body: "Noto Sans CJK SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-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: #1B1227;
      --surface: #281B3A;
      --text: #F0E4CC;
      --muted: #A99BBD;
      --border: #45335F;
      --accent: #F0B93A;
      --accent-text: #241733;
      --pick: #F0B93A;
      --pick-text: #241733;
    }
  }
  :root[data-theme="dark"] {
    --bg: #1B1227;
    --surface: #281B3A;
    --text: #F0E4CC;
    --muted: #A99BBD;
    --border: #45335F;
    --accent: #F0B93A;
    --accent-text: #241733;
    --pick: #F0B93A;
    --pick-text: #241733;
  }

  *, *::before, *::after { box-sizing: inherit; }
  html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
  body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }
  main {
    max-width: 440px;
    margin: 0 auto;
    padding: 20px 16px 32px;
  }
  button { font: inherit; color: inherit; }
  :focus-visible { outline: 3px solid var(--pick); outline-offset: 2px; }

  /* Intro */
  .intro { text-align: center; padding-top: min(8vh, 56px); }
  .intro .clock { width: min(62vw, 240px); margin: 0 auto 26px; }
  .intro h1 {
    font-family: var(--display);
    font-weight: 700;
    font-size: clamp(1.8rem, 8.4vw, 2.5rem);
    line-height: 1.3;
    margin: 0 auto 10px;
  }
  .intro p { margin: 0 auto 18px; color: var(--muted); }
  .intro .intro-detail { font-size: 0.82rem; margin-bottom: 8px; }
  .hand { transform-box: view-box; transform-origin: 100px 100px; }
  .hand.hour { animation: hour 1.4s cubic-bezier(.3,.1,.2,1) both; }
  .hand.minute { animation: minute 1.4s cubic-bezier(.3,.1,.2,1) both; }
  @keyframes hour { from { transform: rotate(-6deg); } to { transform: rotate(0deg); } }
  @keyframes minute { from { transform: rotate(-72deg); } to { transform: rotate(0deg); } }

  .primary {
    display: inline-block;
    border: 0;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
    padding: 14px 28px;
    margin-top: 10px;
    cursor: pointer;
  }
  .quiet {
    border: 0;
    background: none;
    color: var(--muted);
    font-weight: 500;
    padding: 10px 4px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  /* Question */
  .progress { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.85rem; }
  .progress .track { flex: 1; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
  .progress .fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 200ms ease; }
  .question h2 {
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.65rem;
    line-height: 1.5;
    margin: 26px 0 20px;
  }
  .options { display: grid; gap: 10px; }
  .option {
    text-align: left;
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 15px 16px;
    cursor: pointer;
    line-height: 1.6;
  }
  .option[aria-pressed="true"] { background: var(--pick); border-color: var(--pick); color: var(--pick-text); }

  .slider-box { background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 18px 16px 14px; }
  .slider-value { font-family: var(--display); font-size: 2.2rem; line-height: 1.1; margin-bottom: 4px; }
  .slider-sub { color: var(--muted); font-size: 0.9rem; min-height: 1.3em; margin-bottom: 10px; }
  input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; margin: 0; }
  .slider-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.82rem; }
  .nav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; min-height: 48px; }

  /* Result card */
  .card {
    background: radial-gradient(120% 80% at 50% 0%, var(--card-dusk) 0%, var(--card-night) 62%);
    color: var(--card-parch);
    border-radius: 22px;
    padding: 18px 18px 14px;
  }
  .card .token-wrap { width: 118px; margin: 0 auto 8px; }
  .card h2 {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.9rem;
    line-height: 1.1;
    margin: 0;
    text-align: center;
  }
  .card .kind { text-align: center; font-size: 0.92rem; color: var(--card-dim); margin: 4px 0 0; }
  .card .kind b { font-weight: 600; }
  .card .code {
    font-family: var(--display);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: 0.22em;
    margin-left: 0.22em;
    color: var(--card-candle);
  }
  .card .roast { font-size: 1rem; line-height: 1.7; margin: 12px 0 14px; text-align: center; }
  .axis { margin-bottom: 9px; }
  .axis .labels { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--card-dim); margin-bottom: 4px; }
  .axis .labels .on { color: var(--card-parch); font-weight: 600; }
  .axis .bar { position: relative; height: 6px; border-radius: 3px; background: var(--card-track); }
  .axis .bar::before { content: ""; position: absolute; left: 50%; top: -2px; width: 1px; height: 10px; background: var(--card-dim); opacity: 0.6; }
  .axis .dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--card-candle); border: 2px solid var(--card-night); }
  .card .avoided { text-align: center; font-size: 0.9rem; margin: 12px 0 0; }
  .card .avoided b { font-weight: 600; }
  .card .foot { text-align: center; font-family: var(--display); font-size: 0.85rem; color: var(--card-dim); margin: 8px 0 0; }

  .after { margin-top: 16px; }
  .after p { color: var(--muted); font-size: 0.92rem; margin: 0 0 6px; }
  .legend { margin: 14px 0 0; padding: 0; list-style: none; font-size: 0.92rem; color: var(--muted); }
  .legend li { margin-bottom: 4px; }
  .legend b { color: var(--text); font-weight: 600; }

  .site-footer { max-width: 440px; margin: 0 auto; padding: 0 16px 24px; text-align: center; font-size: 0.7rem; color: var(--muted); overflow-wrap: anywhere; }
  .site-footer a { color: inherit; text-underline-offset: 3px; }

  @media (prefers-reduced-motion: reduce) { .progress .fill { transition: none; } .hand { animation: none !important; } }
