/* カイロソフト風ピクセルUI v2: 草原背景 + ダークウッドのHUD + クリーム色パネル */
:root {
  --ink: #2b2118;
  --wood: #5b4632;
  --wood-dark: #3f3022;
  --wood-light: #7a6248;
  --cream: #fdf3d7;
  --cream-dark: #ecdfb4;
  --accent: #f59038;
  --accent-dark: #c26418;
  --gold: #f7c948;
  --gold-light: #ffe9a0;
  --green: #4a7e38;
  --red: #a83220;
  --bevel: inset 2px 2px 0 rgba(255, 255, 255, .45), inset -2px -2px 0 rgba(43, 33, 24, .18);
  --hard-shadow: 3px 3px 0 rgba(43, 33, 24, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(170deg, #c3dc92 0%, #aecb7d 45%, #9cbc6c 100%) fixed;
  color: var(--ink);
  font-family: 'DotGothic16', 'Hiragino Maru Gothic ProN', 'Yu Gothic', sans-serif;
  user-select: none;
}
/* 背景にうっすらドットパターン */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(43, 33, 24, .05) 1px, transparent 1px);
  background-size: 14px 14px;
}

button { font-family: inherit; color: var(--ink); }

.hud-ico {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  flex: 0 0 20px;
}

/* ---- タイトル画面 ---- */
#title-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 33, 24, .85);
}
#title-screen[hidden] { display: none; }
#title-screen { transition: opacity .3s steps(6); }
#title-screen.closing { opacity: 0; pointer-events: none; }
#title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 7px var(--ink), 10px 12px 0 rgba(0, 0, 0, .45);
  padding: 30px 52px;
  text-align: center;
}
#title-logo-cv {
  width: 312px;
  image-rendering: pixelated;
}
#title-art {
  width: 260px;
  image-rendering: pixelated;
}
.title-sub { margin: 0 0 8px; font-size: 13px; }
.title-ver { margin: 6px 0 0; font-size: 11px; opacity: .6; }

/* ---- タイトルメニュー ---- */
#title-menu { display: flex; flex-direction: column; gap: 8px; width: 280px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  text-align: left;
  background: var(--cream-dark);
  border: 3px solid var(--ink);
  cursor: pointer;
  box-shadow: var(--bevel), 3px 3px 0 rgba(43, 33, 24, .35);
}
.menu-item.selected {
  background: var(--gold-light);
  outline: 2px solid var(--accent-dark);
}
.menu-item:active { box-shadow: var(--bevel); transform: translate(2px, 2px); }
.mi-cursor {
  visibility: hidden;
  color: var(--accent-dark);
  font-weight: bold;
  animation: blink-cursor .8s steps(2) infinite;
}
.menu-item.selected .mi-cursor { visibility: visible; }
@keyframes blink-cursor { 50% { opacity: 0; } }
.mi-body { display: flex; flex-direction: column; }
.mi-label { font-weight: bold; font-size: 15px; }
.mi-sub { font-size: 10px; opacity: .7; }

/* ---- モーダル ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 33, 24, .7);
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(540px, 92vw);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 7px var(--ink), 10px 12px 0 rgba(0, 0, 0, .45);
}
.modal-title {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--wood);
  color: var(--gold-light);
  padding: 8px 12px;
  font-weight: bold;
  border-bottom: 3px solid var(--ink);
}
.modal-close {
  width: 28px;
  height: 28px;
  border: 2px solid var(--ink);
  background: var(--cream);
  cursor: pointer;
  font-weight: bold;
  box-shadow: var(--bevel);
}
.modal-close:active { transform: translate(1px, 1px); }
.modal-body { padding: 14px 18px; font-size: 13px; }
.modal-body h4 { margin: 14px 0 6px; border-bottom: 2px dotted var(--ink); padding-bottom: 3px; }
.help-steps { padding-left: 20px; margin: 0; }
.help-steps li { margin-bottom: 8px; line-height: 1.5; }
#help-combos { padding-left: 18px; font-size: 12px; margin: 0; }
#help-combos li { margin-bottom: 4px; }
.help-keys { font-size: 12px; }
.help-goal {
  margin: 0 0 4px;
  padding: 8px 10px;
  background: var(--cream-dark);
  border: 2px solid var(--ink);
  box-shadow: var(--bevel);
  line-height: 1.5;
}
.help-note { margin: 0 0 6px; line-height: 1.5; }
.help-bad { color: var(--red); font-weight: bold; }
/* HUD 凡例: アイコン語と説明を2カラムで並べる */
.help-legend {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 12px;
}
.help-legend li { line-height: 1.4; }
.help-warn-list { padding-left: 18px; margin: 0; font-size: 12px; }
.help-warn-list li { margin-bottom: 4px; line-height: 1.4; }
@media (max-width: 480px) { .help-legend { grid-template-columns: 1fr; } }

/* ---- ゲームオーバー画面 ---- */
.go-reason {
  margin: 4px 0 12px;
  padding: 12px;
  text-align: center;
  font-weight: bold;
  line-height: 1.5;
  background: #6e2014;
  color: var(--gold-light);
  border: 3px solid var(--ink);
  box-shadow: var(--bevel);
}
.go-restart {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  font-weight: bold;
  font-size: 14px;
  color: var(--ink);
  background: var(--gold);
  border: 3px solid var(--ink);
  cursor: pointer;
  box-shadow: var(--bevel), 3px 3px 0 rgba(43, 33, 24, .35);
}
.go-restart:active { box-shadow: var(--bevel); transform: translate(3px, 3px); }
.go-icon { font-size: 20px; }
.set-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dotted var(--ink);
}
.set-row button {
  padding: 6px 12px;
  border: 2px solid var(--ink);
  background: var(--cream-dark);
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(43, 33, 24, .3);
  font-weight: bold;
  font-size: 12px;
}
.set-row button:active { box-shadow: var(--bevel); transform: translate(2px, 2px); }
.set-btns { display: flex; gap: 6px; }
.set-ver { text-align: center; font-size: 11px; opacity: .6; margin: 12px 0 0; }

/* ---- ヘッダーHUD（ダークウッド） ---- */
#header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: linear-gradient(var(--wood), var(--wood-dark));
  border-bottom: 4px solid var(--ink);
  box-shadow: inset 0 2px 0 var(--wood-light), inset 0 -2px 0 rgba(0, 0, 0, .3);
}
#header h1 { margin: 0; line-height: 0; }
#header-logo {
  width: 148px;
  height: 24px;
  image-rendering: pixelated;
}
#date {
  color: var(--cream);
  font-weight: bold;
  font-size: 13px;
  background: rgba(0, 0, 0, .25);
  border: 2px solid var(--ink);
  padding: 3px 10px;
}
#speed-controls { display: flex; gap: 4px; }
#speed-controls button {
  width: 36px;
  height: 30px;
  font-size: 13px;
  border: 2px solid var(--ink);
  background: var(--cream);
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(0, 0, 0, .35);
}
#speed-controls button.active {
  background: var(--gold);
  box-shadow: var(--bevel);
  transform: translate(2px, 2px);
}
#resources { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.res {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--wood-dark);
  border: 2px solid var(--ink);
  box-shadow: inset 1px 1px 0 var(--wood-light), 2px 2px 0 rgba(0, 0, 0, .3);
  padding: 3px 12px 3px 8px;
  font-size: 14px;
  font-weight: bold;
  color: var(--gold-light);
}
.res.danger { background: #6e2014; color: #ffb4a6; }
.res-btn { cursor: pointer; font-family: inherit; }
.res-btn:hover { box-shadow: inset 1px 1px 0 var(--wood-light), 0 0 0 2px var(--gold); }
.res-btn:active { transform: translate(1px, 1px); }

/* ---- 町ランク一覧モーダル ---- */
#ranks-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.rank-row {
  border: 2px solid var(--ink);
  background: var(--cream);
  box-shadow: var(--bevel);
  padding: 7px 10px;
}
.rank-row.current { background: var(--gold-light); box-shadow: 0 0 0 2px var(--gold), var(--bevel); }
.rank-row.locked { opacity: 0.62; }
.rank-head { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.rank-mark { font-size: 13px; }
.rank-head b { flex: 1; }
.rank-req { font-size: 11px; color: var(--wood); font-weight: bold; }
.rank-unlock { font-size: 11px; color: var(--wood-dark); margin-top: 4px; line-height: 1.4; }
.rank-progress { margin: 5px 0 3px; }
.rank-bar {
  height: 8px;
  border: 2px solid var(--ink);
  background: var(--cream-dark);
  overflow: hidden;
}
.rank-bar span { display: block; height: 100%; background: var(--accent); }
.rank-remain { font-size: 11px; color: var(--accent-dark); font-weight: bold; }

/* ---- 需要バー ---- */
#demand {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 16px;
  background: var(--wood-dark);
  border-bottom: 3px solid var(--ink);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, .25);
  font-size: 13px;
}
.demand-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--wood);
  border: 2px solid var(--ink);
  box-shadow: inset 1px 1px 0 var(--wood-light);
  padding: 2px 10px 2px 6px;
  color: var(--cream);
}
.demand-item b { color: var(--gold-light); }
.demand-item.bottleneck { background: #7a2c20; }
.demand-item.bottleneck b { color: #ffb4a6; }
#buffs { display: flex; gap: 6px; }
.buff {
  background: var(--gold);
  border: 2px solid var(--ink);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: bold;
}

/* ---- レイアウト ---- */
main {
  display: grid;
  grid-template-columns: 252px 1fr 324px;
  gap: 14px;
  padding: 14px;
  max-width: 1400px;
  margin: 0 auto;
}
.panel {
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 2px var(--cream), 0 0 0 4px var(--ink), var(--hard-shadow);
  padding: 12px;
  height: fit-content;
}
.panel h2 {
  margin: 12px -12px 8px;
  padding: 4px 12px;
  font-size: 13px;
  background: var(--wood);
  color: var(--gold-light);
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  text-shadow: 1px 1px 0 var(--ink);
}
.panel h2:first-child { margin-top: -12px; border-top: none; }

/* ---- 建設パレット ---- */
#palette { display: flex; flex-direction: column; gap: 6px; max-height: 72vh; overflow-y: auto; padding-right: 2px; }
/* 「選択」をパレット最上部に固定（スクロール追従）。下に流れる施設はパネル背景色で隠す */
.palette-pin { position: sticky; top: 0; z-index: 3; background: var(--cream); padding-bottom: 6px; }
#palette::-webkit-scrollbar, #tab-ach::-webkit-scrollbar, #tab-stats::-webkit-scrollbar, #tab-creators::-webkit-scrollbar, #log::-webkit-scrollbar { width: 8px; }
#palette::-webkit-scrollbar-thumb, #tab-ach::-webkit-scrollbar-thumb, #tab-stats::-webkit-scrollbar-thumb, #tab-creators::-webkit-scrollbar-thumb, #log::-webkit-scrollbar-thumb {
  background: var(--wood);
  border: 2px solid var(--cream);
}
.tool-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: #fffae8;
  border: 2px solid var(--ink);
  padding: 5px 8px;
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(43, 33, 24, .3);
}
.tool-btn:hover { background: #fff1c4; }
.tool-btn.active {
  background: var(--gold-light);
  box-shadow: var(--bevel);
  transform: translate(2px, 2px);
  outline: 2px solid var(--accent-dark);
}
.tool-btn.unaffordable { opacity: .55; }
.tool-btn.locked { opacity: .5; background: #ddd5be; cursor: default; box-shadow: none; }
.t-icon {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  background: linear-gradient(#b9d694, #a5c77f);
  border: 2px solid var(--ink);
}
.t-icon-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  background: var(--cream-dark);
}
.palette-cat {
  font-size: 10px;
  font-weight: bold;
  background: var(--wood);
  color: var(--gold-light);
  padding: 2px 8px;
  margin-top: 4px;
  border: 2px solid var(--ink);
}
.t-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.t-name { font-weight: bold; font-size: 13px; }
.t-cost { font-size: 11px; font-weight: bold; color: var(--accent-dark); }
.t-sub { font-size: 10px; opacity: .75; line-height: 1.3; }

/* ---- マップ（canvas ドット絵） ---- */
#map-panel { position: relative; }
.walker-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #fff;
  border: 2px solid var(--ink);
  padding: 1px 7px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 2px 2px 0 rgba(43, 33, 24, .3);
  pointer-events: none;
  z-index: 5;
}
.walker-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  margin-left: -3px;
  border: 3px solid transparent;
  border-top: 4px solid var(--ink);
}

#map {
  display: block;
  width: 100%;
  max-width: 672px;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 4px var(--ink), 4px 6px 0 rgba(43, 33, 24, .35);
  cursor: pointer;
}

#log {
  margin: 12px auto 0;
  max-width: 672px;
  max-height: 110px;
  overflow-y: auto;
  font-size: 12px;
  background: #f7ecd2;
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 rgba(43, 33, 24, .08);
  padding: 6px 10px;
}
.log-line { padding: 1px 0; opacity: .9; }
.log-line:first-child { color: var(--accent-dark); font-weight: bold; }

/* ---- 右パネル ---- */
#milestone-box {
  background: linear-gradient(#fff3c4, #ffe9a8);
  border: 2px solid var(--ink);
  box-shadow: var(--bevel);
  padding: 8px 10px;
  margin-bottom: 10px;
}
.ms-title { font-weight: bold; font-size: 13px; }
.ms-desc { font-size: 12px; margin-top: 2px; }
.ms-reward { font-size: 11px; font-weight: bold; color: var(--accent-dark); margin-top: 2px; }

#info-box { min-height: 96px; font-size: 13px; }
.hint { font-size: 12px; opacity: .7; }
.detail-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: bold; }
.d-icon {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  background: linear-gradient(#b9d694, #a5c77f);
  border: 2px solid var(--ink);
}
.d-icon-emoji { font-size: 22px; }
.lv-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  padding: 0 5px;
  border: 1px solid var(--ink);
}
.detail-desc { font-size: 11px; margin: 3px 0; opacity: .8; }
.detail-combo {
  font-size: 11px;
  font-weight: bold;
  color: var(--accent-dark);
  background: #fff1c4;
  border: 1px dotted var(--ink);
  padding: 2px 6px;
  margin: 3px 0;
}
.detail-status { font-size: 12px; font-weight: bold; margin: 6px 0; }
.st-fire { color: var(--red); }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-actions button {
  flex: 1;
  min-width: 110px;
  padding: 7px;
  font-weight: bold;
  font-size: 12px;
  border: 2px solid var(--ink);
  background: #8ecf7a;
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(43, 33, 24, .3);
}
.detail-actions button:active { box-shadow: var(--bevel); transform: translate(2px, 2px); }
.detail-actions button:disabled { background: #c4bda9; cursor: default; }
#dozer-btn { background: #ef9086; }
#upgrade-btn { background: var(--gold); }

#report-box { font-size: 13px; }
.rp-row { display: flex; justify-content: space-between; padding: 2px 0; }
.rp-row.net { border-top: 2px dotted var(--ink); margin-top: 2px; padding-top: 4px; }
.rp-row.net.plus b { color: var(--green); }
.rp-row.net.minus b { color: var(--red); }

#tabs { display: flex; gap: 4px; margin: 12px 0 8px; }
.tab-btn {
  flex: 1;
  padding: 6px 0;
  font-size: 11px;
  font-weight: bold;
  border: 2px solid var(--ink);
  background: var(--cream-dark);
  cursor: pointer;
  box-shadow: var(--bevel);
}
.tab-btn.active { background: var(--wood); color: var(--gold-light); }

#tab-ach, #tab-stats, #tab-creators { max-height: 280px; overflow-y: auto; }

/* ---- クリエイタータブ ---- */
.cr-head { font-weight: bold; font-size: 12px; margin-bottom: 6px; }
#scout-btn {
  width: 100%;
  padding: 8px 0;
  margin-bottom: 8px;
  font-weight: bold;
  font-size: 13px;
  border: 2px solid var(--ink);
  background: #8ecf7a;
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(43, 33, 24, .3);
}
#scout-btn:active { box-shadow: var(--bevel); transform: translate(2px, 2px); }
#scout-btn:disabled { background: #c4bda9; cursor: default; box-shadow: none; }
.cr-card {
  background: #fffae8;
  border: 2px solid var(--ink);
  box-shadow: var(--bevel);
  padding: 6px 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.cr-top { display: flex; align-items: center; gap: 6px; }
.cr-stars { color: var(--accent-dark); letter-spacing: -1px; }
.cr-genre {
  margin-left: auto;
  background: var(--cream-dark);
  border: 1px solid var(--ink);
  padding: 0 6px;
  font-size: 10px;
}
.cr-stats { font-size: 10px; margin: 4px 0; opacity: .85; }
.cr-dismiss {
  font-size: 10px;
  padding: 2px 8px;
  border: 2px solid var(--ink);
  background: #efe3c8;
  cursor: pointer;
}
.cr-dismiss:hover { background: #ef9086; color: #fff; }
/* 商品開発パネル */
.dev-panel {
  background: #fff4e0;
  border: 2px solid var(--ink);
  box-shadow: var(--bevel);
  padding: 6px 8px;
  margin-bottom: 10px;
}
#dev-btn {
  width: 100%;
  padding: 7px 0;
  margin-bottom: 4px;
  font-weight: bold;
  font-size: 12px;
  border: 2px solid var(--ink);
  background: #f3b86a;
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(43, 33, 24, .3);
}
#dev-btn:active { box-shadow: var(--bevel); transform: translate(2px, 2px); }
#dev-btn:disabled { background: #c4bda9; cursor: default; box-shadow: none; }
.dev-bar {
  height: 12px;
  border: 2px solid var(--ink);
  background: var(--cream-dark);
  margin: 4px 0;
  overflow: hidden;
}
.dev-bar > span {
  display: block;
  height: 100%;
  background: #8ecf7a;
  transition: width .2s linear;
}
.dev-status { font-size: 10px; opacity: .85; }
/* 商品履歴リスト */
.prod-head { font-size: 11px; margin-top: 8px; font-weight: bold; }
.prod-list { max-height: 160px; overflow-y: auto; margin-top: 4px; }
.prod-row {
  background: #fffae8;
  border: 2px solid var(--ink);
  box-shadow: var(--bevel);
  padding: 3px 6px;
  margin-bottom: 4px;
}
.prod-row-top { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.prod-tag {
  margin-left: auto;
  background: var(--cream-dark);
  border: 1px solid var(--ink);
  padding: 0 5px;
  font-size: 10px;
}
.prod-row-sub { font-size: 10px; opacity: .85; margin-top: 2px; }
.dev-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.dev-label { font-size: 10px; font-weight: bold; width: 36px; flex: none; }
.dev-opts { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.dev-opt {
  flex: 1;
  padding: 3px 2px;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  border: 2px solid var(--ink);
  background: #fffae8;
  cursor: pointer;
}
.dev-opt.active { background: #8ecf7a; font-weight: bold; }
.dev-opt:active { transform: translate(1px, 1px); }
.dev-opt:disabled { opacity: .45; cursor: not-allowed; }

/* ---- 取材・連載・トレンド ---- */
.trend-chip b { color: #ffd27a; }
.research-panel { background: #eef6ff; }
.prod-tag.serial { background: #cfe6ff; }
.prod-tag.cancelled { background: #f3c9c2; color: #7a2c20; }
.prod-boost {
  margin-left: 6px;
  padding: 0 5px;
  font-size: 9px;
  border: 1px solid var(--ink);
  background: #ffe9a8;
  cursor: pointer;
}
.prod-boost:disabled { opacity: .45; cursor: not-allowed; }

/* ---- 実績・統計 ---- */
.ach-count { font-weight: bold; margin-bottom: 6px; font-size: 13px; }
.ach-item {
  display: flex;
  flex-direction: column;
  padding: 5px 6px;
  border-bottom: 1px dotted var(--ink);
  font-size: 12px;
  opacity: .55;
}
.ach-item.done { opacity: 1; }
.ach-desc { font-size: 10px; opacity: .75; }
.graph-title { font-size: 11px; font-weight: bold; margin-bottom: 3px; }
#fan-graph { width: 100%; border: 2px solid var(--ink); margin-bottom: 8px; image-rendering: pixelated; }
.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 4px;
  font-size: 12px;
  border-bottom: 1px dotted var(--ink);
}

#footer-btns { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
#footer-btns button {
  flex: 1;
  min-width: 70px;
  padding: 7px 0;
  font-weight: bold;
  font-size: 11px;
  border: 2px solid var(--ink);
  background: var(--cream-dark);
  cursor: pointer;
  box-shadow: var(--bevel), 2px 2px 0 rgba(43, 33, 24, .3);
}
#footer-btns button:active { box-shadow: var(--bevel); transform: translate(2px, 2px); }

/* ---- トースト ---- */
#toasts {
  position: fixed;
  top: 96px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: 300px;
}
.toast {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-left-width: 8px;
  box-shadow: var(--hard-shadow);
  padding: 10px 14px;
  font-size: 13px;
  animation: slide-in .25s steps(5);
}
.toast.clickable { cursor: pointer; }
.toast.event { border-left-color: var(--accent-dark); background: #fff1c4; }
.toast.event:hover { background: var(--gold-light); }
.toast.fire { border-left-color: var(--red); background: #ffd5cc; }
.toast.rankup { border-left-color: #76519e; background: #ead9f7; }
.toast.achievement { border-left-color: var(--green); background: #ddf2d4; }
@keyframes slide-in { from { transform: translateX(120%); } }

/* ---- 秘書ツムギ ---- */
#secretary {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 90;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 420px;
  cursor: pointer;
  animation: sec-pop .25s steps(4);
}
#secretary[hidden] { display: none; }
#sec-face {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  /* アニメ調イラストなので滑らかに縮小する（pixelated禁止） */
  background: linear-gradient(#fff3c4, #ffe9a8);
  border: 3px solid var(--ink);
  box-shadow: var(--bevel), 3px 3px 0 rgba(43, 33, 24, .35);
}
.sec-bubble {
  position: relative;
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(43, 33, 24, .35);
  padding: 11px 12px 9px;
  min-width: 230px;
  margin-bottom: 4px;
}
.sec-bubble::before {
  content: '';
  position: absolute;
  left: -13px;
  bottom: 16px;
  border: 6px solid transparent;
  border-right: 8px solid var(--ink);
}
.sec-bubble::after {
  content: '';
  position: absolute;
  left: -6px;
  bottom: 18px;
  border: 4px solid transparent;
  border-right: 6px solid var(--cream);
}
.sec-name {
  position: absolute;
  top: -12px;
  left: 8px;
  background: var(--wood);
  color: var(--gold-light);
  font-size: 10px;
  font-weight: bold;
  padding: 1px 8px;
  border: 2px solid var(--ink);
}
#sec-text { font-size: 13px; line-height: 1.55; min-height: 20px; }
@keyframes sec-pop { from { transform: translateY(20px); opacity: 0; } }

/* ---- レスポンシブ ---- */
@media (max-width: 1080px) {
  main { grid-template-columns: 1fr; }
  #map-panel { order: -1; }
  /* 2列はグリッドで組み、カテゴリ見出しは全幅にする */
  #palette {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    max-height: none;
  }
  .tool-btn { width: auto; }
  .palette-cat { grid-column: 1 / -1; margin-top: 2px; }
  /* 狭い画面ではパレットがページスクロール側になるため固定を解除し、全幅で先頭に置く */
  .palette-pin { grid-column: 1 / -1; position: static; padding-bottom: 0; }
}
