/* 1画面のゲーム：上に所持金、その下に依頼の列（横にスクロール）、残りを盤面が使う。
   色はブログ（0forest）の「ゼロの森」パレットに合わせる。 */
:root {
  --bg: #fef4e8;          /* cream：ページ */
  --paper: #fffaf1;       /* 紙：依頼カード */
  --cell: #f6e9d4;        /* 盤面のマス */
  --cell-edge: #ead6b8;
  --ink: #2b2a26;
  --ink-soft: #6f6555;
  --primary: #84491b;     /* brown：見出し・数字 */
  --accent: #858c4f;      /* olive：生成器・納品ボタン */
  --accent-ink: #fffaf1;
  --wanted: #ce7a78;      /* rose：依頼に合うアイテム */
  --gen-cell: #ead2ae;    /* ジェネレーターのマス（caramel を薄く） */
  --gen-edge: #d4ad78;
  --shadow: 0 1px 0 rgba(132, 73, 27, 0.12), 0 4px 12px rgba(132, 73, 27, 0.08);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  --radius: 10px;
  --bolt: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M9.5 1.5L3.5 9h4l-1 5.5 6-7.5h-4z' fill='%23f6dc7a' stroke='%23f6dc7a' stroke-width='.8' stroke-linejoin='round'/%3E%3C/svg%3E");
  /* チェックの白い線（色は固定の白で、どちらのテーマでも緑の上に置く） */
  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fffaf1' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141a15; --paper: #1d261e; --cell: #273228; --cell-edge: #354438;
    --ink: #ebe2d0; --ink-soft: #b3aa96; --primary: #c79254;
    --accent: #a3ab6a; --accent-ink: #141a15; --wanted: #e29a96;
    --gen-cell: #3d3426; --gen-edge: #5a4a32;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141a15; --paper: #1d261e; --cell: #273228; --cell-edge: #354438;
  --ink: #ebe2d0; --ink-soft: #b3aa96; --primary: #c79254;
  --accent: #a3ab6a; --accent-ink: #141a15; --wanted: #e29a96;
    --gen-cell: #3d3426; --gen-edge: #5a4a32;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game {
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 560px;
  margin: 0 auto;
  padding-block: 6px;
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
}

/* ---- 上の帯 ---- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.title small {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-left: 0.4em;
}
.title { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .title small { display: none; } }
.right { display: flex; align-items: center; gap: 10px; }
.money {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.money.bump { animation: bump 0.35s ease-out; }
.money { font-size: 0.8rem; }
.money span { font-size: 0.95rem; }
.pill {
  font: inherit;
  font-size: 0.75rem;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--cell-edge);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}
.reset { font-size: 0.62rem; padding: 2px 8px; }

/* ---- レベル・経験値・所持金 ---- */
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}
.lv { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.lv-badge {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}
.lv-badge b { font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.xp {
  flex: 1;
  max-width: 140px;
  height: 6px;
  border-radius: 999px;
  background: var(--cell);
  box-shadow: inset 0 0 0 1px var(--cell-edge);
  overflow: hidden;
}
.xp-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.4s ease-out; }
.xp.bump { animation: bump 0.35s ease-out; }
.inbox {
  position: relative;
  border: 0;
  padding: 0;
  background: none;
  width: 26px;
  height: 26px;
  cursor: pointer;
  animation: wobble 1.6s ease-in-out infinite;
}
.inbox img { width: 100%; height: 100%; }
.inbox span {
  position: absolute;
  right: -4px;
  top: -4px;
  min-width: 16px;
  height: 16px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  border-radius: 999px;
  background: var(--wanted);
  color: var(--accent-ink);
}

/* ---- 依頼 ---- */
.orders {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  /* 影が切れないよう少し余白を取り、その分だけ外へ広げる */
  padding: 4px 4px 8px;
  margin: -4px -4px -4px;
  scrollbar-width: none;
}
.orders::-webkit-scrollbar { display: none; }
.order {
  position: relative;
  flex: 0 0 148px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  box-sizing: border-box;
}
.who { display: flex; gap: 6px; align-items: flex-start; }
.face { width: 24px; height: 24px; flex: none; }
.line {
  margin: 0;
  font-size: 0.6rem;
  line-height: 1.35;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}
.want { display: flex; gap: 4px; align-items: center; height: 44px; }
.want-items { display: flex; gap: 2px; flex: 1; min-width: 0; height: 100%; }
/* 1つでも3つでも同じ形。数が多いと、絵は少し小さくなる（最大44px） */
.order-item { flex: 1 1 0; min-width: 0; max-width: 44px; height: 100%; object-fit: contain; }
.order:not(.is-ready) .want .order-item:not(.is-have) { opacity: 0.45; }
.want .reward { flex: none; white-space: nowrap; }
.want-text { display: flex; flex-direction: column; min-width: 0; }
.order-name { font-size: 0.72rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reward {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.66rem;
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.reward img { width: 16px; height: 16px; }
/* プレゼント付きの依頼：右上にプレゼントのマーク */
.gift-tag {
  position: absolute;
  top: -4px;
  right: -2px;
  width: 26px;
  height: 26px;
  transform: rotate(10deg);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}
.deliver {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  width: 100%;
  min-height: 26px;
  border: 0;
  border-radius: 999px;
  background: var(--cell);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
/* 枠は内側に描く（外側の outline は、横スクロールの枠で切れるため） */
.order.is-ready { box-shadow: inset 0 0 0 2px var(--accent), var(--shadow); }
.order.is-ready .deliver {
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.order.is-waiting {
  justify-content: center;
  font-size: 0.7rem;
  color: var(--ink-soft);
  text-align: center;
  background: transparent;
  box-shadow: none;
  border: 1px dashed var(--cell-edge);
}

/* ---- 盤面 ---- */
.board-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.board {
  --cols: 6;
  --rows: 8;
  width: min(100cqw, 100cqh * var(--cols) / var(--rows));
  aspect-ratio: var(--cols) / var(--rows);
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 3px;
  touch-action: none;
}
.cell {
  position: relative;
  background: var(--cell);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--cell-edge);
  display: grid;
  place-items: center;
}
.cell img {
  width: 90%;
  height: 90%;
  pointer-events: none;
}
/* ジェネレーター：マスを木の色にして、アイテムと見分ける（緑はチェックだけに使う） */
.cell.is-generator {
  background: var(--gen-cell);
  box-shadow: inset 0 0 0 1px var(--gen-edge);
}
/* 右下に⚡（マージゲームでよくある「タップで出る」の印） */
.cell.is-generator::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 24%;
  aspect-ratio: 1;
  min-width: 14px;
  border-radius: 50%;
  background: var(--bolt) center / 72% no-repeat, #84491b; /* brown：どちらのテーマでも黄色の⚡が見えるように固定 */
  box-shadow: 0 0 0 1.5px var(--gen-cell);
  pointer-events: none;
}
/* 依頼に出せるアイテム：右上にチェック */
.cell.is-wanted::before {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 30%;
  aspect-ratio: 1;
  min-width: 16px;
  border-radius: 50%;
  background:
    var(--check-mark) center / 70% no-repeat,
    var(--accent);
  box-shadow: 0 0 0 2px var(--bg);
  z-index: 1;
  pointer-events: none;
}
/* ごほうびの箱：タップできることを、ゆっくり揺れて知らせる */
.cell.is-gift img { animation: wobble 2.2s ease-in-out infinite; }
.cell.is-hover { box-shadow: inset 0 0 0 2px var(--primary); }
.cell.is-lifted img { opacity: 0.3; }

.ghost {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 20;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25));
}

/* ---- 動き ---- */
.pop { animation: jelly 0.7s linear; transform-origin: 50% 85%; }
.squash { animation: squash 0.22s ease-out; }
.spawn { animation: spawn 0.24s ease-out; }
/* 合成：つぶれて→伸びて→だんだん小さく揺れて止まる（ぽよよ〜ん） */
@keyframes jelly {
  0%   { transform: scale(0.6, 0.6); }
  15%  { transform: scale(1.3, 0.75); }
  30%  { transform: scale(0.8, 1.25); }
  45%  { transform: scale(1.15, 0.88); }
  60%  { transform: scale(0.93, 1.07); }
  75%  { transform: scale(1.04, 0.97); }
  88%  { transform: scale(0.99, 1.01); }
  100% { transform: scale(1, 1); }
}
@keyframes squash { 0% { transform: scale(1.15, 0.85); } 50% { transform: scale(0.92, 1.08); } 100% { transform: scale(1); } }
@keyframes spawn { from { transform: translate(var(--dx), var(--dy)) scale(0.3); } to { transform: none; } }
@keyframes wobble { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-7deg); } 86% { transform: rotate(6deg); } 93% { transform: rotate(-3deg); } }
@keyframes bump { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) {
  .pop, .squash, .spawn, .bump, .inbox, .cell.is-gift img { animation: none; }
}

/* ---- お知らせ ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  text-wrap: balance;
  background: var(--primary);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 30;
  text-align: center;
}

.pill:focus-visible, .deliver:focus-visible, .inbox:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 納品：依頼カードへ飛んでいくアイテム */
.flying {
  position: fixed;
  margin: 0;
  pointer-events: none;
  z-index: 25;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

/* ---- 図鑑・レベルアップ ---- */
.panel {
  width: min(520px, calc(100% - 32px));
  max-height: min(80vh, 720px);
  box-sizing: border-box;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-family: var(--font);
}
.panel::backdrop { background: rgba(20, 26, 21, 0.45); }
.panel h2 { margin: 0; font-size: 1.05rem; color: var(--primary); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.book-count { margin: 0 0 4px; font-size: 0.8rem; color: var(--ink-soft); }
.book-body h3 { margin: 14px 0 6px; font-size: 0.85rem; color: var(--primary); }
.book-lock { margin-left: 8px; font-size: 0.72rem; font-weight: 500; color: var(--ink-soft); }
.book-row {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.book-row li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  background: var(--cell);
  border-radius: 8px;
  font-size: 0.65rem;
  text-align: center;
}
.book-row img { width: 44px; height: 44px; }
/* まだ見つけていないもの：影だけ */
.book-row li.is-unknown img { filter: brightness(0); opacity: 0.18; }
.book-row li.is-unknown span { color: var(--ink-soft); }
.level-panel { text-align: center; }
.level-list { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.level-list li { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.level-list img { width: 40px; height: 40px; flex: none; }
.level-note { margin: 0 0 12px; font-size: 0.75rem; color: var(--ink-soft); }
.level-panel .deliver { background: var(--accent); color: var(--accent-ink); cursor: pointer; max-width: 200px; }

/* ---- ヘッダーのメニュー ---- */
.menu { display: flex; gap: 4px; }
.menu-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 44px;
  padding: 2px 4px;
  font: inherit;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--primary);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.menu-btn img { width: 26px; height: 26px; }
.menu-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  padding: 0 4px;
  font-size: 0.55rem;
  line-height: 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--cell);
  font-variant-numeric: tabular-nums;
}
.menu-badge.is-done { color: var(--accent-ink); background: var(--accent); }
.menu-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- 今日の目標・スタンプカード ---- */
.goal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.goal-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--cell);
  border-radius: 10px;
  font-size: 0.82rem;
}
.goal-list img { width: 32px; height: 32px; flex: none; }
.goal-main { flex: 1; display: grid; gap: 5px; min-width: 0; }
.goal-bar { height: 6px; border-radius: 999px; background: var(--paper); overflow: hidden; }
.goal-bar div { height: 100%; background: var(--accent); border-radius: inherit; }
.goal-count { font-size: 0.75rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.goal-list li.is-done .goal-count { color: var(--accent); font-weight: 700; }
.daily-note { margin: 8px 0 0; font-size: 0.72rem; color: var(--ink-soft); line-height: 1.6; }
.daily-note img { width: 18px; height: 18px; vertical-align: -4px; }
.daily-body h3, .shop-body h3 { margin: 18px 0 0; font-size: 0.9rem; color: var(--primary); }
.stamp-card {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.stamp-card li {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px dashed var(--cell-edge);
  font-size: 0.7rem;
  color: var(--ink-soft);
}
.stamp-card li.is-on { border: 2px solid var(--wanted); background: var(--cell); }
.stamp-card img { width: 80%; height: 80%; }

/* ---- お店 ---- */
.shop-money { margin: 0 0 10px; font-size: 0.8rem; color: var(--ink-soft); }
.shop-money b { color: var(--primary); font-size: 1rem; }
.shop-pick {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 10px 10px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--cell);
  box-shadow: inset 0 0 0 2px var(--wanted);
}
.pick-label {
  position: absolute;
  top: 0;
  left: 10px;
  padding: 1px 8px 2px;
  font-size: 0.65rem;
  color: var(--accent-ink);
  background: var(--wanted);
  border-radius: 0 0 6px 6px;
}
.shop-pick img { width: 44px; height: 44px; }
.pick-name { flex: 1; font-size: 0.85rem; font-weight: 700; }
.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.shop-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: var(--cell);
  border-radius: 10px;
  font-size: 0.68rem;
  text-align: center;
}
.shop-list img { width: 40px; height: 40px; }
.buy {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.buy:disabled { background: var(--paper); color: var(--ink-soft); cursor: default; }
.order.is-star .line { padding-right: 16px; }

/* ---- 大釜 ---- */
.cell.is-cauldron { background: var(--gen-cell); box-shadow: inset 0 0 0 1px var(--gen-edge); }
.pot-contents {
  position: absolute;
  left: 2px;
  top: 2px;
  display: flex;
  gap: 1px;
  pointer-events: none;
}
.pot-contents img {
  width: 16px !important;
  height: 16px !important;
  background: var(--paper);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--gen-edge);
}
.pot-now { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 10px 0; font-size: 0.78rem; }
.pot-now img { width: 30px; height: 30px; }
.take-out { margin-bottom: 8px; }
.recipe-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.recipe-list li {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--cell);
  border-radius: 10px;
  font-size: 0.72rem;
}
.recipe-list img { width: 34px; height: 34px; }
.recipe-list img.is-unknown { filter: brightness(0); opacity: 0.18; }
.recipe-list span { color: var(--ink-soft); }

/* ---- 目標の受け取り ---- */
.claim {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--wanted);
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
  animation: wobble 1.6s ease-in-out infinite;
}
.goal-list li.is-claim { box-shadow: inset 0 0 0 2px var(--wanted); }
.goal-list li.goal-all { background: var(--paper); box-shadow: inset 0 0 0 1px var(--cell-edge); }
.goal-list li.goal-all.is-claim { box-shadow: inset 0 0 0 2px var(--wanted); }
.menu-badge.is-claim { color: var(--accent-ink); background: var(--wanted); font-weight: 700; }

/* ---- ごほうびを大きく見せる ---- */
.reward-panel { text-align: center; overflow: hidden; width: min(320px, calc(100% - 48px)); padding: 24px 16px 18px; }
.reward-img { position: relative; width: 132px; height: 132px; animation: reward-in 0.6s cubic-bezier(.3,1.6,.5,1) both; }
.reward-name { position: relative; margin: 6px 0 0; font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.reward-get { position: relative; margin: 2px 0 0; font-size: 1.6rem; font-weight: 700; letter-spacing: 0.1em; color: var(--wanted); animation: reward-in 0.6s 0.15s cubic-bezier(.3,1.6,.5,1) both; }
.reward-note { position: relative; margin: 8px 0 14px; font-size: 0.75rem; color: var(--ink-soft); }
.reward-panel .deliver { position: relative; background: var(--accent); color: var(--accent-ink); cursor: pointer; max-width: 200px; }
.reward-burst {
  position: absolute;
  left: 50%;
  top: 90px;
  width: 260px;
  height: 260px;
  margin: -130px 0 0 -130px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(246, 220, 122, 0.55) 0 10deg, transparent 10deg 30deg);
  opacity: 0;
}
.reward-burst.go { animation: burst 2.4s ease-out forwards, spin 12s linear infinite; }
@keyframes reward-in { from { transform: scale(0.2); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes burst { from { opacity: 0; scale: 0.4; } 30% { opacity: 1; scale: 1; } to { opacity: 0.7; scale: 1; } }
@keyframes spin { to { rotate: 360deg; } }

/* ---- アトリエ ---- */
.room { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 320 / 220; box-shadow: inset 0 0 0 1px var(--cell-edge); }
.room > img:first-child { width: 100%; height: 100%; display: block; }
.decor { position: absolute; z-index: 1; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.decor.is-settling { transition: left 0.18s ease-out, top 0.18s ease-out; }
.decor.is-moving { cursor: grabbing; z-index: 99 !important; filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.3)); }
.room-note { margin: 6px 0 0; font-size: 0.72rem; color: var(--ink-soft); text-align: center; }
.decor-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.decor-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--cell); border-radius: 10px; font-size: 0.8rem; }
.decor-list li > span:first-of-type { flex: 1; }
.decor-list img { width: 34px; height: 34px; }
.decor-list li.is-locked img { filter: grayscale(1); opacity: 0.5; }

/* ---- はじめの案内 ---- */
.guide {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px var(--accent), var(--shadow);
  z-index: 15;
}
.guide[hidden] { display: none; }
.guide-text { flex: 1; margin: 0; font-size: 0.8rem; font-weight: 700; color: var(--primary); line-height: 1.5; }
.guide-skip { font: inherit; font-size: 0.65rem; color: var(--ink-soft); background: none; border: 0; cursor: pointer; }
.cell.is-guide, .order.is-guide .deliver { animation: guide-pulse 1.2s ease-in-out infinite; }
@keyframes guide-pulse { 50% { box-shadow: 0 0 0 4px var(--accent); } }
@media (prefers-reduced-motion: reduce) {
  .claim, .reward-img, .reward-get, .reward-burst.go, .cell.is-guide, .order.is-guide .deliver { animation: none; }
  .reward-burst.go { opacity: 0.6; }
}

/* 案内が出ているあいだは、お知らせを案内の上に出す */
.guide:not([hidden]) ~ .toast { bottom: 96px; }

/* 「最初から」の確認 */
.confirm-panel { text-align: center; width: min(320px, calc(100% - 48px)); padding: 22px 18px 18px; }
.confirm-text { margin: 10px 0 16px; font-size: 0.8rem; line-height: 1.6; color: var(--ink-soft); text-wrap: pretty; }
.confirm-btns { display: flex; gap: 8px; justify-content: center; }
.confirm-btns .pill { padding-inline: 16px; }
.confirm-btns .confirm-yes { background: var(--accent); color: var(--accent-ink); cursor: pointer; width: auto; max-width: 170px; }

/* ゴール：アトリエの完成 */
.atelier-goal { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin: 0 0 8px; font-size: 0.78rem; color: var(--ink-soft); text-wrap: pretty; }
.atelier-goal b { color: var(--primary); font-size: 0.9rem; white-space: nowrap; }
.atelier-goal.is-done { color: var(--primary); font-weight: 700; }
.guest { position: absolute; width: 14%; z-index: 60; pointer-events: none; filter: drop-shadow(0 2px 2px rgb(0 0 0 / 0.2)); animation: guest-hop 2.4s ease-in-out infinite; }
.guest:nth-of-type(2n) { animation-delay: -1.2s; }
@keyframes guest-hop { 0%, 80%, 100% { transform: none; } 88% { transform: translateY(-8%); } }
.ending-panel { width: min(360px, calc(100% - 32px)); }
.ending-room { position: relative; margin: 10px 0 0; animation: reward-in 0.6s 0.1s cubic-bezier(.3,1.6,.5,1) both; }
.ending-room .decor { cursor: default; }
@media (prefers-reduced-motion: reduce) { .guest, .ending-room { animation: none; } }

/* 住人からの手紙 */
.letter-from { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-weight: 700; color: var(--primary); font-size: 0.9rem; }
.letter-face { width: 44px; height: 44px; }
.letter-text { position: relative; margin: 10px 4px 4px; padding: 10px 12px; background: var(--cell); border-radius: 10px; font-size: 0.82rem; line-height: 1.7; text-align: left; }
.letter-panel .reward-img { width: 96px; height: 96px; }

/* 売る・しまう（アイテムをタップしたとき） */
.cell.is-picked { box-shadow: inset 0 0 0 3px var(--primary); }
.pick {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  width: min(420px, calc(100% - 24px)); box-sizing: border-box; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--paper); border-radius: 14px; box-shadow: inset 0 0 0 2px var(--cell-edge), var(--shadow); z-index: 16;
}
.pick[hidden] { display: none; }
.pick-img { width: 36px; height: 36px; flex: none; }
.pick-name { flex: 1; min-width: 0; font-size: 0.85rem; font-weight: 700; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .pill { padding: 6px 12px; flex: none; }
.pick .pill:disabled { opacity: 0.5; }
.pick .deliver { width: auto; flex: none; padding: 6px 14px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.guide:not([hidden]) ~ .pick { bottom: 96px; }
.pick:not([hidden]) ~ .toast { bottom: 96px; }
.guide:not([hidden]) ~ .pick:not([hidden]) ~ .toast { bottom: 172px; }
.store-btn b { font-weight: 700; color: var(--primary); }
.store-slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.store-slots li { aspect-ratio: 1; border-radius: 10px; background: var(--cell); display: grid; place-items: center; font-size: 0.7rem; color: var(--ink-soft); }
.store-take { all: unset; cursor: pointer; display: grid; justify-items: center; gap: 2px; width: 100%; height: 100%; place-content: center; text-align: center; }
.store-take img { width: 70%; height: auto; }
.store-take span { font-size: 0.6rem; color: var(--ink); line-height: 1.2; }
.book-done { margin-left: 6px; font-size: 0.7rem; color: var(--accent-ink); background: var(--accent); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.pick.is-top { bottom: auto; top: calc(12px + env(safe-area-inset-top, 0px)); }
.store-body .daily-note { margin: 0 0 10px; }

/* アイテムの説明（依頼のアイテムを押したとき） */
.order-item, .pick-img { cursor: pointer; }
.info-head { display: flex; align-items: center; gap: 12px; }
.info-head img { width: 64px; height: 64px; flex: none; }
.info-head div, .info-gen div { display: flex; flex-direction: column; gap: 2px; }
.info-head b { font-size: 1.05rem; color: var(--primary); }
.info-head span, .info-gen span { font-size: 0.75rem; color: var(--ink-soft); }
.info-body h3 { margin: 14px 0 6px; font-size: 0.85rem; color: var(--primary); }
.info-gen { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--gen-cell); border-radius: 10px; }
.info-gen img { width: 44px; height: 44px; flex: none; }
.info-gen b { font-size: 0.85rem; }
.info-chain li { position: relative; }
.info-chain li:not(:nth-child(4n))::after { content: "›"; position: absolute; right: -6px; top: 18px; font-size: 0.8rem; color: var(--ink-soft); }
.info-chain li.is-target { box-shadow: inset 0 0 0 2px var(--wanted); }
.info-recipe { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 0.75rem; }
.info-recipe span { display: grid; justify-items: center; gap: 2px; padding: 6px; background: var(--cell); border-radius: 10px; }
.info-recipe img { width: 44px; height: 44px; }
.info-recipe i { font-style: normal; color: var(--ink-soft); }
