/* =====================================================================
   UI キット — 「黒鉄と燻した金」 (Phase 0 基盤)
   トークン (色・間隔・動き) / 街シェルとタブバー / シート / トースト / ボタン・行・区分・チップ /
   品の札・肖像・数値 / 場面の暗転。theme.css の --plate・--corners・--grain を土台に重ねる。
   押せる場所は最低 44×44。主ボタンは 48px (シートの決め手は 56px)。
   ===================================================================== */

/* 武器の攻撃性能: 結果を主役にし、能力参照・内訳は補足として読む。 */
.wp-performance { margin: 10px 0; padding: 12px 14px; border: 1px solid #6b5830; border-radius: 4px; background: linear-gradient(120deg, rgba(201,162,39,.10), rgba(10,9,13,.5)); color: #e6dbc2; }
.wp-performance-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.wp-performance-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--gold-hi, #e8d08a); }
.wp-performance-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; font-variant-numeric: tabular-nums; }
.wp-performance-number { font-size: 30px; line-height: 1.15; color: #fff2cf; }
.wp-performance-delta { font-size: 12px; color: #b6a88b; }
.wp-performance-delta.up { color: var(--up); }
.wp-performance-delta.down { color: var(--down); }
.wp-performance-note { margin-top: 5px; font-size: 11px; line-height: 1.6; color: #b6a88b; }
.wp-performance-refs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.wp-performance-ref-label { margin-right: 3px; color: #a99a7b; font-size: 11px; }
.wp-performance-ref { padding: 3px 7px; border: 1px solid #4b422f; border-radius: 3px; background: rgba(0,0,0,.2); }
.wp-performance-details { margin-top: 9px; border-top: 1px solid #443923; font-size: 11px; color: #b6a88b; }
.wp-performance-details summary { min-height: 44px; display: list-item; align-content: center; cursor: pointer; }
.wp-performance-details summary:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.wp-performance-formula { padding: 2px 0 7px; line-height: 1.7; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.pt-slot-power, .pt-cand-power, .pt-chc-power { display: block; color: #f3dfad; font-size: 13px; line-height: 1.5; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-slot-power { font-size: 12px; }
.pt-chc-power { font-size: 11px; }

:root {
  /* 鉄 */
  --iron-950: #07060b;
  --iron-900: #0e0c13;
  --iron-800: #16131c;
  --iron-700: #221d29;
  --iron-line: #3a3140;
  /* 金 */
  --gold: #c9a227;
  --gold-hi: #e8d08a;
  --gold-tarnish: #7a6220;
  /* 血・魂・門 */
  --blood: #a3302b;
  --blood-hi: #e4554f;
  --soulblue: #7fd0ff;
  --gate: #8e6fd0;
  --up: #7fd68a;
  --down: #e4554f;
  /* 間隔 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px;
  --hit: 44px;
  /* 動き (§4) */
  --t-tap: 80ms;
  --t-fast: 140ms;
  --t-base: 200ms;
  --t-page: 260ms;
  --t-sheet: 280ms;
  --ease-base: cubic-bezier(.2,.7,.2,1);
  --ease-page: cubic-bezier(.2,.8,.2,1);
  --ease-sheet: cubic-bezier(.16,1,.3,1);
  /* 寸法 */
  --tabbar-h: 64px;
  --header-h: 56px;
}

/* ---------- 通貨の印 (絵文字の代わり) ---------- */
.ui-g { display: inline-block; flex: 0 0 auto; width: 0.74em; height: 0.74em; margin: 0 0.2em 0 0.08em; vertical-align: -0.06em; border-radius: 50%; }
.ui-g-gold { border-radius: 0; background: url("art/dungeon/crypt-gold.webp") center / contain no-repeat; }
.ui-g-soul { width: 0.6em; height: 0.6em; margin: 0 0.26em 0 0.14em; border-radius: 0; transform: rotate(45deg); background: radial-gradient(circle, #ffffff, #7fd0ff 55%, #1d5a86); box-shadow: 0 0 6px rgba(127,208,255,0.9); }
.ui-g-red { background: radial-gradient(circle at 35% 30%, #ffc2b2, #d1261a 50%, #4a0604 100%); box-shadow: 0 0 6px rgba(255,50,30,0.7); }
.ui-g-ember { border-radius: 0; background: url("art/dungeon/crypt-ember.webp") center / contain no-repeat; }

/* ---------- 線画アイコン ---------- */
.ui-ic, .ui-btn-ic, .ui-hbtn-ic, .ui-row-chev, .ui-tab-ic, .ui-tab-lock {
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round;
}

/* =====================================================================
   街シェル: 中身 (#town-screen) + 下のタブバー
   ===================================================================== */
#town-shell {
  position: fixed; inset: 0; z-index: 70;
  width: min(100%, 520px);
  max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column;
  background: #070508;
  overflow: hidden;
}
#town-shell > #town-screen {
  position: relative; inset: auto; z-index: auto;
  flex: 1 1 auto; min-height: 0;
  width: auto; max-width: none; margin: 0;
  padding-bottom: 28px; /* 浮いた門 (16px) の下に隠れないように */
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#town-shell > #town-screen::-webkit-scrollbar { display: none; }
#town-shell > #town-screen.shop-mode { padding-bottom: 20px; }
#town-shell.has-head > #town-screen { padding-top: 8px; --tw-top: 8px; }
/* 旧広場の「迷宮へ潜る」帯は、タブバーの門と重ならないよう流れの中へ置く */
#town-shell #town-screen .tw-divebar { position: static; bottom: auto; padding-bottom: 4px; }
.ts-park { display: none !important; }
.ts-head { flex: 0 0 auto; position: relative; z-index: 3; }
.ts-coaching { flex: 0 0 auto; min-height: 0; max-height: 27dvh; overflow-y: auto; padding: 7px 14px; background: #19131a; border-bottom: 1px solid #574532; }
.tutorial-hint { margin: 0 0 5px; font-size: 13px; line-height: 1.5; color: #eadbbd; }
.tutorial-actions { display: flex; gap: 8px; }
.tutorial-actions .ui-btn { min-height: 32px; padding: 5px 12px; }
.tutorial-choices { margin-top: 5px; font-size: 12px; color: #baa88a; }
.tutorial-choices summary { cursor: pointer; }
.tutorial-choice-list { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 5px; }
.dk-idle.movement-tip { display: flex !important; flex-basis: 100%; color: #f3d58b; }

/* ---------- 見出し (新しい画面) ---------- */
.ui-header {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--sp-3) 0 var(--sp-2);
  background: var(--grain), linear-gradient(180deg, #221b22 0%, #140f15 70%, #0d0a0e 100%);
  box-shadow: 0 1px 0 rgba(201,162,74,0.45), 0 6px 18px rgba(0,0,0,0.7);
}
.ui-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: var(--gold-line); opacity: 0.7; pointer-events: none; }
.ui-hbtn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: var(--hit); min-height: var(--hit); padding: 0 6px;
  background: none; border: 0; color: var(--ink); cursor: pointer; font-family: var(--font);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.ui-hbtn-ic { width: 22px; height: 22px; filter: drop-shadow(0 1px 0 #000); }
.ui-hbtn-l { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; color: #cdbf9f; }
.ui-hbtn:active { transform: scale(0.95); }
.ui-htitle { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.ui-htitle-t {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 18px; font-weight: 800; letter-spacing: 0.18em; padding-left: 0.18em; color: var(--accent-hi);
  text-shadow: 0 0 12px rgba(201,162,74,0.35), 0 2px 0 #000;
}
.ui-htitle-s { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.12em; }

/* ---------- 通貨の札 ---------- */
.ui-cur { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.ui-cur-c {
  display: inline-flex; align-items: center; justify-content: flex-end;
  min-height: 15px; padding: 0 2px; background: none; border: 0; cursor: pointer;
  font-family: var(--font); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25;
  text-shadow: 0 1px 0 #000; touch-action: manipulation;
}
.ui-cur-c.c-gold { color: #f0d48c; } .ui-cur-c.c-soul { color: #b4e6ff; } .ui-cur-c.c-red { color: #ff8a7a; } .ui-cur-c.c-ember { color: #ffb070; }

/* =====================================================================
   タブバー: 黒鉄の梁・燻した金の罫・中央に浮く門
   ===================================================================== */
.ui-tabbar {
  position: relative; z-index: 4; flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background:
    var(--grain),
    radial-gradient(60% 120% at 50% 0%, rgba(122,90,216,0.16), rgba(0,0,0,0) 70%),
    linear-gradient(180deg, #1d171c 0%, #120e13 45%, #0a080b 100%);
  border-top: 1px solid #000;
  box-shadow: 0 -10px 22px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,236,200,0.06);
}
.ui-tabbar::before { /* 金の罫 */
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: var(--gold-line); opacity: 0.85; pointer-events: none;
}
.ui-tabbar::after { /* 鋲を打った梁の陰影 */
  content: ""; position: absolute; left: 0; right: 0; top: 2px; height: 2px; pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,0) 0 38px, rgba(201,162,74,0.22) 38px 40px, rgba(0,0,0,0) 40px 78px);
  opacity: 0.6;
}
.ui-tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 0; min-height: var(--hit); height: var(--tabbar-h); padding: 6px 0 8px;
  background: none; border: 0; cursor: pointer;
  color: #8f8372; font-family: var(--font);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: color var(--t-fast) ease-out;
}
.ui-tab-icw { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ui-tab-ic { width: 25px; height: 25px; filter: drop-shadow(0 1px 0 #000); transition: filter var(--t-fast) ease-out, transform var(--t-tap) ease-out; }
.ui-tab-l { font-size: 11.5px; font-weight: 700; letter-spacing: 0.32em; padding-left: 0.32em; line-height: 1; text-shadow: 0 1px 0 #000; white-space: nowrap; }
.ui-tab-l.long { letter-spacing: 0.06em; padding-left: 0.06em; } /* 4字の名札 (人業の館) は字間を詰めて収める */
.ui-tab:active .ui-tab-ic { transform: scale(0.92); }
.ui-tab.on { color: var(--accent-hi); }
.ui-tab.on .ui-tab-ic { filter: drop-shadow(0 0 6px rgba(243,213,139,0.55)) drop-shadow(0 1px 0 #000); }
.ui-tab.on:not(.center)::after { /* 燠火の下線 */
  content: ""; position: absolute; left: 50%; bottom: 4px; width: 24px; height: 2px; transform: translateX(-50%);
  border-radius: 1px;
  background: linear-gradient(90deg, rgba(255,140,40,0), #ff9a3a 25%, #ffe2a0 50%, #ff9a3a 75%, rgba(255,140,40,0));
  box-shadow: 0 0 8px rgba(255,140,40,0.85), 0 0 2px rgba(255,220,160,0.9);
}
.ui-tab.on:not(.center)::before { /* 点いたタブの奥に灯る薄い光 */
  content: ""; position: absolute; inset: 6px 10% 6px; pointer-events: none;
  background: radial-gradient(60% 70% at 50% 60%, rgba(243,213,139,0.10), rgba(0,0,0,0) 70%);
}
@media (hover: hover) { .ui-tab:not(.on):not(.locked):hover { color: #cdbf9f; } }
/* 閉ざされたタブ: 暗く、鎖の印 */
.ui-tab-lock { position: absolute; right: -9px; bottom: -4px; width: 15px; height: 15px; display: none; color: #b8a47a; stroke-width: 2.1; filter: drop-shadow(0 1px 0 #000) drop-shadow(0 0 2px #000); }
.ui-tab.locked { color: #4f473f; }
.ui-tab.locked .ui-tab-ic { opacity: 0.55; }
.ui-tab.locked .ui-tab-lock { display: block; }
/* 印 (数・点) */
.ui-tab-badge {
  position: absolute; top: 5px; left: calc(50% + 7px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  font-size: 10px; font-weight: 800; line-height: 15px; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: 0;
  color: #fff3d6; background: radial-gradient(circle at 40% 30%, #ff7a6a, #b3241c 60%, #5a0c08);
  border: 1px solid #f3d58b; box-shadow: 0 0 6px rgba(228,85,79,0.75), 0 1px 2px #000;
}
.ui-tab-badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 8px; left: calc(50% + 9px); }
/* 中央の門 (72px の円が 16px 浮く) */
.ui-tab.center { overflow: visible; justify-content: flex-end; padding-bottom: 5px; }
.ui-tab.center .ui-tab-icw { position: absolute; left: 50%; top: -18px; width: 72px; height: 72px; transform: translateX(-50%); }
.ui-gate-medal {
  position: absolute; inset: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 46%, rgba(178,140,255,0.62) 0%, rgba(96,58,168,0.42) 30%, rgba(26,14,40,0.95) 62%, #0b0710 74%),
    #0b0710;
  box-shadow:
    0 0 0 2px #050306, 0 0 0 3px #8a6d2e, 0 0 0 4px #2a2018, 0 0 0 5px #0a0709, 0 0 0 6px rgba(201,162,74,0.55),
    0 0 16px rgba(140,108,240,0.4), 0 10px 18px rgba(0,0,0,0.85),
    inset 0 0 16px rgba(0,0,0,0.9), inset 0 2px 0 rgba(255,236,200,0.12);
  transition: transform var(--t-tap) ease-out, filter var(--t-tap) ease-out;
}
/* 門の呼吸: 影そのものを動かすと毎コマ描き直すので、強い光の層を重ねて不透明度だけを動かす (合成だけで済む) */
.ui-gate-medal::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 6px rgba(243,213,139,0.6), 0 0 32px rgba(140,108,240,0.7);
  opacity: 0; will-change: opacity;
  animation: ui-gate-breathe 3.4s ease-in-out infinite;
}
.ui-gate-medal::before { /* 門柱の金の鋲 (上下左右) */
  content: ""; position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle at 50% 2.5px, #f3d58b 0 2px, rgba(0,0,0,0) 2.6px),
    radial-gradient(circle at 2.5px 50%, #c9a24a 0 1.6px, rgba(0,0,0,0) 2.2px),
    radial-gradient(circle at calc(100% - 2.5px) 50%, #c9a24a 0 1.6px, rgba(0,0,0,0) 2.2px);
}
.ui-gate-ic { position: relative; width: 44px; height: 52px; image-rendering: pixelated; filter: drop-shadow(0 0 8px rgba(160,128,255,0.75)) drop-shadow(0 2px 0 #000); }
.ui-tab.center .ui-tab-ic { width: 34px; height: 34px; color: #d9ccff; }
.ui-tab.center:active .ui-gate-medal { transform: scale(0.95); filter: brightness(0.92); }
.ui-tab.center .ui-tab-l { /* 門の下の名札 */
  position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 9px; letter-spacing: 0.3em;
  color: var(--accent-hi);
  background: linear-gradient(180deg, #2c2318, #140f0a);
  border: 1px solid #8a6d2e; border-radius: 1px;
  box-shadow: 0 0 0 1px #000, 0 3px 8px rgba(0,0,0,0.85), 0 0 10px rgba(201,162,74,0.25);
}
.ui-tab-dia { display: inline-block; width: 5px; height: 5px; transform: rotate(45deg); background: linear-gradient(135deg, #f3d58b, #8a6d2e); box-shadow: 0 0 4px rgba(243,213,139,0.6); }
.ui-tab.center .ui-tab-lock { right: 2px; bottom: 2px; width: 20px; height: 20px; }
.ui-tab.center.locked .ui-gate-medal { filter: grayscale(0.85) brightness(0.55); }
.ui-tab.center.locked .ui-gate-medal::after { animation: none; }
.ui-tab.center.locked .ui-tab-l { color: #7d7468; border-color: #4a3d36; }
@keyframes ui-gate-breathe { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }


/* =====================================================================
   シート (#ui-layer に積み重なる。z 81+n)
   ===================================================================== */
#ui-layer { position: static; }
.ui-sheet-wrap {
  position: fixed; inset: 0; /* z は積み順で JS が付ける */
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
}
.ui-sheet-wrap.k-celebrate { justify-content: center; padding: 20px; }
.ui-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 35%, rgba(30,18,26,0.62), rgba(3,2,4,0.84) 72%);
}
.ui-sheet {
  position: relative; width: min(100%, 520px); max-width: 520px;
  max-height: 88vh; max-height: 88dvh;
  display: flex; flex-direction: column;
  outline: none;
  color: var(--ink);
}
.ui-sheet:not(.k-celebrate) {
  background:
    var(--corner-tl) top 5px left 5px / 18px 18px no-repeat, var(--corner-tr) top 5px right 5px / 18px 18px no-repeat,
    var(--grain),
    radial-gradient(120% 50% at 50% 0%, rgba(201,162,74,0.10), rgba(0,0,0,0) 60%),
    linear-gradient(180deg, #1e181e 0%, #141015 50%, #0e0b0f 100%);
  border-top: 1px solid var(--sheet-accent, #8a6d2e);
  border-radius: 6px 6px 0 0;
  box-shadow: 0 -1px 0 #000, 0 -14px 40px rgba(0,0,0,0.85); /* color-mix 非対応の端末向け */
  box-shadow: 0 -1px 0 #000, 0 -14px 40px rgba(0,0,0,0.85), 0 -2px 26px color-mix(in srgb, var(--sheet-accent, #c9a24a) 22%, transparent);
  padding-bottom: var(--safe-bottom);
}
.ui-sheet:not(.k-celebrate)::before { /* 金の罫 */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--gold-line); opacity: 0.55; pointer-events: none;
}
.ui-sheet.k-celebrate { max-width: 340px; animation: none; border-color: var(--sheet-accent, var(--accent)); box-shadow: 0 0 40px rgba(201,162,74,0.4); box-shadow: 0 0 40px color-mix(in srgb, var(--sheet-accent, #c9a24a) 40%, transparent); padding: 16px 16px 14px; }
.ui-grab { flex: 0 0 auto; height: 22px; display: flex; align-items: center; justify-content: center; cursor: grab; }
.ui-grab i { display: block; width: 42px; height: 4px; border-radius: 2px; background: #4a3d36; box-shadow: inset 0 1px 0 rgba(255,236,200,0.18), 0 1px 0 #000; }
.ui-sheet-head { flex: 0 0 auto; padding: 0 var(--sp-4); }
.ui-sheet-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 2px 0 4px; font-size: 13px; font-weight: 800; letter-spacing: 0.24em;
  color: var(--sheet-accent, var(--accent)); text-shadow: 0 1px 0 #000;
}
.ui-sheet-banner::before, .ui-sheet-banner::after { content: ""; flex: 0 1 46px; height: 1px; background: linear-gradient(90deg, rgba(201,162,74,0), currentColor); opacity: 0.7; }
.ui-sheet-banner::after { background: linear-gradient(90deg, currentColor, rgba(201,162,74,0)); }
/* 見出し (「★ レジェンドの魂を入手 ★」など) は折り返さない。幅の狭い祝祭の札では字間と飾り罫を詰める */
.ui-sheet-banner { white-space: nowrap; }
.ui-sheet.k-celebrate .ui-sheet-banner { letter-spacing: 0.12em; gap: 8px; }
.ui-sheet.k-celebrate .ui-sheet-banner::before, .ui-sheet.k-celebrate .ui-sheet-banner::after { flex-basis: 22px; }
.ui-sheet-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px var(--sp-4) var(--sp-3); text-align: center;
  touch-action: pan-y; overscroll-behavior: contain;
}
.ui-art { position: relative; display: inline-block; padding: 10px; margin: 2px auto 4px; background: radial-gradient(circle, rgba(201,162,74,0.22), rgba(0,0,0,0) 68%); background: radial-gradient(circle, color-mix(in srgb, var(--sheet-accent, #c9a24a) 26%, transparent), rgba(0,0,0,0) 68%); }
.ui-art canvas.spr { display: block; max-width: 132px; max-height: 132px; }
.ui-art.float canvas.spr { animation: ig-float 2s ease-in-out infinite; } /* 宙に浮く魔物だけゆらめく */
/* 手ほどきの情景は高精細でも本文を押し出さない。小さい画面では高さも抑える。 */
.tut-intro .ui-art { max-width: 100%; box-sizing: border-box; }
.tut-intro .ui-art canvas {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: min(160px, 24vh); max-height: min(160px, 24dvh);
}
.ui-sheet-title { margin: 4px 0 2px; font-size: 17px; font-weight: 800; line-height: 1.5; letter-spacing: 0.04em; color: var(--ink); text-shadow: 0 1px 0 #000, 0 0 12px rgba(0,0,0,0.8); }
.ui-sheet-line { margin: 6px 2px; font-size: 13px; line-height: 1.75; color: #b2a68f; text-wrap: pretty; }
.ui-sheet-foot {
  flex: 0 0 auto; display: grid; gap: 8px;
  padding: 10px var(--sp-4) 14px;
  border-top: 1px solid #241d22;
  background: linear-gradient(180deg, rgba(14,11,15,0.7), #0e0b0f);
}
.ui-sheet.k-celebrate .ui-sheet-foot { background: none; border-top: 0; padding: 12px 0 0; }
.ui-sheet.k-celebrate .ui-sheet-body { padding: 0 2px; }
.ui-choice-list { display: grid; gap: 8px; margin: 10px 0 4px; }
.ui-skill .sk-mp { margin-top: 0; }
.ui-skill .sk-lines { margin: 6px 2px 2px; }
.ui-skill .sk-line.on { color: var(--accent-2, #e8c766); }

/* =====================================================================
   トースト (ヘッダの下・最大3)
   ===================================================================== */
.ui-toasts {
  position: fixed; z-index: 85; left: 50%; top: calc(var(--safe-top) + 58px); transform: translateX(-50%);
  width: min(92vw, 440px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.ui-toasts.top { z-index: 240; } /* タイトル画面 (z 210) の上にも出す (「もう一度で閉じる」) */
.ui-toast {
  display: flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 8px 14px 8px 12px;
  font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; line-height: 1.45;
  color: var(--accent-hi);
  background: var(--grain), linear-gradient(180deg, #2a2114, #17120b);
  border: 1px solid #8a6d2e; border-left: 3px solid var(--toast-edge, #c9a24a); border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.7), 0 6px 20px rgba(0,0,0,0.7), 0 0 18px rgba(201,162,74,0.25);
  text-shadow: 0 1px 0 #000;
  opacity: 0; transform: translateY(-10px);
  transition: opacity var(--t-fast) ease-out, transform var(--t-fast) ease-out;
  pointer-events: none;
}
.ui-toast.show { opacity: 1; transform: none; }
.ui-toast.out { opacity: 0; transform: translateY(-8px); transition-duration: 0.28s; }
.ui-toast.t-good { color: #cfeec4; border-color: #4c7a3c; --toast-edge: #6fbf5a; background: var(--grain), linear-gradient(180deg, #17220f, #0e150a); }
.ui-toast.t-bad { color: #ffc4b8; border-color: #7a2a24; --toast-edge: #e4554f; background: var(--grain), linear-gradient(180deg, #2a1212, #170909); }
.ui-toast.t-info { color: #e6dbc2; border-color: #4a3d36; --toast-edge: #8c7a5a; background: var(--grain), linear-gradient(180deg, #1f1a1c, #120f12); }
.ui-toast.has-act { pointer-events: auto; padding-right: 6px; }
.ui-toast-ic { flex: 0 0 auto; display: inline-flex; }
.ui-toast-ic canvas { width: 24px; height: 24px; }
.ui-toast-t { min-width: 0; }
.ui-toast-act {
  flex: 0 0 auto; min-height: 36px; min-width: 52px; padding: 0 12px; margin: -4px 0;
  font-family: var(--font); font-size: 12px; font-weight: 800; letter-spacing: 0.1em;
  color: var(--accent-hi); background: rgba(0,0,0,0.35); border: 1px solid #8a6d2e; border-radius: 2px; cursor: pointer;
}

/* =====================================================================
   ボタン・行・区分・チップ
   ===================================================================== */
.ui-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 48px; padding: 7px 14px;
  font-family: var(--font); font-size: 15px; font-weight: 700; letter-spacing: 0.08em; line-height: 1.35;
  color: var(--ink); text-align: center; text-shadow: 0 1px 0 #000;
  background: var(--grain), var(--plate-hi);
  border: 1px solid #4a3d36; border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,236,200,0.08), inset 0 0 0 1px rgba(0,0,0,0.55), inset 0 -8px 14px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.6);
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform var(--t-tap) ease-out, filter var(--t-tap) ease-out;
}
.ui-btn:active:not(:disabled) { transform: scale(0.97); filter: brightness(0.9); }
.ui-btn.s-lg { min-height: 56px; font-size: 16px; letter-spacing: 0.14em; }
.ui-btn.s-sm { width: auto; min-height: var(--hit); padding: 4px 12px; font-size: 13px; }
.ui-btn.k-primary {
  color: var(--accent-hi); border-color: #8a6d2e;
  background: var(--grain), linear-gradient(180deg, #2c2318 0%, #1c160f 60%, #130f0a 100%);
  box-shadow: inset 0 1px 0 rgba(255,226,160,0.14), inset 0 0 0 1px rgba(0,0,0,0.5), 0 0 0 1px rgba(201,162,74,0.25), 0 0 16px rgba(201,162,74,0.18), 0 2px 6px rgba(0,0,0,0.6);
  text-shadow: 0 0 8px rgba(243,213,139,0.35), 0 1px 0 #000;
}
.ui-btn.k-danger { color: #ffb0a4; border-color: #7a2a24; background: var(--grain), linear-gradient(180deg, #2c1515 0%, #1c0e0e 60%, #130909 100%); }
.ui-btn.k-ghost { color: var(--ink-dim); background: rgba(10,8,11,0.5); border-color: #33292a; box-shadow: none; }
.ui-btn:disabled { opacity: 0.45; filter: grayscale(0.4); cursor: default; }
@media (hover: hover) { .ui-btn:hover:not(:disabled) { border-color: #6a5642; } .ui-btn.k-primary:hover:not(:disabled) { border-color: #b8913e; } }
.ui-btn-ic { flex: 0 0 auto; width: 20px; height: 20px; }
.ui-btn-t { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.ui-btn-l { max-width: 100%; }
.ui-btn-s { font-size: 11px; font-weight: 500; letter-spacing: 0.04em; color: var(--ink-dim); }
.ui-cost {
  flex: 0 0 auto; display: inline-flex; align-items: center; padding: 2px 7px;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--accent-hi);
  background: rgba(0,0,0,0.38); border: 1px solid rgba(201,162,74,0.4); border-radius: 2px;
}
.ui-btn .ui-badge { position: absolute; top: -6px; right: -6px; }

.ui-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px;
  text-align: left; font-family: var(--font); color: var(--ink);
  background: var(--grain), var(--plate); border: 1px solid #33292a; border-radius: 3px; box-shadow: var(--plate-edge);
}
.ui-row.tap { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform var(--t-tap) ease-out, filter var(--t-tap) ease-out; }
.ui-row.tap:active { transform: scale(0.985); filter: brightness(0.92); }
.ui-row-ic { flex: 0 0 auto; display: inline-flex; }
.ui-row-t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ui-row-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-row-sub { font-size: 12px; color: var(--ink-dim); }
.ui-row-r { flex: 0 0 auto; min-width: var(--hit); min-height: var(--hit); display: inline-flex; align-items: center; justify-content: flex-end; color: var(--accent-hi); font-weight: 700; }
.ui-row-chev { flex: 0 0 auto; width: 18px; height: 18px; color: #8a6d2e; }
.ui-row.t-gold { border-color: #8a6d2e; }
.ui-row.t-bad { border-color: #7a2a24; }

.ui-seg { display: flex; gap: 0; padding: 3px; background: rgba(5,4,7,0.7); border: 1px solid #2c2427; border-radius: 3px; box-shadow: inset 0 1px 4px rgba(0,0,0,0.7); }
.ui-seg-b {
  position: relative; flex: 1 1 0; min-height: var(--hit); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font); font-size: 14px; font-weight: 700; letter-spacing: 0.16em;
  color: #9a8e78; background: none; border: 1px solid transparent; border-radius: 2px; cursor: pointer;
  transition: color var(--t-fast) ease-out, background var(--t-fast) ease-out; touch-action: manipulation;
}
.ui-seg-b.on { color: var(--accent-hi); border-color: #8a6d2e; background: var(--grain), linear-gradient(180deg, #2c2318, #17120c); box-shadow: 0 0 10px rgba(201,162,74,0.18); }

.ui-chips { position: relative; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%); }
.ui-chips-in { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; padding: 4px 12px; scrollbar-width: none; touch-action: pan-x; }
.ui-chips-in::-webkit-scrollbar { display: none; }
.ui-chip {
  flex: 0 0 auto; scroll-snap-align: center; position: relative;
  min-height: var(--hit); padding: 0 14px; display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: 0.1em; white-space: nowrap;
  color: #b2a68f; background: var(--plate-hi); border: 1px solid #3a3029; border-radius: 2px; cursor: pointer;
  background-clip: padding-box; touch-action: manipulation;
}
.ui-chip.on { color: var(--accent-hi); border-color: #8a6d2e; background: linear-gradient(180deg, #2c2318, #17120c); }

/* =====================================================================
   品の札・肖像・数値・印
   ===================================================================== */
.ui-tile {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: #0d0a0d; border: 1px solid var(--tile-edge, #3a302c); border-radius: 2px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.9), 0 0 6px color-mix(in srgb, var(--tile-edge, #000) 25%, transparent);
  cursor: pointer; touch-action: manipulation;
}
.ui-tile.s56 { width: 56px; height: 56px; }
.ui-tile.empty { border-style: dashed; border-color: #2a2226; cursor: default; }
.ui-tile-seal { position: absolute; right: 1px; bottom: 0; font-size: 11px; font-weight: 800; color: #ffd9a0; text-shadow: 0 0 4px #000, 0 1px 0 #000; }
.ui-tile-new { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: #ff9a3a; box-shadow: 0 0 6px rgba(255,140,40,0.9); }
.ui-tile-price { position: absolute; left: 1px; bottom: 0; font-size: 9.5px; font-weight: 700; color: var(--accent-hi); text-shadow: 0 1px 0 #000; }

.ui-port {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 52px; height: 52px; padding: 0; background: #0e0b0f;
  border: 1px solid #4a3d36; border-radius: 3px;
  box-shadow: var(--plate-edge), 0 0 10px color-mix(in srgb, var(--glow, #000) 30%, transparent);
  cursor: pointer; touch-action: manipulation;
}
.ui-port.s48 { width: 48px; height: 48px; } .ui-port.s64 { width: 64px; height: 64px; }
.ui-port.sel { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(201,162,74,0.5), 0 0 14px rgba(201,162,74,0.3); }
.ui-port.dead { filter: grayscale(0.9) brightness(0.7); }
.ui-port.empty { border-style: dashed; border-color: #3a3029; }
.ui-port-plus { font-size: 20px; color: #6e6457; }
.ui-port-dead { position: absolute; top: 1px; right: 4px; font-size: 14px; font-weight: 800; color: #e4554f; text-shadow: 0 1px 0 #000; }
.ui-port-hp { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 3px; background: #1a0d0d; border-radius: 1px; overflow: hidden; }
.ui-port-hp i { display: block; height: 100%; background: linear-gradient(90deg, #5fbf4a, #9ee07a); }
.ui-port-hp.low i { background: linear-gradient(90deg, #b3241c, #e4554f); animation: ui-pulse 1.2s ease-in-out infinite; }
.ui-port-row { position: absolute; left: 3px; top: 1px; font-size: 9px; color: var(--ink-dim); }
@keyframes ui-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.ui-delta { display: inline-flex; flex-wrap: wrap; gap: 2px 8px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ui-delta .up { color: var(--up); } .ui-delta .dn { color: var(--down); } .ui-delta .eq { color: var(--ink-faint); font-weight: 500; }
.ui-bar { display: inline-block; width: 100%; height: 6px; background: #120d10; border: 1px solid #2a2226; border-radius: 1px; overflow: hidden; vertical-align: middle; }
.ui-bar i { display: block; height: 100%; }
.ui-bar.t-hp i { background: linear-gradient(90deg, #4a9a3a, #8fd46a); }
.ui-bar.t-mp i { background: linear-gradient(90deg, #2c5a9a, #7fb6ff); }
.ui-bar.t-soul i { background: linear-gradient(90deg, #1d5a86, #7fd0ff); }
.ui-bar.t-gold i { background: linear-gradient(90deg, #8a6d2e, #f3d58b); }
.ui-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  font-size: 10px; font-weight: 800; line-height: 1; color: #fff3d6; font-variant-numeric: tabular-nums;
  background: radial-gradient(circle at 40% 30%, #ff7a6a, #b3241c 60%, #5a0c08); border: 1px solid #f3d58b;
  box-shadow: 0 0 6px rgba(228,85,79,0.7);
}
.ui-badge.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; }
/* 初ゲット！ (鑑定で初めて正体を知った品) */
.first-get {
  display: inline-flex; align-items: center; flex: 0 0 auto; margin-left: 6px; padding: 1px 6px 2px; border-radius: 3px;
  font-size: 11px; font-weight: 800; line-height: 1.3; letter-spacing: 0.06em; vertical-align: middle; white-space: nowrap;
  color: #2a1606; text-shadow: none; background: linear-gradient(180deg, #ffe7a3, #f0b53c 60%, #c27a16);
  border: 1px solid #fff0c4; box-shadow: 0 0 8px rgba(255,196,80,0.6);
  animation: first-get-in 0.5s ease-out 0.2s both;
}
@keyframes first-get-in { 0% { opacity: 0; transform: scale(1.6) rotate(-6deg); } 100% { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .first-get { animation: none; } }

/* ---------- 番人のひとこと (48px の行) ---------- */
.ui-whisper {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 4px 10px 4px 4px;
  text-align: left; font-family: var(--font); color: var(--ink);
  background: var(--grain), linear-gradient(180deg, rgba(31,24,22,0.95), rgba(16,12,13,0.95));
  border: 1px solid #3a3029; border-radius: 2px; box-shadow: var(--plate-edge);
}
button.ui-whisper { cursor: pointer; touch-action: manipulation; }
.ui-whisper-bust { flex: 0 0 auto; width: 40px; height: 40px; overflow: hidden; background: #07060a; box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(201,162,74,0.4); }
.ui-whisper-bust canvas { width: 100%; height: auto; image-rendering: pixelated; display: block; }
.ui-whisper-t { min-width: 0; display: flex; flex-direction: column; }
.ui-whisper-who { font-size: 10.5px; font-weight: 700; letter-spacing: 0.2em; color: var(--accent); }
.ui-whisper-line { font-size: 12.5px; line-height: 1.55; color: #e6dbc2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =====================================================================
   場面の暗転・金の閃き・数の浮き上がり
   ===================================================================== */
.ui-scene-veil { position: fixed; inset: 0; z-index: 95; opacity: 0; pointer-events: auto; overflow: hidden; }
.ui-ember {
  position: absolute; bottom: -6px; width: 3px; height: 3px; border-radius: 50%;
  background: #ffb066; box-shadow: 0 0 6px 1px rgba(255,140,40,0.85);
  animation: ui-ember-rise 0.9s ease-out both;
}
@keyframes ui-ember-rise { from { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } to { transform: translate(var(--dx, 0px), -46vh); opacity: 0; } }
.ui-flash { position: fixed; inset: 0; z-index: 300; pointer-events: none; opacity: 0; }
.ui-delta-float { position: fixed; z-index: 86; pointer-events: none; font-family: var(--font); font-size: 13px; font-weight: 800; text-shadow: 0 1px 0 #000, 0 0 6px #000; }
.ui-delta-float.up { color: var(--up); } .ui-delta-float.dn { color: var(--down); }

/* ---------- 視差を減らす設定 ---------- */
@media (prefers-reduced-motion: reduce) {
  .ui-gate-medal::after, .ui-port-hp.low i, .ui-art canvas.spr { animation: none !important; }
  .ui-toast, .ui-tab, .ui-btn, .ui-row.tap { transition-duration: 0.12s !important; }
  .ui-ember { display: none; }
}

/* ===== 縦にスクロールする箱 (kit.js scrollBox) ===== */
.ui-scrollbox { overflow-y: auto !important; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

/* ===== 種別・属性の札 (物/魔/回復/その他 ・ 火/水/風/土/光/闇) ===== */
.ui-tags { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; vertical-align: middle; white-space: nowrap; }
.ui-tag {
  display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box;
  min-width: 1.7em; height: 1.7em; padding: 0 0.35em; font-size: 10px; font-weight: 800; line-height: 1; letter-spacing: 0;
  font-family: var(--font, inherit); color: var(--tag-c, #cdbf9f);
  border: 1px solid var(--tag-c, #6a5c4a); border-radius: 2px; background: rgba(0,0,0,0.45);
  background: color-mix(in srgb, var(--tag-c, #6a5c4a) 18%, rgba(8,6,9,0.7));
  text-shadow: 0 1px 0 #000;
}
/* 属性は丸い印、種別は角札 */
.ui-tag.el { width: 1.7em; padding: 0; border-radius: 50%; }
.ui-affinity { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 16px; }
.ui-aff { display: inline-flex; align-items: center; gap: 6px; }
.ui-aff-l { font-size: 11.5px; font-weight: 800; letter-spacing: 0.15em; }
.ui-aff.weak .ui-aff-l { color: #ff9a7a; }
.ui-aff.resist .ui-aff-l { color: #8fb6ff; }
.ui-aff .ui-tag { font-size: 11.5px; }
.ui-skill > .ui-tags { display: flex; justify-content: center; margin-top: 6px; }

/* ===== 敵の情報の段階開示 (itemview.js revealLock) ===== */
.ui-reveal-lock { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0 2px; padding: 9px 12px; border: 1px dashed #3d3236; border-radius: 3px; background: rgba(8,6,9,0.55); text-align: left; }
.ui-reveal-w { font-size: 12.5px; font-weight: 700; color: #8f8470; letter-spacing: 0.06em; }
.ui-reveal-n { flex: 0 0 auto; font-size: 12px; color: #c9a65a; letter-spacing: 0.08em; }
.ui-reveal-n::before { content: "🔒"; margin-right: 4px; font-size: 11px; filter: grayscale(1) brightness(1.2); }

/* ===== イレーヌの操作案内: 押す所を光らせる ===== */
.tut-glow {
  outline: 2px solid #ffd76a !important; outline-offset: 2px;
  animation: tut-glow 1.3s ease-in-out infinite;
}
.pt-recruit-slot.tut-glow .pt-port-plus { color: #ffd76a; }
@keyframes tut-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,215,106,0.0), 0 0 10px rgba(255,215,106,0.35); }
  50% { box-shadow: 0 0 0 4px rgba(255,215,106,0.28), 0 0 22px rgba(255,215,106,0.7); }
}
@media (prefers-reduced-motion: reduce) { .tut-glow { animation: none; box-shadow: 0 0 14px rgba(255,215,106,0.6); } }

/* 解放済みの手引き・旅の物語。本文だけを縦にスクロールする。 */
.jr-shortcuts { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:8px 0; }
.jr-shortcuts .ui-btn { min-width:0; font-size:13px; }
.jr-sheet .ui-sheet-body { text-align:left; }
@media (max-width: 600px) {
  /* 長い見出し・語句もシート内で折り、スマホで横へ押し出さない。 */
  .jr-sheet .ui-sheet-head, .jr-sheet .ui-sheet-body { min-width: 0; }
  .jr-sheet .ui-sheet-banner { white-space: normal; overflow-wrap: anywhere; letter-spacing: .12em; }
  .jr-sheet :is(.ui-sheet-title, .jr-intro, .jr-empty, .jr-card, .jr-card-sub, .jr-line, .jr-note, .jr-subtitle) {
    min-width: 0; max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere;
  }
  .jr-sheet .ui-seg-b, .jr-sheet .ui-seg-b > span { min-width: 0; overflow-wrap: anywhere; }
  .jr-sheet .ui-seg-b { letter-spacing: .04em; }
}

.jr-intro, .jr-empty { font-size:13px; line-height:1.8; color:var(--ink-dim); text-wrap:pretty; }
.jr-group { margin:18px 0 8px; font-size:14px; color:var(--sheet-accent); }
.jr-card { margin:0 0 8px; align-items:flex-start; text-align:left; flex-direction:column; gap:4px; letter-spacing:0.04em; }
.jr-card-sub { font-size:11px; color:var(--ink-dim); font-weight:400; }
.jr-illustration { margin:10px auto 16px; max-width:576px; overflow:hidden; border:1px solid #554739; background:#08070b; }
.jr-illustration img, .jr-illustration canvas { display:block; width:100%; height:auto; image-rendering:pixelated; }
.jr-line { max-width:36em; margin:0 auto 14px; font-size:clamp(13px,1.6vw,15px); line-height:1.85; text-align:left; word-break:keep-all; overflow-wrap:break-word; line-break:strict; text-wrap:pretty; }
.jr-subtitle { margin:0 auto 14px; max-width:36em; font-size:12px; color:var(--sheet-accent); }
/* 未読の物語 (一覧の札) と「物語が記された」の知らせ */
/* 未読の数もボタン内に並べ、街の端やスクロール領域からはみ出させない。 */
.jr-shortcuts .ui-btn .ui-badge { position:static; flex:0 0 auto; }
.jr-card { position:relative; }
.jr-card.is-new { border-color:rgba(217,183,110,0.7); }
.jr-new { position:absolute; top:6px; right:8px; padding:2px 6px; font-size:11px; font-weight:700; line-height:1.3; letter-spacing:0.08em; color:#1a1208; background:#d9b76e; border-radius:2px; text-shadow:none; -webkit-font-smoothing:antialiased; }
.jr-card.is-new .ui-btn-l { padding-right:3.4em; }
.jr-notice .jr-illustration { margin-top:4px; }
.jr-notice .jr-lead { color:var(--ink); }
/* ヘルプ・酒場の噂話: 書き留めた心得 (金の縁) と言い伝え (紫の縁) */
.jr-segbox { margin:0 0 10px; }
.jr-note { margin:0 0 6px; padding:8px 11px; font-size:13px; line-height:1.75; color:#cfc4ad; background:rgba(16,12,13,0.75); border:1px solid #2a2226; border-left:2px solid #8a6a2c; border-radius:3px; text-wrap:pretty; }
.jr-note.k-lore { border-left-color:#5f4a7e; }
.jr-group-lore { color:#b9a2dc; }
.jr-more, .jr-hint { max-width:36em; margin:0 auto 10px; font-size:12px; line-height:1.7; color:var(--ink-dim); }

/* ロックした装備の印 (品の名前の右。game.js itemNameEl) */
.item-lk { width: 0.95em; height: 0.95em; margin-left: 0.3em; vertical-align: -0.1em; fill: none; stroke: #d9b45a; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* 描き下ろしの原画の情景 (townpaint.js) は、ドット絵用の pixelated を外して滑らかに */
canvas.tw-vig-hd { image-rendering: auto !important; }

/* 共通袋の並び順。タッチ操作とキーボード操作に対応した選択欄。 */
.ui-bag-sort { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; font-size: 12px; color: var(--ink-dim); }
.ui-bag-sort-select { min-height: 44px; min-width: 0; max-width: 100%; padding: 6px 28px 6px 10px; font: inherit; font-size: 14px; color: var(--ink); background: var(--plate-hi); border: 1px solid #5a4a3a; border-radius: 3px; cursor: pointer; }
.ui-bag-sort-select option { color: var(--ink); background: #171217; }
.ui-bag-sort-select:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

/* 装備更新の知らせ: 取得品には肖像と▲、人業には右下の赤丸。 */
.gear-upgrade-icons { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 4px; vertical-align: middle; }
.gear-upgrade-icons[hidden] { display: none; }
.gear-upgrade-icons .wpc-dic { position: relative; width: 28px; height: 28px; flex: 0 0 28px; }
.gear-upgrade-arrow { position: absolute; right: -2px; bottom: -2px; color: #91e4ae; font-size: 10px; line-height: 1; text-shadow: 0 1px 2px #000, 1px 0 2px #000; }
.gear-upgrade-dot { position: absolute; right: 1px; bottom: 1px; width: 7px; height: 7px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 1.5px #211715; z-index: 5; pointer-events: none; }
.hb-pc-fr { position: relative; }

/* 手帳・設定のプレイヤー名。長い名でも編集ボタンを押し出さない。 */
.player-name-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 10px; border: 1px solid #62503a; border-radius: 3px; background: rgba(8,6,9,.5); }
.player-name-text { flex: 1; min-width: 0; }
.player-name-label { display: block; font-size: 12px; color: #c3b49b; }
.player-name-value { margin-top: 4px; color: #f1e4c8; font-size: 18px; overflow-wrap: anywhere; }
.player-name-card > .ui-btn { flex: 0 0 auto; width: auto; min-width: 64px; }
.player-name-input { display: block; box-sizing: border-box; width: 100%; min-height: 48px; margin-top: 8px; padding: 10px; font: inherit; font-size: 16px; color: #f1e4c8; background: #151019; border: 1px solid #746044; border-radius: 3px; }
.player-name-help { color: #c3b49b; font-size: 13px; line-height: 1.7; }
.player-name-error { color: #ffad97; min-height: 1.5em; font-size: 13px; }

.player-name-insight { margin-top: 4px; color: #d9bd83; font-size: 13px; font-variant-numeric: tabular-nums; }
.player-name-insight:not([hidden]) { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 2px; }
.player-name-points { white-space: nowrap; }

/* 職業の魂の入手イラスト。WebP 自体がゆらめく。 */
.ui-soul-art { position: relative; display: block; width: 176px; height: 176px; }
.ui-soul-art img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
.ui-soul-art > svg { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-soul-art canvas.spr { width: 132px; height: 132px; margin: 22px; }

/* 先読みで間に合わなかった絵は待機画面で準備し、欠けた場面を見せない。 */
body.screen-loading .sc-scene *, body.screen-loading .op-overlay * { animation-play-state: paused !important; }
body.scene-preparing::before, body.screen-loading::before, body.booting::before {
  content: ""; position: fixed; inset: 0; z-index: 2147483647; background: #000;
}
.image-loading {
  position: fixed; left: calc(env(safe-area-inset-left, 0px) + 10px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  width: 42px; height: 63px; z-index: 2147483647; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity 180ms ease, visibility 180ms;
  filter: drop-shadow(0 2px 4px #000);
}
.image-loading[data-state="loading"], .image-loading[data-state="error"] { opacity: 1; visibility: visible; }
.image-loading img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.image-loading-body { clip-path: inset(26% 0 0); }
.image-loading-flame { clip-path: inset(0 0 74%); transform-origin: 50% 26%; }
.image-loading[data-state="loading"] .image-loading-flame { animation: image-loading-flame 1200ms ease-in-out infinite alternate; }
.image-loading[data-state="error"] img { display: none; }
.image-loading-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes image-loading-flame {
  0% { transform: scale(.94, 1) skewX(-3deg); opacity: .85; }
  35% { transform: scale(1.03, .96) skewX(2deg); opacity: 1; }
  65% { transform: scale(.97, 1.04) skewX(-1deg); opacity: .9; }
  100% { transform: scale(1.02, .98) skewX(3deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .image-loading { transition: none; }
  .image-loading[data-state="loading"] .image-loading-flame { animation: none; }
}

/* 背景が届くまで直前の街の画面を残す。新しい中身は配置だけ先に整える。 */
#town-screen:has(> .scene-hold) { position: relative; }
.scene-hold { position: absolute; inset: 0; z-index: 20; overflow: hidden; background: #121018; }
.scene-next { visibility: hidden; }

/* 場面を保ったまま画像取得に失敗した時の、画面を覆わない再試行。 */
.image-loading-retry { display:none; position:absolute; left:0; bottom:72px; white-space:nowrap; padding:8px 12px; color:#e8dfcc; background:#292635; border:1px solid #9a8657; font:inherit; font-size:12px; pointer-events:auto; cursor:pointer; }
.image-loading[data-state="error"] .image-loading-retry { display:block; }

/* 説明と手ほどきは語りと同じ明朝体・文節の折り返しに揃える。 */
.ui-sheet-line, .tut-step-note, .rf-note, .bk-sheet p, .inf-note {
  font-family: var(--font);
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
  text-wrap: pretty;
  min-width: 0;
  max-width: 100%;
}

/* 仕様説明は必要な時だけ開き、一覧の高さを確保する。 */
.ui-help { display:inline-flex; align-items:center; justify-content:center; flex:0 0 44px; width:44px; height:44px; min-height:44px; padding:0; margin:2px 0; border:1px solid var(--line, #74603e); border-radius:50%; color:var(--gold, #d5b778); background:rgba(12,12,16,.8); font:700 20px/1 sans-serif; cursor:pointer; vertical-align:middle; }
.ui-help:focus-visible { outline:2px solid #edcf86; outline-offset:2px; }
.ui-help-sheet .ui-sheet-line { line-height:1.7; }
