  @import url("https://fonts.googleapis.com/css2?family=Oswald:wght@300;400;500;600;700&display=swap");

  :root {
    --bg: #17120e; --panel: #211a14; --text: #f6eee2; --muted: #a8977f;
    --accent: #ff9f1c; --good: #46e6a0; --warn: #ffd23f; --bad: #ff5d6c; --line: #332a20;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; height: 100%; }
  body {
    background: radial-gradient(1200px 700px at 50% -10%, #2a201a 0%, var(--bg) 60%);
    color: var(--text); font-family: "Oswald", system-ui, sans-serif;
    min-height: 100%; display: flex; flex-direction: column; align-items: center;
    padding: 1rem; overflow-x: hidden;
  }
  a { color: var(--accent); text-decoration: none; font-weight: 600; }
  .back-link { align-self: flex-start; font-size: 0.95rem; opacity: 0.85; position: relative; z-index: 30; }
  .wrap { width: 100%; max-width: 520px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }

  header.top { text-align: center; margin: 0.6rem 0 0.4rem; }
  header.top h1 { font-size: 1.9rem; font-weight: 900; margin: 0; letter-spacing: -0.02em; }
  header.top p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }

  /* HUD */
  .hud { display: flex; gap: 0.6rem; margin: 0.9rem 0 0.2rem; }
  .stat { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0.55rem 0.7rem; text-align: center; }
  .stat .label { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
  .stat .value { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 1px; }

  /* Budget meter */
  .budget { margin: 0.9rem 0 0.2rem; }
  .budget .row { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.32rem; }
  .budget .row b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 700; }
  .meter { height: 14px; background: #120d09; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
  .meter > span { display: block; height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--good), var(--warn) 70%, var(--bad)); transition: width 0.45s cubic-bezier(.2,.8,.2,1); }

  /* Main stage */
  .stage { position: relative; flex: 1; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin-top: 0.6rem; }
  .target-line { color: var(--muted); font-size: 0.95rem; font-weight: 600; letter-spacing: 0.02em; min-height: 1.2em; }
  .target-big { font-size: 3.6rem; font-weight: 900; line-height: 1; letter-spacing: -0.03em; margin: 0.15rem 0 0.1rem; }
  .target-big small { font-size: 1.4rem; font-weight: 800; color: var(--muted); }
  .sub { color: var(--muted); font-size: 0.85rem; min-height: 1.2em; text-align: center; padding: 0 0.5rem; }

  .btn-main {
    margin-top: 1.3rem; width: 200px; height: 200px; border-radius: 50%;
    border: none; cursor: pointer; font-family: inherit; font-weight: 900;
    font-size: 1.7rem; letter-spacing: 0.06em; color: #2a1500;
    background: radial-gradient(120px 120px at 50% 35%, #ffc46b, var(--accent));
    box-shadow: 0 12px 40px -10px rgba(255,159,28,0.55), inset 0 -6px 18px rgba(0,0,0,0.25);
    transition: transform 0.08s ease, filter 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    user-select: none; touch-action: manipulation;
  }
  .btn-main:active { transform: scale(0.96); }
  .btn-main.stop { color: #1a0608; background: radial-gradient(120px 120px at 50% 35%, #ff97a3, var(--bad)); box-shadow: 0 12px 40px -10px rgba(255,93,108,0.6), inset 0 -6px 18px rgba(0,0,0,0.25); }
  .btn-main.counting { animation: pulse 1.1s ease-in-out infinite; }
  .btn-main:disabled { opacity: 0.45; cursor: default; filter: grayscale(0.4); animation: none; }
  @keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.045); } }

  /* Result readout */
  .result { min-height: 4.2rem; text-align: center; margin-top: 0.4rem; }
  .result .you { font-size: 2.1rem; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
  .result .delta { font-size: 1rem; font-weight: 700; margin-top: 0.1rem; }

  /* Big center overlay (countdown / game over) */
  .overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(8,10,16,0.82); backdrop-filter: blur(3px); z-index: 20; padding: 1rem; }
  .overlay.show { display: flex; }

  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 1.6rem 1.4rem; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 24px 60px -20px rgba(0,0,0,0.7); }
  .card h2 { margin: 0 0 0.3rem; font-size: 1.9rem; font-weight: 900; }
  .card p { color: var(--muted); margin: 0.35rem 0; line-height: 1.5; font-size: 0.92rem; }
  .card .big { font-size: 3rem; font-weight: 900; margin: 0.4rem 0 0.1rem; }
  .card .big small { font-size: 1.1rem; color: var(--muted); font-weight: 700; }
  .bust { background: #1b1016; border: 1px solid #3a1f28; border-radius: 12px; padding: 0.7rem 0.8rem; font-size: 0.85rem; color: #ffb3bd; margin: 0.8rem 0; font-variant-numeric: tabular-nums; }
  .rules { text-align: left; font-size: 0.86rem; color: var(--muted); line-height: 1.55; margin: 0.6rem 0 1rem; }
  .rules li { margin: 0.25rem 0; }
  .btn {
    cursor: pointer; background: var(--accent); color: #2a1500; border: none; border-radius: 10px;
    padding: 0.8rem 1.6rem; font-family: inherit; font-size: 1.05rem; font-weight: 800;
    transition: filter 0.15s ease, transform 0.08s ease;
  }
  .btn:hover { filter: brightness(1.08); }
  .btn:active { transform: scale(0.97); }
  .btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 700; font-size: 0.9rem; padding: 0.6rem 1rem; }

  /* mode picker on the start card */
  .modepick { display: flex; gap: 0.5rem; margin: 0.2rem 0 1rem; }
  .modebtn { flex: 1; cursor: pointer; background: #1a140e; border: 1px solid var(--line); color: var(--muted); border-radius: 10px; padding: 0.65rem 0.5rem; font-family: inherit; font-weight: 800; font-size: 0.95rem; transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease; }
  .modebtn.sel { border-color: var(--accent); color: var(--text); background: #2e2212; }
  .modebtn small { display: block; font-weight: 500; font-size: 0.68rem; color: var(--muted); margin-top: 2px; line-height: 1.3; }

  .footer-controls { display: flex; gap: 0.6rem; align-items: center; justify-content: center; margin: 0.8rem 0 0.4rem; }
  .mute { cursor: pointer; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 0.35rem 0.6rem; font-size: 1rem; }
  .mode-pill { font-size: 0.78rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.7rem; }
  .hint { color: var(--muted); font-size: 0.78rem; text-align: center; margin-top: 0.2rem; }
  .hidden { display: none !important; }
  /* Accessibility: honor prefers-reduced-motion — neutralize animations,
   transitions, and motion effects (pulse, shake, drop, blink, glows). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
