/* 色は「くすんだ暖色」。モンスターの絵（墨の線・低い彩度）に合わせています。 */
:root {
  --bg: #15110f;
  --panel: rgba(23, 19, 16, 0.93);
  --panel-2: rgba(38, 31, 25, 0.95);
  --line: #5a4b3e;
  --line-2: #7a6650;
  --text: #ecdfca;
  --text-dim: #b3a48e;
  --gold: #c9a54a;
  --gold-dim: #8e7337;
  --red: #b5503c;
  --green: #8fae6a;
  --blue: #7f9bb0;
  --radius: 12px;
  font-family: "BIZ UDPGothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
#scene.pointing { cursor: pointer; }

/* ---------------------------------------------------------------- 上のバー */
#hud {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start;
  padding: max(10px, env(safe-area-inset-top)) 12px 0; pointer-events: none; gap: 8px;
}
#hud > * { pointer-events: auto; }
.res, .tools { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 15px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.pill b { font-size: 17px; min-width: 1.6em; text-align: right; font-variant-numeric: tabular-nums; }
.pill.wave b { min-width: 0; }
.pill.bump { animation: bump 0.35s ease-out; }
.pill.hurt { animation: hurt 0.6s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); } }
@keyframes hurt { 0%, 60% { background: rgba(120, 40, 30, 0.95); } }
.ico { width: 19px; height: 19px; flex: none; }
.ico.coin circle { fill: var(--gold); }
.ico.coin .in { fill: none; stroke: #8e7337; stroke-width: 1.6; }
.ico.heart path { fill: var(--red); }
.ico.moon path { fill: #c9cfe6; }
.ico.sun circle { fill: #f0c56a; }
.ico.sun path { stroke: #f0c56a; stroke-width: 1.6; stroke-linecap: round; }
#daypill .sun { display: none; }
#daypill.isday .sun { display: block; }
#daypill.isday .moon { display: none; }
#daypill #phase { color: #c9cfe6; font-weight: 700; }
#daypill.isday #phase { color: #f0c56a; }

/* ---------------------------------------------------------------- ボタン */
.btn {
  border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 14px; cursor: pointer;
  background: linear-gradient(#4b3d31, #322820); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: filter 0.12s, transform 0.08s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: default; }
.btn.small { padding: 6px 12px; min-width: 40px; font-weight: 700; }
.btn.go {
  font-size: 17px; font-weight: 800; padding: 13px 26px; letter-spacing: 0.04em;
  background: linear-gradient(#8f6d36, #5b4322); border-color: var(--gold); color: #fff4dc;
}
.btn.go.busy { background: linear-gradient(#4b3d31, #322820); border-color: var(--line-2); color: var(--text-dim); }
.btn.danger { border-color: #8a4a3c; background: linear-gradient(#5a3329, #3a221c); }
.btn.ghost { background: transparent; box-shadow: none; }

/* ---------------------------------------------------------------- 下 */
#bottom {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(92vw, 560px);
}
#bottom > * { pointer-events: auto; }
#hint {
  font-size: 14px; color: var(--text-dim); background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; text-align: center; line-height: 1.5;
}
#hint:empty { display: none; }

/* ---------------------------------------------------------------- 右の パネル（スマホは 下から） */
#panel {
  position: fixed; right: 12px; top: 62px; width: 318px; max-height: calc(100% - 160px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); scrollbar-width: thin;
}
#panel h2 { margin: 0 26px 4px 0; font-size: 19px; display: flex; align-items: center; gap: 8px; }
#panel .lv { font-size: 12px; color: #1e1712; background: var(--gold); border-radius: 6px; padding: 1px 6px; }
#panel p { margin: 4px 0 10px; font-size: 13.5px; line-height: 1.6; color: var(--text-dim); }
#panel .close { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; padding: 0; border-radius: 8px; }
#panel .sec { font-size: 12px; color: var(--gold); letter-spacing: 0.08em; margin: 12px 0 6px; }
#panel .why { font-size: 13px; color: #d9a07f; margin: 6px 0; }
.list { display: flex; flex-direction: column; gap: 6px; }
.opt {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; text-align: left; width: 100%;
  padding: 7px 10px 7px 7px; border-radius: 10px;
}
.opt .name { font-weight: 700; font-size: 14.5px; }
.opt .desc { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin-top: 1px; }
.opt .cost { font-weight: 800; color: var(--gold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.opt .cost.free { color: var(--text-dim); font-weight: 400; }
.opt img, .mon img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: radial-gradient(#3a2f26, #1f1915); }
.room-ico { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; font-size: 20px; font-weight: 800; background: #2a221c; color: var(--gold); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.actions .btn { flex: 1 1 auto; font-size: 14px; }
.mon {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 6px 8px 6px 6px;
  border-radius: 10px; background: var(--panel-2); border: 1px solid #3c3129;
}
.mon .name { font-size: 14px; font-weight: 700; }
.mon .sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.mon.down { opacity: 0.6; }
.bar { height: 6px; border-radius: 4px; background: #2a211b; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--green); width: 100%; transition: width 0.15s; }
.mon.down .bar i { background: var(--blue); }
.mon .x { width: 28px; height: 28px; padding: 0; border-radius: 7px; font-size: 13px; }
.empty { font-size: 13px; color: var(--text-dim); padding: 6px 2px; }

/* ---------------------------------------------------------------- 小さな 表示 */
#tip {
  position: fixed; z-index: 5; pointer-events: none; font-size: 13px; padding: 5px 10px; border-radius: 8px;
  background: rgba(20, 16, 13, 0.92); border: 1px solid var(--line); white-space: nowrap; transform: translate(14px, 14px);
}
#tip b { color: var(--gold); }
#toast {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
#toast .t {
  padding: 8px 16px; border-radius: 999px; background: rgba(28, 21, 17, 0.95); border: 1px solid var(--line-2);
  font-size: 14px; animation: toast 2.4s ease forwards;
}
#toast .t.bad { border-color: #8a4a3c; color: #f0c2ad; }
#toast .t.good { border-color: var(--gold-dim); color: #f3dfaa; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#banner {
  position: fixed; top: 32%; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 4;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.85), 0 1px 0 #000;
}
#banner .b { animation: banner 2.6s ease forwards; }
#banner .b1 { font-size: clamp(26px, 5vw, 44px); font-weight: 800; letter-spacing: 0.06em; color: #f6e7c6; }
#banner .b2 { font-size: clamp(14px, 2.4vw, 18px); color: var(--text-dim); margin-top: 6px; }
@keyframes banner { 0% { opacity: 0; transform: scale(0.94); } 10%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------------------------------------------------------------- ダメージ・金貨の 数字 */
#popups { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.pop { position: absolute; left: 0; top: 0; will-change: transform; }
.pop span {
  display: block; transform: translate(-50%, -50%); font-weight: 800; font-size: 17px; white-space: nowrap;
  text-shadow: 0 2px 0 #000, 0 0 6px rgba(0, 0, 0, 0.8); animation: pop 0.9s ease-out forwards;
}
.pop.dmg span { color: #f2e2c4; }
.pop.hurt span { color: #f09a7f; }
.pop.gold span { color: #f0cf6c; font-size: 18px; }
.pop.heal span { color: #a8e09a; }
.pop.lose span { color: #ff8f73; font-size: 20px; }
.pop.big span { font-size: 24px; }
@keyframes pop { 0% { opacity: 0; margin-top: 6px; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; margin-top: -34px; } }

/* ---------------------------------------------------------------- まど（遊び方・おわり） */
#modal { position: fixed; inset: 0; z-index: 10; background: rgba(10, 8, 7, 0.62); display: grid; place-items: center; padding: 16px; }
#modal[hidden] { display: none; }
#modal .card {
  width: min(560px, 100%); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 16px; padding: 22px 22px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
#modal h1 { margin: 0 0 6px; font-size: 24px; }
#modal h1 small { font-size: 13px; color: var(--text-dim); font-weight: 400; margin-left: 6px; }
#modal p, #modal li { font-size: 14.5px; line-height: 1.75; color: var(--text); }
#modal ul { padding-left: 1.2em; margin: 8px 0; }
#modal li b { color: var(--gold); }
#modal .keys { font-size: 13px; color: var(--text-dim); border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
#modal .row { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }

#modal .sec { font-size: 12.5px; color: var(--gold); letter-spacing: 0.08em; margin: 14px 0 6px; }
#modal .small { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; margin: 6px 0 0; }
#modal .opts { display: flex; flex-wrap: wrap; gap: 6px; }
#modal .opts .btn { min-width: 64px; }
#modal .opts .btn.on { border-color: var(--gold); background: linear-gradient(#7d6032, #4f3b20); color: #fff4dc; }
.foes { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.foe {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid #3c3129; font-size: 14px;
}
.foe img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: radial-gradient(#3a2f26, #1f1915); }
.foe b { color: var(--gold); }
.foe.boss { border-color: #8a4a3c; }
.lock { font-size: 13px; color: #f0c56a; background: rgba(90, 70, 30, 0.35); border: 1px solid #6e5a2e; border-radius: 8px; padding: 6px 10px; margin: 6px 0 4px; }
#perf {
  position: fixed; left: 10px; bottom: 10px; z-index: 5; pointer-events: none; font: 12px/1.4 ui-monospace, Consolas, monospace;
  color: #d8ccb5; background: rgba(16, 13, 11, 0.8); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}

#loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--bg); transition: opacity 0.4s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .box { font-size: 16px; color: var(--text-dim); letter-spacing: 0.06em; }

@media (max-width: 760px) {
  #panel { left: 8px; right: 8px; top: auto; bottom: 118px; width: auto; max-height: 46vh; }
  .pill { padding: 5px 10px; font-size: 13px; }
  .pill b { font-size: 15px; }
  .btn.go { font-size: 15px; padding: 11px 20px; }
  #hint { font-size: 12.5px; }
}

/* ゲートの 札（ゲートの 部屋の 上。敵が 出てくる 所が ひと目で わかる） */
.gatemark {
  position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none; white-space: nowrap;
  padding: 3px 10px 4px; border-radius: 999px; font-size: 13px; font-weight: 700; letter-spacing: 0.04em;
  color: #e6f6ff; background: rgba(14, 32, 46, 0.86); border: 1px solid #6fc2ec;
  box-shadow: 0 0 10px rgba(110, 190, 240, 0.45);
}
.gatemark .ico { margin-right: 5px; color: #9fdcff; }
.gatemark::after {
  content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  border: 6px solid transparent; border-bottom: 0; border-top-color: #6fc2ec;
}
.gatemark.active { animation: gatepulse 0.9s ease-in-out infinite; }
@keyframes gatepulse {
  0%, 100% { box-shadow: 0 0 8px rgba(110, 190, 240, 0.45); }
  50% { box-shadow: 0 0 22px rgba(140, 215, 255, 0.95); border-color: #bfe8ff; }
}

/* 毎晩の 発見（3まいの カード） */
#modal .card.wide { width: min(760px, 94vw); }
.offers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.btn.offer {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 14px 10px 12px;
  white-space: normal; min-height: 210px; border-radius: 12px;
}
.btn.offer .kind { font-size: 11.5px; letter-spacing: 0.06em; color: var(--text-dim); }
.btn.offer.room .kind { color: #9fdcff; }
.btn.offer.acc .kind { color: #f0c56a; }
.btn.offer .name { font-weight: 800; font-size: 16px; }
.btn.offer .desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.btn.offer .where { font-size: 11.5px; color: #cdbb98; line-height: 1.4; }
.btn.offer:hover { border-color: var(--gold); transform: translateY(-2px); }
.opt.locked { opacity: 0.55; }
.opt.acc-on { border: 1px solid #5d6e3a; border-radius: 10px; padding: 6px 8px; background: rgba(70, 90, 40, 0.18); }
@media (max-width: 640px) { .offers { grid-template-columns: 1fr; } .btn.offer { min-height: 0; } }
