/* Cắt Duyên Âm — Đông Hồ woodblock look: điệp paper, flat pigments, thick ink. */
:root {
  --paper: #f4e6c8;
  --paper-2: #fbf3e1;
  --card: #fffaf0;
  --ink: #2a1f1a;
  --text: #2a1f1a;
  --text-dim: #5c4a3e;
  --muted: #8a7766;
  --son: #c8352b;
  --hoe: #e7ad1f;
  --cham: #2f6b5a;
  --hong: #f08ca0;
  --line: rgba(42, 31, 26, .22);
  /* aliases used by the ritual stages */
  --red: var(--son);
  --red-2: #e0574b;
  --pink: var(--hong);
  --gold: var(--hoe);
  --gold-text: #8f6200;
  --jade: var(--cham);
  --lav: #6f5fb8;
  --thread: var(--ink);
  --surface: var(--card);
  --surface-2: var(--paper-2);
  --radius: 10px;
  --display: 'Baloo 2', 'Be Vietnam Pro', system-ui, sans-serif;
  --hand: 'Patrick Hand', 'Be Vietnam Pro', system-ui, sans-serif;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  position: relative;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 40px);
  -webkit-tap-highlight-color: transparent;
  /* giấy điệp: fibre noise + shell flecks */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .32 0 0 0 0 .15 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(rgba(255, 255, 255, .75) .8px, transparent 1.4px) 0 0 / 13px 13px,
    radial-gradient(rgba(255, 255, 255, .5) .8px, transparent 1.4px) 6px 7px / 19px 19px,
    var(--paper);
}
[hidden] { display: none !important; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--hoe); outline-offset: 2px; }

/* the patterned ribbon across the top of every page */
.bg {
  position: absolute; top: 0; left: 0; right: 0; height: 16px; pointer-events: none;
  border-bottom: 2.5px solid var(--ink);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='16'%3E%3Crect width='24' height='16' fill='%23c8352b'/%3E%3Cpath d='M12 2 L19 8 L12 14 L5 8 Z' fill='%23e7ad1f' stroke='%232a1f1a' stroke-width='1.3'/%3E%3C/svg%3E") repeat-x;
}

.screen { max-width: 600px; margin: 0 auto; padding-top: 12px; }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1; font-weight: 800; }
h1 { font-size: clamp(44px, 13vw, 76px); letter-spacing: -.01em; color: var(--ink); text-shadow: 4px 4px 0 var(--hoe); }
.center { text-align: center; }
.lore { color: var(--text-dim); margin: 14px 0 0; max-width: 62ch; }
.lore b { color: var(--son); font-weight: 700; }
.fineprint { color: var(--muted); font-size: 12.5px; margin: 22px 0 0; }
small { color: var(--muted); font-weight: 400; }
.section-title { font-size: 26px; margin: 34px 0 8px; display: flex; align-items: center; gap: 10px; }
.section-title::before {
  content: ''; flex: none; width: 46px; height: 25px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-2 0 64 32'%3E%3Cpath d='M6 28 Q0 28 2 21 Q4 15 11 17 Q12 8 21 9 Q26 2 34 6 Q42 3 45 11 Q54 10 54 19 Q60 22 56 28 Z' fill='%23fffaf0' stroke='%232a1f1a' stroke-width='2.4' stroke-linejoin='round'/%3E%3Cpath d='M14 23 Q13 18 18 18 Q21 19 19 22 M30 15 Q31 10 36 11 Q39 14 36 16 M42 24 Q42 20 46 20' fill='none' stroke='%232a1f1a' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- surfaces ---------- */
.card {
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 22px;
  box-shadow: 5px 5px 0 var(--ink);
}

.btn {
  font: 700 15px/1 var(--sans);
  color: var(--ink);
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  padding: 13px 20px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, opacity .2s;
  touch-action: manipulation;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--son); color: #fff8e8; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 8px 13px; font-size: 13px; }
.link { background: none; border: 0; color: var(--text-dim); font: 600 15px var(--sans); cursor: pointer; padding: 6px 0; }

input:not([type=checkbox]), textarea {
  width: 100%;
  font: 500 16px var(--sans);
  color: var(--text);
  background: #fffdf7;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 10px 13px;
  margin-top: 6px;
}
input:focus, textarea:focus { outline: 3px solid var(--hoe); outline-offset: 1px; }

.bubble {
  position: absolute; z-index: 3; margin: 0; pointer-events: none;
  background: #fffdf7; color: var(--ink); border: 2.5px solid var(--ink); border-radius: 12px;
  font: 400 18px/1.15 var(--hand); padding: 7px 11px; box-shadow: 3px 3px 0 var(--ink);
  width: max-content; max-width: min(220px, 56vw);
}
.bubble::after {
  content: ''; position: absolute; width: 11px; height: 11px; background: #fffdf7;
  border: solid var(--ink); border-width: 0 2.5px 2.5px 0; bottom: -7.5px; left: var(--tail, 70%); transform: rotate(45deg);
}

/* ---------- intro ---------- */
.hero { position: relative; }
.hero-art { display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; cursor: pointer; }
.scene { display: block; width: 100%; height: auto; }
.art-wrap { position: relative; }
.hero-say { top: 0; left: 0; max-width: 42%; --tail: 80%; }
.hero h1 { font-size: clamp(40px, 11.5vw, 76px); margin-top: 22px; }
.seal {
  position: absolute; right: 10px; bottom: -16px; transform: rotate(-6deg);
  background: var(--son); color: #fff6e0; border-radius: 6px; padding: 7px 8px;
  font: 800 15px/1.02 var(--display); text-align: center;
  box-shadow: inset 0 0 0 2px var(--son), inset 0 0 0 3.5px #fff6e0, 3px 3px 0 var(--ink);
}
.title-thread { display: block; width: min(100%, 400px); height: auto; margin-top: 4px; }

.setup { display: flex; gap: 16px; align-items: stretch; flex-wrap: wrap; }
.photo-pick {
  flex: 0 0 120px; height: 150px; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 2.5px dashed var(--ink); display: grid; place-items: center; text-align: center;
  color: var(--son); font-size: 13px; line-height: 1.4; background: var(--paper-2);
}
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.fields { flex: 1 1 220px; display: flex; flex-direction: column; gap: 12px; }
.fields label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.so-intro { flex: 1 1 100%; border-top: 2px dashed var(--line); padding-top: 12px; }
.so-intro summary { cursor: pointer; font-weight: 700; }
.so-intro .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-top: 8px; }
.submit-row { flex: 1 1 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
#so-count { font-size: 13px; color: var(--gold-text); font-weight: 700; }
.resume { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- altar ---------- */
.altar-top { display: flex; justify-content: space-between; align-items: center; }
.threads-left { font-size: 13px; color: var(--muted); }
.threads-left b { color: var(--text); }
.shrine { text-align: center; }
.shrine-box { position: relative; width: min(100%, 440px); aspect-ratio: 400 / 420; margin: 4px auto 0; }
.shrine-art, .shrine-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.portrait {
  position: absolute; left: 26.25%; top: 21.43%; width: 47.5%; aspect-ratio: 1;
  border-radius: 50%; overflow: hidden; border: 2.5px solid var(--ink);
  box-shadow: 0 0 0 7px var(--hoe), 0 0 0 9.5px var(--ink);
}
.portrait img, .portrait #portrait-initial {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: saturate(.5) sepia(.18);
  transition: filter .8s;
}
.portrait #portrait-initial { display: grid; place-items: center; background: #fbe3d6; font: 800 clamp(56px, 18vw, 90px) var(--display); color: var(--son); }
.portrait.freed img, .portrait.freed #portrait-initial { filter: none; }
/* tappable bronze bell in the courtyard: swings once per tap */
.shrine-art svg .temple-bell { cursor: pointer; transform-box: fill-box; transform-origin: 50% 0; outline: none; }
.shrine-art svg .temple-bell:focus-visible path { stroke: var(--son); }
.temple-bell.ring { animation: bell-swing 1.1s cubic-bezier(.3, .6, .4, 1); }
@keyframes bell-swing { 15% { transform: rotate(14deg); } 35% { transform: rotate(-10deg); } 55% { transform: rotate(6deg); } 75% { transform: rotate(-3deg); } }
#threads-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#threads-svg path { fill: none; stroke: var(--ink); stroke-width: 4.5; stroke-linecap: round; }
#threads-svg path.cut { stroke: var(--son); stroke-dasharray: 3 10; opacity: .55; }
.ghost-pal { position: absolute; left: 73.5%; top: 42.6%; width: 22.5%; background: none; border: 0; padding: 0; cursor: pointer; }
.ghost-pal .bubble { bottom: 100%; right: 0; margin-bottom: 10px; text-align: left; --tail: 72%; }
.ghost-svg { display: block; width: 100%; height: auto; overflow: visible; }
#altar-name { font-size: 40px; margin-top: 10px; text-shadow: 3px 3px 0 var(--hoe); }
.verdict { color: var(--text-dim); margin: 8px auto 0; font-size: 14px; max-width: 460px; }

.meter-row { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.meter-row b { font: 800 44px/1 var(--display); color: var(--son); }
.bar { height: 16px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--son) 0 8px, #df5a4d 8px 16px); border-right: 2px solid var(--ink); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter-note { color: var(--muted); font-size: 13px; margin: 10px 0 14px; }
.cut-btn { width: 100%; font-size: 17px; padding: 16px; }

.rituals { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.ritual {
  position: relative; text-align: left; cursor: pointer;
  background: var(--card); color: var(--text);
  border: 2.5px solid var(--ink); border-radius: var(--radius);
  padding: 12px; font: inherit; display: flex; flex-direction: column; gap: 3px;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.ritual:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.ritual.fresh { background: #fff1c4; }
.ritual .by { font-size: 12px; color: var(--cham); font-weight: 700; }
.ritual .ico {
  width: 52px; height: 52px; border-radius: 10px; display: grid; place-items: center; margin: 4px 0;
  font-size: 28px; line-height: 1; background: var(--tile, #f7dc8a); border: 2px solid var(--ink);
}
.ritual .nm { font-weight: 700; font-size: 14.5px; }
.ritual .og { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.ritual .gain { font-size: 12.5px; color: var(--cham); font-weight: 700; }
.ritual .gain.low { color: var(--muted); font-weight: 500; }
.ritual .cnt {
  position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 99px; background: var(--son); color: #fff; border: 2px solid var(--ink); font: 700 12px/20px var(--sans); text-align: center;
}

.so {
  position: relative; border-radius: 3px; margin: 18px 8px 12px; padding: 14px 16px;
  background: #fffbea repeating-linear-gradient(transparent 0 43px, rgba(231, 173, 31, .35) 43px 44px);
  box-shadow: none; border-width: 2px 2.5px;
}
.so::before, .so::after {
  content: ''; position: absolute; left: -12px; right: -12px; height: 16px; border-radius: 8px;
  background: linear-gradient(#b0713a, #7a4520); border: 2.5px solid var(--ink);
}
.so::before { top: -10px; }
.so::after { bottom: -10px; }
.so-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; min-height: 44px; }
.so-row input { margin: 0; padding: 7px 10px; font-size: 16px; } /* under 16px makes iOS zoom in on focus */
.so-k { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.so-v { font: 400 19px/1.1 var(--hand); color: var(--son); overflow-wrap: anywhere; }
.so-lock { font-size: 14px; }
@media (max-width: 420px) { .so-row { grid-template-columns: 1fr auto; } .so-row .so-k { grid-column: 1 / -1; margin-top: 6px; } }

.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.log li { font-size: 13.5px; color: var(--text-dim); padding-left: 12px; border-left: 4px solid var(--hoe); }
.log li.good { border-color: var(--cham); }
.log li.bad { border-color: var(--son); }
.log li:first-child { color: var(--text); }
.log time { color: var(--muted); font-size: 11px; margin-right: 6px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(42, 31, 26, .45);
  padding: 0 0 env(safe-area-inset-bottom);
  overscroll-behavior: contain;
}
.sheet {
  width: 100%; max-width: 560px; max-height: 94dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--card); border: 2.5px solid var(--ink); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 18px 16px 22px;
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 16px; border-bottom: 2.5px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); } }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; }
.sheet-head > div { flex: 1; }
.r-icon {
  font-size: 32px; line-height: 1; width: 58px; height: 58px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--tile, #f7dc8a); border: 2.5px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
#r-title { font-size: 25px; }
.r-origin { margin: 3px 0 0; color: var(--gold-text); font-size: 12.5px; font-weight: 700; }
.x { background: none; border: 0; color: var(--ink); font-size: 32px; line-height: 1; cursor: pointer; padding: 0 4px; }
.r-how { color: var(--text-dim); font-size: 14px; margin: 12px 0; }
.stage {
  position: relative; height: 280px; border-radius: var(--radius); overflow: hidden;
  background: var(--paper-2); border: 2.5px solid var(--ink);
  display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.progress { height: 12px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--cham); transition: width .2s; }
.r-status { min-height: 1.5em; margin: 10px 0 0; font-size: 14px; text-align: center; font-weight: 600; }
.r-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
/* press-and-hold buttons: a drifting finger must not turn into a scroll and cancel the hold */
.r-actions .btn { min-height: 48px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* stage bits */
.big-emoji { font-size: 96px; line-height: 1; transition: transform .2s; }
.stage-note { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--muted); }
.wood-shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.knock-fx { position: absolute; font: 800 30px var(--display); color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .5); pointer-events: none; animation: knock .7s ease-out forwards; }
@keyframes knock { to { transform: translateY(-40px) scale(1.3); opacity: 0; } }

.compass { position: relative; width: 220px; height: 220px; border-radius: 50%; border: 2px dashed var(--line); }
.compass .dir {
  position: absolute; width: 56px; height: 56px; margin: -28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: #fff; border: 2px solid var(--line); color: var(--text-dim);
  transition: background .3s, color .3s;
}
.compass .dir.near { border-color: var(--gold); color: var(--gold-text); }
.compass .dir.done { background: var(--gold); color: #fff; border-color: var(--gold); }

.blow-cloud { position: absolute; font-size: 34px; transition: transform .1s linear, opacity .1s linear; }
.level { position: absolute; left: 16px; right: 16px; bottom: 16px; height: 10px; border-radius: 99px; background: #fde8e0; overflow: hidden; }
.level i { display: block; height: 100%; width: 0; background: var(--jade); }

.grain { position: absolute; width: 5px; height: 5px; border-radius: 1px; background: #c9b896; animation: fall 1.2s ease-in forwards; }
@keyframes fall { to { transform: translate(var(--dx), 260px) rotate(180deg); opacity: 0; } }

.blocks { display: flex; gap: 22px; }
.block {
  width: 80px; height: 120px; border-radius: 80px 80px 20px 20px / 120px 120px 20px 20px;
  background: linear-gradient(160deg, #ff6b5b, #c7302a); box-shadow: inset 0 -10px 20px rgba(0, 0, 0, .2);
  transition: transform .6s cubic-bezier(.3, 1.6, .5, 1);
}
.block.flat { background: linear-gradient(160deg, #ffd27a, #e09a1a); box-shadow: inset 0 0 0 4px rgba(0, 0, 0, .08); }
.block.toss { animation: toss .7s ease-in-out; }
@keyframes toss { 40% { transform: translateY(-120px) rotate(380deg); } }
.keo-result { position: absolute; top: 14px; left: 0; right: 0; text-align: center; font: 800 20px var(--display); color: var(--red); }

.beads { position: relative; width: 240px; height: 240px; }
.bead {
  position: absolute; width: 26px; height: 26px; margin: -13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c79b6b, #6e4424); transition: transform .15s, box-shadow .2s;
}
.bead.on { background: radial-gradient(circle at 35% 30%, #ffe3a3, #e09a1a); box-shadow: 0 0 12px rgba(240, 168, 30, .7); }
.bead.cur { transform: scale(1.35); }
.beads .mid { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font: 800 44px var(--display); color: var(--text-dim); }

.incense { display: flex; gap: 26px; align-items: flex-end; height: 200px; }
.stick { position: relative; width: 5px; height: 170px; background: #8a5a3c; border-radius: 3px; }
.stick .burn { position: absolute; left: 0; right: 0; bottom: 30px; top: 0; background: #e2533f; transform-origin: bottom; transition: transform .2s linear; }
.stick .tip { position: absolute; left: -3px; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(#ffd27a, #e2533f 60%, transparent 70%); transition: bottom .2s linear; }
.stick .tip.out { background: #aaa; }
.smoke { position: absolute; left: -10px; width: 26px; height: 26px; border-radius: 50%; background: rgba(120, 110, 140, .18); filter: blur(4px); animation: smoke 2.4s linear infinite; }
@keyframes smoke { to { transform: translate(14px, -90px) scale(2.2); opacity: 0; } }

.coin {
  position: absolute; bottom: 30px; left: 50%; width: 64px; height: 64px; margin-left: -32px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8, #e0a92e 60%, #a8790f); box-shadow: 0 4px 0 #8a6414;
  display: grid; place-items: center; font: 800 18px var(--display); color: #7a560c; cursor: grab;
}
.fountain { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 160px; height: 60px; border-radius: 50%; background: radial-gradient(ellipse, #7fd0f0, #3b8fc0); box-shadow: inset 0 0 18px #1e5f88; }

.draw-wrap { position: relative; width: 240px; height: 240px; }
.draw-wrap img, .draw-wrap .face { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; position: absolute; left: 50px; top: 50px; }
.draw-wrap .face { display: grid; place-items: center; background: #ffe3ea; color: var(--red); font: 800 56px var(--display); }
.draw-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }

.clover-field { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 10px; width: 100%; }
.clover-field span { font-size: 30px; line-height: 1.3; text-align: center; cursor: pointer; transition: opacity .2s; }
.clover-field span.nope { opacity: .15; }
.clover-field span.found { animation: pop .45s; filter: drop-shadow(0 0 8px var(--jade)); }
@keyframes pop { 50% { transform: scale(2); } }

.thread-svg { width: 100%; height: 100%; touch-action: none; }
.thread-svg text { pointer-events: none; user-select: none; }

.fold { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.paper { width: 120px; height: 120px; background: linear-gradient(135deg, #ffd6e2, #ff9fbd); display: grid; place-items: center; font-size: 56px; transition: transform .3s, border-radius .3s; box-shadow: 0 8px 18px -10px rgba(150, 60, 80, .6); }
.folds { display: flex; gap: 6px; font: 700 22px var(--sans); color: var(--muted); }
.folds .cur { color: var(--red); transform: scale(1.3); }
.folds .ok { color: var(--jade); }

.fire { font-size: 90px; line-height: 1; padding-top: 40px; }
.fire span { display: inline-block; transform-origin: 50% 100%; }

.grapes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; font-size: 34px; padding-top: 30px; }
.grapes .eaten { opacity: .15; transform: scale(.6); transition: .2s; }

.night { position: absolute; inset: 0; background: radial-gradient(1.5px 1.5px at 20% 30%, #fff, transparent), radial-gradient(1.5px 1.5px at 70% 20%, #fff, transparent), radial-gradient(1.5px 1.5px at 40% 70%, #fff, transparent), radial-gradient(1.5px 1.5px at 85% 60%, #fff, transparent), linear-gradient(#2b2a6b, #6a4c9c 70%, #e58fb0); }
.star { position: absolute; font-size: 34px; background: none; border: 0; padding: 14px; cursor: pointer; line-height: 1; }
.star.got { filter: drop-shadow(0 0 12px var(--gold)); }

.tanzaku-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bamboo { font-size: 48px; }
.tanzaku { width: 120px; height: 190px; resize: none; border: 0; border-radius: 4px; padding: 12px 10px; font: 700 16px/1.45 var(--sans); user-select: text; -webkit-user-select: text; color: var(--text); text-align: center; margin: 0; }
.tanzaku.hang { animation: hang 1s ease-in-out forwards; }
@keyframes hang { to { transform: translateY(-60px) rotate(-6deg) scale(.6); } }

/* ---------- cut overlay ---------- */
#cut-modal { align-items: center; background: rgba(244, 230, 200, .96); }
.cut-stage { width: 100%; max-width: 420px; text-align: center; padding: 16px; }
.cut-hint { color: var(--text-dim); margin: 0 0 8px; font-weight: 600; }
#cut-svg { width: 100%; max-height: 60dvh; touch-action: none; user-select: none; -webkit-user-select: none; cursor: none; }
#cut-svg text { pointer-events: none; }
.cut-result { min-height: 3em; font: 800 22px/1.25 var(--display); margin: 8px 0 14px; }
.cut-result.ok { color: var(--cham); }
.cut-result.fail { color: var(--son); }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- done ---------- */
.farewell { position: relative; max-width: 520px; margin: 0 auto; }
.farewell .bubble { top: 0; left: 0; max-width: 54%; --tail: 80%; }
.done-title { text-align: center; font-size: clamp(40px, 11vw, 62px); margin-top: 14px; }
.share-card { width: 100%; height: auto; border-radius: var(--radius); margin-top: 20px; border: 2.5px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); background: var(--card); display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats .n { font: 800 34px/1.1 var(--display); color: var(--son); display: block; }
.stats .l { font-size: 12px; color: var(--muted); }
.stats .list { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.stats .chip { font-size: 12.5px; background: var(--paper-2); border-radius: 8px; padding: 4px 9px; border: 1.5px solid var(--ink); }
.stats .wish { grid-column: 1 / -1; font: 400 23px/1.3 var(--hand); color: var(--ink); margin: 12px 0 0; }
.share-box { display: flex; flex-direction: column; gap: 12px; }
.share-box .row { display: flex; gap: 10px; margin-top: 10px; }
.share-box .row .btn { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-dim); }
.check input { width: 18px; height: 18px; accent-color: var(--son); }
#new-btn { display: block; margin: 22px auto 0; }

/* confetti: one burst when the last thread snaps */
.confetti { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; display: block; border: 1.5px solid var(--ink); animation: confetti var(--dur) cubic-bezier(.3, .6, .6, 1) forwards; }
@keyframes confetti { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); } }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 24px); transform: translateX(-50%); z-index: 20; pointer-events: none;
  background: var(--ink); color: #fff8e8; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  box-shadow: 3px 3px 0 var(--hoe); max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- share page ---------- */
.share-page .details { margin-top: 18px; }
.share-page .cta { display: block; text-align: center; text-decoration: none; margin-top: 24px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
