:root {
  --bg: #fbf3e6;
  --paper: #fffdf8;
  --ink: #4a2f22;
  --ink-soft: #8a6a58;
  --accent: #e2725b;
  --accent-ink: #ffffff;
  --line: #ecdcc6;
  --chip: #fff6ea;
  --chip-on: #4a2f22;
  --gold: #d9a520;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  font-weight: 500;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; max-width: 520px; margin: 0 auto;
}
.shop-name { font-weight: 700; letter-spacing: .08em; font-size: 14px; }
.zukan-btn {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; font-weight: 700;
}
.zukan-count { color: var(--accent); }

main { max-width: 520px; margin: 0 auto; padding: 0 16px 48px; }
.screen { animation: fadeUp .45s ease both; text-align: center; }
.title { font-size: 24px; font-weight: 900; margin: 12px 0 0; }
.title.small { font-size: 20px; }
.lead { color: var(--ink-soft); margin: 4px 0 8px; font-size: 14px; }
.note { color: var(--ink-soft); font-size: 12px; margin: 8px 0; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.primary-btn {
  display: block; width: 100%; margin: 16px 0 4px; padding: 16px;
  border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
  font-weight: 900; font-size: 17px; box-shadow: 0 4px 0 #b9533f;
  transition: transform .08s;
}
.primary-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9533f; }
.primary-btn:disabled { opacity: .45; }
.ghost-btn {
  margin-top: 8px; padding: 10px 16px; border-radius: 999px;
  border: 1px dashed var(--ink-soft); background: transparent; font-size: 14px;
}

/* ---------- cookie ---------- */
.cookie-stage { position: relative; width: 260px; height: 260px; margin: 8px auto 0; }
.cookie-btn {
  position: relative; width: 100%; height: 100%; padding: 0; border: 0; background: none;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.cookie-btn svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 10px 12px rgba(120, 70, 30, .25)); }
.cookie-btn.idle svg { animation: breathe 2.4s ease-in-out infinite; }
.cookie-btn.hit svg { animation: squish .18s ease; }
.cookie-btn.shake svg { animation: wobble .35s ease; }
.crack { fill: none; stroke: #6b3d1c; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; transition: stroke-dashoffset .2s ease; }
.half { transition: transform .7s cubic-bezier(.2, .9, .3, 1.2), opacity .7s; transform-origin: 120px 120px; }
.broken .half-left { transform: translate(-70px, 30px) rotate(-28deg); opacity: 0; }
.broken .half-right { transform: translate(70px, 30px) rotate(28deg); opacity: 0; }
.broken .crack { opacity: 0; }
.paper {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 120px;
  transform: translate(-50%, -50%) scaleY(.1); opacity: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  writing-mode: vertical-rl; font-weight: 900; font-size: 14px; letter-spacing: .2em;
  transition: transform .6s .25s cubic-bezier(.2, .9, .3, 1.3), opacity .3s .25s;
}
.broken .paper { transform: translate(-50%, -50%) scaleY(1); opacity: 1; }
.crumbs { position: absolute; inset: 0; pointer-events: none; }
.crumb { position: absolute; width: 8px; height: 8px; border-radius: 40%; background: #d69b55; animation: crumb .7s ease-out forwards; }
.spark { position: absolute; font-size: 18px; animation: crumb .9s ease-out forwards; }
.meter { width: 200px; height: 10px; margin: 8px auto 0; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { width: 0; height: 100%; background: linear-gradient(90deg, #f2c46d, var(--accent)); transition: width .2s; }
.combo { font-weight: 900; font-size: 18px; min-height: 1.7em; margin: 6px 0 0; }
.combo.pop { animation: pop .3s ease; }

/* ---------- result ---------- */
.slip {
  position: relative; margin-top: 12px; padding: 24px 20px 20px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 8px 24px rgba(120, 70, 30, .1);
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 14px 14px;
}
.slip.r-SR { box-shadow: 0 0 0 3px #c9b1f0, 0 8px 24px rgba(120, 70, 30, .1); }
.slip.r-SSR { box-shadow: 0 0 0 3px var(--gold), 0 0 30px rgba(217, 165, 32, .45); animation: glow 2s ease-in-out infinite; }
.rank { margin: 0; font-size: 34px; font-weight: 900; color: var(--accent); letter-spacing: .1em; }
.chara-wrap { position: relative; width: 140px; margin: 8px auto; }
.chara {
  flex: none; padding: 0; width: 140px; height: 140px; aspect-ratio: 1; border-radius: 50%; border: 0; font-size: 72px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .08);
}
.chara svg, .chara img { width: 124px; height: 124px; display: block; object-fit: contain; }
.chara.boing { animation: boing .45s ease; }
.rarity {
  position: absolute; right: -8px; top: 0; padding: 0 10px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 900;
}
.rarity.SSR { background: linear-gradient(90deg, #d9a520, #f7e08a, #d9a520); color: var(--ink); }
.rarity.SR { background: #8c6bd1; }
.rarity.R { background: #4d9a8a; }
.bubble {
  position: absolute; left: 50%; top: calc(100% - 18px); z-index: 2; transform: translateX(-50%); width: max-content; max-width: 240px;
  margin: 0; padding: 6px 12px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.bubble.show { opacity: 1; }
.chara-name { margin: 4px 0 0; font-size: 22px; font-weight: 900; }
.product-name { margin: 0; color: var(--ink-soft); font-size: 13px; }
.fortune { margin: 12px 0; font-size: 16px; text-align: left; }
.lucky { display: flex; gap: 8px; margin: 0; }
.lucky div { flex: 1; background: var(--chip); border-radius: 12px; padding: 8px; }
.lucky dt { font-size: 11px; color: var(--ink-soft); }
.lucky dd { margin: 0; font-weight: 700; }
.new-badge { margin: 12px 0 0; font-weight: 900; color: var(--accent); animation: pop .4s ease .3s both; }

/* ---------- survey ---------- */
.progress { height: 6px; background: var(--line); border-radius: 999px; margin: 8px 0 12px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.cards { padding-bottom: 28vh; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  animation: grow .4s cubic-bezier(.2, .9, .3, 1.1) both; transform-origin: top center;
}
.card.done { padding: 10px 16px; cursor: pointer; }
.card.done .q { font-size: 13px; color: var(--ink-soft); }
.card.ai { border-color: #c9b1f0; }
.card .ai-tag { display: inline-block; font-size: 11px; font-weight: 900; color: #8c6bd1; margin-bottom: 2px; }
.card.shop { border-style: dashed; }
.q { margin: 0; font-weight: 700; font-size: 16px; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 8px 14px;
  font-size: 14px; transition: transform .1s, background .15s;
}
.chip:active { transform: scale(.94); }
.chip[aria-pressed="true"] { background: var(--chip-on); color: #fff; border-color: var(--chip-on); }
.card p { margin: 0; }
.answer { margin-top: 2px; font-weight: 700; }
.card textarea, #review {
  width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; font: inherit; color: var(--ink); font-size: 16px; resize: vertical;
}
.card-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.next-btn { border: 0; border-radius: 999px; background: var(--accent); color: #fff; padding: 8px 18px; font-weight: 700; }
.next-btn:disabled { opacity: .4; }
.skip-btn { border: 0; background: none; color: var(--ink-soft); font-size: 13px; }
.thinking { color: #8c6bd1; font-size: 13px; padding: 4px 4px 0; animation: blink 1s ease-in-out infinite; }
.grow {
  position: sticky; bottom: 12px; margin-top: 16px; padding: 12px 16px; text-align: left;
  background: rgba(255, 253, 248, .96); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 6px 20px rgba(120, 70, 30, .12); max-height: 24vh; overflow: auto;
}
.grow-label { margin: 0; font-size: 12px; font-weight: 900; color: var(--accent); }
.grow-text { margin: 4px 0 0; font-size: 14px; }
.grow-text.bump { animation: pop .3s ease; }

/* ---------- finish ---------- */
.deep {
  margin-top: 12px; padding: 16px; border-radius: 20px; text-align: left;
  background: linear-gradient(135deg, #fff3d6, #fde3e3); border: 1px solid var(--line);
  animation: pop .5s ease both;
}
.deep h3 { margin: 0 0 4px; font-size: 16px; }
.deep p { margin: 0; font-size: 14px; }
.deep h3 { font-size: 17px; text-align: center; margin-bottom: 8px; }
.ft-type { font-weight: 900; font-size: 15px !important; }
.ft-line { margin-top: 2px !important; }
.ft-rows { display: grid; gap: 8px; margin: 12px 0; }
.ft-row { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; align-items: center; background: rgba(255,255,255,.6); border-radius: 12px; padding: 8px 10px; }
.ft-label { font-weight: 900; font-size: 13px; }
.ft-stars { color: var(--accent); letter-spacing: 1px; text-align: right; }
.ft-text { grid-column: 1 / -1; font-size: 13px !important; margin-top: 2px !important; }
.ft-lucky { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 10px; }
.ft-lucky div { background: rgba(255,255,255,.6); border-radius: 12px; padding: 6px 10px; }
.ft-lucky dt { font-size: 11px; color: var(--ink-soft); }
.ft-lucky dd { margin: 0; font-weight: 700; font-size: 13px; }
.ft-advice { font-size: 13px !important; padding: 8px 10px; border-left: 3px solid var(--accent); background: rgba(255,255,255,.5); border-radius: 0 10px 10px 0; }
.ft-next { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.ft-next-art { flex: none; width: 64px; height: 64px; }
.ft-next-art svg, .ft-next-art img { width: 64px; height: 64px; display: block; object-fit: contain; }
.ft-next p { font-size: 13px !important; font-weight: 700; }
.line-btn { display: block; margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: #06c755; color: #fff; font-weight: 700; font-size: 14px; text-align: center; text-decoration: none; }
.line-btn[hidden] { display: none; }
.text-link { display: block; margin: 6px auto 0; padding: 8px 12px; border: 0; background: none; color: var(--ink-soft); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.other-input { display: block; width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font: inherit; font-size: 16px; background: #fff; box-sizing: border-box; }
.other-input[hidden] { display: none; }
.chip.other { border-style: dashed; }
.count { margin: 2px 0 0; text-align: right; font-size: 12px; color: var(--ink-soft); }
.steps { list-style: none; padding: 0; margin: 12px 0; text-align: left; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.steps b { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 13px; }

/* ---------- zukan ---------- */
dialog {
  width: min(480px, calc(100vw - 32px)); border: 0; border-radius: 20px; padding: 20px;
  background: var(--paper); color: var(--ink); text-align: center;
}
dialog::backdrop { background: rgba(74, 47, 34, .45); }
dialog h2 { margin: 0; font-size: 20px; }
.zukan-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.zk { border-radius: 14px; background: var(--chip); padding: 8px 4px; font-size: 11px; line-height: 1.3; }
.zk .e { font-size: 32px; display: block; }
.zk .e svg, .zk .e img { width: 60px; height: 60px; display: block; margin: 0 auto; object-fit: contain; }
.zk.locked .e { filter: grayscale(1) brightness(0); opacity: .18; }
.zk .n { font-size: 10px; color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 40px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  transition: .25s; pointer-events: none; z-index: 10; max-width: calc(100vw - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- reward ---------- */
.reward { display: flex; gap: 12px; align-items: center; margin-top: 16px; padding: 12px 14px; text-align: left;
  background: var(--paper); border: 2px dashed var(--accent); border-radius: 18px; }
.reward-art { flex: none; width: 72px; height: 72px; }
.reward-art svg, .reward-art img { width: 72px; height: 72px; display: block; object-fit: contain; }
.reward-art.waiting svg, .reward-art.waiting img { filter: brightness(0); opacity: .25; animation: breathe 1.6s ease-in-out infinite; }
.reward-title { margin: 0; font-weight: 900; font-size: 14px; }
.reward-sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.ghost-btn.wide { display: block; width: 100%; margin-top: 4px; }

/* ---------- partner / evolve ---------- */
.partner {
  display: flex; gap: 12px; align-items: center; width: 100%; margin-top: 12px; padding: 12px 14px; text-align: left;
  background: var(--paper); border: 2px solid var(--accent); border-radius: 18px;
}
.partner-art { flex: none; width: 72px; height: 72px; }
.partner-art svg, .partner-art img { width: 72px; height: 72px; display: block; object-fit: contain; }
.partner-body { flex: 1; min-width: 0; }
.partner-label { margin: 0; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.partner-label b { color: var(--accent); margin-left: 6px; }
.partner-name { margin: 0; font-size: 17px; font-weight: 900; }
.partner-msg { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.dots { display: flex; gap: 4px; margin-top: 4px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.dots i:nth-child(3), .dots i:nth-child(7) { box-shadow: 0 0 0 2px var(--gold); }
.evolve {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; background: radial-gradient(circle, #fffdf8 0%, #fbe3c4 60%, #f3c58e 100%); text-align: center;
}
.evolve-art { width: 220px; height: 220px; }
.evolve-art svg, .evolve-art img { width: 100%; height: 100%; object-fit: contain; }
.evolve-art.flicker { animation: flicker .25s steps(2) 9; }
.evolve-art.flicker svg { filter: brightness(0) invert(1) drop-shadow(0 0 18px #fff); }
.evolve-art.pop { animation: pop .6s ease; }
.evolve-text { font-size: 18px; font-weight: 900; max-width: 320px; }
.evolve-btns { width: 100%; max-width: 360px; }
.zk-line { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.zk-line-name { grid-column: 1 / -1; margin: 4px 0 -4px; text-align: left; font-size: 11px; color: var(--ink-soft); }
@keyframes flicker { 50% { opacity: .2; transform: scale(1.06); } }

/* ---------- season ---------- */
.season-banner {
  display: inline-block; margin: 6px 0 0; padding: 4px 14px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; animation: pop .5s ease both;
}
.season-deco { position: absolute; inset: -20px; pointer-events: none; }
.season-deco span {
  position: absolute; font-size: 26px; opacity: .85;
  animation: floaty calc(3s + var(--i) * .4s) ease-in-out infinite alternate;
}
.zk-head { grid-column: 1 / -1; margin: 6px 0 0; text-align: left; font-weight: 900; font-size: 13px; }
.zk-head small { font-weight: 500; color: var(--ink-soft); font-size: 11px; }
.zk[data-wall] { cursor: pointer; }
.zk .n.now { color: var(--accent); font-weight: 900; }
body.theme-halloween { --bg: #fdeedd; --accent: #e8701c; --chip: #fff3e3; --line: #f0d4b4; }
body.theme-halloween .season-banner { background: linear-gradient(90deg, #5b2d8a, #e8701c); }
body.theme-christmas { --bg: #f6f3ee; --accent: #c8352e; --line: #e2d9cc; }
body.theme-christmas .season-banner { background: linear-gradient(90deg, #2f6b3a, #c8352e); }
@keyframes floaty { from { transform: translateY(0) rotate(-8deg); } to { transform: translateY(-14px) rotate(8deg); } }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 50% { transform: scale(1.03) rotate(-2deg); } }
@keyframes squish { 40% { transform: scale(1.08, .9); } 70% { transform: scale(.96, 1.04); } }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes crumb { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }
@keyframes pop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes boing { 30% { transform: scale(1.15, .85); } 60% { transform: scale(.9, 1.1) translateY(-10px); } }
@keyframes glow { 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 50px rgba(217, 165, 32, .7); } }
@keyframes grow { from { opacity: 0; transform: scaleY(.6) translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: .4; } }

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

/* ---------- photos ---------- */
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ph { position: relative; width: 88px; height: 88px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(74,47,34,.75); color: #fff; font-size: 14px; line-height: 24px; padding: 0; }
.photo-add { display: inline-block; margin-top: 10px; padding: 10px 16px; border-radius: 999px; border: 1px dashed var(--accent); color: var(--accent); font-weight: 700; font-size: 14px; cursor: pointer; }
.photo-box { margin-top: 12px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; text-align: left; }
.photo-note { margin: 0; font-size: 13px; font-weight: 700; }
#copyOpen { font-size: 15px; padding: 16px 8px; white-space: nowrap; }
.card-actions[hidden], .next-btn[hidden] { display: none; }
.friend-tip { margin: 8px 0 0; padding: 10px 12px; border-radius: 14px; background: #e9f9ef; border: 1px solid #b7e8c8; font-size: 13px; text-align: left; }
.friend-tip a { display: inline-block; margin-top: 6px; padding: 6px 12px; border-radius: 999px; background: #06c755; color: #fff; font-weight: 700; text-decoration: none; }
.friend-tip[hidden] { display: none; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 0; padding: 10px 12px; border-radius: 14px; background: var(--paper); border: 1px solid var(--line); text-align: left; font-size: 13px; }
.consent[hidden] { display: none; }
.consent input { flex: none; width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); }
.consent small { display: block; margin-top: 2px; color: var(--ink-soft); font-size: 11px; }
.chip-group { flex-basis: 100%; margin: 6px 0 -2px; font-size: 12px; font-weight: 700; color: var(--ink-soft); text-align: left; }
.chip-group:first-child { margin-top: 0; }
