:root {
  --bg: #f3ede2; --paper: #fbf8f2; --ink: #1d2a5b; --ink2: #4a5482; --muted: #736b5c;
  --red: #e8553d; --green: #1f8a70; --line: #e6dfd2;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
button { font: inherit; cursor: pointer; border: 0; }
[hidden] { display: none !important; }

.app {
  height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
}
.top { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.brand b { color: var(--red); }
.num { font-size: 16px; font-weight: 600; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.icon { width: 36px; height: 36px; border-radius: 18px; background: var(--paper); color: var(--ink); font-weight: 800; font-size: 18px; }
.sub { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.dots { display: flex; gap: 6px; }
.dot { width: 22px; height: 22px; border-radius: 6px; background: var(--line); transition: background 0.2s, transform 0.2s; }
.dot.fail { background: var(--red); }
.dot.win { background: var(--green); transform: scale(1.12); }
.lname { font-size: 14px; font-weight: 700; color: var(--muted); }

.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; container-type: size; }
#board {
  width: min(100cqw, 62.5cqh); height: auto; aspect-ratio: 400 / 640; border-radius: 18px; background: var(--paper);
  box-shadow: 0 10px 30px rgba(29, 42, 91, 0.1); touch-action: none; display: block;
}
.toast {
  position: absolute; left: 50%; top: 16px; transform: translate(-50%, -10px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px; font-weight: 700; font-size: 15px;
  transition: opacity 0.2s, transform 0.2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.fail { background: var(--red); }
.toast.win { background: var(--green); }

.bar { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.ink { flex: 1; display: flex; align-items: center; gap: 8px; }
.inklab { font-size: 12px; font-weight: 800; color: var(--muted); letter-spacing: 0.08em; }
.inkbar { flex: 1; min-width: 60px; height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; }
.inkfill { display: block; width: 100%; height: 100%; background: var(--ink); border-radius: 6px; transform-origin: left center; }
.inkpct { width: 40px; text-align: right; font-size: 13px; font-weight: 700; color: var(--ink2); font-variant-numeric: tabular-nums; }
.btns { display: flex; gap: 8px; }
.btn { white-space: nowrap; height: 46px; padding: 0 18px; border-radius: 23px; font-weight: 800; font-size: 16px; letter-spacing: 0.02em; }
.btn.primary { background: var(--red); color: #fff; }
.btn.ghost { background: var(--paper); color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.wide { width: 100%; margin-top: 16px; }

.modal { position: fixed; inset: 0; background: rgba(29, 42, 91, 0.35); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.card { position: relative; width: 100%; max-width: 380px; background: var(--paper); border-radius: 22px; padding: 24px 22px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.card h2 { font-size: 24px; font-weight: 800; text-align: center; }
.steps { margin: 16px 0 0 20px; display: grid; gap: 10px; font-size: 16px; line-height: 1.4; }
.g { color: var(--green); } .r { color: var(--red); }
.note { margin-top: 14px; font-size: 14px; color: var(--muted); line-height: 1.45; }
.close { position: absolute; right: 12px; top: 12px; background: var(--bg); font-size: 22px; }
.squares { display: flex; justify-content: center; gap: 8px; margin: 16px 0 8px; }
.sq { width: 34px; height: 34px; border-radius: 9px; }
.sq.fail { background: var(--red); } .sq.win { background: var(--green); }
.score { text-align: center; font-weight: 700; font-size: 17px; }
.today { text-align: center; font-size: 13px; color: var(--muted); min-height: 18px; margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 14px; text-align: center; }
.stats b { display: block; font-size: 22px; font-weight: 800; }
.stats span { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.share-text { width: 100%; margin-top: 10px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); font: 13px ui-monospace, monospace; color: var(--ink); background: #fff; user-select: text; }
.next { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.next b { color: var(--ink); font-variant-numeric: tabular-nums; }
.support { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; }
.support p { font-size: 13px; color: var(--muted); }
.kofi {
  display: inline-block; margin-top: 8px; padding: 9px 16px; border-radius: 20px; background: #fff2ea; color: #b8431f;
  font-weight: 800; font-size: 14px; text-decoration: none; border: 1px solid #f6cdb8;
}
.madeby { margin-top: 12px; text-align: center; font-size: 13px; color: var(--muted); }
.madeby a { color: #b8431f; font-weight: 700; text-decoration: none; }
