  :root {
    --bg: #0a0a0e;
    --fg: #ece8df;
    --fg-dim: #9c978c;
    --accent: #a8c5e6;
    --accent-dark: #0a1828;
    --good: #67d77f;
    --bad: #e36363;
    --card: #16161c;
    --border: #2a2a33;
    --border-strong: #44485a;
    --input-bg: #1d1d24;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
    min-height: 100dvh;
  }
  body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 14px 24px;
    max-width: 480px;
    margin: 0 auto;
  }
  .header {
    width: 100%;
    text-align: center;
    position: relative;
  }
  h1 {
    font-family: "Helvetica Neue", "SF Pro Display", system-ui, sans-serif;
    font-weight: 800;
    font-size: 42px;
    letter-spacing: 0.6px;
    margin: 0;
    color: var(--fg);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
  }
  .title-luna {
    background: linear-gradient(180deg, #fdf6e0 0%, #e6ecf6 50%, #a8c5e6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 22px rgba(168, 197, 230, 0.28);
    filter: drop-shadow(0 0 10px rgba(168, 197, 230, 0.18));
  }
  .title-le {
    color: var(--fg-dim);
    font-weight: 600;
    letter-spacing: 1.2px;
  }
  .title-moon {
    width: 28px;
    height: 28px;
    margin-right: 4px;
    filter: drop-shadow(0 0 6px rgba(253, 246, 224, 0.35));
  }
  .title-moon-new {
    width: 28px;
    height: 28px;
    margin-left: 6px;
    filter: drop-shadow(0 0 8px rgba(253, 246, 224, 0.55));
  }
  .title-logo {
    max-height: 66px;
    width: auto;
    display: block;
    margin: 0 auto;
  }
  .subtitle {
    font-size: 13px;
    color: var(--fg-dim);
    margin-top: 2px;
    letter-spacing: 0.3px;
  }
  .icons {
    margin-top: 6px;
    display: flex;
    justify-content: center;
    gap: 12px;
  }
  .icon-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    width: 32px; height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
  }
  .icon-btn:hover { opacity: 0.7; }
  .icon-btn:active { transform: scale(0.94); }

  .moon-stage {
    width: 100%;
    margin-top: 12px;
    background: #000;
    border-radius: 14px;
    padding: 12px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }
  canvas#moon {
    width: 220px; height: 220px;
    max-width: 70vw;
    max-height: 70vw;
    display: block;
  }

  .input-row {
    width: 100%;
    margin-top: 12px;
    display: flex;
    gap: 8px;
  }
  input[type="number"], input[type="tel"] {
    flex: 1;
    background: var(--input-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 14px;
    font-size: 17px;
    -webkit-appearance: none;
    appearance: textfield;
    text-align: center;
    letter-spacing: 0.5px;
  }
  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
  input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

  button.primary {
    background: var(--accent);
    color: var(--accent-dark);
    border: 0;
    border-radius: 10px;
    padding: 0 22px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.4px;
    transition: opacity 0.15s, transform 0.1s;
  }
  button.primary:hover { opacity: 0.92; }
  button.primary:active { transform: scale(0.97); }
  button.primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  .attempts-label {
    margin-top: 10px;
    font-size: 12px;
    color: var(--fg-dim);
    letter-spacing: 0.4px;
    text-transform: uppercase;
  }
  .guesses {
    margin-top: 4px;
    width: 100%;
    list-style: none;
    padding: 0;
  }
  .guesses li {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
  }
  .guesses .pct {
    font-weight: 700;
    font-size: 17px;
    width: 60px;
    flex-shrink: 0;
  }
  .guesses .clue {
    text-align: right;
    color: var(--fg);
    font-size: 15px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .guesses .clue .dir {
    font-size: 20px;
    line-height: 1;
    font-weight: 900;
    display: inline-block;
    transform: translateY(-1px);
  }
  .guesses .clue .dir.freezing { color: #cdd5de; }
  .guesses .clue .dir.cold { color: #6ba3d6; }
  .guesses .clue .dir.getting-hot { color: #c8b44a; }
  .guesses .clue .dir.hot { color: #c8844a; }
  .guesses .clue .dir.boiling { color: #c85a5a; }
  .guesses .clue .dir.exact {
    font-size: 18px;
    color: var(--good);
  }
  .toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c1717;
    color: var(--fg);
    border: 1px solid #5a2828;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 200;
  }
  .toast.show { opacity: 1; }

  /* Modal */
  .modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 18px;
  }
  .modal-bg.show { display: flex; }
  .modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 100%;
    max-width: 360px;
    padding: 22px 22px 26px;
    position: relative;
    max-height: 90dvh;
    overflow-y: auto;
  }
  .modal h2 {
    margin: 0 0 12px;
    font-size: 20px;
    text-align: center;
    letter-spacing: 0.4px;
  }
  .modal p { font-size: 14px; line-height: 1.5; color: var(--fg); margin: 6px 0; }
  .modal-help { text-align: center; }
  .modal-help h2 {
    margin-bottom: 6px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.5px;
  }
  .modal-help p {
    font-size: 15px;
    line-height: 1.55;
    padding: 0 6px;
    margin: 12px 0;
  }
  .modal-help p b { color: var(--accent); font-weight: 700; }
  .modal-help .footnote {
    color: var(--fg-dim);
    font-size: 13.5px;
    font-style: italic;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }
  .modal-help .help-start {
    display: none;
    width: 100%;
    margin-top: 16px;
    padding: 12px 0;
  }
  .help-moon-stage {
    display: flex;
    justify-content: center;
    margin: 14px 0 6px;
    position: relative;
  }
  .help-moon-stage::before {
    content: "";
    position: absolute;
    inset: -10px;
    background: radial-gradient(circle at center, rgba(168,197,230,0.18), rgba(168,197,230,0) 65%);
    pointer-events: none;
    z-index: 0;
  }
  .help-moon-stage canvas {
    width: 120px;
    height: 120px;
    background: #000;
    border-radius: 50%;
    position: relative;
    z-index: 1;
    box-shadow: inset 0 0 0 1px #1c1c24;
  }
  .modal small { color: var(--fg-dim); font-size: 12.5px; }
  .modal .close {
    position: absolute;
    top: 8px; right: 10px;
    background: transparent;
    border: 0;
    color: var(--fg-dim);
    font-size: 22px;
    cursor: pointer;
    width: 32px; height: 32px;
    border-radius: 50%;
  }
  .modal .close:hover { color: var(--fg); background: #22222a; }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 14px 0 8px;
  }
  .stat-card {
    background: #1d1d24;
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
  }
  .stat-card .val { font-size: 20px; font-weight: 700; }
  .stat-card .lbl { font-size: 10px; color: var(--fg-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

  .dist {
    margin-top: 10px;
  }
  .dist h3 {
    font-size: 12px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 6px;
  }
  .dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 13px;
  }
  .dist-row .num {
    width: 14px; text-align: right;
    color: var(--fg-dim);
  }
  .dist-row .bar {
    flex: 1;
    background: var(--input-bg);
    border-radius: 4px;
    overflow: hidden;
    height: 22px;
    display: flex;
    align-items: center;
  }
  .dist-row .bar-fill {
    background: #3a4a5e;
    height: 100%;
    min-width: 24px;
    text-align: right;
    padding-right: 8px;
    font-weight: 700;
    color: #8aadcc;
    font-size: 12px;
    line-height: 22px;
    transition: width 0.4s;
  }
  .dist-row .bar-fill.empty {
    background: #22222c;
    color: #55545a;
  }
  .dist-row .bar-fill.win-row {
    background: #2a5038;
    color: #7ecb9a;
  }

  .help-section {
    background: #1d1d24;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 10px;
  }
  .help-section .row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin: 4px 0;
  }
  .help-section .row .lbl { color: var(--fg); }
  .help-section .row .dist { color: var(--fg-dim); }

  .end-moon {
    background: #000;
    border-radius: 12px;
    margin: 12px auto;
    width: 200px; height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .end-moon canvas { width: 180px; height: 180px; }

  .end-result {
    text-align: center;
    margin-top: 6px;
  }
  .end-result .ans {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.5px;
  }
  .end-result .phase {
    font-size: 15px;
    color: var(--fg);
    margin-top: 4px;
    text-transform: capitalize;
  }
  .end-result .verdict {
    font-size: 17px;
    margin-top: 10px;
    font-weight: 600;
  }
  .end-result .verdict.win { color: var(--good); }
  .end-result .verdict.loss { color: var(--bad); }

  .game-over-locked {
    text-align: center;
    color: var(--fg-dim);
    font-size: 13px;
    margin-top: 10px;
    font-style: italic;
  }

  /* Phase rounds */
  .round-indicator {
    display: flex; align-items: center; gap: 8px; margin-top: 10px;
    justify-content: center; font-size: 13px; color: var(--fg-dim); letter-spacing: 0.3px;
  }
  .ri-step { padding: 3px 10px; border-radius: 20px; transition: background 0.2s, color 0.2s; }
  .ri-step.active { background: var(--accent); color: var(--accent-dark); font-weight: 700; }
  .ri-step.done { color: var(--fg); }
  .ri-sep { color: var(--border-strong); }
  .round-section { width: 100%; margin-top: 12px; }
  #round2-section { margin-top: 0; }
  #round3-section { margin-top: 12px; }
  .round-label {
    font-size: 13px; color: var(--fg-dim); text-align: center;
    margin-bottom: 8px; letter-spacing: 0.3px;
    display: flex; align-items: center; justify-content: center; gap: 5px;
  }
  .hint-btn {
    width: 15px; height: 15px; flex-shrink: 0;
    background: transparent; border: 1px solid var(--fg-dim);
    border-radius: 50%; color: var(--fg-dim); font-size: 9px;
    cursor: pointer; font-weight: 700; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
  }
  .hint-btn:hover { border-color: var(--accent); color: var(--accent); }
  .hint-modal { max-width: 300px; }
  .hint-modal h4 { font-size: 14px; font-weight: 700; margin: 0 0 6px; color: var(--fg); }
  .hint-modal p { font-size: 12px; color: var(--fg-dim); margin: 0 0 10px; line-height: 1.4; }
  .hint-examples { display: flex; gap: 10px; justify-content: center; margin-top: 2px; }
  .hint-examples + .hint-examples { margin-top: 8px; }
  .hint-example { display: flex; flex-direction: column; align-items: center; gap: 4px; }
  .hint-example canvas { background: #000; border-radius: 50%; }
  .hint-example span { font-size: 10px; color: var(--fg-dim); text-align: center; }
  .phase-btns { display: grid; gap: 8px; width: 100%; }
  .phase-btns.grid-2x2 { grid-template-columns: 1fr 1fr; }
  .phase-btn {
    background: var(--card); border: 1px solid var(--border); color: var(--fg);
    border-radius: 10px; padding: 14px 10px; font-size: 15px; font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
    letter-spacing: 0.3px;
  }
  .phase-btn:hover:not(:disabled) { background: var(--input-bg); border-color: var(--border-strong); }
  .phase-btn:active:not(:disabled) { transform: scale(0.97); }
  .phase-btn.correct { background: #162b1c; border-color: var(--good); color: var(--good); }
  .phase-btn.incorrect { background: #2b1616; border-color: var(--bad); color: var(--bad); }
  .phase-btn:disabled { cursor: default; opacity: 1; }
  .share-btn {
    display: block; width: 100%; margin-top: 16px;
    padding: 10px 0; border: none; border-radius: 8px;
    background: var(--accent); color: #0d0d12;
    font-size: 15px; font-weight: 700; cursor: pointer;
    letter-spacing: 0.4px; transition: opacity 0.15s;
  }
  .share-btn:hover { opacity: 0.85; }
  .share-btn:active { transform: scale(0.97); }
  .bonus-btn {
    display: block;
    width: 100%;
    min-height: 42px;
    margin-top: 16px;
  }
  .bonus-answered-row {
    text-align: center;
    color: var(--good);
    font-size: 13px;
    font-weight: 700;
    margin-top: 14px;
  }
  .skip-msg { text-align: center; color: var(--fg-dim); font-size: 13px; font-style: italic; padding: 8px 0; }
  .lunar-wizard { text-align: center; margin-bottom: 2px; line-height: 1; }
  .stat-wizard-row { margin-top: 8px; background: #1d1d24; border-radius: 8px; padding: 10px; text-align: center; border: 1px solid rgba(251,191,36,0.28); }
  .stat-wizard-row .lbl { font-size: 10px; color: var(--fg-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
  .badge-count-display { display: flex; align-items: center; justify-content: center; gap: 10px; }
  .badge-count-display img { display: block; }
  .badge-xcount { font-size: 26px; font-weight: 800; color: #fbbf24; line-height: 1; }
  .lunar-wizard-label {
    text-align: center; color: #f0c040; font-size: 13px; font-weight: 700;
    letter-spacing: 0.6px; margin-bottom: 10px; text-transform: uppercase;
  }
  #badge-subtitle {
    color: #a8c5e6; font-size: 12px; font-weight: 400;
    text-transform: none; letter-spacing: 0.2px; margin-top: 14px;
  }

  /* Reduced motion */
  .visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }
  @media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
  }
