:root {
  --parch: #fbf3df;
  --parch2: #f3e5c4;
  --ink: #4a3424;
  --ink-soft: #7a5f48;
  --wood: #a86d3c;
  --wood-dark: #6e4425;
  --jade: #2fae8a;
  --jade-light: #7ff0cc;
  --red: #d8504a;
  --gold: #f2c14e;
  --shadow: 0 6px 18px rgba(40, 24, 10, 0.28), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  --font: "M PLUS Rounded 1c", "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3f0; color: var(--ink); font-family: var(--font); font-weight: 500; }
button { font-family: inherit; }
.hidden { display: none !important; }
img.px { image-rendering: pixelated; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 0.4em; margin: 0 1px; border-radius: 6px;
  background: #fffaf0; border: 1px solid #c9ae86; border-bottom-width: 3px; color: var(--ink);
  font-family: var(--font); font-size: 0.82em; line-height: 1.5; text-align: center; font-weight: 700;
}

#game { position: fixed; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; }
#view { position: absolute; inset: 0; display: block; }
#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 120% 95% at 50% 52%, rgba(0, 0, 0, 0) 58%, rgba(30, 20, 40, 0.34) 100%),
    linear-gradient(180deg, rgba(255, 236, 200, 0.10) 0%, rgba(255, 236, 200, 0) 35%, rgba(60, 80, 140, 0) 70%, rgba(40, 50, 110, 0.10) 100%);
}
#world-ui { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* HUD・パネルは画面の高さに合わせて拡大（--ui は ui.js が入れる） */
#hud, #panel-layer, #help { zoom: var(--ui, 1); }

/* ---------- パネル共通 ---------- */
.panel {
  background: linear-gradient(180deg, var(--parch) 0%, var(--parch2) 100%);
  border: 3px solid #d9bf8f; border-radius: 16px; box-shadow: var(--shadow);
  outline: 2px solid rgba(110, 68, 37, 0.45); outline-offset: -1px;
  color: var(--ink);
}
.panel.slim { border-radius: 14px; }
.panel-title {
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px;
  padding: 8px 10px 8px 12px; margin: -3px -3px 6px; border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, #b77a45, #94592c); color: #fff6e6; text-shadow: 0 1px 0 rgba(60, 30, 10, 0.6);
  border-bottom: 2px solid #6e4425;
}
.panel-title .picon { width: 32px; height: 32px; filter: drop-shadow(0 1px 0 rgba(0,0,0,.3)); }
.panel-title .role { font-size: 12px; font-weight: 700; color: #ffe2b8; opacity: 0.95; margin-left: 2px; }
.panel-title .close {
  margin-left: auto; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff3dc; background: #c9573f;
  color: #fff; font-size: 16px; font-weight: 900; cursor: pointer; line-height: 1; padding: 0;
}
.panel-title .close:hover { background: #e06a4f; }
.btn {
  font-weight: 800; color: #fff; cursor: pointer; border: none; border-radius: 12px; padding: 8px 18px; font-size: 15px;
  background: linear-gradient(180deg, #48c79f, #2a9a79); box-shadow: 0 3px 0 #1f7259, 0 4px 10px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px 0 rgba(0, 60, 40, 0.5); transition: transform 0.06s, filter 0.1s;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #1f7259; }
.btn:disabled { filter: grayscale(0.8) brightness(0.95); opacity: 0.55; cursor: default; }
.btn.small { font-size: 13px; padding: 6px 12px; border-radius: 10px; }
.btn.tiny { font-size: 12px; padding: 3px 8px; border-radius: 8px; box-shadow: 0 2px 0 #1f7259; }
.btn.tiny small { font-weight: 700; opacity: 0.85; }
.btn.danger { background: linear-gradient(180deg, #e2715d, #c04a3a); box-shadow: 0 3px 0 #8b3328; }
.btn.on { background: linear-gradient(180deg, #f2c14e, #d79a2a); box-shadow: 0 2px 0 #9a6a14; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; padding: 1px 7px 1px 2px; margin: 1px 2px; border-radius: 10px;
  background: #fff8e8; border: 1px solid #e0c99f; font-weight: 800; font-size: 13px; color: var(--ink); vertical-align: middle;
}
.chip img { width: 24px; height: 24px; }
.chip.lack { color: #fff; background: #e06a5a; border-color: #b8483a; }
.sec { font-size: 12px; font-weight: 800; color: var(--ink-soft); margin: 10px 2px 4px; letter-spacing: 0.05em; }
.desc { font-size: 13px; line-height: 1.55; color: var(--ink-soft); margin: 2px 2px 6px; }
.note { font-size: 12px; color: var(--ink-soft); margin: 8px 2px 2px; text-align: center; }
.empty { font-size: 12px; color: #a89070; padding: 6px; }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#hud-status { position: absolute; left: 16px; top: 14px; padding: 8px 14px 8px 10px; display: flex; flex-direction: column; gap: 4px; }
#hearts { display: flex; gap: 2px; }
#hearts .heart { width: 32px; height: 32px; filter: drop-shadow(0 1px 0 rgba(80, 30, 20, 0.35)); }
#hearts.hurt { animation: shake 0.35s; }
#golem-count { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 17px; }
#golem-count img { width: 28px; height: 28px; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

#quest-card { position: absolute; right: 16px; top: 14px; width: 340px; padding: 10px 14px 12px; }
#quest-card .quest-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--wood); letter-spacing: 0.08em; }
#quest-card .quest-head img { width: 26px; height: 26px; }
#quest-card .quest-num { margin-left: auto; color: var(--ink-soft); }
#quest-card .quest-text { font-size: 17px; font-weight: 800; line-height: 1.45; margin-top: 4px; }
#quest-card .quest-progress { font-size: 14px; font-weight: 800; color: var(--jade); margin-top: 4px; }
#quest-card .quest-progress:empty, #quest-card .quest-hint:empty { display: none; }
#quest-card .quest-hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; line-height: 1.5; }
#quest-card.flash { animation: qflash 1.2s; }
@keyframes qflash { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(127, 240, 204, 0.9); } 20% { transform: scale(1.04); } 100% { transform: scale(1); box-shadow: 0 0 0 18px rgba(127, 240, 204, 0); } }

#hotbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 6px; padding: 7px 10px;
  background: rgba(60, 38, 22, 0.78); border: 2px solid rgba(255, 230, 190, 0.35); border-radius: 16px; box-shadow: 0 6px 16px rgba(0,0,0,.25);
  max-width: calc(var(--W, 100vw) - 560px); flex-wrap: wrap; justify-content: center;
}
#hotbar .slot {
  position: relative; width: 50px; height: 50px; border-radius: 10px; background: linear-gradient(180deg, #fbf0d6, #e9d4a8);
  border: 2px solid #c9a46a; display: grid; place-items: center; cursor: default;
}
#hotbar .slot img { width: 36px; height: 36px; }
#hotbar .slot .n { position: absolute; right: 3px; bottom: 0; font-weight: 900; font-size: 14px; color: #fff; text-shadow: 0 0 3px #3a2010, 0 0 3px #3a2010, 1px 1px 0 #3a2010; }
#hotbar .slot.usable { cursor: pointer; border-color: var(--jade); }
#hotbar .slot.bump { animation: bump 0.3s; }
#hotbar .slot .tip {
  position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: rgba(40, 26, 14, 0.9); color: #fff;
  font-size: 12px; padding: 3px 8px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 0.12s;
}
#hotbar .slot:hover .tip { opacity: 1; }
#hotbar .empty { color: #f3dcb8; font-size: 13px; padding: 14px 12px; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

#side-buttons { position: absolute; right: 16px; bottom: 14px; display: flex; gap: 8px; }
#side-buttons button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; width: 70px; padding: 6px 4px 5px;
  border-radius: 14px; border: 2px solid #d9bf8f; background: linear-gradient(180deg, var(--parch), var(--parch2)); cursor: pointer;
  color: var(--ink); font-weight: 800; font-size: 12px; box-shadow: 0 4px 0 #b08f5f, 0 6px 12px rgba(0, 0, 0, 0.2);
}
#side-buttons button:hover { transform: translateY(-1px); filter: brightness(1.04); }
#side-buttons button img { width: 32px; height: 32px; }
#side-buttons button .q { width: 32px; height: 32px; display: grid; place-items: center; font-size: 22px; font-weight: 900; color: var(--wood); }
#side-buttons button kbd { position: absolute; top: -8px; right: -6px; font-size: 10px; }

#mode-banner {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 9px 18px; border-radius: 999px;
  background: rgba(35, 70, 60, 0.88); color: #eafff7; font-size: 15px; font-weight: 700; display: flex; gap: 14px; align-items: center;
  border: 2px solid rgba(127, 240, 204, 0.6); box-shadow: 0 4px 14px rgba(0,0,0,.25); pointer-events: none; white-space: nowrap;
  max-width: calc(var(--W, 100vw) - 760px); overflow: hidden;
}
#mode-banner b { color: var(--jade-light); }
#mode-banner .bmain { white-space: nowrap; }
#mode-banner span { font-size: 13px; opacity: 0.85; }
#mode-banner kbd { font-size: 11px; }
#hint-bar { display: none; }

#toasts { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  padding: 8px 18px; border-radius: 999px; background: rgba(255, 250, 236, 0.96); color: var(--ink); font-weight: 800; font-size: 15px;
  border: 2px solid #d9bf8f; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); animation: toastIn 0.25s ease-out; transition: opacity 0.4s, transform 0.4s;
}
.toast.warn { background: #fff0ea; border-color: #e5917e; color: #a53a2c; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.95); } to { opacity: 1; transform: none; } }

/* ---------- 会話 ---------- */
#dialog { position: absolute; left: 16px; bottom: 88px; display: flex; align-items: flex-end; gap: 0; max-width: min(640px, calc(var(--W, 100vw) - 560px)); min-width: 420px; cursor: pointer; }
#dialog .portrait { width: 150px; height: 160px; flex: 0 0 auto; position: relative; z-index: 2; margin-right: -22px; }
#dialog .portrait img { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 168px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3)); }
#dialog[data-who="pico"] .portrait img { height: 150px; }
#dialog .bubble { position: relative; flex: 1; padding: 12px 18px 14px 34px; min-height: 104px; margin-bottom: 4px; }
#dialog .who {
  position: absolute; top: -14px; left: 26px; padding: 2px 14px; border-radius: 999px; font-weight: 900; font-size: 14px; color: #fff;
  background: linear-gradient(180deg, #8b62c8, #6a44a8); box-shadow: 0 2px 0 #4c2f80;
}
#dialog[data-who="pico"] .who { background: linear-gradient(180deg, #4fb7d8, #2f8fb0); box-shadow: 0 2px 0 #20708c; }
#dialog .text { font-size: 16.5px; line-height: 1.7; font-weight: 700; white-space: pre-wrap; margin-top: 6px; }
#dialog .next { position: absolute; right: 14px; bottom: 6px; color: var(--wood); font-size: 13px; opacity: 0; }
#dialog.done .next { opacity: 1; animation: blink 0.9s infinite; }
#dialog.pop .bubble { animation: popIn 0.22s ease-out; }
/* 建設メニューを開いている間は、会話をメニューの右へずらす（重ならないように）。かばんの間は隠す */
body.bm-open #dialog { left: calc(16px + 460px + 14px); min-width: 340px; max-width: min(560px, calc(var(--W, 100vw) - 490px - 390px)); }
body.bag-open #dialog { display: none; }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes popIn { from { transform: translateY(10px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 3D についていく表示 ---------- */
#world-ui .pop, #world-ui .mark { position: absolute; left: 0; top: 0; translate: -50% -100%; white-space: nowrap; will-change: transform; }
/* 重なり順: HP バーなどの目印 < ダメージ数字 < 拾った品の表示 */
#world-ui .mark { z-index: 1; }
#world-ui .pop.dmg { z-index: 3; }
#world-ui .pop.item { z-index: 4; }
#world-ui .mark.cursor-tip, #world-ui .mark.name-tip { z-index: 5; }
#world-ui .pop.item {
  display: flex; align-items: center; gap: 3px; font-weight: 900; font-size: 16px; color: #fff;
  text-shadow: 0 0 3px #3a2410, 0 0 3px #3a2410, 0 2px 0 #3a2410;
}
#world-ui .pop.item img { width: 26px; height: 26px; filter: drop-shadow(0 1px 0 #3a2410); }
#world-ui .pop.item.small { font-size: 13px; opacity: 0.9; }
#world-ui .pop.item.small img { width: 20px; height: 20px; }
#world-ui .pop.dmg { font-weight: 900; font-size: 24px; color: #fff; text-shadow: 0 0 3px #000, 0 2px 0 #000; font-family: "Zen Maru Gothic", var(--font); }
#world-ui .pop.dmg.player { color: #ff7a7a; }
#world-ui .pop.dmg.golem { color: #ffcf7a; font-size: 20px; }
#world-ui .pop.dmg.heal { color: #8fffb0; }
#world-ui .mark.excl {
  font-weight: 900; font-size: 20px; color: #fff; background: #e85a3a; border: 2px solid #fff; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); animation: bob 0.8s ease-in-out infinite;
}
#world-ui .mark.excl.small { width: 22px; height: 22px; font-size: 15px; background: #e0902a; }
#world-ui .mark.excl.red { width: auto; padding: 0 8px; border-radius: 999px; background: #d8302a; }
@keyframes bob { 50% { margin-top: -4px; } }
#world-ui .mark.hp { width: 40px; height: 7px; border-radius: 4px; background: rgba(30, 20, 20, 0.75); border: 1px solid rgba(255,255,255,.8); overflow: hidden; }
#world-ui .mark.hp > div { height: 100%; background: linear-gradient(180deg, #ff8a6a, #e04a3a); }
#world-ui .mark.hp.golem > div { background: linear-gradient(180deg, #9fffd0, #2fae8a); }
#world-ui .mark.ngauge { width: 46px; height: 9px; border-radius: 5px; background: rgba(40, 26, 14, 0.8); border: 2px solid #fff5e0; overflow: hidden; }
#world-ui .mark.ngauge > div { height: 100%; background: linear-gradient(180deg, #ffe58a, #f2a92e); transition: width 0.08s; }
#world-ui .mark.ngauge.bld > div { background: linear-gradient(180deg, #9fffd0, #2fae8a); }
#world-ui .mark.bubble {
  background: #fffaf0; color: var(--ink); font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 12px; border: 2px solid #d9bf8f;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
#world-ui .mark.blocked-at { display: flex; align-items: center; gap: 6px; }
#world-ui .mark.blocked-at b { width: 30px; height: 30px; border-radius: 50%; background: #e04a3a; color: #fff; display: grid; place-items: center; font-size: 20px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
#world-ui .mark.blocked-at span { background: rgba(255, 240, 234, 0.95); color: #a53a2c; font-weight: 800; font-size: 13px; padding: 3px 9px; border-radius: 10px; border: 2px solid #e5917e; }
#world-ui .mark.cursor-tip { translate: 0 0; background: rgba(40, 26, 14, 0.86); color: #fff6e6; font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 8px; }
#world-ui .mark.cursor-tip b { color: var(--gold); }
#world-ui .mark.name-tip { background: rgba(40, 26, 14, 0.82); color: #fff6e6; font-size: 13px; font-weight: 800; padding: 2px 10px; border-radius: 999px; border: 1px solid rgba(255, 240, 210, 0.5); }

/* ---------- 施設・ゴーレムのパネル ---------- */
#panel-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
#panel-layer > * { pointer-events: auto; }
.side-panel { position: absolute; right: 16px; top: 186px; width: 360px; max-height: calc(var(--H, 100vh) - 186px - 100px); overflow-y: auto; padding: 0 12px 12px; }
.side-panel.pop, .build-menu.pop { animation: popIn 0.18s ease-out; }
.side-panel::-webkit-scrollbar, .build-menu .bm-list::-webkit-scrollbar { width: 8px; }
.side-panel::-webkit-scrollbar-thumb, .build-menu .bm-list::-webkit-scrollbar-thumb { background: #d2b07c; border-radius: 4px; }
.status { font-weight: 800; font-size: 14px; padding: 6px 10px; border-radius: 10px; background: #fff8e8; border: 1px solid #e6d2a8; }
.status small { font-weight: 700; color: var(--ink-soft); margin-left: 4px; }
.status.s-working, .status.s-ready { color: #1f8c6c; }
.status.s-waiting { color: #a8742a; }
.status.s-full, .status.s-cap, .status.s-blocked { color: var(--red); }
.recipes { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.recipe {
  display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 10px; border: 2px solid #e0c99f; background: #fffaf0; cursor: pointer;
  font-size: 12px; font-weight: 800; color: var(--ink); text-align: left;
}
.recipe img { width: 28px; height: 28px; flex: none; }
.recipe:hover { border-color: var(--jade); }
.recipe.on { border-color: var(--jade); background: #e4fbf2; box-shadow: 0 0 0 2px rgba(47, 174, 138, 0.25); }
.recipe-line { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 8px 0 2px; padding: 6px; border-radius: 10px; background: rgba(255,255,255,.5); }
.recipe-line .arrow { font-weight: 900; color: var(--wood); margin: 0 3px; }
.recipe-line .time { margin-left: auto; font-size: 12px; color: var(--ink-soft); font-weight: 800; }
.bufs { display: flex; flex-direction: column; gap: 4px; }
.buf { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 10px; background: rgba(255, 255, 255, 0.55); border: 1px solid #ead7b0; }
.buf img { width: 30px; height: 30px; }
.buf .nm { flex: 1; font-size: 13px; font-weight: 700; }
.buf .cnt { font-weight: 900; font-size: 15px; min-width: 44px; text-align: right; }
.buf .cnt small { font-size: 11px; color: var(--ink-soft); }
.buf.lack .cnt { color: var(--red); }
.buf.need .bar { flex: 1; height: 8px; border-radius: 4px; background: #e8d6b4; overflow: hidden; }
.buf.need .bar div { height: 100%; background: linear-gradient(90deg, #48c79f, #2a9a79); }
.buf.need .nm { flex: 0 0 76px; }
.gauge { position: relative; height: 30px; border-radius: 12px; background: #4a3424; border: 2px solid #6e4425; overflow: hidden; margin-top: 4px; }
.gauge .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, #ffe58a, #f2a92e); transition: width 0.1s; }
.gauge .glabel { position: relative; z-index: 1; text-align: center; line-height: 26px; font-size: 12.5px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.gauge.clickable { cursor: pointer; border-color: var(--jade); box-shadow: 0 0 0 3px rgba(127, 240, 204, 0.35); }
.gauge.clickable:hover { filter: brightness(1.1); }
.gauge.clickable:active { transform: scale(0.98); }
.gauge.mini { height: 8px; border-radius: 4px; border-width: 1px; margin-top: 3px; }
.workers { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-top: 6px; }
.workers img { width: 22px; height: 22px; }
.panel-foot { margin: 14px 0 0; padding: 8px 0 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border-top: 1px dashed #d9bf8f; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.panel-foot .btn.confirm { animation: blink 0.9s infinite; }
/* 下に続きがあるとき、下端をフェードさせてスクロールできることを見せる */
.side-panel.can-scroll { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 30px), rgba(0,0,0,0.25)); mask-image: linear-gradient(to bottom, #000 calc(100% - 30px), rgba(0,0,0,0.25)); }
.sec small { font-weight: 700; color: var(--ink-soft); margin-left: 6px; font-size: 11px; }
.btn.ghost { background: linear-gradient(180deg, #c9a878, #a8834f); box-shadow: 0 2px 0 #7a5a30; }
.buf .btn.tiny { padding: 4px 8px; }
.buf.leftover { background: rgba(255, 236, 214, 0.7); border-style: dashed; }
.buf.leftover .nm small { display: block; font-size: 10px; color: var(--ink-soft); }
.far-note { margin-top: 8px; font-size: 12px; font-weight: 700; color: #a8742a; background: #fff3d8; border-radius: 8px; padding: 4px 8px; }
.grid-items { display: flex; flex-wrap: wrap; gap: 5px; }
.gitem { position: relative; width: 48px; height: 48px; border-radius: 10px; border: 2px solid #d9bf8f; background: #fffaf0; cursor: pointer; padding: 0; display: grid; place-items: center; }
.gitem:hover:not(:disabled) { border-color: var(--jade); background: #effcf6; }
.gitem:disabled { opacity: 0.6; cursor: default; }
.gitem img { width: 34px; height: 34px; }
.gitem .n { position: absolute; right: 2px; bottom: 0; font-weight: 900; font-size: 13px; color: #fff; text-shadow: 0 0 3px #3a2010, 0 0 3px #3a2010; }
.wb-list { display: flex; flex-direction: column; gap: 5px; }
.wb-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; border: 2px solid #e0c99f; background: #fffaf0; cursor: pointer; }
.wb-row:hover { border-color: var(--jade); background: #effcf6; }
.wb-row.on { border-color: var(--jade); }
.wb-row.cant { opacity: 0.72; }
.wb-row .out { width: 36px; height: 36px; }
.wb-mid { flex: 1; min-width: 0; }
.wb-name { font-size: 13.5px; font-weight: 800; }
.wb-name .chip { font-size: 11px; }
.wb-name .chip img { width: 18px; height: 18px; }
.wb-in .chip img { width: 20px; height: 20px; }
.wb-clicks { text-align: center; font-weight: 900; font-size: 15px; color: var(--wood); line-height: 1; }
.wb-clicks small { display: block; font-size: 9px; font-weight: 700; }
.hpbar { position: relative; height: 18px; border-radius: 9px; background: #4a3424; overflow: hidden; margin: 2px 0 8px; }
.hpbar div { height: 100%; background: linear-gradient(180deg, #9fffd0, #2fae8a); }
.hpbar span { position: absolute; inset: 0; text-align: center; font-size: 11px; font-weight: 800; color: #fff; line-height: 18px; text-shadow: 0 1px 2px #000; }
.gstate { font-size: 16px; font-weight: 800; padding: 6px 10px; border-radius: 10px; background: #e9fbf4; color: #1f7a60; border: 1px solid #b8ead8; }
.gstate.warn { background: #fff0ea; color: #b8402e; border-color: #f0b8a8; }
.gtask { font-size: 13px; margin-top: 6px; }
.guide { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: #2f5a4e; color: #eafff7; font-size: 13px; line-height: 1.55; }
.guide b { color: var(--gold); }
.filters { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fbtn { width: 38px; height: 38px; border-radius: 9px; border: 2px solid #d9bf8f; background: #fffaf0; cursor: pointer; padding: 0; display: grid; place-items: center; }
.fbtn img { width: 28px; height: 28px; }
.fbtn.on { border-color: var(--gold); background: #fff2c8; }

/* ---------- 建設メニュー ---------- */
.build-menu { position: absolute; left: 16px; top: 112px; width: 420px; padding: 0 10px 10px; max-height: calc(var(--H, 100vh) - 112px - 60px); display: flex; flex-direction: column; }
.build-menu .bm-list { overflow-y: auto; display: flex; flex-direction: column; gap: 5px; padding-right: 2px; padding-bottom: 18px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent); }
/* 2列のカード（UI は画面の高さに合わせて拡大するので、どの解像度でも8項目が1画面に収まるように） */
.build-menu { width: 460px; }
.build-menu .bm-list { display: grid; grid-template-columns: 1fr 1fr; padding-bottom: 4px; -webkit-mask-image: none; mask-image: none; }
.build-menu .bm-item { position: relative; flex-direction: column; align-items: stretch; gap: 2px; padding: 5px 7px; }
.build-menu .bm-item:hover { transform: none; }
.build-menu .bm-icon { width: 36px; height: 36px; position: absolute; right: 6px; top: 4px; }
.build-menu .bm-name { font-size: 13.5px; padding-right: 40px; flex-wrap: wrap; row-gap: 0; min-height: 36px; }
.build-menu .bm-desc { font-size: 11px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bm-item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px 8px; border-radius: 12px; border: 2px solid #e0c99f; background: #fffaf0; cursor: pointer; color: var(--ink); }
.bm-item:hover { border-color: var(--jade); background: #effcf6; transform: translateX(2px); }
.bm-item.cant { opacity: 0.78; }
.bm-icon { width: 48px; height: 48px; flex: none; }
.bm-mid { flex: 1; min-width: 0; }
.bm-name { font-weight: 900; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.mana-tag { font-size: 10.5px; font-weight: 800; color: #fff; background: linear-gradient(180deg, #48c79f, #2a9a79); padding: 1px 7px; border-radius: 999px; }
.bm-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.45; margin: 1px 0 3px; }

/* ---------- かばん ---------- */
.bag-panel { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 640px; max-width: calc(var(--W, 100vw) - 40px); max-height: calc(var(--H, 100vh) - 80px); overflow-y: auto; padding: 0 12px 12px; }
.bag-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bag-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: #fffaf0; border: 2px solid #e6d2a8; }
.bag-item.none { opacity: 0.45; }
.bag-item img { width: 40px; height: 40px; }
.bi-mid { flex: 1; min-width: 0; }
.bi-name { font-weight: 800; font-size: 14px; display: flex; }
.bi-n { margin-left: auto; font-weight: 900; color: var(--wood); }
.bi-desc { font-size: 11.5px; color: var(--ink-soft); line-height: 1.4; }

/* ---------- 操作説明 ---------- */
#help { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 600px; padding: 0 16px 14px; z-index: 30; }
#help table { width: 100%; border-collapse: collapse; font-size: 14px; }
#help td { padding: 6px 4px; border-bottom: 1px dashed #e0c99f; vertical-align: middle; }
#help td:first-child { white-space: nowrap; width: 1%; padding-right: 14px; font-weight: 800; }

/* ---------- タイトル ---------- */
.screen { position: absolute; inset: 0; z-index: 40; }
#title { background: #1c2a36; overflow: hidden; }
#title .title-art { position: absolute; inset: -2%; background: url(../assets/ui/title.webp) center / cover no-repeat; animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.07) translate(-1%, -1%); } }
#title .title-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(20, 14, 30, 0.72) 0%, rgba(20, 14, 30, 0.35) 42%, rgba(0, 0, 0, 0) 65%), radial-gradient(ellipse at 50% 120%, rgba(10, 6, 20, 0.55), transparent 60%); }
#title .title-box { position: absolute; left: 6vw; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 30px; }
.logo { color: #fff; }
.logo-sub { font-family: "Zen Maru Gothic", var(--font); font-weight: 900; font-size: 22px; letter-spacing: 0.3em; color: #bff7e4; text-shadow: 0 2px 0 #1d4a3e, 0 0 14px rgba(127, 240, 204, 0.6); margin-bottom: 4px; }
.logo-main { font-family: "Zen Maru Gothic", var(--font); font-weight: 900; line-height: 1.05; display: flex; flex-direction: column; }
.logo-main span { font-size: 40px; color: #ffe9c4; -webkit-text-stroke: 7px #5a2f6e; paint-order: stroke fill; text-shadow: 0 6px 0 #3a1a4a, 0 10px 24px rgba(0, 0, 0, 0.5); letter-spacing: 0.06em; }
.logo-main span.big {
  font-size: 84px; letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fffbe8 0%, #ffe08a 45%, #f2a93a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 0; filter: drop-shadow(0 0 0 #5a2f6e) drop-shadow(3px 0 0 #5a2f6e) drop-shadow(-3px 0 0 #5a2f6e) drop-shadow(0 3px 0 #5a2f6e) drop-shadow(0 -3px 0 #5a2f6e) drop-shadow(0 8px 0 #3a1a4a) drop-shadow(0 12px 18px rgba(0,0,0,.45));
  text-shadow: none;
}
.title-menu { display: flex; flex-direction: column; gap: 12px; width: 300px; }
.btn.big { font-size: 22px; padding: 14px 24px; border-radius: 18px; letter-spacing: 0.15em; }
#btn-new { background: linear-gradient(180deg, #f2c14e, #d7892a); box-shadow: 0 4px 0 #8f5a14, 0 6px 16px rgba(0,0,0,.3); }
.title-help { color: #f5ead8; font-size: 13.5px; line-height: 2.1; background: rgba(20, 14, 30, 0.5); padding: 10px 16px; border-radius: 14px; border: 1px solid rgba(255,255,255,.15); }
.title-help kbd { font-size: 11px; }
.title-foot {
  position: absolute; right: 18px; bottom: 14px; color: #fff8ec; font-size: calc(14px * var(--ui, 1)); font-weight: 800;
  padding: 4px 14px; border-radius: 999px; background: rgba(40, 26, 14, 0.62); border: 1px solid rgba(255, 240, 210, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); letter-spacing: 0.04em;
}

/* ---------- クリア ---------- */
#clear { background: radial-gradient(ellipse at center, rgba(255, 250, 220, 0.25), rgba(20, 30, 40, 0.6)); display: grid; place-items: center; animation: fadeIn 0.8s; }
@keyframes fadeIn { from { opacity: 0; } }
.clear-box { width: 480px; padding: 20px 26px 22px; text-align: center; }
.clear-title { font-family: "Zen Maru Gothic", var(--font); font-size: 44px; font-weight: 900; color: #ffe08a; -webkit-text-stroke: 6px #5a2f6e; paint-order: stroke fill; text-shadow: 0 5px 0 #3a1a4a; }
.clear-sub { font-weight: 800; color: var(--ink-soft); margin: 6px 0 14px; }
.clear-stats { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.cs-row { display: flex; align-items: baseline; gap: 8px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.6); flex-wrap: wrap; }
.cs-row span { flex: 1; font-weight: 700; color: var(--ink-soft); }
.cs-row b { font-size: 20px; }
.cs-row small { width: 100%; text-align: right; font-size: 12px; color: var(--ink-soft); }
.cs-items { display: flex; flex-wrap: wrap; justify-content: center; }
.clear-buttons { display: flex; justify-content: center; gap: 12px; margin-top: 16px; }

/* ---------- 読み込み ---------- */
#loading { background: linear-gradient(180deg, #bfe3f0, #e9f4e0); display: grid; place-items: center; z-index: 50; }
.loading-box { display: flex; flex-direction: column; align-items: center; gap: 14px; font-weight: 800; color: var(--ink); font-size: 18px; text-align: center; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 6px solid rgba(47, 174, 138, 0.25); border-top-color: var(--jade); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 小さめの画面（1280x720） */
@media (max-height: 760px) {
  #quest-card { width: 300px; }
  #quest-card .quest-text { font-size: 15px; }
  .side-panel { top: 166px; width: 340px; max-height: calc(var(--H, 100vh) - 166px - 92px); }
  .recipes { grid-template-columns: 1fr 1fr 1fr; gap: 4px; }
  .recipe { padding: 2px 4px; font-size: 10.5px; gap: 2px; border-radius: 8px; height: 30px; overflow: hidden; line-height: 1.15; }
  .recipe img { width: 22px; height: 22px; }
  .side-panel .sec { margin-top: 6px; }
  .buf { padding: 1px 6px; }
  .buf img { width: 26px; height: 26px; }
  .gauge { height: 26px; }
  .gauge .glabel { line-height: 22px; }
  #dialog .portrait { width: 120px; height: 128px; }
  #dialog .portrait img { height: 136px; }
  #dialog[data-who="pico"] .portrait img { height: 120px; }
  #dialog .bubble { min-height: 88px; }
  #dialog .text { font-size: 15px; }
  #dialog { min-width: 380px; max-width: min(560px, calc(var(--W, 100vw) - 600px)); }
  .build-menu { top: 100px; max-height: calc(var(--H, 100vh) - 100px - 40px); }
  body.bm-open #dialog { min-width: 330px; max-width: calc(var(--W, 100vw) - 490px - 360px); }
  #hotbar .slot { width: 44px; height: 44px; }
  #hotbar .slot img { width: 32px; height: 32px; }
  .logo-main span.big { font-size: 68px; }
  .logo-main span { font-size: 32px; }
}

/* タイトルの「はじめから」の確認（セーブがあるとき） */
#btn-new.confirm { font-size: 17px; letter-spacing: 0.02em; line-height: 1.3; background: linear-gradient(180deg, #f6b24a, #e08a2a); }
#btn-new.confirm small { display: block; font-size: 12px; opacity: 0.9; }
/* ピコの「話す」顔は羽を広げていて立ち絵の箱より横に広いので、吹き出しの文字が羽に隠れないよう余白を足す */
#dialog[data-who="pico"] .bubble { padding-left: 48px; }
