:root {
  --bg: #fbf6ee; --card: #fffaf3; --ink: #2b2530; --muted: #8a7f8c; --line: #e6dccd;
  --cell: #fff; --given: #f1e8da; --accent: #ff8a5c; --good: #3dbb82; --bad: #e5484d; --bad-bg: #ffe3e3;
  --hint: #ffe39a; --shadow: 0 6px 24px rgba(60, 40, 20, .08);
  --size: min(94vw, 58dvh, 440px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1820; --card: #26212b; --ink: #f3ecf5; --muted: #a59aa8; --line: #3a3340; --cell: #2d2733; --given: #3a3340;
    --bad-bg: #4a2327; --hint: #5b4a1c; --shadow: 0 6px 24px rgba(0, 0, 0, .35); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
button:disabled { cursor: not-allowed; opacity: .4; }
.app { max-width: 480px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 100dvh; }
.top { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 26px; letter-spacing: -.5px; }
.logo { width: 30px; height: 30px; }
.top-btns { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--card); }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn[aria-pressed="false"] { color: var(--muted); }
.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs button { padding: 6px 20px; border-radius: 999px; color: var(--muted); min-height: 36px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.status { display: flex; gap: 14px; align-items: center; min-height: 24px; font-variant-numeric: tabular-nums; color: var(--muted); }
.timer { font-weight: 600; color: var(--ink); }
.streak { color: var(--accent); font-weight: 700; animation: pop .35s; }
.day-streak { font-size: 14px; }
.msg-line { min-height: 36px; display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; font-weight: 600; }
.msg-line .m { animation: rise .4s both; max-width: 100%; }
.msg-line .m.good { color: var(--good); }
.msg-line .m.bad { color: var(--bad); }
.msg-line .m.hint { font-weight: 500; background: var(--hint); padding: 6px 12px; border-radius: 12px; font-size: 15px; }
.pill { background: var(--bad); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 14px; min-height: 32px; }
.board-wrap { position: relative; width: var(--size); height: var(--size); }
.board { position: absolute; inset: 0; display: grid; grid-template: repeat(6, 1fr) / repeat(6, 1fr); gap: 4px; padding: 4px; background: var(--line); border-radius: 18px; box-shadow: var(--shadow); touch-action: manipulation; }
.cell { position: relative; background: var(--cell); border-radius: 10px; display: grid; place-items: center; padding: 0; min-width: 0; min-height: 0; transition: background .15s; }
.cell:hover:not(.given):not(:disabled) { background: var(--card); }
.cell.given { background: var(--given); cursor: default; }

.cell svg { width: 82%; height: 82%; stroke: none; }
.cell.put svg { animation: pop .3s; }
.cell.hinted { background: var(--hint); animation: pulse 1s 2; }
.cell.bad { background: var(--bad-bg); box-shadow: inset 0 0 0 2.5px var(--bad); animation: shake .4s; }
.cell.blocked { animation: shake .35s; }
.cell:disabled { cursor: default; opacity: 1; }
.cell.given:disabled, .board.done .cell { cursor: default; }
.edges { position: absolute; inset: 0; pointer-events: none; }
.edge { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--card); border: 2px solid var(--line); display: grid; place-items: center; font-size: 14px; font-weight: 800; line-height: 1; color: var(--ink); }
.fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.spark { position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--c, #ffb400); animation: spark .65s ease-out forwards; }
.rule-hint { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.rule-hint .mini { width: 16px; height: 16px; vertical-align: -3px; stroke: none; }
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 66px; min-height: 52px; padding: 6px 8px; border-radius: 14px; font-size: 12px; color: var(--muted); }
.ctl svg { width: 24px; height: 24px; color: var(--ink); }
.ctl:hover:not(:disabled) { background: var(--card); }
[hidden] { display: none !important; }
.sheet { border: 0; border-radius: 22px; padding: 0; background: var(--card); color: var(--ink); width: min(92vw, 400px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.sheet::backdrop { background: rgba(20, 12, 24, .5); }
.sheet-body { padding: 22px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.sheet h2 { margin: 0; font-size: 24px; }
.win-pets { display: flex; justify-content: center; gap: 6px; }
.win-pets svg { width: 64px; height: 64px; stroke: none; animation: hop 1s ease-in-out infinite alternate; }
.win-pets svg:last-child { animation-delay: .25s; }
.chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--bg); border-radius: 12px; padding: 8px 14px; font-weight: 700; }
.chip small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.badges { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 0; }
.badge { background: var(--good); color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; }
.win-streak { margin: 0; color: var(--muted); }
.sheet-actions { display: flex; gap: 8px; justify-content: center; margin-top: 4px; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; min-height: 44px; cursor: pointer; }
.row small { display: block; color: var(--muted); font-size: 12px; }
.row input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.grid-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 3px; z-index: 50; pointer-events: none; animation: fall var(--d, 2.2s) ease-in forwards; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--hint); } }
@keyframes spark { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--x), var(--y)) scale(.2); opacity: 0; } }
@keyframes fall { to { transform: translate(var(--x, 0), 105vh) rotate(540deg); opacity: .9; } }
@keyframes hop { to { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
@media (max-height: 640px) { .rule-hint { display: none; } .tabs button { min-height: 32px; } }
