/* nonogram — スタイル（Cairn Design System 準拠） */
:root {
  --bg: #f2f2ef;
  --card: #ffffff;
  --fg: #1b1b1d;
  --sub: #a3a3a6;
  --sub2: #c6c6c8;
  --hairline: #e7e7e4;
  --pill: #4a4a4c;
  --red: #e5484d;
  --green: #38b26f;
  /* 盤面 */
  --cell-bg: #ffffff;
  --line: #e3e3df;
  --line-strong: #9a9a9c;
  --mark: #c6c6c8;
  /* 浮いている部品（ツールバー・トースト） */
  --float-bg: #474745;
  --float-fg: #f2f2ef;
  --float-hi: #62625f;
  --float-shadow: 0 6px 20px rgba(0,0,0,0.16);
  --primary-bg: #b9b9b4;
  --primary-fg: #1b1b1d;
  --toggle-on: #8e8e93;
  --sheet-r: 22px;
  --postit-glow: rgba(27, 27, 29, 0.28); /* お知らせの付箋が光るときのにじみ */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

.theme-dark {
  --bg: #161618;
  --card: #232326;
  --fg: #ececee;
  --sub: #86868a;
  --sub2: #5a5a5e;
  --hairline: #313134;
  --cell-bg: #1f1f22;
  --line: #2c2c2f;
  --line-strong: #6b6b6f;
  --mark: #5a5a5e;
  --postit-glow: rgba(236, 236, 238, 0.45);
  --float-bg: #2c2c2e;
  --float-fg: #ffffff;
  --float-hi: #4c4c50;
  --float-shadow: 0 8px 24px rgba(0,0,0,0.28);
  --primary-bg: #ececee;
  --primary-fg: #161618;
  --toggle-on: #ececee;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg); }
/* 画面そのものは動かさない（iOS Safari の引っぱりスクロール・ゴム伸びを止める）。中身のスクロールは .sheet などだけ */
html, body { overflow: hidden; overscroll-behavior: none; }
body { position: fixed; inset: 0; width: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* ダブルタップ拡大を止める。盤面（.ng-grid）だけは none でなぞり塗りに専念する */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.hidden { display: none !important; }

#app {
  height: 100dvh;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: calc(10px + env(safe-area-inset-top));
}

/* ---------- ブランドタグ ---------- */
.brand-tag {
  position: absolute;
  top: calc(4px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--sub);
  z-index: 6;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 4px;
  letter-spacing: 0.3px;
}
.brand-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--sub2); display: inline-block; }

/* ---------- ヘッダー ---------- */
.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 0;
  min-height: 56px;
  flex-shrink: 0;
  z-index: 5;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--sub);
  transition: transform 0.12s, color 0.15s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(0.88); color: var(--fg); }
.energy {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding-right: 6px;
  color: var(--sub);
}
.energy .wait { font-size: 11.5px; font-variant-numeric: tabular-nums; letter-spacing: 0.3px; }
.energy .wait.extra { color: var(--fg); font-weight: 700; font-size: 12.5px; }
.energy .pips { display: flex; gap: 3px; }
.energy .pips i { width: 8px; height: 8px; background: var(--sub2); opacity: 0.55; transition: background 0.3s, opacity 0.3s; }
.energy .pips i.on { background: var(--fg); opacity: 1; }
.energy.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.count {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: 6px;           /* 上の余白 12px の分だけ、ボタンの高さの中央に合わせる */
  transform: translateY(-50%);
  text-align: center;
  pointer-events: none;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  letter-spacing: 0.3px;
}
.count.bump { animation: bump 0.45s var(--ease); }
@keyframes bump { 0% { transform: translateY(-50%) scale(1); } 35% { transform: translateY(-50%) scale(1.35); } 100% { transform: translateY(-50%) scale(1); } }

/* ---------- 盤面 ---------- */
.stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px calc(132px + env(safe-area-inset-bottom));
  min-height: 0;
}
.ng {
  --n: 10;
  --cell: 28px;
  --clue-font: 12px;
  --slot: 18px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  opacity: 1;
  transition: opacity 0.18s;
}
.ng.loading { opacity: 0; }
.ng { transform-origin: 0 0; }
.ng.centering { transition: opacity 0.18s, transform 0.8s var(--ease); }
/* 次の問題へ: いまの画面がゆっくり消え、新しい問題がゆっくり現れる */
.stage, .toolbar { transition: opacity 0.9s ease; }
#app.leaving .stage, #app.leaving #nextbar { opacity: 0; }
.stage { overflow: hidden; }
/* 拡大中、画面の外に出たヒントを上と左に固定して出す */
.pin { position: absolute; z-index: 3; overflow: hidden; pointer-events: auto; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--fg); }
.pin[hidden] { display: none; }
.pin-top { background: var(--bg); border-bottom: 1px solid var(--line-strong); }
.pin-left { background: var(--bg); border-right: 1px solid var(--line-strong); }
.pin-corner { background: var(--bg); border-right: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.pin-col { position: absolute; bottom: 4px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; line-height: 1.15; }
.pin-row { position: absolute; right: 6px; left: 0; display: flex; align-items: center; justify-content: flex-end; gap: 0.45em; }
.pin .done { color: var(--sub2); }
.ng-corner { grid-area: 1 / 1; }
.ng-cols {
  grid-area: 1 / 2;
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell));
}
.ng-rows {
  grid-area: 2 / 1;
  display: grid;
  grid-template-rows: repeat(var(--n), var(--cell));
}
.ng-grid {
  grid-area: 2 / 2;
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell));
  grid-template-rows: repeat(var(--n), var(--cell));
  touch-action: none;
  outline: 1.5px solid var(--line-strong);
  transition: outline-color 0.5s;
}

.clue {
  display: flex;
  font-weight: 700;
  font-size: var(--clue-font);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s, opacity 0.5s;
  line-height: 1;
}
.clue span { display: grid; place-items: center; }
.clue-col {
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 5px;
  gap: calc(var(--clue-font) * 0.28);
}
.clue-row {
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
}
.clue-row span { width: var(--slot); text-align: center; }
.clue.done { color: var(--sub2); }
.clue.hi { color: var(--fg); }
.clue.hi.done { color: var(--sub); }
.clue-col.sep { border-left: 1.5px solid transparent; }
.clue-row.sep { border-top: 1.5px solid transparent; }

.cell {
  background: var(--cell-bg);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: background 0.08s, border-color 0.5s;
}
.cell.sep-l { border-left: 1.5px solid var(--line-strong); }
.cell.sep-t { border-top: 1.5px solid var(--line-strong); }
.cell.fill { background: var(--fg); }
.cell.mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(45deg, transparent calc(50% - 0.7px), var(--mark) calc(50% - 0.7px), var(--mark) calc(50% + 0.7px), transparent calc(50% + 0.7px)),
    linear-gradient(-45deg, transparent calc(50% - 0.7px), var(--mark) calc(50% - 0.7px), var(--mark) calc(50% + 0.7px), transparent calc(50% + 0.7px));
  background-size: 42% 42%;
  background-position: center;
  background-repeat: no-repeat;
}

/* クリア: 罫線とヒントを消して、塗りだけを絵として残す */
.ng.cleared .ng-grid { outline-color: transparent; }
.ng.cleared .cell { border-color: transparent; background: transparent; transition: background 0.5s, border-color 0.5s; }
.ng.cleared .cell.fill { background: var(--fg); }
.ng.cleared .cell.mark::after { opacity: 0; transition: opacity 0.4s; }
.ng.cleared .clue { opacity: 0; }

/* ---------- ツールバー ---------- */
.toolbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom));
  background: transparent;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  z-index: 10;
  animation: pop-in 0.2s var(--ease);
}
.tb-btn {
  width: 64px;
  height: 48px;
  border-radius: 0;
  display: grid;
  place-items: center;
  color: var(--sub2);
  transition: color 0.2s ease, transform 0.12s;
}
.tb-btn:active { transform: scale(0.9); }
.tb-btn svg { width: 22px; height: 22px; }
.tb-btn.active { color: var(--fg); }
.tb-btn.sub { color: var(--sub); }
.tb-btn.wide {
  width: auto;
  color: var(--fg);
  padding: 0 20px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}
.tb-btn.wide svg { width: 16px; height: 16px; flex-shrink: 0; }
.tb-btn.up { font-size: 13.5px; font-weight: 600; }
.tb-btn.up.done { color: var(--sub); }
.tb-btn:disabled { cursor: default; }
.tb-btn:disabled:active { transform: none; }

/* ---------- オーバーレイ ---------- */
.dim { position: fixed; inset: 0; background: rgba(0,0,0,0.22); z-index: 30; animation: fade-in 0.18s ease; }
.dim.over { z-index: 38; background: rgba(0,0,0,0.5); } /* メニューの上にダイアログを重ねるとき */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { transform: translate(-50%, 0) scale(0.7); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes pop-in-c { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet {
  /* 全体を暗くおおう画面。文字や項目は、その上に直接のる */
  position: fixed;
  inset: 0;
  z-index: 34;
  background: rgba(8, 8, 10, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #f4f4f6;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* 暗い地の上では、文字・線・ボタンを明るい色にする */
  --fg: #f4f4f6;
  --sub: rgba(255, 255, 255, 0.62);
  --sub2: rgba(255, 255, 255, 0.34);
  --hairline: rgba(255, 255, 255, 0.14);
  --card: #f4f4f6;
}
.sheet.enter { animation: fade-in 0.22s ease; }
.sheet-body { max-width: 520px; margin: 0 auto; padding: calc(84px + env(safe-area-inset-top)) 26px calc(56px + env(safe-area-inset-bottom)); }
.sheet-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  transition: transform 0.12s;
  z-index: 1;
}
.sheet-close:active { transform: scale(0.88); }
.sheet-close svg { width: 34px; height: 34px; stroke: #f4f4f6; stroke-width: 1.8; }
/* スクロールバーは見せない（デザインに合わないので。スクロールはできる） */
.sheet, .inbox, .ml-alert .field.area { scrollbar-width: none; -ms-overflow-style: none; }
.sheet::-webkit-scrollbar, .inbox::-webkit-scrollbar, .ml-alert .field.area::-webkit-scrollbar { display: none; width: 0; height: 0; }

.sheet h2 { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 14px; }
.sheet .hint { font-size: 12.5px; color: var(--sub); line-height: 1.7; text-align: center; margin-top: 12px; }

/* 設定カード */
/* 行をグループごとの余白で区切る。カードの背景や角丸は使わない */
.set-card { margin-bottom: 22px; }
.set-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  font-size: 15px;
  text-align: left;
  position: relative;
}
.set-row + .set-row::before { content: ""; position: absolute; top: 0; left: 0; right: 0; border-top: 1px solid var(--hairline); }
.set-row .grow { flex: 1; }
.set-row .val { color: var(--sub); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.set-row .chev-r { color: var(--sub2); font-size: 16px; }
.set-row .sub-l { display: block; font-size: 12px; color: var(--sub); margin-top: 2px; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.set-row.danger { color: var(--red); }

.toggle {
  width: 46px; height: 28px; border-radius: 999px; background: var(--sub2);
  position: relative; transition: background 0.2s; flex-shrink: 0; display: inline-block;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s var(--ease);
}
.toggle.on { background: var(--toggle-on); }
.toggle.on::after { transform: translateX(18px); }

.seg { background: rgba(0,0,0,0.055); border-radius: 999px; padding: 3px; display: inline-flex; }
.theme-dark .seg { background: rgba(255,255,255,0.08); }
.seg button { font-size: 12.5px; padding: 6px 13px; border-radius: 999px; color: var(--sub); transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.seg button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.12); }

/* 遊び方 */
.howto { font-size: 14.5px; line-height: 1.7; }
.howto .item { display: flex; gap: 12px; padding: 9px 0; }
.howto .item + .item { border-top: 1px solid var(--hairline); }
.howto .k { flex-shrink: 0; width: 76px; font-weight: 700; font-size: 13px; padding-top: 2px; }
.howto .d { flex: 1; color: var(--fg); }
.howto .d small { color: var(--sub); display: block; font-size: 12.5px; }
.howto-pic { display: flex; justify-content: center; margin: 4px 0 14px; }
.howto-pic svg { width: 180px; height: auto; }

/* 統計 */
.set-row.stat { padding-top: 11px; padding-bottom: 11px; }
.set-row .big { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }
.seg.sizes { display: flex; }
.seg.sizes button { flex: 1; padding: 7px 0; font-variant-numeric: tabular-nums; }

/* Spectrum（スクリーンセーバー） */
.spectrum {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #07070b;
  animation: fade-in 0.6s ease;
  transition: opacity 0.45s ease;
  cursor: pointer;
}
.spectrum.out { opacity: 0; }
.spectrum canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sp-empty {
  position: absolute;
  left: 0; right: 0; top: 50%;
  text-align: center;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.28);
}

/* ダイアログ */
.ml-alert {
  position: fixed;
  left: 50%; top: 50%;
  translate: -50% -50%;
  width: calc(100% - 60px);
  max-width: 330px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
  padding: 22px 20px 16px;
  z-index: 40;
  animation: pop-in-c 0.2s var(--ease);
}
.ml-alert .ttl { font-size: 17px; font-weight: 800; text-align: center; margin-bottom: 6px; }
.ml-alert .msg { font-size: 14.5px; line-height: 1.65; margin-bottom: 16px; text-align: center; color: var(--sub); }
.ml-alert .a-btn {
  display: block; width: 100%; padding: 12px; border-radius: 12px; font-size: 14.5px;
  margin-top: 8px; background: var(--bg); text-align: center; transition: transform 0.12s;
}
.ml-alert .a-btn:active { transform: scale(0.97); }
.ml-alert .a-btn.primary { background: var(--primary-bg); color: var(--primary-fg); font-weight: 700; }
.ml-alert .a-btn.warn { color: var(--red); background: rgba(229,72,77,0.08); }
.ml-alert .a-btn.ghost { background: none; color: var(--sub); }
.ml-alert .a-row { display: flex; gap: 10px; }
.ml-alert .a-row .a-btn { flex: 1; }

/* 入力欄（iOS で拡大されないよう 16px 以上） */
input, textarea { font: inherit; color: var(--fg); -webkit-user-select: text; user-select: text; }
.ml-alert .field {
  display: block; width: 100%; background: var(--bg); border: none; border-radius: 10px;
  padding: 12px 14px; outline: none; font-size: 16px; margin-bottom: 6px; text-align: center;
}
.ml-alert .field.area { text-align: left; resize: none; line-height: 1.6; min-height: 130px; }
.ml-alert .note { min-height: 20px; font-size: 13px; color: var(--red); text-align: center; margin-bottom: 4px; }
.ml-alert .note.shake { animation: shake 0.4s; }
.ml-alert .a-btn:disabled { opacity: 0.4; }

/* チュートリアル */
.tut .tut-pic { display: flex; justify-content: center; align-items: center; min-height: 160px; margin: 4px 0 12px; color: var(--fg); }
.tut .tut-pic svg { max-width: 100%; height: auto; }
.tut .msg { min-height: 50px; color: var(--fg); }
.tut .msg b { font-weight: 700; }
.tut-dots { display: flex; justify-content: center; gap: 6px; margin: -4px 0 6px; }
.tut-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--sub2); }
.tut-dots span.on { background: var(--fg); }
.tut-tools { display: flex; align-items: center; gap: 6px; color: var(--sub2); }
.tut-tools span { width: 52px; height: 44px; display: grid; place-items: center; }
.tut-tools span.on { color: var(--fg); }
.tut-tools svg { width: 24px; height: 24px; }
.tut-energy { transform: scale(1.8); }

/* メニュー: 名前は、その色の札にのせる */
.name-chip { font-size: 14px; font-weight: 600; padding: 4px 11px; border-radius: 8px; max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Mail box・Peep into the Spectrum: 角丸の線で囲んだボタン */
.link-btns { display: flex; flex-direction: column; gap: 10px; }
.link-btn {
  display: block; width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1.5px solid var(--sub2); font-size: 15px; text-align: center;
  transition: transform 0.12s, background 0.15s;
}
.link-btn:active { transform: scale(0.97); background: var(--hairline); }

/* Mail box: 届いたメール（新しい 3 通） */
.inbox { list-style: none; margin: 4px 0 14px; padding: 0; text-align: left; max-height: 34vh; overflow-y: auto; }
.inbox li { padding: 10px 2px; border-top: 1px solid var(--hairline); }
.inbox li:last-child { border-bottom: 1px solid var(--hairline); }
.inbox .when { font-size: 11px; color: var(--sub); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.inbox .body { font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.ml-alert .field-label { display: block; font-size: 11.5px; color: var(--sub); text-align: left; margin: 0 2px 5px; }

/* ショップ */
.shop-row .buy { background: var(--primary-bg); color: var(--primary-fg); border-radius: 999px; font-size: 13px; font-weight: 700; padding: 7px 14px; flex-shrink: 0; transition: transform 0.12s; }
.shop-row .buy:active { transform: scale(0.92); }
.shop-row .buy:disabled { opacity: 0.4; }
.shop-row .have { font-size: 13px; color: var(--sub); flex-shrink: 0; }
.shop-empty { color: var(--sub); text-align: center; padding: 26px 0; font-size: 14px; }
.shop-id { font-size: 10.5px; color: var(--sub2); text-align: center; margin-top: 14px; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; -webkit-user-select: text; user-select: text; }

/* チュートリアル: 左右にめくる */
.tut { touch-action: pan-y; }
.tut-slide.from-right { animation: tut-in-r 0.28s var(--ease); }
.tut-slide.from-left { animation: tut-in-l 0.28s var(--ease); }
@keyframes tut-in-r { from { transform: translateX(36px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tut-in-l { from { transform: translateX(-36px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 初めてのチュートリアルのあと: 暗転して Spectrum から名前を呼ばれる */
.intro {
  position: fixed; inset: 0; z-index: 300;
  background: #000; opacity: 0;
  display: grid; place-items: center;
  transition: opacity 2s ease;
  pointer-events: none;
}
.intro.dark { opacity: 1; pointer-events: auto; }
.intro.dark.lift { opacity: 0; transition-duration: 2.4s; }
.intro-msg {
  color: rgba(255,255,255,0.88);
  font-size: 19px; font-weight: 300; letter-spacing: 3px;
  padding: 0 24px; text-align: center; line-height: 1.8;
  opacity: 0; filter: blur(6px);
  transition: opacity 1.6s ease, filter 1.6s ease;
}
.intro.show .intro-msg { opacity: 1; filter: blur(0); }
.intro-name { font-weight: 400; }
.intro-msg { max-width: 22em; line-height: 2.1; }

/* 右上、体力の下のお知らせ。画面の右の端にくっついた、横長の四角い付箋。色はテーマに合わせた黒（ダークでは白）。未読があるあいだ、ぴかぴか光る */
.postit {
  position: absolute;
  right: 0;
  top: calc(env(safe-area-inset-top) + 64px);
  width: 72px; height: 24px;
  background: var(--fg);
  border-radius: 0;
  z-index: 8;
  animation: postit-glow 1.4s ease-in-out infinite;
}
/* 押しやすいよう、見た目より広く反応させる */
.postit::before { content: ""; position: absolute; inset: -12px 0 -12px -12px; }
.postit:active { opacity: 0.5; }
@keyframes postit-glow {
  0%, 100% { opacity: 0.45; box-shadow: 0 0 0 0 transparent; }
  50% { opacity: 1; box-shadow: -3px 0 16px 4px var(--postit-glow); }
}

/* Mail box: その人の名前の色の画面。文字やボタンは、その色の上で読める色に */
.ml-alert.themed { background: var(--al-bg); color: var(--al-ink); }
.ml-alert.themed .ttl { color: var(--al-ink); }
.ml-alert.themed .field { background: var(--al-ink-3); color: var(--al-ink); caret-color: var(--al-ink); }
.ml-alert.themed .field::placeholder { color: var(--al-ink-2); }
.ml-alert.themed .field-label { color: var(--al-ink-2); }
.ml-alert.themed .a-btn { background: var(--al-ink-3); color: var(--al-ink); }
.ml-alert.themed .a-btn.primary { background: var(--al-ink); color: var(--al-inv); }
.ml-alert.themed .a-btn:disabled { opacity: 0.45; }
.ml-alert.themed .inbox li { border-color: var(--al-ink-4); }
.ml-alert.themed .inbox .when { color: var(--al-ink-2); }
.ml-alert.themed .inbox .body { color: var(--al-ink); }

/* トースト */
.toast {
  position: fixed;
  bottom: calc(132px + env(safe-area-inset-bottom));
  left: 50%;
  translate: -50% 0;
  background: var(--float-bg);
  color: var(--float-fg);
  box-shadow: var(--float-shadow);
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 999px;
  z-index: 100;
  width: max-content;
  max-width: calc(100% - 40px);
  text-align: center;
  line-height: 1.5;
  animation: pop-in-c 0.2s ease;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* チュートリアル中: 左右のスワイプを、ブラウザのスクロールに取られない */
body.tut-open, body.tut-open #dim, body.tut-open #alert { touch-action: none; }
.tut-slide { will-change: transform, opacity; }

/* 暗い画面（メニュー・ショップ）の上の部品 */
.sheet .toggle { background: rgba(255,255,255,0.28); }
.sheet .toggle.on { background: #f4f4f6; }
.sheet .toggle.on::after { background: #111; }
.sheet .seg { background: rgba(255,255,255,0.12); }
.sheet .seg button.on { background: #f4f4f6; color: #111; box-shadow: none; }
.sheet .link-btn { border-color: rgba(255,255,255,0.4); }
.sheet .link-btn:active { background: rgba(255,255,255,0.12); }
.sheet .set-row.danger { color: #ff6b6f; }
.sheet .shop-row .buy { background: #f4f4f6; color: #111; }

/* Mail box の一覧: 開くまで中身は見えない。未読は日付の横に点 */
.inbox li { padding: 0; }
.mail-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 2px; text-align: left; }
.mail-head .env { width: 22px; height: 22px; display: grid; place-items: center; flex-shrink: 0; }
.mail-head .env svg { width: 22px; height: 22px; stroke: currentColor; }
.mail-head .when { margin: 0; font-size: 13px; color: var(--sub); }
.inbox .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fg); display: none; flex-shrink: 0; }
.inbox li.unread .dot { display: inline-block; }
.inbox li.unread .when { color: var(--fg); font-weight: 700; }
.inbox li .body { padding: 0 2px 14px 32px; animation: fade-in 0.2s ease; }
.ml-alert.themed .mail-head { color: var(--al-ink); }
.ml-alert.themed .inbox .dot { background: var(--al-ink); }
.ml-alert.themed .inbox li.unread .when { color: var(--al-ink); }

/* メニューの名前: 中央にそろえる */
.set-row.name-row { flex-direction: column; justify-content: center; align-items: center; gap: 12px; padding: 6px 0 2px; text-align: center; }
.set-row.name-row .name-chip { max-width: 100%; white-space: normal; font-size: 16px; padding: 6px 14px; }

/* 手紙: Mail box の上に、便せんのようにひらく */
.letter {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade-in 0.2s ease;
  cursor: pointer;
}
.paper {
  width: 100%; max-width: 340px;
  background-color: #fffdf6;
  color: #2a2620;
  padding: 26px 26px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  transform-origin: 50% 40%;
  animation: paper-open 0.45s var(--ease);
}
@keyframes paper-open {
  from { transform: perspective(700px) rotateX(-55deg) scale(0.86); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.paper-date { text-align: right; font-size: 12px; color: rgba(42, 38, 32, 0.55); font-variant-numeric: tabular-nums; margin-bottom: 14px; }
.paper-body { font-size: 17px; line-height: 30px; white-space: pre-wrap; word-break: break-word; min-height: 90px; max-height: 50vh; overflow-y: auto; scrollbar-width: none; -webkit-user-select: text; user-select: text; }
.paper-body::-webkit-scrollbar { display: none; }
.paper-end { text-align: center; font-size: 12px; color: rgba(42, 38, 32, 0.45); margin-top: 16px; font-family: inherit; }
