:root {
  --ink: #2b2b2b;
  --paper: #ffffff;
  --sky: #cfe6fb;
  --accent: #ff5a6e;
  --belly: #ffb347;
  --love: #ff7fa8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Zen Maru Gothic", "Rounded Mplus 1c", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; height: 100lvh; } /* lvh: 画面の下端（ホームバーの所）まで */
#app canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#hud {
  position: fixed;
  /* iPhone のノッチ（画面上の切り欠き）にかからないように */
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  pointer-events: none;
}

.counts { display: flex; gap: 10px; }

.count, .belly, .love {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 0 var(--ink);
}

.count b { min-width: 1.2em; text-align: right; font-variant-numeric: tabular-nums; }

.belly .label, .love .label { font-size: 15px; font-weight: bold; }

.love-name { font-size: 13px; font-weight: bold; color: #d94a7a; white-space: nowrap; }

.gauge {
  width: 140px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: #eee;
}

#belly-bar {
  height: 100%;
  width: 100%;
  background: var(--belly);
  transition: width 0.2s linear, background 0.3s;
}

#belly-bar.empty { background: #7fb8e6; }

#love-bar {
  height: 100%;
  width: 0;
  background: var(--love);
  transition: width 0.3s ease-out;
}

#toast {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -10px) scale(0.9);
  max-width: calc(100% - 32px);
  padding: 10px 22px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 18px;
  font-weight: bold;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(207, 230, 251, 0.55);
}

.overlay.hidden { display: none; }

.card {
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 24px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 6px 0 var(--ink);
  font-size: 16px;
  line-height: 1.7;
}

.card h1 { margin: 0 0 8px; font-size: 34px; line-height: 1.2; }
.card h1 small { font-size: 20px; }
.card p { margin: 10px 0; }

.keys { font-size: 14px; }

kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 0 4px;
  margin: 0 1px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  background: #f6f6f6;
}

button {
  margin-top: 8px;
  font: inherit;
  font-size: 20px;
  font-weight: bold;
  padding: 8px 32px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}

button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* ---------------------------------------------------------------- ひみつ図鑑 */
.book-btn {
  pointer-events: auto;
  margin: 0 0 0 auto;
  position: relative;
  padding: 4px 14px;
  font-size: 17px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
.book-btn b { font-variant-numeric: tabular-nums; }
.book-btn.complete { background: #fff3b0; }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: bold;
  line-height: 1.6;
  vertical-align: middle;
}
.badge.hidden { display: none; }
.book-btn .badge { position: absolute; top: -10px; right: -8px; border: 2px solid var(--ink); }

.card h2 { margin: 0 0 4px; font-size: 24px; line-height: 1.3; }

.book-card {
  max-width: 520px;
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 20px 20px 16px;
}
.book-card h2, .book-progress, .book-card > button { text-align: center; align-self: center; }
.book-progress { margin: 0 0 10px; font-size: 14px; font-weight: bold; color: #d94a7a; }

.book-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  overflow-y: auto;
  display: grid;
  gap: 8px;
}
.book-list li {
  display: grid;
  grid-template-columns: auto 2em 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fff8fb;
}
.book-list li.locked { background: #eef3f8; color: #7b8794; border-style: dashed; }
.book-list .no { font-size: 12px; font-weight: bold; color: #9aa5b1; font-variant-numeric: tabular-nums; }
.book-list .icon { font-size: 24px; text-align: center; }
.book-list .title { font-size: 16px; }
.book-list .text { margin: 2px 0 0; font-size: 14px; line-height: 1.5; }

.secret-card { animation: pop 0.35s ease-out; }
.secret-lead { margin: 0; font-size: 15px; font-weight: bold; color: #d94a7a; }
.secret-no { margin-top: 10px; font-size: 13px; font-weight: bold; color: #9aa5b1; }
.secret-icon { font-size: 52px; line-height: 1.2; }
.secret-text { font-size: 18px; }

@keyframes pop {
  from { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.05); opacity: 1; }
  to { transform: scale(1); }
}

#book, #secret { z-index: 10; }
.sub-btn { display: block; margin: 12px auto 0; font-size: 15px; padding: 4px 18px; background: var(--paper); color: var(--ink); }

/* ひみつの文章は、ことばの途中（「ゆ／め」など）で改行しないように、空白や句読点で折り返す */
.secret-text, .book-list .text { word-break: keep-all; overflow-wrap: anywhere; }

/* ふりがな */
.secret-text, .book-list .text { line-height: 2; }
rt { font-size: 0.55em; font-weight: normal; color: #6b7280; }

/* 説明画面も、ことばの途中や「よ。」だけで改行しないよう、スペースの位置で折り返す */
#title .card p { word-break: keep-all; overflow-wrap: anywhere; }

/* ホーム画面から開いたとき（全画面）: iPhone は画面上部の時計の帯の少し下まで、
   中身をすりガラスのようにぼかすので、HUD やカードをその下にずらす */
@media (display-mode: fullscreen), (display-mode: standalone) {
  #hud { top: calc(env(safe-area-inset-top) + 40px); }
  .overlay { padding-top: calc(env(safe-area-inset-top) + 40px); }
}
