:root {
  --ink: #3b2f2a;
  --ink-soft: #7b6a5f;
  --bg: #f5efe3;
  --paper: #ffffff;
  --line: #e9dfd0;
  --accent: #d9774a;
  --accent-dark: #a9532c;
  --leaf: #5f9f52;
  --leaf-dark: #437a39;
  --gold: #e5b53a;
  --font: "Zen Maru Gothic", system-ui, sans-serif;
  --hand: "Kiwi Maru", "Zen Maru Gothic", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 500; line-height: 1.7; line-break: strict;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%27120%27%20height%3D%27120%27%3E%3Cg%20fill%3D%27%23eadcc6%27%3E%3Cellipse%20cx%3D%2720%27%20cy%3D%2724%27%20rx%3D%274%27%20ry%3D%275%27%2F%3E%3Cellipse%20cx%3D%2788%27%20cy%3D%2776%27%20rx%3D%273.4%27%20ry%3D%274.4%27%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"); }
[hidden] { display: none !important; }
button { font-family: var(--font); }

.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 560px; margin: 0 auto; font-size: 13px; font-weight: 900; }
.g-brand { color: var(--ink-soft); text-decoration: none; }
.g-title { flex: 1; text-align: center; }
.g-head [data-mg-account] a { color: var(--accent-dark); text-decoration: none; }
main { max-width: 560px; margin: 0 auto; padding: 0 12px 24px; }

/* 看板 */
.sign { position: relative; background: var(--paper); border-radius: 18px; padding: 0 14px 12px; overflow: hidden; border-top: 6px solid var(--leaf); box-shadow: 0 8px 22px rgba(59, 47, 42, 0.08); }
.village { margin: 0 -14px 6px; line-height: 0; aspect-ratio: 400 / 185; overflow: hidden; }
.village svg { display: block; width: 100%; height: 100%; }
.sign-name { font: 500 21px/1.3 var(--hand); color: var(--leaf-dark); letter-spacing: 0.04em; }
.sign-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 2px; }
.acorn { font-weight: 900; }
.acorn .lbl { display: block; font-size: 11px; color: var(--ink-soft); }
.acorn b { font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counts { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; font-weight: 700; color: var(--ink-soft); line-height: 1.5; }
.counts b { color: var(--ink); font-variant-numeric: tabular-nums; }
.goal { margin-top: 8px; padding: 8px 10px; background: #fbf6ec; border-radius: 12px; }
.goal-text { margin: 0; font-size: 13px; font-weight: 900; }
.goal-text.tut { color: var(--accent-dark); }
.goal-text.tut::before { content: "はじめに　"; color: var(--ink-soft); font-size: 11px; }
.goal-sub { margin: 4px 0 0; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.visitor { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 8px; padding: 6px 12px 6px 6px; border: 2px solid var(--gold); border-radius: 14px; background: #fff8e4; color: var(--ink); text-align: left; cursor: pointer; animation: knock 1.6s ease-in-out infinite; }
.visitor svg { width: 56px; height: 56px; flex: none; }
.visitor b { display: block; font-size: 14px; }
.visitor small { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
@keyframes knock { 0%, 100% { transform: none; } 50% { transform: translateY(-2px); } }

/* タブ */
.tabs { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 14px 0 10px; padding: 6px 0; background: var(--bg); }
.tabs button { position: relative; min-height: 44px; padding: 10px 2px; border: 0; border-radius: 12px; background: var(--paper); color: var(--ink-soft); font: 900 13px/1.2 var(--font); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--leaf); color: #fff; }
.badge { position: absolute; top: 3px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; line-height: 16px; }
.sub-h { font-size: 15px; font-weight: 900; margin: 18px 2px 6px; }
.panel-b > .sub-h:first-child { margin-top: 2px; }
.hint { margin: 6px 2px 8px; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.book-head { display: flex; align-items: baseline; gap: 8px; }
.book-head .sub-h { margin-right: auto; }
.book-count { font-size: 13px; font-weight: 900; color: var(--accent-dark); }

/* ハリネズミをえらぶ */
.hz-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.hz-pick { position: relative; flex: none; width: 64px; padding: 4px 2px 3px; border: 2px solid transparent; border-radius: 14px; background: var(--paper); cursor: pointer; color: var(--ink); }
.hz-pick svg { display: block; width: 56px; height: 56px; margin: 0 auto; }
.hz-pick span { display: block; font-size: 11px; font-weight: 900; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hz-pick.on { border-color: var(--leaf); background: #f1f8ec; }
.hz-pick:disabled { opacity: 0.35; cursor: default; }
.hz-pick .dot { position: absolute; top: 4px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.hz-strip.small .hz-pick { width: 56px; }
.hz-strip.small .hz-pick svg { width: 48px; height: 48px; }

/* ステージ */
.stage { position: relative; margin-top: 6px; background: linear-gradient(#fff, #f6f1e6); border-radius: 18px; padding: 4px 10px 10px; text-align: center; overflow: hidden; }
.hz-art { display: block; width: min(260px, 72vw); aspect-ratio: 1; margin: 0 auto; padding: 0; border: 0; background: none; cursor: pointer; }
.hz-art svg { display: block; width: 100%; height: 100%; }
.sleep-note { margin: -4px 0 2px; font-size: 12px; color: #6f63a6; font-weight: 700; }
.hz-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 8px; }
.hz-name { font: 500 19px/1.3 var(--hand); }
.hearts { display: inline-flex; gap: 1px; }
.hz-ht { width: 16px; height: 16px; fill: #eadfd6; }
.hz-ht.on { fill: #f07a9a; }
.hz-lv, .hz-molt { width: 100%; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.hz-molt b { color: var(--ink); font-size: 14px; }
.hz-molt small { font-size: 11px; }
.ground { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding: 6px 8px; background: #efe4cf; border-radius: 12px; }
.ground .lbl { font-size: 12px; font-weight: 900; }
.ground-q { display: inline-flex; gap: 2px; }
.gq svg { width: 18px; height: 26px; transform: rotate(70deg); }
.heart-fx { position: absolute; top: 40%; width: 26px; height: 26px; pointer-events: none; animation: heartUp 1.1s ease-out forwards; }
@keyframes heartUp { from { transform: translateY(0) scale(0.6); opacity: 1; } to { transform: translateY(-90px) scale(1.2); opacity: 0; } }

/* ハリネズミの動き */
.hz-anim .hz-lift { animation: breathe 3.6s ease-in-out infinite; transform-origin: 100px 190px; }
@keyframes breathe { 0%, 100% { transform: none; } 50% { transform: scale(1.012, 0.99); } }
.hz-anim.hz-m-happy .hz-fig { animation: hop 0.5s ease-out 2; transform-origin: 100px 190px; }
@keyframes hop { 0%, 100% { transform: none; } 40% { transform: translateY(-8px); } }
.hz-anim.hz-m-eat .hz-chew { animation: chew 0.3s ease-in-out infinite; transform-origin: 100px 135px; }
@keyframes chew { 50% { transform: scaleY(0.5); } }
.hz-anim.hz-m-sleep .hz-fig { animation: sleepy 3s ease-in-out infinite; transform-origin: 100px 180px; }
@keyframes sleepy { 50% { transform: scale(1.02, 0.98); } }
.hz-anim .hz-z { animation: zz 2.4s ease-in-out infinite; }
@keyframes zz { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
.hz-anim .hz-eyes { animation: blink 4.6s infinite; transform-origin: 100px 112px; }
@keyframes blink { 0%, 95%, 100% { transform: none; } 97% { transform: scaleY(0.1); } }
.hz-hintring { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { stroke-opacity: 0.2; } }
.hz-sparkle { animation: twinkle 0.8s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.2; } }

/* お世話 */
.care { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.care-b { min-height: 52px; padding: 6px 8px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; cursor: pointer; box-shadow: 0 3px 0 var(--accent-dark); }
.care-b span { display: block; font-size: 15px; font-weight: 900; line-height: 1.3; }
.care-b small { display: block; font-size: 11px; font-weight: 700; opacity: 0.95; }
.care-b:disabled { background: #e8ddd2; color: #9b8a7f; box-shadow: none; cursor: default; }
.care-note { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--ink-soft); text-align: center; font-weight: 700; }

/* ハリの盤 */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 14px 0 8px; padding: 4px; background: #ebe1d2; border-radius: 14px; }
.modes button { min-height: 44px; border: 0; border-radius: 11px; background: transparent; color: var(--ink-soft); font-weight: 900; font-size: 14px; cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 6px rgba(59, 47, 42, 0.1); }
.sw-n { margin: 0 2px 6px; font-size: 12px; font-weight: 900; color: var(--accent-dark); text-align: center; }
.board { display: grid; grid-template-columns: 52px repeat(6, 1fr); gap: 4px; align-items: center; background: var(--paper); border-radius: 16px; padding: 8px; }
.row-l { white-space: nowrap; font-size: 10px; font-weight: 900; color: var(--ink-soft); line-height: 1.2; text-align: right; padding-right: 2px; }
.qb { position: relative; min-height: 56px; padding: 2px 0; border: 2px solid transparent; border-radius: 10px; background: #f8f3ea; cursor: pointer; }
.qb svg { display: block; width: 100%; height: 44px; }
.qb.on { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 3px #fff inset; }
.qb.hint { background: #fff7c8; animation: hintq 1.4s ease-in-out infinite; }
@keyframes hintq { 50% { background: #f8f3ea; } }
.qb.empty small { position: absolute; left: 0; right: 0; bottom: 2px; font-size: 9px; font-weight: 900; color: var(--ink-soft); line-height: 1.1; }
.qb.empty svg { height: 34px; margin-bottom: 10px; }
.qb .pv { position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2); font: 900 9px/11px var(--font); font-style: normal; color: #fff; text-align: center; }
.action { margin-top: 8px; }
.act-hint { margin: 4px 2px; font-size: 13px; font-weight: 700; }
.act-box { display: flex; gap: 10px; align-items: center; background: var(--paper); border-radius: 14px; padding: 8px 12px; }
.act-q svg { width: 34px; height: 48px; display: block; }
.act-t { flex: 1; text-align: left; }
.act-t b { font-size: 15px; }
.act-t small { margin-left: 6px; font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.act-t p { margin: 2px 0 0; font-size: 12px; font-weight: 700; color: var(--ink-soft); line-height: 1.55; }
.act-t p b { font-size: 12px; color: var(--accent-dark); }
.plant { display: flex; flex-wrap: wrap; gap: 6px; }
.pl { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; color: var(--ink); text-align: left; }
.pl svg { width: 22px; height: 32px; }
.pl span { font-size: 12px; font-weight: 900; line-height: 1.3; }
.pl small { display: block; font-size: 10px; color: var(--ink-soft); }
.colmode { display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: 13px; font-weight: 700; }
.colmode input { width: 20px; height: 20px; }
.swap-b { margin-top: 6px; }
.b-head { display: flex; align-items: center; gap: 8px; margin: 6px 2px; }
.b-art svg { width: 64px; height: 64px; display: block; }
.b-head b { font: 500 17px/1.3 var(--hand); }

/* かご */
.bag { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.bag li { display: flex; align-items: center; gap: 4px; background: var(--paper); border-radius: 12px; padding: 6px 8px 6px 4px; }
.bag li svg { width: 24px; height: 34px; flex: none; }
.bag li span { font-size: 12px; font-weight: 900; line-height: 1.3; }
.bag li b { display: block; font-size: 13px; }
.bag li.none { grid-column: 1 / -1; font-size: 13px; color: var(--ink-soft); padding: 12px; }

/* お客さん */
.order { background: #fff8ec; border: 2px solid #f2d6a2; border-radius: 16px; padding: 10px 12px 12px; }
.contest { margin-top: 10px; background: #f3f7fd; border-color: #cfdcf2; }
.o-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.o-face svg { width: 46px; height: 46px; display: block; }
.o-tag { display: inline-block; margin-right: 6px; font-size: 11px; font-weight: 900; color: #fff; background: #d08a2c; border-radius: 999px; padding: 1px 8px; vertical-align: 2px; }
.ct-tag { background: #5b7fc4; }
.o-text { margin: 8px 0 4px; font-size: 14px; font-weight: 900; }
.o-sub { margin: 4px 0; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.o-sub svg { vertical-align: -3px; }
.o-done { margin: 8px 0 0; font-weight: 900; color: var(--leaf-dark); font-size: 13px; }
.o-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ribbons { display: flex; gap: 10px; margin: 6px 0; }
.rb { display: flex; align-items: center; gap: 4px; opacity: 0.35; filter: grayscale(0.8); }
.rb.on { opacity: 1; filter: none; }
.rb small { font-size: 10px; font-weight: 900; line-height: 1.3; }
.rib { margin: 6px 4px 0; font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.friends { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.friends li { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 14px; padding: 6px 10px 6px 6px; }
.friends li > svg { width: 54px; height: 54px; flex: none; }
.friends li b { display: block; font-size: 14px; }
.friends li small { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 700; line-height: 1.5; }
.mini-hearts { display: inline-flex; }
.mini-hearts .hz-ht { width: 12px; height: 12px; }
.friends li.next { background: #fbf6ec; border: 2px dashed var(--line); }
.friends .q { flex: none; width: 54px; height: 54px; display: grid; place-items: center; font-size: 22px; font-weight: 900; color: #b8a994; }

/* 図鑑 */
.colors { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.colors li { display: flex; align-items: center; gap: 6px; background: var(--paper); border-radius: 12px; padding: 6px 8px 6px 6px; opacity: 0.75; }
.colors li.got, .colors li.hintc { opacity: 1; }
.colors li.hintc { background: #fff7d6; }
.colors li svg { width: 34px; height: 34px; flex: none; }
.colors li b { display: block; font-size: 13px; line-height: 1.3; }
.colors li small { display: block; font-size: 10px; color: var(--ink-soft); font-weight: 700; line-height: 1.4; }
.pats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pats li { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 12px; padding: 6px 10px 6px 6px; }
.pat-art { flex: none; width: 64px; height: 64px; }
.pat-art svg { width: 100%; height: 100%; display: block; }
.pat-art.none { display: grid; place-items: center; background: #f3ece1; border-radius: 12px; font-weight: 900; color: #b8a994; font-size: 22px; }
.pats li b { display: block; font-size: 14px; }
.pats li small { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 700; line-height: 1.5; }
.pats li:not(.got) b { color: var(--ink-soft); }

/* お店 */
.shop-acorn { margin: 0 2px 8px; font-weight: 900; }
.shop-acorn b { font-size: 20px; }
.ups { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ups li { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: 12px; padding: 8px 10px; }
.ups li > span:first-child { flex: 1; }
.ups li b { display: block; font-size: 14px; }
.ups li small { display: block; font-size: 11px; color: var(--ink-soft); font-weight: 700; }
.ups li.got { opacity: 0.7; }
.ups .done { font-size: 12px; font-weight: 900; color: var(--leaf-dark); }
.ups .later { font-size: 12px; font-weight: 900; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 2px; }

/* ボタン */
.btn { display: block; width: 100%; margin: 8px 0 0; padding: 12px 10px; min-height: 48px; border: 0; border-radius: 14px; background: var(--leaf); color: #fff; font: 900 15px/1.3 var(--font); cursor: pointer; box-shadow: 0 3px 0 var(--leaf-dark); }
.btn:disabled { background: #e3dbd0; color: #9b8a7f; box-shadow: none; cursor: default; }
.btn.small { width: auto; display: inline-block; min-height: 44px; padding: 9px 16px; font-size: 13px; margin: 0; }
.btn.tiny { width: auto; flex: none; display: inline-flex; align-items: center; gap: 3px; min-height: 44px; margin: 0; padding: 6px 12px; font-size: 13px; border-radius: 10px; box-shadow: 0 2px 0 var(--leaf-dark); }
.btn.tiny:disabled { box-shadow: none; }
.btn.primary { background: var(--accent); box-shadow: 0 3px 0 var(--accent-dark); }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); box-shadow: none; }

.records { margin: 14px 2px 0; font-size: 12px; color: var(--ink-soft); text-align: center; }
.panel { margin-top: 12px; display: grid; gap: 10px; }
.panel .mg-box { background: var(--paper); border-color: transparent; }

/* ダイアログ */
.dlg { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(59, 47, 42, 0.5); }
.dlg-in { width: 100%; max-width: 400px; max-height: 86vh; overflow: auto; background: var(--paper); border-radius: 18px; padding: 20px 16px 16px; }
.dlg h2 { margin: 0 0 10px; font-size: 19px; font-weight: 900; text-align: center; }
.dlg p { margin: 0 0 10px; font-size: 14px; }
.cel { text-align: center; }
.cel-art { display: grid; place-items: center; margin: 0 auto 4px; }
.cel-art svg { width: 64px; height: 90px; }
.cel-art.cel-hz svg { width: 180px; height: 180px; }
.cel-tag { display: inline-block; margin: 0 0 4px !important; padding: 1px 10px; border-radius: 999px; background: var(--gold); color: #fff; font-size: 12px !important; font-weight: 900; }
.cel h2 { font: 500 24px/1.3 var(--hand); }
.cel-gain { font-weight: 900; display: flex; align-items: center; justify-content: center; gap: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; width: max-content; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 16px; background: rgba(67, 122, 57, 0.95); color: #fff; font-weight: 900; font-size: 14px; text-align: center; pointer-events: none; }

/* 説明 */
.guide { margin-top: 28px; background: var(--paper); border-radius: 18px; padding: 22px 20px 12px; font-size: 15px; line-height: 1.85; }
.guide p { margin: 0 0 1em; }
.guide h2 { font-size: 19px; margin: 32px 0 12px; padding-left: 10px; border-left: 5px solid var(--leaf); line-height: 1.4; }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide .steps { list-style: none; padding: 0; margin: 0 0 1em; }
.guide .steps li { display: flex; align-items: baseline; gap: 6px; margin: 6px 0; }
.guide .steps .num { flex: none; font-weight: 900; color: var(--leaf-dark); }
.guide details { border-top: 1px solid var(--line); padding: 12px 0; }
.guide details p { margin: 8px 0 4px; }
.guide summary { font-weight: 900; cursor: pointer; }
.reset-row { text-align: center; margin-top: 16px !important; }
.g-foot { max-width: 560px; margin: 0 auto; padding: 14px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }

@media (max-width: 380px) {
  .board { grid-template-columns: 40px repeat(6, 1fr); gap: 3px; padding: 6px; }
  .row-l { font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
