/* ==========================================================================
   ワードローグ — スタイル
   ========================================================================== */

:root {
  /* ── 明るい紙と墨 ────────────────────────────────────────────────────
     地は白い紙、panel はその上に載せる一枚、境界は罫線、文字は墨。
     明るい地で効かせるコツは彩度を上げることではなく **濃く** すること。
     ネオンの発光はやめ、淡いドロップシャドウと朱の差し色で立体を出す。 */
  --bg:        #f8fbff;
  --bg-2:      #eef3fb;
  --panel:     #ffffff;
  --panel-2:   #f4f7fc;
  --line:      #e3e9f3;
  --line-2:    #c6cfdf;
  --fg:        #212a3a;
  --fg-dim:    #5a6577;
  --fg-mute:   #8a92a3;

  --ink:       #1b2333;   /* 墨 — 塗りのチップ (語・文) の地 */
  --ink-2:     #2c3548;
  --accent:    #e0482d;   /* 朱 */
  --accent-2:  #e8933a;   /* 柿 */
  --accent-ink:#a5311b;
  --gold:      #c08a10;
  /* 語・接続詞・熟語の色。明るい地でも読める濃さで固定する。 */
  --word:      #1b2333;   /* 語の文字 */
  --word-bg:   linear-gradient(180deg, #ffffff, #f2f6fd);
  --word-line: #c6cfdf;
  --conn:      #2457d6;   /* 接続詞 */
  --conn-bg:   rgba(36, 87, 214, .09);
  --conn-line: rgba(36, 87, 214, .5);

  --ok:        #16915a;
  --ng:        #d63c30;
  --idiom:     #c26a0d;
  --great:     #c62b73;
  --fire:      #e2541a;
  --ice:       #0d7fc4;
  --info:      #0d7fc4;
  --thunder:   #a8780a;
  --poison:    #3d8a22;
  --dark:      #6a4bd0;

  /* 紙のざらつき。画像は使わず、重ねた gradient で出す。明るい地では
     ごく薄くしないと汚れて見えるので、濃さは 1% 程度に抑える。 */
  --grain:
    repeating-linear-gradient(0deg, rgba(23, 43, 84, .014) 0 1px, rgba(23, 43, 84, 0) 1px 3px),
    repeating-linear-gradient(90deg, rgba(23, 43, 84, .010) 0 1px, rgba(23, 43, 84, 0) 1px 4px);

  --r:   6px;
  --r-s: 4px;
  --shadow:   0 12px 30px rgba(23, 43, 84, 0.09), 0 1px 0 rgba(255, 255, 255, .95) inset;
  --shadow-s: 0 2px 8px rgba(23, 43, 84, 0.07);
  --ring:     0 0 0 2px rgba(224, 72, 45, .22);
  --font: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo,
          system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* セーフエリア (iPad / iPhone のノッチと丸角) を 1 つの値にまとめる。 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性を必ず効かせる。display を指定した要素は UA の
   [hidden]{display:none} を上書きしてしまうため、ここで固定する。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  /* 明るい紙。上から光が差して、下へ向けてわずかに青みが沈む。 */
  background:
    var(--grain),
    radial-gradient(120% 80% at 12% 0%, #ffffff 0%, rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  /* iPad の横持ちで左右いっぱいに広げないようにする (文字が大きくなりすぎる)。 */
  max-width: 100%;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body { user-select: none; }

#app { position: fixed; inset: 0; }

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.layer[hidden] { display: none !important; }

.screen {
  pointer-events: auto;
  /* 中身が収まるときは中央、はみ出すときは上端から (safe center)。
     grid の place-items: center だと、はみ出したときに
     パネルの上端が画面の外へ出てしまう。 */
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  /* セーフエリア (丸角・ノッチ) を避ける。iPad は丸角と
     ホームバーのぶんだけ内側に寄せる。 */
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: rgba(246, 250, 255, .9);
  backdrop-filter: blur(9px) saturate(.9);
  -webkit-backdrop-filter: blur(9px) saturate(.9);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ══ ボタン ══════════════════════════════════════════════════════════ */

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--fg);
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, var(--shadow-s);
  padding: 9px 16px;
  cursor: pointer;
  transition: background .13s, border-color .13s, box-shadow .13s, transform .08s, opacity .13s;
}
.btn:hover:not(:disabled) { background: #ffffff; border-color: var(--accent); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

/* 主ボタンは墨を塗るように。朱一色 + 白い字 */
.btn-primary {
  background: linear-gradient(180deg, #d3563b, var(--accent));
  border-color: var(--accent-ink);
  color: #fff7f3;
  text-shadow: 0 1px 0 rgba(23, 43, 84, 0.245);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .28) inset, var(--shadow-s);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #e0654a, #e0482d); border-color: var(--accent-ink); }

.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .7); }
.btn-danger { background: #f7dedb; border-color: #d9a0a8; color: #d63c30; }
.btn-danger:hover:not(:disabled) { background: #f2ccc7; }

.btn-lg { font-size: 1.15rem; padding: 13px 34px; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  display: grid; place-items: center;
  font-size: 1.1rem; border-radius: 9px;
}
.btn-close {
  position: absolute; top: 12px; right: 12px;
  width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  font-size: 1rem;
}
/* 使い方 (初回の説明) を開き直す「?」。閉じるボタンの左に並べる。 */
.btn-help {
  right: 52px;
  font-size: .92rem;
  font-weight: 800;
  color: var(--fg-dim);
}
.btn-help:hover:not(:disabled) { color: var(--accent); }

kbd {
  font-family: var(--mono);
  font-size: .82em;
  background: #f1f5fb;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
}
code {
  font-family: var(--mono);
  font-size: .88em;
  background: #f1f5fb;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--accent);
}

.muted { color: var(--fg-mute); font-size: .86rem; }
.ok  { color: var(--ok); }
.ng  { color: var(--ng); }

/* ══ パネル ══════════════════════════════════════════════════════════ */

.panel {
  position: relative;
  width: min(880px, 100%);
  max-height: 100%;
  background: linear-gradient(180deg, #ffffff 0%, var(--panel) 42%, var(--panel-2) 100%);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise .2s ease-out;
}

.panel-head { position: relative; padding-right: 46px; padding-bottom: 10px; flex: none; }
/* 「?」と「✕」が並ぶ見出しは、本文がボタンの下へ潜らないよう右を広く取る。 */
.panel-head:has(.btn-help) { padding-right: 92px; }
/* 見出しの下に朱の帯 — 紙の一枚に「見出し」と「本文」の境目をつける */
.panel-head::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0 78px, var(--line) 78px 100%);
  border-radius: 2px;
}
.panel-head h2 { margin: 0 0 2px; font-size: 1.32rem; letter-spacing: .02em; font-weight: 800; }
.panel-sub { margin: 0; color: var(--fg-dim); font-size: .88rem; }
.panel-sub strong { color: var(--accent); }

.panel-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
/* 「戦闘へ戻る」のようなボタンの文字は折り返さない。 */
.panel-foot .btn { flex: none; white-space: nowrap; }

/* ══ HUD ═════════════════════════════════════════════════════════════ */

.hud { display: flex; flex-direction: column; }

.hud-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 14px calc(14px + var(--safe-l));
  /* 画面の上が「計器の帯」だと分かるように、紙を一枚かぶせる */
  background: linear-gradient(180deg, rgba(255, 255, 255, .97) 0%, rgba(255, 255, 255, .8) 62%, rgba(255, 255, 255, 0) 100%);
  border-bottom: 1px solid rgba(224, 232, 245, .95);
}

.hud-col { min-width: 0; }
.hud-left  { display: flex; flex-direction: column; gap: 5px; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-center { text-align: center; }

.bar {
  position: relative;
  height: 19px;
  background: #e9eef7;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(23, 43, 84, 0.098) inset;
  /* 文字を外に出るので切り詰めない。丸い角は fill 側で確保する。 */
  overflow: visible;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 100%;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(180deg, #d9556b, #d63c30);
  transition: width .12s linear;
}
.bar-shield {
  position: absolute; inset: 0 auto 0 0;
  width: 0;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(180deg, #0d7fc4, #0f6aa8);
  opacity: .85;
  transition: width .12s linear;
}
.bar-xp { height: 17px; }
.bar-xp .bar-fill { background: linear-gradient(180deg, #d9a406, #d9a406); }
.bar-sta { height: 16px; }
.bar-sta .bar-fill {
  background: linear-gradient(180deg, #16915a, #16915a);
  transition: width .06s linear;
}
.bar-sta .bar-fill.dashing { background: linear-gradient(180deg, #d9a406, #d98a12); }
.bar-sta .bar-fill.empty { background: linear-gradient(180deg, #d63c30, #d63c30); }
.bar-sta .bar-text { font-size: .64rem; }

.hud-self {
  align-self: flex-start;
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--ink);
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 3px 10px;
  box-shadow: var(--shadow-s);
}
.hud-self-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-self-mark {
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 4px;
  opacity: .85;
}
.hud-self-pow {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  color: #5a6577;
  letter-spacing: .02em;
}
.hud-self.invalid { color: #fff6f2; background: rgba(214, 60, 48, .92); border-color: var(--accent-ink); }
.hud-self.invalid .hud-self-pow { color: #ffd9cf; }
.bar-text {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: .74rem; font-weight: 700;
  font-family: var(--mono);
  /* 地が紙になったので、字は墨 + 白い縁取り。バーの色が濃くても読める */
  color: var(--ink);
  text-shadow: 0 0 3px rgba(255, 255, 255, .95), 0 0 2px rgba(255, 255, 255, .95);
  letter-spacing: .04em;
}
/* 細いバー (経験値 / スタミナ) の文字はバーの中に入れる。
   外へ出すと、中央の時計やステージ名に重なる (iPad 横で重なった)。 */
.bar-xp .bar-text,
.bar-sta .bar-text {
  inset: 0;
  transform: none;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: .64rem;
  color: #212a3a;
  text-shadow: 0 0 3px rgba(255, 255, 255, .95), 0 0 2px rgba(255, 255, 255, .95);
  white-space: nowrap;
}

.hud-stats {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
  /* 地が明るくなっても読めるように、紙の土台を敷く。 */
  padding: 4px;
  border-radius: 9px;
  background: rgba(255, 255, 255, .93);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-s);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* 能力 1 項目。ラベルは小さく淡く、数値は大きく明るく。 */
.statbox {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(215, 225, 240, .8);
  white-space: nowrap;
}
.statbox-k {
  font-size: .68rem;
  color: #6b7484;
  letter-spacing: .08em;
}
.statbox-v {
  font-family: var(--mono);
  font-size: .84rem;
  font-weight: 700;
  color: #212a3a;
  text-shadow: 0 0 3px rgba(255, 255, 255, .92);
}
.statbox.up .statbox-v { color: #16915a; }
.statbox.up { background: rgba(22, 145, 90, 0.09); }

.hud-stage {
  font-size: .8rem;
  color: var(--fg-dim);
  letter-spacing: .1em;
}
.hud-timer {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: .04em;
  text-shadow: 0 2px 10px rgba(23, 43, 84, 0.203);
}
.hud-timer.urgent { color: var(--ng); animation: pulse .6s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.hud-boss { margin-top: 6px; }
.boss-name { font-size: .78rem; color: var(--ng); letter-spacing: .06em; }
.bar-boss { height: 9px; margin-top: 3px; }
.bar-boss .bar-fill { background: linear-gradient(180deg, #e0783c, #a81b32); transition: width .18s; }
.hud-boss.mid .boss-name { color: #a8770f; }
.hud-boss.mid .bar-boss .bar-fill { background: linear-gradient(180deg, #e8b425, #b8730a); }

.hud-num { display: flex; align-items: baseline; gap: 5px; }
.hud-num b { font-family: var(--mono); font-size: 1.05rem; }
.hud-num span { font-size: .7rem; color: var(--fg-mute); }

.hud-btns { display: flex; gap: 6px; margin-top: 2px; }
.hud-btns .btn-icon { pointer-events: auto; }

.hud-hint {
  align-self: center;
  margin-top: 4px;
  padding: 7px 18px;
  background: rgba(255, 255, 255, .95);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: .86rem;
  color: #212a3a;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(23, 43, 84, 0.175);
  text-shadow: 0 0 3px rgba(255, 255, 255, .92);
  animation: rise .2s;
}

/* レベルアップの 3 択。選択中はゲームを止め、画面中央の大きな札で選ぶ。 */
.hud-choice-veil {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(23, 43, 84, .34);
  pointer-events: auto;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.hud-choice {
  position: absolute;
  left: 50%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  z-index: 16;
  /* HUD は .layer で pointer-events: none。3 択だけはクリックできるように戻す。 */
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(92vw, 760px);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px 26px 26px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(224, 72, 45, .55);
  box-shadow: 0 28px 90px rgba(23, 43, 84, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: choiceIn .18s cubic-bezier(.16, 1, .3, 1);
}
@keyframes choiceIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.hud-choice-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  justify-content: center;
}
.hud-choice-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--accent-ink);
}
.hud-choice-timer {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  color: #5a6577;
  min-width: 1.4em;
  text-align: right;
}
.hud-choice-timer.urgent { color: #d63c30; }
.hud-choice-sub {
  margin-top: -5px;
  text-align: center;
  font-size: .72rem;
  letter-spacing: .12em;
  color: #7a8494;
}
.hud-choice-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.hud-choice-list.small {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 7px;
  max-width: 100%;
  max-height: 190px;
  overflow-y: auto;
  padding: 2px;
}
.hud-choice-note {
  margin: 0 0 5px;
  font-size: .74rem;
  color: #b8355c;
  text-align: center;
}
.hud-choice-forget {
  padding-top: 7px;
  border-top: 1px solid rgba(214, 60, 48, 0.28);
}

/* 3 択のカード。中央の大きな札として、ひと目で選べる大きさにする。 */
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 0;
  min-width: 150px;
  min-height: 132px;
  padding: 20px 16px 18px;
  border-radius: 14px;
  border: 2px solid var(--line-2);
  background: linear-gradient(180deg, #ffffff, #f1f5fb);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(23, 43, 84, 0.12);
  font-size: 1.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, background .1s, border-color .1s, box-shadow .1s;
}
.choice-card:hover {
  transform: translateY(-3px);
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(23, 43, 84, 0.18);
}
.choice-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.choice-card-cat {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  opacity: .8;
}
.choice-card-fx {
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 600;
  opacity: .92;
}
.choice-card.forget {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  padding: 9px 8px;
  border-radius: 9px;
  font-size: 1rem;
  border-style: dashed;
  border-color: rgba(214, 60, 48, 0.44);
  background: rgba(214, 60, 48, 0.08);
}
.choice-card.forget:hover { background: rgba(214, 60, 48, 0.18); }
.choice-card.gone { opacity: .38; }
.choice-card .conn-mark {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: .5rem;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--connect, #2457d6);
  color: #1b2333;
  font-weight: 700;
}
.hud-weapons {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding: 8px calc(14px + var(--safe-r)) calc(12px + var(--safe-b)) calc(14px + var(--safe-l));
  flex-wrap: wrap;
  align-items: flex-end;
  /* 武器チップの土台。黒背景の上にそのまま置いても読めるように。 */
  background: linear-gradient(to top, rgba(255, 255, 255, 0.82), rgba(23, 43, 84, 0));
  border-radius: 12px 12px 0 0;
}

.wchip {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: #212a3a;
  text-shadow: 0 0 3px rgba(255, 255, 255, .92);
  box-shadow: 0 3px 12px rgba(23, 43, 84, 0.147);
  transition: border-color .12s, background .12s;
}
.wchip:hover { background: #e6dfcc; }
.wchip .wchip-lv {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--fg-dim);
  background: #efe8d5;
  border-radius: 4px;
  padding: 1px 5px;
}
.wchip .wchip-txt { letter-spacing: .04em; }
.slot-tail {
  border-style: solid;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  cursor: default;
  opacity: 1;
}
.slot-tail:hover { transform: none; }
.wchip.broken {
  border-color: var(--ng);
  background: rgba(247, 222, 219, 0.95);
  color: #b8355c;
}
.wchip.broken .wchip-txt { text-decoration: line-through; text-decoration-thickness: 1px; }
.wchip.idiom { border-color: var(--idiom); }
.wchip.great { border-color: var(--great); box-shadow: 0 0 0 1px rgba(176, 42, 99, 0.28); }

/* ダッシュボタン。画面の右中段に置く。
   右下は武器チップ (入れ替えのドロップ先) があるので避ける。 */
.hud-dash {
  position: absolute;
  right: calc(14px + var(--safe-r));
  /* 武器チップ (下) も 3 択 (中央下) も避けた位置。 */
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  pointer-events: auto;
  touch-action: none;
  width: 96px;
  height: 96px;
  padding: 0;
  border-radius: 999px;
  border: 2px solid rgba(224, 72, 45, 0.45);
  background: rgba(255, 255, 255, 0.78);
  color: #b8860b;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .08em;
  box-shadow: 0 6px 22px rgba(23, 43, 84, 0.161);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform .08s, background .08s, border-color .08s;
}
.hud-dash[hidden] { display: none; }
.hud-dash.on {
  background: rgba(224, 72, 45, 0.21);
  border-color: #e0482d;
  color: #8a6410;
  transform: translateY(-50%) scale(.95);
}
/* スタミナが足りないと押しても利かない。 */
.hud-dash.empty { opacity: .4; }

/* ダッシュボタンは右中段。3 択は中央下なので縦には重ならない。
   タッチでは 3 択を画面幅いっぱいのカード列にして、指で選びやすくする。 */
body.touch .hud-choice {
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  width: min(94vw, 760px);
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px);
  transform: translate(-50%, -50%);
  animation: choiceIn .18s cubic-bezier(.16, 1, .3, 1);
}
body.touch .hud-choice-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
body.touch .hud-choice-list.small { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
body.touch .choice-card {
  min-width: 0;
  min-height: 110px;
  padding: 14px 6px;
  font-size: 1.6rem;
  justify-content: center;
}
body.touch .choice-card-cat { font-size: .7rem; }
body.touch .choice-card-fx { font-size: .72rem; line-height: 1.25; }
body.touch .hud-choice-title { font-size: 1rem; }

.hud-paused {
  position: absolute; inset: 0;
  z-index: 20;
  display: flex;
  align-items: safe center;
  justify-content: safe center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r))
           calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background: rgba(23, 43, 84, 0.42);
  backdrop-filter: blur(5px) saturate(.85);
  -webkit-backdrop-filter: blur(5px) saturate(.85);
  pointer-events: auto;
  animation: fade .14s ease-out;
}
.pause-card {
  width: min(420px, 100%);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #ffffff 0%, var(--panel) 48%, var(--panel-2) 100%);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: 0 18px 52px rgba(23, 43, 84, 0.30), 0 1px 0 rgba(255, 255, 255, .95) inset;
  animation: rise .18s ease-out;
}
.pause-head { text-align: center; }
.pause-kicker {
  display: block;
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .28em;
  color: var(--accent);
}
.pause-title { margin: 2px 0 0; font-size: 1.55rem; letter-spacing: .16em; }
.pause-meta {
  min-height: 1.5em;
  margin: 5px 0 0;
  color: var(--fg-dim);
  font-size: .78rem;
  line-height: 1.5;
}
.pause-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.pause-actions .btn { min-height: 46px; padding: 10px 12px; }
.pause-resume { grid-column: 1 / -1; font-size: 1.02rem; }
.pause-quit { width: 100%; min-height: 40px; color: var(--fg-dim); font-size: .84rem; }
.pause-quit.armed {
  color: #fff7f3;
  background: linear-gradient(180deg, #d3563b, var(--accent));
  border-color: var(--accent-ink);
}
.pause-hint { color: var(--fg-mute); font-size: .76rem; text-align: center; }

/* ══ 言葉鍛冶 ════════════════════════════════════════════════════════ */

.panel-forge { width: min(1180px, 100%); height: min(820px, 100%); }

.forge-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}

.forge-weapons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.wrow {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  border-radius: var(--r);
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  box-shadow: var(--shadow-s);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.wrow.broken { border-color: rgba(214, 60, 48, .45); border-left-color: var(--ng); background: rgba(214, 60, 48, .06); }
.wrow.great, .wrow.idiom { border-left-color: var(--accent); }
.wrow.great { box-shadow: 0 0 0 1px rgba(176, 42, 99, .3), var(--shadow-s); }
/* 動詞待ち — 文は成っているがまだ撃てない。破線で見せる */
.wrow.pending { border-style: dashed; border-color: rgba(194, 106, 13, .6); background: rgba(194, 106, 13, .06); }
/* 行ごとまとめて外すボタン (3 枠が埋まったまま動かない、を防ぐ出口) */
.wrow-drop {
  padding: 1px 8px;
  font: inherit;
  font-size: .72rem;
  font-weight: 700;
  color: #d63c30;
  background: rgba(214, 60, 48, .08);
  border: 1px solid rgba(214, 60, 48, .4);
  border-radius: 999px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.wrow-drop:hover { background: #d63c30; color: #fff7f3; border-color: #a5311b; }

.wrow-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.wrow-name { font-weight: 700; font-size: .85rem; }
.wrow-core {
  font-size: .74rem;
  color: var(--fg-mute);
  border: 1px dashed var(--line-2);
  border-radius: 5px;
  padding: 0 5px;
}
.wrow-lv {
  font-family: var(--mono);
  font-size: .68rem;
  background: #eef2f9;
  border-radius: 4px;
  padding: 0 5px;
  color: var(--fg-dim);
}
/* 「空にする」 … 文の語を全部語彙へ戻す。並べ直すときの逃げ道。 */
.wrow-clear {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--fg-dim);
  background: #eef2f9;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 1px 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.wrow-clear:hover { color: var(--fg); border-color: var(--fg-dim); }
.wrow-grade {
  margin-left: auto;
  font-size: .70rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.grade-plain  { color: var(--ok); }
.grade-idiom  { color: var(--idiom); }
.grade-great  { color: var(--great); }
.grade-broken { color: var(--ng); }

.wrow-why { font-size: .72rem; color: var(--ng); line-height: 1.4; }

.slots { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.slot {
  width: 58px; height: 44px;
  display: grid; place-items: center;
  border: 1.5px dashed var(--line-2);
  border-radius: 8px;
  background: #eef2f9;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
  position: relative;
}
.slot.filled {
  border-style: solid;
  border-color: var(--line-2);
  background: #e8eef7;
}
.slot.filled:hover { background: #e2dac6; }
.slot.armed { border-color: var(--accent); background: #ffece3; box-shadow: 0 0 0 2px rgba(224, 72, 45, 0.15); }
.slot.hinted { border-color: var(--accent); animation: hintPulse 1.1s infinite; }
@keyframes hintPulse { 50% { box-shadow: 0 0 0 3px rgba(224, 72, 45, 0.19); } }
.slot.drop { border-color: var(--ok); background: #e2f0e0; }
.slot .empty-mark { color: var(--fg-mute); font-size: 1.1rem; font-weight: 400; }

/* ドラッグ */
.slot.filled, .pword, .sen-word { cursor: grab; }
.slot.filled:active, .pword:active, .sen-word:active { cursor: grabbing; }
/* 掴んだ語は薄くし、指の下へ出る影だけを見えるようにする。 */
.dragging { opacity: .22; filter: saturate(.5); }
.drag-ghost {
  position: fixed;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 9px;
  border: 1.5px solid var(--accent);
  border-radius: 9px;
  background: #fff3ec;
  box-shadow: 0 10px 22px rgba(23, 43, 84, 0.161), 0 0 0 3px rgba(224, 72, 45, 0.14);
  pointer-events: none;
  transform: scale(1.06) rotate(-1.5deg);
}
.drag-ghost .dg-word {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
}
.drag-ghost .dg-conn {
  padding: 0 6px;
  border-radius: 999px;
  border: 1.5px solid rgba(36, 87, 214, 0.77);
  background: rgba(36, 87, 214, 0.19);
  color: #2457d6;
  font-size: .82rem;
  font-weight: 700;
}
.drop-hot {
  border-color: var(--accent) !important;
  background: #ffece3 !important;
  box-shadow: 0 0 0 2px rgba(224, 72, 45, 0.26);
  transform: translateY(-1px);
}

.slot-plus {
  width: 26px; text-align: center;
  color: var(--fg-mute); font-size: .8rem;
}

/* ── 自由に並べた文 ───────────────────────────────────────────────────────
   語と語のあいだには何も置かない。文はそのまま連結して見える。
   接続詞は「語 + 接続詞」の 1 組で、語のタップで切り替わる。
   語を足す「＋」は文の末尾にだけ置く。                                  */
.sen-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef2f9;
  min-height: 30px;
}
.sen-item { position: relative; display: inline-flex; align-items: center; gap: 0; }
.sen-word {
  position: relative;
  min-width: 34px; min-height: 30px;
  padding: 3px 6px;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-2);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f4f7fc);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 1px 3px rgba(23, 43, 84, 0.06);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  /* これが無いと指がスクロールになり、ドラッグの途中で pointercancel される。 */
  touch-action: none;
}

.sen-word:active { cursor: grabbing; }
.sen-word.armed {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--ring);
}
/* 長押しで持ち上げた語。文の語や行の余白をタップで移せる。 */
.sen-word.held {
  border-color: var(--accent);
  background: #fff6df;
  box-shadow: var(--ring), 0 6px 14px rgba(23, 43, 84, 0.126);
  transform: translateY(-2px);
}
/* 熟語を構成する語。下からマーカーを引いたように光らせる。成立した瞬間は行ごと弾ませる。 */
.sen-word.idiom-word {
  border-color: var(--idiom);
  background: linear-gradient(180deg, #ffffff 52%, rgba(255, 205, 80, .55) 52% 84%, #ffffff 84%);
  box-shadow: 0 0 0 2px rgba(194, 106, 13, .3);
}
.wrow.idiom-born { animation: idiomBorn .9s ease-out; }
.wrow.idiom-born .sen-word.idiom-word { animation: idiomPop .9s ease-out; }
@keyframes idiomBorn {
  0% { box-shadow: 0 0 0 0 rgba(194, 106, 13, 0.00); }
  25% { box-shadow: 0 0 26px 5px rgba(194, 106, 13, 0.44); }
  100% { box-shadow: 0 0 0 0 rgba(194, 106, 13, 0.00); }
}
@keyframes idiomPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.18); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.sen-word.sen-tail {
  border-style: dashed;
  background: #edf1f8;
  color: var(--fg-mute);
  cursor: default;
}

.sen-conn {
  min-width: 34px; height: 30px;
  margin: 0;
  padding: 0 6px;
  display: grid; place-items: center;
  border: 1.5px dashed rgba(36, 87, 214, 0.38);
  border-radius: 999px;
  background: rgba(36, 87, 214, 0.06);
  color: #2457d6;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.sen-conn.filled {
  border-style: solid;
  border-color: rgba(36, 87, 214, 0.77);
  background: rgba(36, 87, 214, 0.19);
}
.sen-conn.empty {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 1;
  width: 10px;
  min-width: 10px;
  height: 10px;
  min-height: 10px;
  padding: 0;
  border-radius: 50%;
  font-size: .5rem;
  opacity: 0;
}
.sen-conn.empty:hover { opacity: 1; }
.wrow-empty {
  padding: 8px 10px;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  font-size: .78rem;
}
.wrow-kind.dim { color: var(--fg-mute); }

.wrow-self {
  border-color: rgba(224, 72, 45, .4);
  border-left: 3px solid var(--accent);
  background: linear-gradient(180deg, #ffffff, #fff7f2);
}
/* 自身の文は行の背景も少し黄め。末尾の「人」まで含む。 */
.wrow-self .sen-row { border-color: rgba(224, 72, 45, .3); background: #fff7f2; }
.wrow-kind {
  font-size: .7rem;
  color: var(--fg-mute);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
}

.wrow-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 4px;
  font-size: .68rem;
  font-family: var(--mono);
}
.stat {
  background: #eef2f9;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  color: var(--fg-dim);
}
.stat.up   { color: var(--ok);  border-color: rgba(22, 145, 90, 0.30); }
.stat.bad  { color: var(--ng);  border-color: rgba(214, 60, 48, 0.28); }
.stat.idom { color: var(--idiom); border-color: rgba(194, 106, 13, 0.36); background: rgba(194, 106, 13, 0.20); }
.stat.nat  { color: #2457d6; border-color: rgba(36, 87, 214, 0.34); }

/* 自然さの内訳。加点は青、減点は赤で区別する。コンパクトにまとめる。 */
.wrow-nat {
  display: flex; flex-wrap: wrap; gap: .2rem .35rem;
  align-items: baseline; margin: .15rem 0 .2rem;
  font-family: var(--mono); font-size: .64rem; line-height: 1.4;
}
.wrow-nat .nat-total { color: #2457d6; font-weight: 700; }
.wrow-nat .nat-plus  { color: var(--ok); }
.wrow-nat .nat-minus { color: var(--ng); }

/* 語彙の語から新しい文を作る＋。属性語・現象語・基本武器にだけ付く */
.pword-craft {
  position: absolute;
  right: 2px; top: 2px;
  width: 17px; height: 17px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: rgba(255, 255, 255, .95);
  color: var(--accent);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  opacity: .8;
  transition: opacity .12s, background .12s, color .12s, transform .08s;
}
.pword-craft:hover { opacity: 1; background: var(--accent); color: #fff7f3; transform: translateY(-1px); }
.pword-craft.special { color: var(--idiom); border-color: rgba(194, 106, 13, .55); }
.pword-craft.special:hover { background: var(--idiom); color: #ffffff; }
.pword-craft.disabled { opacity: .3; pointer-events: none; }
/* 武器語は語彙から引かないので、語彙の札に武器の印は付けない */

/* 語彙 */
.forge-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: #eff3fa;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
}
.forge-side-head { display: flex; align-items: baseline; justify-content: space-between; }
.forge-side-head h3 { margin: 0; font-size: .95rem; letter-spacing: .04em; color: var(--fg-dim); }

.lexicon {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  overflow-y: auto;
  align-content: start;
  padding: 8px;
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  min-height: 200px;
  flex: 1;
}

.pword {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  position: relative;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff, #f1f5fb);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .85) inset;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* 語彙の語はドラッグの起点。スクロールに奪われると置けない。 */
  touch-action: none;
  transition: transform .08s, border-color .12s, background .12s;
  line-height: 1.1;
  text-align: center;
  padding: 2px;
  overflow: hidden;
}
.pword:hover { background: #ffffff; border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(23, 43, 84, 0.098); }
.pword.armed {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff7f3;
  box-shadow: var(--ring);
}
.pword.armed .pword-n { color: rgba(255, 248, 242, .8); }
.pword.empty { border-style: dashed; border-color: #d5dce8; background: transparent; cursor: default; }
.pword.empty:hover { transform: none; background: transparent; }
.pword-n {
  position: absolute;
  right: 2px; bottom: 1px;
  font-family: var(--mono);
  font-size: .6rem;
  color: var(--fg-mute);
}
.pword-conn { opacity: .85; border-style: dashed; }

.forge-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.forge-actions .btn { font-size: .82rem; padding: 7px 10px; }
/* 説明文は自分の行を取る。1 文字ぶんの幅に潰れるのを防ぐ。 */
.forge-note { flex: 1 1 100%; order: -1; font-size: .8rem; color: var(--fg-dim); }
.forge-note strong { color: var(--accent); }
.btn-forget.on {
  background: rgba(214, 60, 48, 0.18);
  border-color: var(--ng);
  color: #d63c30;
}
.btn-forget:disabled { opacity: .4; cursor: not-allowed; }

/* 「忘れる」モード。語彙の語が捨てられる。 */
.pword.forgetable {
  cursor: crosshair;
  border-style: dashed;
  border-color: var(--ng);
  opacity: .9;
}
.pword.forgetable:hover {
  background: rgba(214, 60, 48, 0.20);
  transform: scale(1.06);
}

/* 語を選んだ状態。文の行の落とし場だけを明るくする。 */
.placing .sen-row {
  border-color: rgba(224, 72, 45, 0.29);
  background: #f1f5fb;
}
.placing .sen-word { cursor: copy; }
/* 「忘れる」モードのボタン状態は .btn-forget.on で表現する。 */
#lexiconCount.full { color: var(--ng); font-weight: 700; }

.forge-hint {
  font-size: .78rem;
  color: var(--fg-dim);
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 8px 10px;
  max-height: 130px;
  overflow-y: auto;
}
.forge-hint table { width: 100%; border-collapse: collapse; font-family: var(--mono); }
.forge-hint td { padding: 1px 0; }
.forge-hint .hc { color: var(--idiom); }

.forge-detail {
  font-size: .76rem;
  color: var(--fg-dim);
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 8px 10px;
  min-height: 56px;
}
.forge-detail .dt { color: var(--fg); font-weight: 700; display: block; margin-bottom: 2px; }
.forge-detail .dl { font-family: var(--mono); color: var(--fg-mute); }
/* 直前の操作の結果 (入れた / 戻した / 理由)。 */
.forge-detail .dt.msg { color: var(--ok); }
/* その語に使える接続詞の一覧。 */
.forge-detail .conn-list { color: var(--info, #0d7fc4); }

/* 接続詞を一覧から一発で選ぶメニュー。語の右のマスをタップして開く。 */
.conn-picker {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 96px;
  padding: 6px;
  background: #f1f5fb;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  box-shadow: 0 12px 30px rgba(23, 43, 84, 0.147);
  font-size: .8rem;
}
.conn-picker-head {
  color: var(--fg-mute);
  font-size: .68rem;
  padding: 0 4px 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line);
}
.conn-pick {
  text-align: left;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.conn-pick:hover { color: var(--fg); background: rgba(36, 87, 214, 0.10); }
.conn-pick.cur { color: var(--info, #0d7fc4); border-color: var(--info, #0d7fc4); }

/* ══ タイトル ════════════════════════════════════════════════════════ */

.title-wrap { text-align: center; animation: rise .3s ease-out; padding: 12px 0; width: min(100%, 680px); margin: auto; display: flex; flex-direction: column; align-items: center; }
.title-wrap { overflow-wrap: anywhere; }
.title-menu, .title-record, .title-version { position: relative; flex: none; }
.title-version { isolation: isolate; z-index: 1; transform: none !important; }

/* 紙に墨で題を書き、その下を朱で払う (かすれは gradient だけで作る) */
.title-main {
  position: relative;
  display: inline-block;
  margin: 0;
  font-size: clamp(2.8rem, 11vw, 5rem);
  font-weight: 900;
  letter-spacing: .06em;
  line-height: 1.08;
  color: var(--ink);
}
.title-main span { display: block; color: var(--accent); }
.title-main::after {
  content: '';
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: -.3em;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(224, 72, 45, .06), rgba(224, 72, 45, .6) 34%, rgba(224, 72, 45, .1));
  transform: skewX(-16deg);
}
.title-tag {
  margin: 26px 0 28px;
  color: var(--fg-dim);
  letter-spacing: .2em;
  font-size: .92rem;
}

.title-menu { display: flex; flex-direction: column; gap: 9px; width: min(300px, 84vw); margin: 0 auto; }
.title-menu .btn { font-weight: 700; letter-spacing: .12em; }

.title-record {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 10px;
  margin: 30px auto 0;
  width: min(100%, 640px);
}
.title-record div {
  text-align: center;
  padding: 8px 4px;
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  box-shadow: var(--shadow-s);
}
.title-record div {
  padding: 8px 4px;
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  box-shadow: var(--shadow-s);
}
.title-record b {
  display: block;
  font-family: var(--mono);
  font-size: 1.3rem;
  color: var(--accent);
}
.title-record span { font-size: .7rem; color: var(--fg-mute); letter-spacing: .08em; }

.title-version {
  position: static;
  clear: both;
  display: block;
  width: max-content;
  margin: 16px auto 0;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 700;
  color: var(--fg-dim);
  letter-spacing: .08em;
  pointer-events: none;
}

/* ══ ステージ選択 ════════════════════════════════════════════════════ */

.panel-stages { width: min(760px, 100%); }
/* ステージは 19 面以上ある。パネルの高さに畳んで、
   一覧だけをスクロールで見せる (flex の子は既定で縮まない)。 */
.stage-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.stage-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  box-shadow: var(--shadow-s);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
  transition: border-color .13s, background .13s, box-shadow .13s, transform .08s;
}
.stage-card:hover:not(:disabled) {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(23, 43, 84, 0.112);
  transform: translateX(2px);
}
.stage-card:disabled { opacity: .38; cursor: not-allowed; }
.stage-num {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg-mute);
  width: 34px; text-align: center;
}
.stage-meta { flex: 1; min-width: 0; }
.stage-name { font-weight: 700; }
.stage-intro { font-size: .78rem; color: var(--fg-mute); }
.stage-tags { display: flex; gap: 5px; margin-top: 3px; }
.tag {
  font-size: .68rem;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  color: var(--fg-mute);
}
.tag.boss { color: var(--ng); border-color: rgba(214, 60, 48, 0.32); }
.tag.done { color: var(--ok); border-color: rgba(22, 145, 90, 0.34); }
.stage-stars { font-size: 1.1rem; color: var(--accent); letter-spacing: .1em; }

/* ══ 武器選択 ════════════════════════════════════════════════════════ */

.loadout-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 9px;
  overflow-y: auto;
}

.lo-card {
  position: relative;
  padding: 11px 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
  transition: border-color .13s, background .13s;
}
.lo-card:hover { background: #e9eef7; }
.lo-card.on {
  border-color: var(--accent);
  background: #f5f8fd;
  box-shadow: inset 0 0 0 1px rgba(224, 72, 45, 0.19);
}
.lo-card:disabled { opacity: .35; cursor: not-allowed; }
.lo-name { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.lo-kind {
  font-size: .68rem; font-weight: 600; letter-spacing: .06em;
  color: var(--accent); border: 1px solid currentColor;
  border-radius: 3px; padding: 0 4px; opacity: .85;
}
.lo-core { font-size: .72rem; color: var(--fg-mute); }
.lo-desc { font-size: .76rem; color: var(--fg-dim); margin-top: 3px; }
.lo-lv {
  position: absolute; top: 9px; right: 11px;
  font-family: var(--mono); font-size: .72rem; color: var(--accent);
}
.lo-check {
  position: absolute; top: 8px; right: 10px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffe9dd;
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 800;
}

/* ══ 報酬 ════════════════════════════════════════════════════════════ */

.panel-reward { width: min(940px, 100%); }
.reward-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.rw-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-s);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--fg);
  transition: border-color .13s, background .13s, transform .1s;
}
.rw-card:hover {
  border-color: var(--accent);
  background: #f5f8fd;
  transform: translateY(-3px);
}
.rw-kind {
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--fg-mute);
  text-transform: none;
}
.rw-glyph {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
}
.rw-name { font-weight: 700; font-size: .95rem; }
.rw-desc { font-size: .78rem; color: var(--fg-dim); }
.rw-fx { font-family: var(--mono); font-size: .72rem; color: var(--ok); }

.rw-card[data-kind="weapon"]   { border-left: 3px solid var(--thunder); }
.rw-card[data-kind="weaponup"] { border-left: 3px solid var(--accent); }
.rw-card[data-kind="rest"]     { border-left: 3px solid #2e9159; }

/* ══ 結算 ════════════════════════════════════════════════════════════ */

.panel-result { width: min(560px, 100%); }
.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-family: var(--mono);
}
.rs-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 11px;
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  font-size: .86rem;
}
.rs-row b { color: var(--accent); }
.rs-row.big { grid-column: 1 / -1; }
.rs-row.big b { font-size: 1.3rem; }

/* ══ 遊び方 ═══════════════════════════════════════════════════════════ */

.panel-howto { width: min(720px, 100%); }
.howto-body { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.howto-body h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: .04em;
}
.howto-body p { margin: 0 0 8px; font-size: .89rem; color: var(--fg-dim); }
.howto-body strong { color: var(--fg); }
.howto-list { margin: 0; padding-left: 20px; font-size: .87rem; color: var(--fg-dim); }
.howto-list li { margin: 3px 0; }

/* 遊び方は **見出しだけ** を並べ、読みたい節だけ開く。
   長い説明を常に全部見せると、かえって読まれなくなる。 */
.howto-sec {
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 0 12px;
}
.howto-sec > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}
.howto-sec > summary::-webkit-details-marker { display: none; }
.howto-sec > summary::after {
  content: '＋';
  margin-left: auto;
  color: var(--fg-mute);
  font-size: .8rem;
  font-weight: 700;
}
.howto-sec[open] > summary::after { content: '−'; }
.howto-sec > summary h3 { margin: 0; font-size: .98rem; }
.howto-sec[open] > summary h3 { color: var(--accent); }
.howto-sec-body { padding-bottom: 10px; }
.howto-sec-body > :last-child { margin-bottom: 0; }

/* ══ 書庫 ══════════════════════════════════════════════════════════════ */

.panel-archive { width: min(720px, 100%); }
.archive-ink {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: none;
  padding: 10px 12px;
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
}
.archive-ink-label { font-size: .9rem; color: var(--accent); font-weight: 700; }
.archive-ink b { font-family: var(--mono); font-size: 1.4rem; color: var(--accent); }
.archive-ink-note { font-size: .76rem; color: var(--fg-mute); margin-left: auto; }
.archive-ink-note strong { color: var(--fg-dim); }

.shop-word {
  background: #f1f5fb;
  border: 1.5px solid;
  border-radius: var(--r-s);
  color: var(--fg);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .12s;
}
.shop-word:hover { background: #eef2f9; }
.shop-word.can { box-shadow: 0 0 0 2px rgba(224, 72, 45, 0.17); }
.shop-word.owned { opacity: .55; cursor: default; color: var(--ok); }

/* ══ 部位強化 ══════════════════════════════════════════════════════════ */

.panel-grow { width: min(760px, 100%); }
.grow-body { overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.grow-body h3 { margin: 0 0 8px; font-size: .95rem; color: var(--accent-ink); letter-spacing: .06em; }

/* ── 強化: 左に部位、右に所持語 ─────────────────────────────────────────
   所持語を部位の下に置くと、語が多いほどパネルが縦に伸びて下の語に
   手が届かなくなる。部位の右に独立した一覧を置き、その中だけで
   スクロールさせれば、どの語も必ず押せる (掴める)。 */
.panel-parts {
  width: min(1120px, 100%);
  height: min(880px, 100%);
}
.grow-parts-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  overflow: hidden;
}
.grow-parts-col {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 4px;
}
.grow-pool {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #eff3fa;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
}
.grow-side-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.grow-side-head h3 { margin: 0; font-size: .95rem; letter-spacing: .04em; color: var(--fg-dim); }
.grow-pool > .grow-note { margin: 0; }
/* 語はドラッグの起点なので touch-action: none。指では一覧の上をなぞって
   スクロールできないぶん、上下ボタンでも動かせるようにする。 */
.grow-pool-scroll { display: flex; gap: 4px; flex: none; }
.grow-scroll {
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: .66rem;
  color: var(--fg-dim);
}
.grow-scroll:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.grow-note { margin: 0 0 8px; font-size: .78rem; color: var(--fg-dim); line-height: 1.65; }
.grow-note strong { color: var(--accent); }
.grow-gacha { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.grow-gacha-result { font-size: .9rem; font-weight: 700; color: var(--ok); }

/* 全部位の合計。ここを見れば今どれだけ強いかが分かる */
.grow-total {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  background: linear-gradient(180deg, #ffffff, #f3f8ff);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--ok);
  border-radius: var(--r-s);
  box-shadow: var(--shadow-s);
}
.grow-total-label { font-size: .78rem; font-weight: 800; letter-spacing: .1em; color: var(--fg-dim); }
.grow-total-none { font-size: .78rem; color: var(--fg-mute); }
.grow-total-warn {
  font-size: .74rem;
  font-weight: 700;
  color: var(--ng);
  background: rgba(214, 60, 48, .09);
  border: 1px solid rgba(214, 60, 48, .3);
  border-radius: 999px;
  padding: 1px 8px;
}

/* 能力の差 1 つぶん (「体力 +25」)。合計と部位の両方で使う */
.eff {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(22, 145, 90, .35);
  background: rgba(22, 145, 90, .09);
  color: #0f7a4a;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.eff i { font-style: normal; font-size: .66rem; opacity: .8; }
.eff.big { font-size: .78rem; padding: 2px 9px; }

/* 部位は 1 文。枠は「語 + 接続詞 + ✕」で、戦闘中の文と同じ作り。
   並びは人型にせず、部位を普通に縦に並べる (1 部位 = 1 行)。 */
.grow-parts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.grow-part-row { display: flex; align-items: center; gap: 7px; }
.grow-part-row .grow-part-name { flex: 0 0 auto; min-width: 3.4em; }
/* 部位の文は 1 行。行のどこへ落としてもその位置に入る。 */
.grow-part-row .sen-row { flex: 1 1 auto; min-width: 0; }
.grow-part-row .sen-row.empty { border-style: dashed; background: #f4f7fc; }
.grow-part-placeholder { font-size: .74rem; color: var(--fg-mute); }
.grow-part-lv { flex: 0 0 auto; font-size: .7rem; color: var(--fg-mute); font-variant-numeric: tabular-nums; }
.grow-part-clear {
  flex: 0 0 auto;
  padding: 3px 8px;
  font-size: .72rem;
  font-weight: 700;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #ffffff;
  color: var(--fg-dim);
}
.grow-part-clear:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.grow-part-clear:disabled { opacity: .35; }
.grow-undo { margin-left: 6px; padding: 2px 10px; font-size: .72rem; }
.grow-undo:disabled { opacity: .35; }
/* 空の接続詞のマスも、部位では見えるようにする (タップで一覧が開く)。 */
#growParts .sen-conn.empty { opacity: .45; }
#growParts .sen-conn.empty:hover { opacity: 1; }
#growParts .sen-word { min-height: 28px; font-size: .9rem; }
#growParts .sen-row.drop-hot {
  background: #fff4ec;
  border-color: rgba(224, 72, 45, 0.55);
  box-shadow: inset 0 0 0 1px rgba(224, 72, 45, 0.12);
}
#growParts .sen-item.drop-before::before,
#growParts .sen-item.drop-after::after {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(224, 72, 45, 0.14);
  pointer-events: none;
}
#growParts .sen-item.drop-before::before { left: -2px; }
#growParts .sen-item.drop-after::after { right: -2px; }
#growWords.drop-hot {
  outline: 2px dashed rgba(224, 72, 45, 0.55);
  outline-offset: 3px;
  border-radius: var(--r-s);
}
#growWords .grow-word { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
#growWords .grow-word:active { cursor: grabbing; }
.grow-part {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  gap: 5px;
  padding: 8px 9px 7px;
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-2);
  border-radius: var(--r-s);
  box-shadow: var(--shadow-s);
  transition: border-color .12s, box-shadow .12s;
}
.grow-part.filled { border-left-color: var(--ok); }
.grow-part:has(.grow-part-note.bad) { border-left-color: var(--ng); background: rgba(214, 60, 48, .05); }
.grow-part-name {
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--fg-dim);
}
.grow-sen { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }

.grow-slot {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
}
.grow-slot.filled {
  flex: 0 1 auto;
  /* 接続詞の一覧を枠の下の行へ落とす。wrap が無いと横に潰れて
     一覧が 1 列になり、iPad では読めない縦長の帯になる。 */
  flex-wrap: wrap;
  align-content: start;
}
.grow-slot.empty {
  justify-content: center;
  min-height: 32px;
  border: 1.5px dashed var(--line-2);
  border-radius: 7px;
  color: var(--fg-mute);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
.grow-slot.empty:hover { border-color: var(--accent); background: rgba(224, 72, 45, .07); color: var(--accent); }
.grow-slot.empty:active { transform: translateY(1px); }

/* 語のチップ。タップで接続詞が回る */
.gs-word {
  flex: 1 1 auto;
  min-width: 2.4rem;
  min-height: 34px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: .98rem;
  font-weight: 700;
  color: var(--word);
  background: var(--word-bg);
  border: 1.5px solid var(--word-line);
  border-radius: 7px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .95) inset;
  cursor: pointer;
  touch-action: none;
}
.gs-word:hover { border-color: var(--accent); }
/* 接続詞のマス。一覧を開いている間はずっと強調 */
.gs-conn {
  flex: none;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  font-size: .76rem;
  font-weight: 700;
  border: 1.5px dashed var(--conn-line);
  border-radius: 999px;
  background: var(--conn-bg);
  color: var(--conn);
  cursor: pointer;
}
.gs-conn.filled { border-style: solid; border-color: var(--conn); background: rgba(36, 87, 214, .16); color: var(--conn); font-weight: 800; }
.gs-conn.on, .gs-conn:hover { border-color: var(--accent); color: var(--accent); background: rgba(224, 72, 45, .1); }
.gs-out {
  flex: none;
  width: 20px;
  height: 24px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--fg-mute);
  font-size: .74rem;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
  transition: opacity .12s, background .12s, color .12s;
}
.gs-out:hover { opacity: 1; background: rgba(214, 60, 48, .12); color: #d63c30; }

/* 接続詞の一覧。枠の下にインラインで開く (画面を移動しない) */
.grow-conn-menu {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 7px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  box-shadow: var(--shadow-s);
  animation: rise .12s ease-out;
}
.grow-conn-pick {
  padding: 3px 9px;
  font-size: .82rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1.5px solid var(--line-2);
  background: #ffffff;
  color: var(--conn);
}
.grow-conn-pick:hover { border-color: var(--accent); color: var(--accent); }
.grow-conn-pick.cur {
  border-color: var(--accent);
  background: rgba(224, 72, 45, .12);
  color: var(--accent-ink);
  box-shadow: var(--ring);
}
/* 文が成る形は緑、成らない形は灰。押せるが結果が分かるようにする。 */
.grow-conn-pick.ok { border-color: rgba(22, 145, 90, .5); background: rgba(22, 145, 90, .08); color: #0f7a4a; }
.grow-conn-pick.ok::before { content: '✓'; font-size: .7rem; color: var(--ok); margin-right: 3px; }
.grow-conn-pick.no { color: var(--fg-mute); border-style: dashed; }
.grow-conn-pick.no::before { content: '✕'; font-size: .66rem; opacity: .7; margin-right: 3px; }
.grow-conn-pick.own { font-weight: 800; }
/* 候補の並び。開いた枠の中で横に回り込む。 */
.grow-conn-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
/* 熟語の形 (発電 の する) は色を変えて、語の形と区別する。 */
.grow-conn-pick.idiom { border-color: var(--idiom); color: var(--idiom); }
.grow-conn-none { font-size: .7rem; color: var(--fg-mute); }
.grow-conn-legend { flex: 1 1 100%; font-size: .68rem; color: var(--fg-mute); }
.grow-conn-legend i { font-style: normal; font-weight: 800; }
.grow-conn-legend i.ok { color: var(--ok); }
.grow-conn-legend i.no { color: var(--fg-mute); }

/* 部位の文の評価。**何がどれだけ変わるか** を数字で出す */
.grow-part-note { font-size: .8rem; line-height: 1.5; color: var(--fg-mute); }
.grow-part-note.plain { color: var(--ok); }
.grow-part-note.idiom { color: var(--idiom); font-weight: 700; }
.grow-part-note.great { color: var(--great); font-weight: 700; }
.grow-part-note.bad { color: var(--ng); }
.grow-part-note.empty { color: var(--fg-mute); opacity: .85; }
.grow-part-note b { color: inherit; font-weight: 800; }
.grow-part-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
  margin-bottom: 3px;
}
.grow-part-head b { font-size: .95rem; color: var(--word); letter-spacing: .04em; font-weight: 900; }
.grow-part-grade { font-weight: 700; }
.grow-part-idiom { color: var(--idiom); font-weight: 700; }
.grow-part-eff { display: flex; flex-wrap: wrap; gap: 3px; }
.grow-part-eff.none { font-size: .68rem; color: var(--fg-mute); }
.grow-part-fix { display: block; margin-top: 2px; color: var(--fg-dim); }

/* 所持語は右の列の中でスクロールする。語が多いほど伸びるのではなく、
   一覧の中だけが動くので、パネルの外へはみ出さない。 */
.grow-words {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-content: start;
  padding: 4px;
}
.grow-word {
  font-size: .88rem;
  font-weight: 700;
  padding: 6px 10px;
  position: relative;
  background: linear-gradient(180deg, #ffffff, var(--panel-2));
  border: 1px solid var(--line-2);
  border-radius: 7px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset;
}
.grow-word:hover { border-color: var(--accent); }
.grow-word.sel {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff7f3;
  box-shadow: var(--ring);
}
.grow-word.used { padding-right: 26px; }
.grow-word-used {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-style: normal;
  font-size: .62rem;
  font-weight: 700;
  color: var(--fg-mute);
}
.grow-word.sel .grow-word-used { color: rgba(255, 248, 242, .85); }
/* 部位に入れると効く語は緑の下線。効かない語 (武器で使う語) は淡く出す。 */
.grow-word.has-eff { border-bottom: 2px solid rgba(22, 145, 90, .5); }
.grow-word.no-eff { color: var(--fg-dim); }
/* 語の意味が効く部位 (「賢」→ 頭)。どこに入れると効くかの目印。 */
.grow-word-eff.where { color: var(--conn); background: rgba(36, 87, 214, .10); margin-left: 4px; padding: 0 3px; border-radius: 3px; }
.grow-word-eff {
  display: block;
  font-family: var(--mono);
  font-style: normal;
  font-size: .5rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f7a4a;
}
.grow-word.sel .grow-word-eff { color: rgba(255, 248, 242, .92); }
.grow-word.deck { opacity: .55; }
/* デッキに入っている印は「✓」と文字の色で出す。枠と地の色はランクに譲る
   (どれが入っているかより、どのランクかが色で読めるようにする)。 */
.grow-word.deck.in { opacity: 1; color: var(--ok); }
.grow-deck-count { font-size: .8rem; color: var(--fg-dim); font-weight: 400; }

/* ══ 辞書 ══════════════════════════════════════════════════════════════ */

/* 辞書パネル。画面の 9 割まで伸びる実高さを持たないと、
   内側の .dict-list (flex: 1) が高さを得られず、362 語ぶんの行が
   画面の下まで垂れ流しになって「反映されていない」ように見える。 */
.panel-dict {
  width: min(780px, 100%);
  height: min(92vh, 820px);
}
.dict-bar { display: flex; gap: 10px; align-items: center; flex: none; }
.dict-bar input {
  flex: 1;
  background: #f1f5fb;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  color: var(--fg);
  font-family: inherit;
  font-size: .92rem;
  padding: 9px 12px;
}
.dict-bar input:focus { outline: none; border-color: var(--accent); }
.dict-count { flex: none; font-family: var(--mono); font-size: .78rem; color: var(--fg-mute); }

.dict-tabs { display: flex; gap: 5px; flex-wrap: wrap; flex: none; }
.dict-tab {
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--fg-dim);
  font-family: inherit;
  font-size: .78rem;
  padding: 4px 11px;
  cursor: pointer;
  transition: background .12s;
}
.dict-tab:hover { background: #eef2f9; }
.dict-tab.on { background: #e8eef7; border-width: 1.5px; }

.dict-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* パネルの中で余った高さを全部使う。これが無いと 362 語ぶんの行が
     画面の外まではみ出し、下の語が見えない (スクロールも効かない)。 */
  flex: 1 1 0;
  min-height: 0;
}
.dict-row {
  display: grid;
  grid-template-columns: 3.4rem 4.6rem 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 9px;
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
}
.dict-row:hover { background: #ece5d2; }
.dict-w {
  justify-self: start;
  border: 1.5px solid;
  border-radius: 6px;
  padding: 2px 7px;
  font-size: .95rem;
  font-weight: 700;
}
.dict-cat { font-size: .74rem; }
.dict-fx { font-size: .8rem; color: var(--fg-dim); }
.dict-tags {
  grid-column: 3;
  font-size: .72rem;
  color: var(--fg-mute);
}
.dict-empty { padding: 26px; text-align: center; color: var(--fg-mute); font-size: .9rem; }

/* ══ 初回の説明 (タブ右上の「?」) ═════════════════════════════════════════
   タブの中に長い説明を置かず、初めて開いたときだけこれを出す。 */
.help-screen { z-index: 60; }
.panel-help { width: min(560px, 100%); }
.tip-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tip-list li {
  display: grid;
  grid-template-columns: 5.4em minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  font-size: .9rem;
  line-height: 1.7;
}
.tip-list b {
  justify-self: start;
  padding: 1px 8px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #e9eef7;
  color: var(--fg-dim);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}
.tip-list span { color: var(--fg-dim); }
@media (max-width: 560px) {
  .tip-list li { grid-template-columns: 1fr; gap: 2px; }
}

.dev-panel { width: min(420px, 100%); }
.dev-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dev-word-row { display: flex; gap: 8px; margin-top: 8px; }
.dev-word-row input { flex: 1 1 auto; min-width: 0; }
.dev-screen { z-index: 70; }

/* ══ 設定 ════════════════════════════════════════════════════════════ */

.panel-settings { width: min(480px, 100%); }
.settings-body { display: flex; flex-direction: column; gap: 11px; }
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #f1f5fb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  font-size: .88rem;
}
.set-row > span { flex: none; width: 90px; }
.set-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.set-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.set-row b { font-family: var(--mono); width: 34px; text-align: right; color: var(--accent); }
.set-row-danger { border-color: rgba(214, 60, 48, 0.24); }

/* ══ 画面の広さに合わせる ════════════════════════════════════════════ */

/* パネルは画面より高くしない。dvh を使うと iPad のブラウザ UI でも
   はみ出さず、中のスクロールに収まる。 */
.panel { max-height: min(100%, 100dvh); }

/* iPad の縦 (810〜834px) や分割表示では、鍛冶の 2 列が入らない。
   1 列に落として、語彙と武器の両方をスクロールで見せる。 */
@media (max-width: 1000px) {
  .panel-forge { width: 100%; height: 100%; }
  /* 縦長では 1 本のスクロールにまとめる。入れ子のスクロールは
     指で扱いにくく、語彙が武器を隠してしまう。 */
  .forge-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
  }
  .forge-weapons { flex: none; overflow: visible; max-height: none; }
  .forge-side { flex: none; overflow: visible; }
  .lexicon {
    flex: none;
    min-height: 72px;
    max-height: 24vh;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  }
}

@media (max-width: 860px) {
  .archive-ink-note { display: none; }
  .dict-row { grid-template-columns: 3.2rem 1fr; }
  .dict-cat { justify-self: start; }
  .dict-fx, .dict-tags { grid-column: 2; }
  .title-record { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 320px); }
  .panel { padding: 16px; gap: 12px; }
  .result-stats { grid-template-columns: 1fr; }
  /* 辞書は固定高を保ち、一覧だけをパネル内でスクロールさせる。 */
  .panel-dict { height: min(92dvh, 820px); min-height: 0; }
  .panel-howto, .panel-grow, .panel-archive { height: auto; max-height: min(100%, 100dvh); }
}

/* HUD。狭い画面では 3 列 (左の計器 / 中央の時計 / 右の数) が
   重なるので、左右の列を縮めてタイマーを小さくする。 */
@media (max-width: 900px) {
  .hud-top { padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) 12px calc(10px + var(--safe-l)); gap: 8px; }
  .hud-timer { font-size: 1.6rem; }
  .hud-stage { max-width: 34vw; margin: 0 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hud-stats { display: none; }
  .hud-weapons { padding: 6px 10px calc(10px + var(--safe-b)); }
}

/* 電話 (縦)。数字と時計だけで横幅を使い切る。 */
@media (max-width: 560px) {
  .hud-timer { font-size: 1.35rem; }
  .hud-stage { max-width: 28vw; font-size: .72rem; letter-spacing: .04em; }
  .hud-num b { font-size: .92rem; }
  .hud-num span { display: none; }
  .hud-btns { gap: 4px; }
  .hud-btns .btn-icon { width: 40px; height: 40px; }
  .title-record { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 320px); }
  .title-version { margin-top: 12px; }
  .panel-dict { width: 100%; }
  .dict-list { font-size: .82rem; }
}

/* 横長で低い画面 (iPad 横の 820px など)。タイトルが縦に伸びて
   下が切れるので、題・余白・記録の並びを詰めて 1 画面に収める。 */
@media (max-height: 900px) and (min-width: 700px) {
  .title-main { font-size: clamp(2.4rem, 7vw, 3.6rem); }
  .title-tag { margin: 16px 0 16px; }
  .title-wrap { padding: 4px 0; }
  .title-menu { gap: 7px; }
  .title-menu .btn { padding: 8px 16px; }
  .title-wrap { width: min(100%, 680px); }
  .title-record { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 320px); margin-top: 16px; gap: 8px; }
  .title-version { margin-top: 12px; }
  .title-record div { min-width: 0; overflow-wrap: anywhere; }
  .title-record div { padding: 6px 3px; }
  .title-record b { font-size: 1.1rem; }
}

/* 横長で低い画面 (iPad 横の 820px など)。時計と武器チップを詰める。 */
@media (max-height: 700px) {
  .hud-timer { font-size: 1.4rem; }
  .hud-choice { max-height: calc(100vh - 16px); padding: 16px 18px 18px; }
}
@media (max-height: 560px) {
  .hud-weapons { display: none; }
  .hud-timer { font-size: 1.25rem; }
  .hud-dash { width: 78px; height: 78px; font-size: .8rem; }
}

/* タッチ端末は当たり判定を大きく。指で押す前提の大きさにする。 */
@media (hover: none) and (pointer: coarse) {
  .gs-word { min-height: 40px; padding: 6px 10px; }
  .gs-conn { min-width: 34px; height: 32px; }
  .gs-out { width: 30px; height: 32px; opacity: .7; }
  .grow-word { padding: 8px 12px; }
  .btn-icon { width: 42px; height: 42px; }
  .hud-btns .btn-icon { width: 44px; height: 44px; }
  .wrow-clear { padding: 3px 10px; }
  .sen-conn { min-width: 38px; height: 34px; }
  .pause-actions .btn { min-height: 50px; }
}

/* スクロールバー */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
   UX polish — ホバー/フォーカス/遷移の強化
   ========================================================================== */
button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button, .btn, .stage-card, .lo-card {
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, background .12s ease;
}
button:hover:not(:disabled), .btn:hover:not(.off) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
button:active:not(:disabled), .btn:active:not(.off) {
  transform: translateY(0);
  filter: brightness(0.96);
}
.stage-card:hover, .lo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(23, 43, 84, 0.147);
}
#forge .slot, #forge .gap {
  transition: background .12s ease, box-shadow .12s ease;
}
#forge .slot:hover { box-shadow: 0 0 0 2px var(--accent) inset; }

/* ══ 明るい紙の演出 ══════════════════════════════════════════════════
   ここは「見た目の総仕上げ」。地は白い紙、罫線は淡い青灰、差し色は朱。
   影は薄く広く落として、紙がふわっと浮くようにする。            */
:root {
  --gold: #d49a12;
  --gold-light: #ffe0a0;
  --line: #e4eaf5;
  --line-2: #c9d3e3;
  --shadow: 0 18px 44px rgba(23, 43, 84, .13), 0 1px 0 rgba(255,255,255,.95) inset;
  --shadow-s: 0 2px 9px rgba(23, 43, 84, .08);
}
html, body {
  background:
    var(--grain),
    radial-gradient(ellipse at 50% 4%, #ffffff 0%, rgba(255,255,255,0) 52%),
    radial-gradient(ellipse at 6% 92%, rgba(224, 72, 45, .07), transparent 38%),
    radial-gradient(ellipse at 96% 12%, rgba(36, 87, 214, .06), transparent 42%),
    linear-gradient(180deg, #ffffff 0%, #f6faff 46%, #eaf1fb 100%);
}
.screen {
  background: linear-gradient(180deg, rgba(252, 254, 255, .93), rgba(236, 243, 253, .9));
  backdrop-filter: blur(12px) saturate(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
}
.panel {
  border: 1px solid var(--line-2);
  outline: 1px solid rgba(255,255,255,.9);
  outline-offset: -5px;
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, #ffffff, #fbfdff 60%, #f4f8fe);
}
.panel-head::after { height: 3px; background: linear-gradient(90deg, var(--accent), #e8933a 78px, var(--line) 78px); }
.btn { border-color: var(--line-2); box-shadow: inset 0 1px rgba(255,255,255,.95), 0 2px 9px rgba(23, 43, 84, .07); }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(115deg, #f4623f, #e0482d 52%, #c93b22);
  border: 1px solid #b53a20;
  box-shadow: inset 0 1px rgba(255,232,220,.45), 0 8px 20px rgba(224,72,45,.24);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: ''; position: absolute; inset: -80% auto -80% -40%; width: 25%;
  transform: rotate(24deg); background: linear-gradient(90deg, transparent, rgba(255,255,255,.42), transparent);
  transition: left .5s ease;
}
.btn-primary:hover::after { left: 125%; }
.title-wrap { position: relative; isolation: isolate; }
.title-wrap::before {
  content: '✦'; position: absolute; z-index: -1; top: -1.3em; left: 50%;
  transform: translateX(-50%); font-size: 2rem; color: var(--gold);
  text-shadow: 0 0 22px rgba(212,154,18,.35); animation: sigilGlow 3s ease-in-out infinite;
}
.title-main { color: #212a3a; text-shadow: 0 2px 0 #ffffff, 0 10px 24px rgba(23, 43, 84, .12); }
.title-main span { color: var(--accent); }
.title-main::after { background: linear-gradient(90deg, transparent, var(--accent) 35%, #e8b04a 70%, transparent); height: 4px; }
.title-tag { color: var(--fg-dim); }
.title-record div { background: rgba(255,255,255,.95); border-color: var(--line-2); box-shadow: 0 4px 16px rgba(23, 43, 84, .07), inset 0 1px #fff; }
.title-record b { color: var(--accent); }
.stage-card, .lo-card, .reward-card { transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s, filter .22s; }
.stage-card:hover, .lo-card:hover, .reward-card:hover { transform: translateY(-3px) scale(1.008); filter: saturate(1.06); box-shadow: 0 14px 30px rgba(23, 43, 84, .13); }
@keyframes sigilGlow { 0%,100% { opacity:.55; transform:translateX(-50%) scale(.92) rotate(-8deg); } 50% { opacity:1; transform:translateX(-50%) scale(1.12) rotate(8deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* 幕を閉じたあと、直近の結果を一行でポップさせる。 */
.grow-gacha-result.gacha-reveal { animation: gachaReveal .62s cubic-bezier(.16,1,.3,1); }
@keyframes gachaReveal {
  0% { opacity: 0; transform: translateY(14px) scale(.72); filter: brightness(2) blur(3px); }
  55% { opacity: 1; transform: translateY(-4px) scale(1.14); filter: brightness(1.35); }
  100% { opacity: 1; transform: none; filter: none; }
}
/* 熟語成立: 鍛冶画面の行を発光させ、語チップに連鎖する印 */
#forge .wrow.idiom-born { animation: idiomForge .82s cubic-bezier(.2,.8,.2,1); }
#forge .wrow.idiom-born .sen-word.idiom-word { animation: idiomForgeWord .82s ease-out; }
@keyframes idiomForge {
  0% { filter: brightness(1); box-shadow: inset 0 0 0 rgba(214,160,54,0); }
  32% { filter: brightness(1.35); box-shadow: inset 0 0 34px rgba(255,205,89,.55), 0 0 22px rgba(255,197,66,.7); }
  100% { filter: brightness(1); box-shadow: inset 0 0 0 rgba(214,160,54,0); }
}
@keyframes idiomForgeWord {
  0%,100% { transform: scale(1); }
  28% { transform: translateY(-7px) scale(1.2); box-shadow: 0 0 22px #f3c653; }
  56% { transform: translateY(2px) scale(.97); }
}
/* 武器チップの攻撃周期に合わせた臨場感。成立文ほど強く脈動 */
.hud-weapons .wchip { position: relative; }
.hud-weapons .wchip:not(.broken) { animation: weaponReady 2.8s ease-in-out infinite; }
.hud-weapons .wchip.idiom { animation: weaponIdiom 1.7s ease-in-out infinite; }
@keyframes weaponReady { 0%,100% { box-shadow: 0 2px 8px rgba(23, 43, 84, 0.09); } 50% { box-shadow: 0 3px 14px rgba(192,139,47,.25); } }
@keyframes weaponIdiom { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.13) drop-shadow(0 0 5px rgba(220,166,48,.48)); } }

/* ── 角丸を抑える（要求対応） ──
   元は --r 12px / --r-s 8px および各所 999px のピル形状だったが、
   全体的に丸すぎるため一回り角ばらせる。ダッシュボタンの真円は維持。 */
.btn,
.panel,
.wchip,
.hud-hint,
.sen-word,
.sen-conn,
.lexicon,
.pword,
.drag-ghost,
.wrow,
.forge-side,
.grow-part,
.grow-slot,
.grow-conn-menu,
.grow-word,
.dict-row,
.set-row,
.conn-picker {
  border-radius: 4px !important;
}
.btn-icon,
.wrow-grade,
.wrow-drop,
.grow-conn-pick,
.dict-tab,
.eff,
.hud-self,
.statbox,
.choice-card {
  border-radius: 4px !important;
}
.hud-dash { border-radius: 50% !important; }

/* ═══ 文づくりの補助線を消す (要求対応) ═══════════════════════════════════
   語のあいだの ✕・空欄・隙間は出さない。文は語と接続詞が連続して見える。
   ドロップは文の行のどこでも受け、落とした位置に縦の挿入線だけを出す。 */
#forge .sen-conn.empty {
  display: none;
}
#forge .sen-conn.empty:hover,
#forge .sen-conn.empty:focus-visible { opacity: .55; }
#forge .sen-row.drop-hot {
  background: #fff4ec;
  border-color: rgba(224, 72, 45, 0.55);
  box-shadow: inset 0 0 0 1px rgba(224, 72, 45, 0.12);
}
#forge .sen-item.drop-before::before,
#forge .sen-item.drop-after::after {
  content: '';
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(224, 72, 45, 0.14);
  pointer-events: none;
}
#forge .sen-item.drop-before::before { left: -2px; }
#forge .sen-item.drop-after::after { right: -2px; }
#forge .sen-row.drop-empty {
  background: #fff4ec;
  border-style: dashed;
}
#forge .lexicon.drop-hot {
  border-color: var(--accent);
  background: rgba(224, 72, 45, 0.07);
  box-shadow: inset 0 0 0 1px rgba(224, 72, 45, 0.12);
}

/* ═══ 接続詞メニュー: 縦 1 列でスクロールして選ぶ ═══════════════════════ */
.conn-pick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 132px;
  max-height: min(46vh, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: y proximity;
}
.conn-pick {
  scroll-snap-align: center;
  min-height: 34px;
  padding: 7px 10px;
  font-size: .9rem;
}
.conn-pick.snap { background: rgba(36, 87, 214, 0.10); color: var(--fg); }
@media (hover: none) {
  .conn-pick { min-height: 44px; }
}

/* ═══ チュートリアル ════════════════════════════════════════════════════ */
.tut-steps { max-width: 62ch; }
.tut-step { display: none; }
.tut-step.is-on { display: block; }
.tut-step h3 { margin: 0 0 8px; font-size: 1.02rem; }
.tut-step p { margin: 0 0 10px; font-size: .92rem; line-height: 1.75; }
.tut-step .k {
  font-family: var(--mono);
  font-size: .84em;
  background: #f1f5fb;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  padding: 0 5px;
}
#tutStep { font-variant-numeric: tabular-nums; }

/* ═══ スマホ: 指の届きを保ちつつ省スペース ══════════════════════════════ */
@media (max-width: 640px) {
  #forge .forge-body { gap: 10px; }
  #forge .lexicon { max-height: 18vh; }
  #forge .pword,
  #forge .sen-word { font-size: 1.06rem; }
  #forge .sen-item { gap: 0; }
  .conn-picker { max-width: min(92vw, 340px); }
}

/* ════════════════════════════════════════════════════════════════════════
   モーションと言葉くじの演出
   ════════════════════════════════════════════════════════════════════════ */

/* 画面を開いたとき、パネルが紙のように静かに置かれる。 */
.screen > .panel { animation: panelSettle .34s cubic-bezier(.16,1,.3,1); }
@keyframes panelSettle {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* HP が減ったときの鼓動。数字を見なくても危険が伝わる。 */
.bar-fill.low { animation: hpLow 1.15s ease-in-out infinite; }
.bar-fill.low.critical { animation-duration: .72s; }
@keyframes hpLow {
  0%, 100% { filter: brightness(1); box-shadow: none; }
  50% { filter: brightness(1.22); box-shadow: 0 0 10px rgba(214,60,48,.5), 0 0 0 1px rgba(255,255,255,.5) inset; }
}

/* 経験値バーを流れる光。育っている実感を出す。 */
.bar-xp .bar-fill { overflow: hidden; }
.bar-xp .bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 48%, transparent 76%);
  transform: translateX(-110%);
  animation: xpSweep 2.9s ease-in-out infinite;
}
@keyframes xpSweep {
  0%, 62% { transform: translateX(-110%); }
  100% { transform: translateX(110%); }
}

/* 語を選んだときの手応え。 */
.grow-word { transition: transform .14s cubic-bezier(.2,.8,.2,1), box-shadow .14s, border-color .14s, background .14s, color .14s; }
.grow-word:hover:not(.sel) { transform: translateY(-2px); box-shadow: 0 5px 12px rgba(23,43,84,.12); }
.grow-word.sel { animation: wordPick .28s cubic-bezier(.16,1,.3,1); }
@keyframes wordPick {
  0%   { transform: scale(.92) translateY(3px); }
  55%  { transform: scale(1.05) translateY(-1px); }
  100% { transform: none; }
}
.grow-slot.empty:active { transform: translateY(1px) scale(.98); }

/* くじを引けるときの、ごく弱い呼びかけ。 */
#gachaBtn { position: relative; }
#gachaBtn:not(.off), #gachaTenBtn:not(.off) { animation: gachaReady 3.2s ease-in-out infinite; }
@keyframes gachaReady {
  0%, 100% { box-shadow: inset 0 1px rgba(255,232,220,.45), 0 8px 20px rgba(224,72,45,.24); }
  50% { box-shadow: inset 0 1px rgba(255,232,220,.55), 0 9px 24px rgba(224,72,45,.34), 0 0 0 3px rgba(224,72,45,.09); }
}

/* ── 言葉くじの幕 ────────────────────────────────────────────────────── */

.gacha-veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(14px + var(--safe-t)) calc(14px + var(--safe-r)) calc(14px + var(--safe-b)) calc(14px + var(--safe-l));
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 246, 214, .2), transparent 44%),
    rgba(22, 28, 42, .54);
  backdrop-filter: blur(8px) saturate(.9);
  -webkit-backdrop-filter: blur(8px) saturate(.9);
  animation: gachaVeilIn .18s ease-out;
}
.gacha-veil[hidden] { display: none !important; }
.gacha-veil { overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; align-items: start; }
#grow .gacha-veil:not([hidden]) { display: flex; }
.gacha-box { margin: auto 0; flex: 0 0 auto; width: min(392px, 100%); }
.gacha-veil:not(.is-revealed) { touch-action: pan-y; }
.gacha-card-ten .gacha-lot-list { overflow-y: auto; overscroll-behavior: contain; }
@keyframes gachaVeilIn { from { opacity: 0; } to { opacity: 1; } }

.gacha-box {
  position: relative;
  width: min(392px, 100%);
  padding: 22px 22px 16px;
  text-align: center;
  color: var(--fg);
  background:
    radial-gradient(ellipse at 50% 0%, #ffffff 0%, rgba(255,255,255,0) 58%),
    linear-gradient(180deg, #fffdf7 0%, #fbf7ec 62%, #f1ecdf 100%);
  border: 1px solid #b9b09b;
  outline: 1px solid rgba(255,255,255,.85);
  outline-offset: -6px;
  box-shadow: 0 28px 70px rgba(12, 18, 32, .38), 0 1px 0 #fff inset;
  animation: gachaBoxIn .38s cubic-bezier(.16,1,.3,1);
}
.gacha-box::before,
.gacha-box::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(165, 49, 27, .4);
  pointer-events: none;
}
.gacha-box::before { left: 7px; top: 7px; border-right: 0; border-bottom: 0; }
.gacha-box::after { right: 7px; bottom: 7px; border-left: 0; border-top: 0; }
@keyframes gachaBoxIn {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.gacha-x {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #8a8270;
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
}
.gacha-x:hover { color: var(--accent); background: rgba(224,72,45,.08); }

.gacha-kicker {
  margin: 0 0 2px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .42em;
  text-indent: .42em;
  color: #9a6b2c;
}

.gacha-stage {
  position: relative;
  height: 228px;
  margin: 0 -4px;
  perspective: 700px;
}

/* 幕の奥に薄く置く「籤」の文字。回っている間の余白を紙の意匠で埋める。 */
.gacha-stage::before {
  content: '籤';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10rem;
  font-weight: 900;
  line-height: 1;
  color: rgba(122, 88, 36, .05);
  transform: rotate(-6deg);
  pointer-events: none;
  user-select: none;
}

/* 回っているリール。3 列の目が縦に流れる。 */
.gacha-reels {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: opacity .18s ease, transform .22s ease;
}
.gacha-reel {
  width: 54px;
  height: 72px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff, #f4f0e4);
  border: 1px solid #c9c1ae;
  box-shadow:
    inset 0 12px 16px -14px rgba(40,32,18,.5),
    inset 0 -12px 16px -14px rgba(40,32,18,.5),
    0 1px 0 #fff;
}
.gacha-reel.main {
  width: 86px;
  height: 92px;
  border-color: #c9a24a;
  box-shadow:
    0 0 0 3px rgba(232,163,10,.1),
    inset 0 14px 18px -16px rgba(90,60,10,.45),
    inset 0 -14px 18px -16px rgba(90,60,10,.45),
    0 2px 10px rgba(120,80,20,.12);
}
.gacha-reel span {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: .02em;
}
.gacha-reel.main span { font-size: 2.5rem; }
.gacha-reels.spinning .gacha-reel span { animation: reelFlick .1s linear infinite; }
.gacha-reels.spinning .gacha-reel:nth-child(1) span { animation-duration: .12s; }
.gacha-reels.spinning .gacha-reel:nth-child(2) span { animation-duration: .085s; }
.gacha-reels.spinning .gacha-reel:nth-child(3) span { animation-duration: .135s; }
@keyframes reelFlick {
  0%   { transform: translateY(-10px); opacity: .25; filter: blur(1.5px); }
  40%  { transform: translateY(0); opacity: 1; filter: none; }
  100% { transform: translateY(10px); opacity: .2; filter: blur(1.5px); }
}
.gacha-veil.is-revealed .gacha-reels {
  opacity: 0;
  transform: scale(.88) translateY(4px);
  pointer-events: none;
}

/* 開示される一枚の紙。 */
.gacha-card {
  --cat: var(--accent);
  position: absolute;
  inset: 2px 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  opacity: 0;
  transform: scale(.84) rotateX(-16deg);
  pointer-events: none;
  background: linear-gradient(180deg, #fffefa, #fbf6e9);
  border: 1px solid #c9bda4;
  box-shadow: 0 14px 34px rgba(70,52,20,.18), inset 0 0 0 1px rgba(255,255,255,.9);
}
.gacha-card [hidden] { display: none !important; }
.gacha-lot-list[hidden] { display: none !important; }
.gacha-lot-list {
  position: relative;
  z-index: 1;
  width: min(340px, 96%);
  max-height: 208px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.gacha-lot-item {
  min-height: 32px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  text-align: left;
  background: rgba(255,255,255,.78);
  border: 1px solid #ded3bd;
}
.gacha-lot-item b { font-size: 1rem; }
.gacha-lot-item small { color: var(--fg-dim); font-size: .55rem; }
.gacha-lot-item i { color: #8b6b32; font-size: .55rem; font-style: normal; }
.gacha-lot-item.duplicate { opacity: .68; }
.gacha-lot-number { color: #a98a52; font: .58rem var(--mono); }
.gacha-card.gacha-card-ten { inset: 2px 4px; }
.gacha-card.gacha-card-ten::before { inset: 4px; }
.gacha-card.gacha-card-ten { overflow-y: auto; }
.gacha-card-ten .gacha-lot-list { max-height: min(100%, 54vh); }
.gacha-lot-list { touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.gacha-lot-list[hidden] { display: none !important; }
.gacha-card::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(120,96,52,.24);
  pointer-events: none;
}
.gacha-veil.is-revealed .gacha-card {
  opacity: 1;
  transform: none;
  animation: gachaCardIn .62s cubic-bezier(.16,1,.3,1);
}
@keyframes gachaCardIn {
  0%   { opacity: 0; transform: rotateX(-70deg) scale(.82); }
  55%  { opacity: 1; transform: rotateX(8deg) scale(1.03); }
  100% { opacity: 1; transform: none; }
}

.gacha-seal {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff8f2;
  font-size: .9rem;
  font-weight: 900;
  transform: rotate(-9deg);
  box-shadow: 0 2px 0 rgba(120,30,15,.35);
  opacity: 0;
}
.gacha-veil.is-revealed .gacha-seal {
  animation: gachaStamp .5s cubic-bezier(.2,.8,.3,1) .12s both;
}
@keyframes gachaStamp {
  0%   { opacity: 0; transform: scale(2.1) rotate(-18deg); }
  60%  { opacity: 1; transform: scale(.92) rotate(-9deg); }
  100% { opacity: 1; transform: scale(1) rotate(-9deg); }
}

.gacha-ribbon {
  position: absolute;
  top: 12px;
  right: 2px;
  padding: 3px 10px;
  background: linear-gradient(115deg, #e8b23c, #c08a10);
  color: #fffdf5;
  font-size: .6rem;
  font-weight: 900;
  letter-spacing: .18em;
  box-shadow: 0 2px 8px rgba(150,100,10,.25);
  transform: rotate(3deg);
  opacity: 0;
}
.gacha-ribbon[hidden] { display: none !important; }
.gacha-veil.is-revealed .gacha-ribbon {
  animation: gachaRibbon .42s cubic-bezier(.16,1,.3,1) .26s both;
}
@keyframes gachaRibbon {
  from { opacity: 0; transform: translateX(16px) rotate(10deg); }
  to   { opacity: 1; transform: rotate(3deg); }
}

.gacha-word {
  font-size: clamp(2.7rem, 11vw, 3.6rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--ink);
  text-shadow: 0 2px 0 #fff, 0 5px 14px rgba(60,40,10,.12);
}
.gacha-cat {
  padding: 1px 9px;
  border: 1px solid currentColor;
  color: var(--cat);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .16em;
  background: rgba(255,255,255,.7);
}
.gacha-eff {
  max-width: 88%;
  font-family: var(--mono);
  font-size: .68rem;
  line-height: 1.45;
  color: var(--fg-dim);
}

.gacha-note {
  min-height: 2.5em;
  margin: 2px 0 12px;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--fg-dim);
}
.gacha-note b { color: var(--accent-ink); }

.gacha-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.gacha-actions .btn { min-width: 118px; }

/* 幕の外を押したときの閉じる場所。 */
.gacha-veil { cursor: default; }
.gacha-box { cursor: auto; }

/* 言玉が足りないとき、押したボタンが短く震えて「今は引けない」を伝える。 */
#gachaBtn.gacha-deny,
.btn.gacha-deny { animation: gachaDeny .36s cubic-bezier(.36,.07,.19,.97); }
@keyframes gachaDeny {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(4px); }
  45% { transform: translateX(-3px); }
  60% { transform: translateX(2px); }
  75% { transform: translateX(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .gacha-deny { animation: none; }
  .gacha-box,
  .gacha-veil.is-revealed .gacha-card,
  .gacha-veil.is-revealed .gacha-seal,
  .gacha-veil.is-revealed .gacha-ribbon,
  .gacha-reels.spinning .gacha-reel span { animation: none !important; }
  /* アニメーションの到着状態を直に置く。animation: both を消すと
     印章と NEW が opacity: 0 のまま残ってしまう。 */
  .gacha-veil.is-revealed .gacha-seal { opacity: 1; transform: rotate(-9deg); }
  .gacha-veil.is-revealed .gacha-ribbon { opacity: 1; transform: rotate(3deg); }
}

@media (max-width: 420px) {
  .gacha-box { padding: 18px 14px 14px; width: min(392px, 100%); }
  .gacha-stage { height: 210px; }
  .gacha-card { inset: 2px 6px; }
  .gacha-actions .btn { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
}

/* ═══ 言葉くじの開示を、もう一段だけ華やかに ═══════════════════════════════
   カードの上を光が横切る。NEW のときは後ろに金の光が広がる。 */
.gacha-veil.is-revealed .gacha-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 32%, rgba(255, 255, 255, .9) 47%, transparent 62%);
  transform: translateX(-130%);
  animation: gachaShineSweep .85s cubic-bezier(.2, .8, .3, 1) .3s both;
  pointer-events: none;
}
@keyframes gachaShineSweep {
  to { transform: translateX(130%); }
}
.gacha-veil.is-revealed .gacha-stage::after {
  content: '';
  position: absolute;
  inset: 8% 16%;
  z-index: -1;
  background: radial-gradient(circle, rgba(240, 194, 90, .42), transparent 68%);
  animation: gachaGoldFlash .75s ease-out .12s both;
  pointer-events: none;
}
@keyframes gachaGoldFlash {
  0% { opacity: 0; transform: scale(.6); }
  45% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.18); }
}

/* 3 択のカードは、左から順に少し遅れて立ち上がる。 */
.choice-card {
  animation: choiceRise .3s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes choiceRise {
  from { opacity: 0; transform: translateY(10px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

/* 押した瞬間だけ、少し沈む。反応していることが指に伝わる。 */
.btn:active:not(:disabled),
.choice-card:active {
  transform: translateY(1px) scale(.975);
}

@media (prefers-reduced-motion: reduce) {
  .gacha-veil.is-revealed .gacha-card::after,
  .gacha-veil.is-revealed .gacha-stage::after,
  .choice-card { animation: none !important; }
  .btn:active:not(:disabled),
  .choice-card:active { transform: none; }
}

/* リールの上下を紙に溶かす。目が硬い箱に見えない。 */
.gacha-reel {
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
}

/* 回っている間、ステージの奥がほんのり温かくなる。 */
.gacha-veil.is-spinning .gacha-stage {
  background: radial-gradient(circle at 50% 50%, rgba(240, 194, 90, .16), transparent 62%);
  animation: gachaStageBreathe 1.1s ease-in-out infinite alternate;
}
@keyframes gachaStageBreathe {
  from { filter: brightness(1); }
  to   { filter: brightness(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .gacha-veil.is-spinning .gacha-stage { animation: none; }
}

/* ════════════════════════════════════════════════════════════════════════
   手応えのモーション — 連斬・数字・ヒント
   ════════════════════════════════════════════════════════════════════════ */

/* 連斬。倒すたびに数字が跳ね、8 連斬から朱が少し強くなる。 */
.hud-combo {
  position: absolute;
  right: calc(18px + var(--safe-r));
  top: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  pointer-events: none;
  color: var(--accent-ink);
  transform: scale(var(--combo-scale, 1));
  transform-origin: 50% 30%;
  transition: transform .09s cubic-bezier(.2,.8,.2,1);
  z-index: 4;
}
.hud-combo b {
  font: 800 1.9rem/1 var(--mono);
  letter-spacing: -.02em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .95), 0 3px 9px rgba(23, 43, 84, .12);
}
.hud-combo span {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .22em;
  color: var(--fg-mute);
}
.hud-combo.hot b { color: var(--accent); animation: comboHot .55s ease-in-out infinite alternate; }
@keyframes comboHot {
  from { text-shadow: 0 1px 0 rgba(255,255,255,.95), 0 3px 9px rgba(23,43,84,.12); }
  to   { text-shadow: 0 1px 0 rgba(255,255,255,.95), 0 0 14px rgba(224,72,45,.32); }
}

/* スコアと討伐数。増えた瞬間だけ跳ねる。 */
.hud-num b.bump { animation: numPop .3s cubic-bezier(.16,1,.3,1); }
@keyframes numPop {
  0% { transform: scale(1); }
  38% { transform: scale(1.22) translateY(-2px); color: var(--accent); }
  100% { transform: scale(1); }
}

/* ヒントは下から滑り込む。 */
.hud-hint.pop { animation: hintIn .26s cubic-bezier(.16,1,.3,1); }
@keyframes hintIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* 武器チップは押せるものとして、少し浮く。 */
.wchip { transition: transform .12s cubic-bezier(.2,.8,.2,1), background .12s, border-color .12s, box-shadow .12s; }
.wchip:hover { transform: translateY(-2px); }
.wchip:active { transform: translateY(0) scale(.985); }

/* レベルアップの 3 択は、1 枚ずつ少し遅れて置かれる (既存の animation-delay と併用)。 */
.hud-choice { transform-origin: 50% 50%; }

@media (prefers-reduced-motion: reduce) {
  .hud-combo { transition: none; }
  .hud-combo.hot b,
  .hud-num b.bump,
  .hud-hint.pop,
  .wchip:hover { animation: none !important; transform: none !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   タイトルの紙面 — 大きな墨の気配と、ゆっくり動く染み
   ════════════════════════════════════════════════════════════════════════ */

#title { isolation: isolate; }
#title::before {
  content: '';
  position: absolute;
  inset: -12%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 42% 34% at 28% 30%, rgba(224, 72, 45, .055), transparent 68%),
    radial-gradient(ellipse 38% 30% at 74% 68%, rgba(27, 35, 51, .05), transparent 66%),
    radial-gradient(ellipse 30% 24% at 58% 18%, rgba(192, 138, 16, .05), transparent 70%);
  animation: titleWash 17s ease-in-out infinite alternate;
}
#title::after {
  content: '刃';
  position: absolute;
  right: 4vw;
  bottom: -2vh;
  z-index: 0;
  font-size: min(44vw, 380px);
  font-weight: 900;
  line-height: 1;
  color: rgba(27, 35, 51, .045);
  transform: rotate(-7deg);
  pointer-events: none;
  user-select: none;
}
#title > .title-wrap { position: relative; z-index: 1; width: min(100%, 680px); margin: auto; display: flex; flex-direction: column; align-items: center; }
#title .title-version { display: block; position: relative; clear: both; width: max-content; max-width: 100%; margin: 12px auto 0; transform: none !important; }
@keyframes titleWash {
  from { transform: translate3d(-1.2%, 0.6%, 0) scale(1); }
  to   { transform: translate3d(1.2%, -0.8%, 0) scale(1.035); }
}
@media (max-width: 720px) {
  #title::after { right: -4vw; font-size: 62vw; opacity: .8; }
}
@media (prefers-reduced-motion: reduce) {
  #title::before { animation: none; }
}

/* ==========================================================================
   異常時の案内 (#fatal)
   JS が例外で止まっても、白い画面のまま放置しない。
   セーブは localStorage に残っているので、この画面から再読み込みできる。
   ========================================================================== */
.fatal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(248, 251, 255, .94);
  backdrop-filter: blur(2px);
}
.fatal[hidden] { display: none; }
.fatal-card {
  width: min(100%, 620px);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 24px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--fg);
  font-family: var(--font);
}
.fatal-title { margin: 0 0 8px; font-size: 20px; font-weight: 800; letter-spacing: .02em; }
.fatal-what { margin: 0 0 10px; font-size: 14px; line-height: 1.7; color: var(--fg-dim); }
.fatal-detail {
  margin: 0 0 12px;
  padding: 10px 12px;
  max-height: 30vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--panel-2);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg-dim);
}
.fatal-detail[hidden] { display: none; }
.fatal-note { margin: 0 0 14px; font-size: 12.5px; line-height: 1.75; color: var(--fg-mute); }
.fatal-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* 一時停止の中の操作早見。表のように罫線でそろえ、キーだけ幅を固定する。 */
.pause-keys {
  margin: 10px 0 14px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--panel-2);
  text-align: left;
}
.pause-keys > div { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 10px; align-items: baseline; }
.pause-keys dt { display: flex; gap: 3px; font-size: 11.5px; font-weight: 700; color: var(--fg-dim); white-space: nowrap; }
.pause-keys dd { margin: 0; font-size: 12px; line-height: 1.5; color: var(--fg-dim); }
.pause-keys kbd {
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg);
}
@media (max-width: 520px) {
  .pause-keys > div { grid-template-columns: 1fr; gap: 2px; }
}


/* ══ 部位の人型レイアウト ══════════════════════════════════════════════ */
/* 部位は人型に置かず、普通に縦へ並べる (.grow-parts を参照)。 */

/* 空き枠は ＋ を大きく。押すと選んだ語が入る。 */
.grow-slot.empty { border: 2px dashed rgba(120, 90, 60, .45); min-height: 34px; }
.grow-slot.empty span { font-size: 1.15rem; font-weight: 900; line-height: 1; }

/* 語のランクは札の文字を出さず、下の「レアリティの色」だけで示す。 */


/* ══ 強化タブ: パネルを画面に収め、中を部位と所持語に分ける ═════════════ */
.panel-grow { display: flex; flex-direction: column; }
.panel-grow > .grow-body { min-height: 0; }

/* 狭い画面では 2 列をやめ、上に部位・下に所持語を置く。
   どちらも自分の高さでスクロールするので、下の語にも必ず届く。 */
@media (max-width: 900px) {
  .panel-parts { width: 100%; height: 100%; }
  .grow-parts-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) minmax(150px, 40%);
    gap: 10px;
  }
  .grow-pool { padding: 8px; }
  .grow-words { min-height: 0; }
}

/* 支援ボタン (タイトル) */
.btn.btn-donate { border-color: var(--accent); color: var(--accent-ink); background: rgba(224,72,45,.07); }
.btn.btn-donate:hover { background: rgba(224,72,45,.14); }

/* 言葉デッキの一括操作ボタン */
.grow-deck-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.grow-deck-actions .btn { flex: 1 1 auto; min-width: 80px; }

/* ══ レアリティの色 ═══════════════════════════════════════════════════ */
/* 語のボタンの色がそのままランク。灰=コモン / 緑=アンコモン / 青=レア /
   紫=エピック / 金=レジェンド。文字の札は出さない。 */
.grow-word.rk0 { border-color: #6b7383; }
.grow-word.rk1 { border-color: #12a58a; background: rgba(18, 165, 138, .07); }
.grow-word.rk2 { border-color: #2f7fc4; background: rgba(47, 127, 196, .09); }
.grow-word.rk3 { border-color: #8b5cf6; background: rgba(139, 92, 246, .11); }
.grow-word.rk4 {
  border-color: #d9a406;
  background: linear-gradient(180deg, rgba(217, 164, 6, .16), rgba(217, 164, 6, .07));
  box-shadow: 0 0 0 1px rgba(217, 164, 6, .35);
}

/* ═══ 語の一覧の検索と並び替え (部位・デッキ・辞書で共通) ═══════════════ */
.word-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 4px 0 7px;
  flex-wrap: wrap;
}
.word-tools input[type="search"] {
  flex: 1 1 130px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  font: inherit;
  font-size: .88rem;
  background: #fff;
  color: var(--ink);
}
.word-tools input[type="search"]:focus { outline: none; border-color: var(--accent); }
.word-sorts { display: flex; gap: 4px; flex: 0 0 auto; }
.word-sort {
  font-size: .74rem;
  padding: 5px 9px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #fff;
  color: var(--fg-dim);
  cursor: pointer;
  white-space: nowrap;
}
.word-sort:hover { border-color: var(--accent); color: var(--accent); }
.word-sort.on { background: var(--accent); border-color: var(--accent); color: #fff7f3; }

/* 部位・デッキでも、鍛冶の語彙チップ (pword) と同じ見た目にそろえる。 */
#growWords .pword, #deckWords .pword {
  width: 46px;
  height: 46px;
  font-size: 1.12rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#deckWords .pword { cursor: pointer; touch-action: auto; }
#deckWords .pword:disabled { opacity: .55; cursor: default; transform: none; }
.pword.in { background: var(--accent); border-color: var(--accent); color: #fff7f3; }
.pword.in:hover { background: var(--accent); border-color: var(--accent); color: #fff7f3; }
.pword-rank {
  position: absolute;
  left: 2px;
  top: 1px;
  font-family: var(--mono);
  font-size: .58rem;
  font-weight: 700;
  opacity: .92;
  pointer-events: none;
}
.grow-words-empty { color: var(--fg-dim); font-size: .85rem; padding: 8px 2px; }
.pword.used { box-shadow: 0 0 0 1px rgba(47, 124, 196, .35) inset; }

/* 部位の行頭。**ここだけが鍛冶の文と違う** — 部位名が固定で付く。 */
.grow-part-grade {
  font-size: .72rem;
  padding: 2px 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--fg-dim);
  flex: 0 0 auto;
  white-space: nowrap;
  align-self: center;
}
.pword-where {
  position: absolute;
  right: 2px;
  top: 1px;
  font-size: .52rem;
  font-style: normal;
  font-weight: 700;
  color: rgba(28, 35, 49, .55);
  pointer-events: none;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pword-eff {
  position: absolute;
  left: 2px;
  bottom: 1px;
  font-size: .52rem;
  font-style: normal;
  font-weight: 700;
  color: var(--ok);
  pointer-events: none;
  max-width: 70%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
