/* 自動化王国 — ジオラマ棚スタイル v5
   各部屋 = AI生成アイソメトリック断面ジオラマ(assets/rooms/room_{house}.png・透過)
   キャラ = 6ポーズスプライト(assets/sprites/{id}_{pose}.png・front/side/back/happy/sleepy/worried)
   コンセプト: 暗い書斎の棚に光るジオラマが並び、住人が部屋の中で働いている */

:root {
  --wall:   #1c1410;             /* 棚の壁（濃い焦がし木） */
  --wall2:  #2a1e14;
  --shelfw: #4a3423;
  --cream:  #f6edd9;
  --gold:   #f0c060;
  --bad:    #ff7a70;
  --okc:    #9be89b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background:
    radial-gradient(1400px 800px at 50% -20%, #3a2c1c, transparent 75%),
    var(--wall);
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Yu Gothic UI', sans-serif;
  color: var(--cream);
  min-height: 100vh; min-height: 100dvh;
  overflow-x: hidden;
}

#app {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 14px 14px;
  min-height: 100vh; min-height: 100dvh;
  /* 部屋を広く=ビルは縦長。スクロールでビルを見上げる/見下ろす（Fallout Shelter式） */
}
.hidden { display: none !important; }

/* ===== ヘッダー ===== */
#topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 18px;
  background: linear-gradient(178deg, #3a2a1a, #2a1c10);
  border: 2px solid #16100a; border-radius: 14px;
  box-shadow: inset 0 2px 0 rgba(255,235,190,.15), 0 4px 14px rgba(0,0,0,.4);
}
#kingdom-name { font-weight: 800; font-size: 20px; letter-spacing: 3px; color: var(--gold);
  text-shadow: 0 2px 0 rgba(0,0,0,.4); }
.meta-pills { display: flex; gap: 8px; }
.meta-pill { background: rgba(0,0,0,.3); border-radius: 999px; padding: 3px 13px;
  display: flex; align-items: baseline; gap: 5px; font-size: 11.5px; }
.meta-pill b { font-size: 17px; color: var(--gold); font-weight: 800; }
.meta-pill .mu { opacity: .7; font-size: 10.5px; }
#world-clock { margin-left: auto; font-size: 13px; opacity: .85; letter-spacing: 1px; }

#win-stalled { color: var(--bad); font-weight: 700; font-size: 13.5px;
  background: rgba(90,20,20,.4); border: 1px solid rgba(255,122,112,.5);
  border-radius: 10px; padding: 8px 14px; }

/* ===== ジオラマ棚 ===== */
/* ===== メイン行: ビル + 右の宝物庫 ===== */
#main-row {
  display: flex; gap: 14px; align-items: flex-start;
  width: min(1760px, 100%); margin: 0 auto;
}
#main-row > #shelf { flex: 1; min-width: 0; }

/* ===== 右カラム: 宝物庫 + 住民名簿（stickyで追従・画面高を分け合う） ===== */
#side-col {
  flex: 0 0 384px;                 /* 老眼対応: 文字を大きくするため幅も拡大 */
  position: sticky; top: 10px;
  margin-top: 40px;                        /* ビルの屋上看板と高さを合わせる */
  display: flex; flex-direction: column; gap: 12px;
  height: calc(100dvh - 60px);             /* 高さ確定=2カードが画面高を分け合う */
}
#side-panel {
  background: linear-gradient(178deg, #5d4430, #3a2a1a);
  border: 4px solid #16100a; border-radius: 18px;
  box-shadow: inset 0 2px 0 rgba(255,235,190,.15), 0 10px 34px rgba(0,0,0,.5);
  padding: 10px 14px 12px;
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}
/* タブ */
#tabbar { display: flex; gap: 4px; margin-bottom: 8px; }
.tabbtn {
  flex: 1; font: inherit; font-size: 15px; font-weight: 800; letter-spacing: 1px;
  color: #cdbb9d; background: rgba(0,0,0,.28);
  border: 1.5px solid #1a120b; border-radius: 9px; padding: 8px 2px; cursor: pointer;
}
.tabbtn.active { color: var(--gold); background: rgba(240,192,96,.14);
  border-color: rgba(240,192,96,.5); }
.tabpane { display: none; flex: 1; min-height: 0; flex-direction: column; overflow-y: auto; }
.tabpane.active { display: flex; }

/* けいえいタブ */
.k-sec { margin-bottom: 12px; }
.k-title { font-size: 14.5px; font-weight: 800; color: var(--gold);
  letter-spacing: 1.5px; margin-bottom: 5px; }
.k-big { font-size: 16px; color: #cdbb9d; }
.k-big b { font-size: 32px; font-weight: 800; color: #f6edd9;
  font-variant-numeric: tabular-nums; }
.k-big .ku { font-size: 14px; margin-left: 3px; }
.k-small { font-size: 14.5px; color: #cdbb9d; margin-top: 3px; }
.k-small b { color: #f6edd9; font-size: 17px; }
.k-delta { font-size: 13.5px; font-weight: 800; color: var(--okc); margin-left: 6px; }
/* ゲージ */
.gauge { margin-bottom: 8px; }
.gauge .g-head { display: flex; justify-content: space-between;
  font-size: 13.5px; color: #cdbb9d; margin-bottom: 3px; }
.gauge .g-head b { color: #f6edd9; font-variant-numeric: tabular-nums; }
.gauge .g-bar { height: 12px; border-radius: 999px; background: rgba(0,0,0,.4);
  border: 1px solid #1a120b; overflow: hidden; }
.gauge .g-fill { height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #7ec850, #9be89b); transition: width 1s; }
.gauge.warn .g-fill { background: linear-gradient(90deg, #e8b23d, #f5d83d); }
.gauge.bad  .g-fill { background: linear-gradient(90deg, #e05548, #f4655f); }
/* こんやのよてい */
#schedule-list { list-style: none; overflow-y: auto; flex: 1; min-height: 60px;
  font-size: 14.5px; line-height: 1.6; }
#schedule-list li { display: flex; gap: 9px; align-items: baseline;
  padding: 3.5px 2px; border-bottom: 1px dashed rgba(246,237,217,.1); }
#schedule-list .sc-time { font-weight: 800; color: var(--gold);
  font-variant-numeric: tabular-nums; flex: none; width: 54px; }
#schedule-list .sc-name { color: #f6edd9; font-weight: 700; white-space: nowrap; }
#schedule-list .sc-role { color: #c8b696; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 週間グラフ */
#week-chart { display: flex; gap: 5px; align-items: flex-end;
  height: 64px; padding: 4px 2px 0; }
#week-chart .wc-col { flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
#week-chart .wc-bar { width: 100%; border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #f0c060, #b98a34); min-height: 2px;
  transition: height 1s; }
#week-chart .wc-col.today .wc-bar { background: linear-gradient(180deg, #9be89b, #3ddc97); }
#week-chart .wc-lbl { font-size: 11.5px; color: #cdbb9d; }
#week-chart .wc-val { font-size: 12px; font-weight: 800; color: #f6edd9; }
/* さいきんののうひん */
#recent-posts { list-style: none; font-size: 13.5px; line-height: 1.55; }
#recent-posts li { padding: 4px 2px; border-bottom: 1px dashed rgba(246,237,217,.1); }
#recent-posts a { color: #b8d8f8; text-decoration: none; font-weight: 700; }
#recent-posts a:hover { text-decoration: underline; color: #d8ecff; }
#recent-posts .rp-date { color: #a89a80; font-size: 11.5px; margin-right: 5px; }

/* ===== 住民名簿 ===== */
#roster-list {
  list-style: none; overflow-y: auto; flex: 1; min-height: 0;
  margin-top: 6px;
}
.ros-floor {
  font-size: 13px; font-weight: 800; color: #cdbb9d; letter-spacing: 2px;
  padding: 8px 4px 3px; border-bottom: 1px solid rgba(246,237,217,.14);
}
.ros-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 4px; cursor: pointer; border-radius: 8px;
}
.ros-row:hover { background: rgba(255,235,190,.08); }
.ros-face { width: 30px; height: 40px; flex: none;
  display: flex; align-items: flex-end; justify-content: center; }
.ros-face img { max-width: 30px; max-height: 40px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.ros-info { flex: 1; min-width: 0; line-height: 1.3; }
.ros-name { font-size: 15.5px; font-weight: 800; color: #f6edd9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ros-role { font-size: 12.5px; color: #c8b696;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ros-dot { width: 12px; height: 12px; border-radius: 50%; flex: none;
  box-shadow: 0 0 4px rgba(0,0,0,.4); }
.ros-dot.d-idle    { background: #8a7a60; }
.ros-dot.d-working { background: #f5b83d; animation: blink 1.2s steps(1) infinite; }
.ros-dot.d-success { background: #3ddc97; }
.ros-dot.d-stale, .ros-dot.d-error { background: #f4655f; animation: blink .7s steps(1) infinite; }

.t-title {
  text-align: center; font-weight: 800; font-size: 19px; letter-spacing: 3px;
  color: var(--gold); text-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.t-sub {
  text-align: center; font-size: 13.5px; color: #cdbb9d; letter-spacing: 2px;
  margin: 2px 0 10px;
}
#roster .t-title { font-size: 15px; }
#roster .t-sub { margin-bottom: 4px; }
/* 棚: 成果物は下から積み上がる */
#loot-shelf {
  flex: 1; min-height: 240px; overflow-y: auto;
  display: flex; flex-wrap: wrap-reverse; align-content: flex-start;
  flex-direction: row; gap: 6px 4px;
  padding: 10px 8px;
  background:
    repeating-linear-gradient(180deg, transparent 0 66px, rgba(22,16,10,.85) 66px 72px),
    linear-gradient(178deg, rgba(30,20,12,.5), rgba(20,14,8,.6));
  border: 2px solid #1a120b; border-radius: 10px;
}
.loot {
  position: relative; width: 56px; height: 66px;
  display: flex; align-items: flex-end; justify-content: center;
  cursor: default;
}
.loot img {
  max-width: 52px; max-height: 56px;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.45));
}
.loot .loot-n {                              /* 同種まとめ時の×N */
  position: absolute; right: 0; bottom: 2px;
  background: var(--gold); color: #2a1c10; font-weight: 800; font-size: 10.5px;
  border-radius: 999px; padding: 0 5px; border: 1.5px solid #16100a;
}
.loot .loot-tip {                            /* ホバーで内容表示 */
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: rgba(255,255,252,.97); color: #3a2a18; font-size: 10.5px; font-weight: 700;
  border: 1.5px solid rgba(70,50,30,.85); border-radius: 8px; padding: 2px 8px;
  white-space: nowrap; display: none; z-index: 40;
}
.loot:hover .loot-tip { display: block; }
@keyframes lootdrop {                        /* ぽとっと落ちて弾む */
  0%   { transform: translateY(-46px) scale(.7); opacity: 0; }
  55%  { transform: translateY(0) scale(1.04); opacity: 1; }
  72%  { transform: translateY(-7px) scale(.98); }
  100% { transform: translateY(0) scale(1); }
}
.loot.new { animation: lootdrop .7s cubic-bezier(.34,1.4,.64,1); }
.loot.new::after {                           /* 着地キラッ */
  content: "✨"; position: absolute; top: -6px; right: -4px; font-size: 12px;
  animation: sparkle 1s ease-out 2;
}
/* 殿堂プレート */
.t-plaques { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.plaque {
  display: flex; align-items: baseline; gap: 6px;
  background: rgba(0,0,0,.3); border: 1.5px solid #1a120b; border-radius: 9px;
  padding: 5px 12px;
}
.plaque .pk { font-size: 14px; color: #cdbb9d; letter-spacing: 1px; flex: 1; }
.plaque b { font-size: 24px; font-weight: 800; color: #f6edd9;
  font-variant-numeric: tabular-nums; }
.plaque .pu { font-size: 12.5px; color: #cdbb9d; }
.plaque.gold { background: linear-gradient(178deg, rgba(240,192,96,.22), rgba(240,192,96,.08));
  border-color: rgba(240,192,96,.5); }
.plaque.gold b { color: var(--gold); }
@keyframes countpop { 0% { transform: scale(1); } 40% { transform: scale(1.35); color: #fff; } 100% { transform: scale(1); } }
.plaque b.pop { animation: countpop .5s ease-out; display: inline-block; }

/* ===== 王国本社ビル（完全密着・断面図式） =====
   5フロア×3列。部屋は壁(ボーダー)を共有して隙間ゼロ。
   1階(G): がんしょや受付 + 横長ロビー(2列ぶち抜き)。訪問はロビー経由 */
#shelf {
  position: relative;
  display: grid;
  width: min(1400px, 100%);
  margin: 0 auto;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    "f5a f5b f5c"
    "f4a f4b f4c"
    "f3a f3b f3c"
    "f2a f2b f2c"
    "f1a h   h";
  gap: 0;                           /* 完全密着 */
  /* 建物の外壁 */
  padding: 12px;
  background: linear-gradient(178deg, rgba(74,52,35,.55), rgba(42,30,20,.65));
  border: 4px solid #16100a;
  border-radius: 18px;
  box-shadow: inset 0 2px 0 rgba(255,235,190,.12), 0 10px 34px rgba(0,0,0,.5);
}
/* 屋上の看板（グリッド外・ビル上端に固定） */
#shelf { margin-top: 40px; }
#shelf::before {
  content: "🏰 じどうか おうこく ほんしゃビル";
  position: absolute; left: 50%; top: -38px; transform: translateX(-50%);
  white-space: nowrap;
  padding: 4px 26px;
  background: linear-gradient(#5d4430, #3f2d1c);
  border: 2px solid #16100a; border-radius: 10px 10px 0 0; border-bottom: none;
  font-weight: 800; letter-spacing: 3px; font-size: 15px; color: var(--gold);
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.slot-f5a { grid-area: f5a; } .slot-f5b { grid-area: f5b; } .slot-f5c { grid-area: f5c; }
.slot-f4a { grid-area: f4a; } .slot-f4b { grid-area: f4b; } .slot-f4c { grid-area: f4c; }
.slot-f3a { grid-area: f3a; } .slot-f3b { grid-area: f3b; } .slot-f3c { grid-area: f3c; }
.slot-f2a { grid-area: f2a; } .slot-f2b { grid-area: f2b; } .slot-f2c { grid-area: f2c; }
.slot-f1a { grid-area: f1a; }
.slot-h   { grid-area: h; }

/* ロビー: 2列ぶち抜き（同じ行高なのでキャラサイズも共通） */
.room--hall .room-inner { aspect-ratio: auto; height: 100%; }

/* 部屋カード: 壁とスラブ(床板)をボーダーで共有 = 断面図 */
.room {
  position: relative;
  z-index: 1;
  border: 3px solid #1a120b;       /* 隣接部屋と合わせて6pxの壁/床スラブになる */
}
.room { min-height: 0; }
.room-inner {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 10;           /* 部屋画像は1280x800に正規化済み=無劣化で密着 */
  overflow: hidden;
}
.room-bg {
  position: absolute; inset: 0;
  background: center / cover no-repeat;   /* フルブリード部屋画像を隙間なく */
  transition: filter 1.2s;
}
/* 部屋の明かり（状態で変わる）: ジオラマ全体への色被せ */
.room-light {
  position: absolute; inset: 0; pointer-events: none; z-index: 30;
  transition: background 1.2s, opacity 1.2s;
}
/* 部屋の状態 */
.room.r-working .room-bg { filter: brightness(1.07) saturate(1.1); }
.room.r-working .room-light { background: radial-gradient(60% 50% at 50% 55%, rgba(255,205,110,.18), transparent 75%);
  animation: worklight 2.2s ease-in-out infinite; }
.room.r-working { box-shadow: inset 0 0 0 2px rgba(255,205,110,.5); }
@keyframes worklight { 0%,100% { opacity: .75; } 50% { opacity: 1; } }
.room.r-night .room-bg { filter: brightness(.6) saturate(.8); }
.room.r-night .room-light { background: linear-gradient(rgba(20,28,70,.3), rgba(16,22,58,.36)); }
.room.r-stale .room-bg { filter: grayscale(.75) brightness(.48); }
.room.r-stale .room-light { background: rgba(20,16,30,.35); }
.room.r-error .room-light { background: rgba(140,30,24,.2); animation: alarml 1s steps(1) infinite; }
@keyframes alarml { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.room.r-flash .room-light { background: radial-gradient(closest-side, rgba(255,230,140,.42), transparent 80%); }

/* 部屋の看板 */
.room-plaque {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: linear-gradient(#5d4430, #3f2d1c);
  border: 1.5px solid #16100a; border-radius: 8px;
  color: var(--gold); font-weight: 800; font-size: clamp(13px, 1.4vw, 17px);
  letter-spacing: 1.5px; padding: 3px 14px; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,235,190,.2);
}
/* stale部屋の看板は警告色に */
.room.r-stale .room-plaque { color: var(--bad); }

/* ===== キャラ（部屋の中） =====
   left/top は部屋カード内% ・足元中央基準 */
.char {
  position: absolute; z-index: 20; cursor: pointer;
  height: 47%;                     /* 手前の床に立つ=大きく（遠近の説得力） */
  transform: translate(-50%, -100%);
  transition: left var(--wd, 1.6s) linear, top var(--wd, 1.6s) linear,
              opacity .45s ease;
  display: flex; align-items: flex-end; justify-content: center;
}
.char.ghost { opacity: 0; pointer-events: none; }   /* 訪問の出入りでスッと消える */
.char .flip { height: 100%; display: flex; align-items: flex-end;
  transform: scaleX(var(--mx, 1)); }
.char img { height: 100%; width: auto; display: block;
  filter: drop-shadow(0 3px 3px rgba(10,8,4,.4));
  transform-origin: 50% 100%;      /* ★接地の掟: 変形の支点は常に足元 */
  animation: breathe 2.6s ease-in-out infinite; }
.char::before {  /* 接地影: 濃く・広く=「床に立っている」ことを強調 */
  content: ""; position: absolute; bottom: -2.5%; left: 50%;
  width: 78%; height: 9%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(10,8,4,.55), transparent 72%);
  border-radius: 50%;
}
/* ★接地アニメ設計: 待機・作業は足を床に付けたまま（浮遊するtranslateY禁止）。
   例外=ジャンプ系（celebrate/hop/prepare）だけが意図的に跳ぶ（影は床に残る） */
@keyframes breathe { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(.985); } }
@keyframes trot { 0%,100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-2.5%) rotate(1.5deg); } }
.char.walking img { animation: trot .36s ease-in-out infinite; }
@keyframes workrock { 0%,100% { transform: rotate(0) scaleY(1); } 25% { transform: rotate(-2deg) scaleY(.985); } 75% { transform: rotate(2deg) scaleY(.99); } }
.char.at-work img { animation: workrock .6s ease-in-out infinite; }
.char.sleeping img { animation: none; }
.char.st-stale img { animation: none; filter: grayscale(.6) brightness(.75) drop-shadow(0 3px 3px rgba(0,0,0,.35)); }
.char.st-error img { animation: none; transform: rotate(80deg) translateY(6%); }
@keyframes jump { 0%,100% { transform: translateY(0); } 20% { transform: translateY(-14%); }
  40% { transform: translateY(0); } 60% { transform: translateY(-9%); } 80% { transform: translateY(0); } }
.char.celebrate img { animation: jump 1.2s ease-in-out 2; }

/* キャラ名（部屋内では小さめ・ホバーで強調） */
.cname {
  position: absolute; top: 100%; left: 50%;
  /* --cname-scale は shelf.js が「部屋が混んだとき」だけ 1 未満を入れる（既定は等倍）。
     名前が隣とぶつかって読めなくなるのを防ぐ（2026-07-26 の重なり対策の続き）。 */
  transform: translateX(-50%) scale(var(--cname-scale, 1)); transform-origin: top center;
  margin-top: 1px; white-space: nowrap;
  font-size: clamp(11px, 1.15vw, 15px); font-weight: 800; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 8px rgba(0,0,0,.5);
  opacity: .95; letter-spacing: .3px;
}
.char:hover .cname { opacity: 1; font-weight: 800; }

/* 状態バッジ */
.badge { position: absolute; bottom: 102%; left: 50%; transform: translateX(-50%);
  font-size: clamp(12px, 1.5vw, 18px); line-height: 1; z-index: 25; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes sparkle { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.4); } }
.char.st-working .badge::before { content: "🔨"; display: inline-block; animation: workbob .6s ease-in-out infinite; }
.char.st-success .badge::before { content: "✨"; display: inline-block; animation: sparkle 1.2s infinite; }
.char.st-error   .badge::before { content: "❗"; display: inline-block; color: #ff4040; animation: blink .5s steps(1) infinite; }
.char.st-stale   .badge::before { content: "⚠"; display: inline-block; color: var(--bad); animation: blink 1.2s steps(1) infinite; }
.char.sleeping   .badge::before { content: "💤"; display: inline-block; opacity: .9; }

/* 吹き出し */
.bubble {
  position: absolute; bottom: calc(102% + 1.6vh); left: 50%; transform: translateX(-50%);
  background: rgba(255,255,252,.96); color: #3a2a18;
  border: 2px solid rgba(70,50,30,.85); border-radius: 11px;
  font-size: clamp(12px, 1.25vw, 16px); font-weight: 700; line-height: 1.35;
  padding: 4px 10px;
  white-space: normal; width: max-content; max-width: 200px; text-align: center;
  display: none; z-index: 50;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
.bubble::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -4px;
  border: 4px solid transparent; border-top-color: rgba(70,50,30,.85); }
.char.st-working .bubble, .char.st-error .bubble, .bubble.chatter { display: block; }

/* 頭上エフェクト */
.fx { position: absolute; bottom: 98%; left: 72%;
  font-size: clamp(10px, 1.3vw, 15px); display: none; z-index: 26;
  animation: fxfloat 1.4s ease-out infinite; }
@keyframes fxfloat { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-12px); opacity: 0; } }
.char.has-fx .fx { display: block; }

/* ===== 動物（部屋の住み込み） ===== */
.animal { position: absolute; pointer-events: none; z-index: 18;
  transform: translate(-50%, -100%);
  transition: left var(--wd, 2.5s) linear, top var(--wd, 2.5s) linear; }
.animal .aflip { height: 100%; display: flex; align-items: flex-end;
  transform: scaleX(var(--mx, 1)); }
.animal img { height: 100%; width: auto; display: block;
  filter: drop-shadow(0 2px 2px rgba(10,8,4,.35)); }
.a-cat { height: 12%; }
.a-dog { height: 13%; }
.a-hen { height: 11%; }
@keyframes abob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5%); } }
.animal.moving img { animation: abob .35s ease-in-out infinite; }
.a-cat.pose-sleep img { transform: scaleY(.62); transform-origin: bottom; filter: brightness(.85); }
@keyframes peck { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4%) rotate(10deg); } }
.a-hen.pecking img { animation: peck .45s ease-in-out infinite; }
.animal .abubble { position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  background: rgba(255,255,252,.95); color: #3a2a18; border: 1.5px solid rgba(70,50,30,.8);
  border-radius: 8px; font-size: clamp(8px, .9vw, 11px); font-weight: 700;
  padding: 0 6px; white-space: nowrap; display: none; }
.animal.talking .abubble { display: block; }

/* ===== つうこくのしょ ===== */
#win-log {
  background: linear-gradient(178deg, #3a2a1a, #241810);
  border: 2px solid #16100a; border-radius: 14px;
  box-shadow: inset 0 2px 0 rgba(255,235,190,.12), 0 4px 14px rgba(0,0,0,.4);
  padding: 10px 16px;
  max-height: 168px; display: flex; flex-direction: column;
}
.log-title { color: var(--gold); font-weight: 800; font-size: 15px; margin-bottom: 4px; letter-spacing: 1px; }
#log-list { list-style: none; font-size: 14.5px; line-height: 1.85; overflow-y: auto; flex: 1;
  columns: 1; }
@media (min-width: 900px) { #log-list { columns: 2; column-gap: 28px; } }
@media (min-width: 1500px) { #log-list { columns: 3; } }
#log-list li { break-inside: avoid; border-bottom: 1px dashed rgba(246,237,217,.1); }
#log-list li::before { content: "＊「"; color: #b8d8f8; opacity: .8; }
#log-list li::after  { content: "」"; color: #b8d8f8; opacity: .8; }
#log-list li.ev-error   { color: var(--bad); }
#log-list li.ev-success { color: var(--okc); }
#log-list li .ev-time { color: #a89a80; font-size: 10px; margin-left: 5px; }

/* ===== 詳細モーダル ===== */
.card {
  background: linear-gradient(178deg, #5d4430, #3a2a1a);
  border: 2px solid #16100a; border-radius: 14px;
  box-shadow: inset 0 2px 0 rgba(255,235,190,.18), 0 8px 30px rgba(0,0,0,.5);
  padding: 14px 18px;
}
#modal-back { position: fixed; inset: 0; background: rgba(8,6,3,.65); z-index: 1000;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
#win-detail { width: min(520px, 92vw); position: relative; padding-top: 20px; }
#d-portrait { position: absolute; right: 18px; top: -38px; width: 96px; height: 116px;
  display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
#d-portrait img { max-height: 100%; max-width: 100%;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); }
#d-name { color: var(--gold); font-weight: 800; font-size: 18px; margin-bottom: 8px; letter-spacing: 1px; }
#d-lines div { font-size: 13.5px; line-height: 1.9; }
#d-recovery { margin-top: 10px; }
.d-label { color: #b8d8f8; font-size: 12.5px; font-weight: 700; }
#d-cmd { display: block; background: #17110a; border: 1px solid #5d4430; color: #b8e0b8;
  font-size: 12px; padding: 7px 9px; margin-top: 4px; border-radius: 8px; user-select: all;
  font-family: Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.d-close { margin-top: 12px; text-align: right; cursor: pointer; color: var(--gold);
  font-weight: 700; animation: blink 1.8s steps(1) infinite; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

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

/* 狭い画面: 1列のタワー（ロビーを最上部に）。密着は維持 */
@media (max-width: 900px) {
  #main-row { flex-direction: column; }
  #side-col { flex: none; width: 100%; position: static; margin-top: 12px;
    height: 480px; order: -1; }             /* スマホでは右カラム(タブ)を先頭に固定高で */
  #loot-shelf { min-height: 140px; }
  #shelf { grid-template-columns: 1fr; grid-template-areas: none; }
  [class*="slot-"] { grid-area: auto; }
  .slot-h { grid-row: 1; }
  .room--hall .room-inner { aspect-ratio: 16 / 10; height: auto; }
  #topbar { padding: 6px 12px; }
  #kingdom-name { font-size: 16px; }
  #world-clock { width: 100%; }
}
