:root {
  --ink: #0b0a0f;
  --stone: #15131c;
  --stone-2: #1e1b26;
  --parchment: #e8dcc0;
  --parchment-dim: #b6a988;
  --gold: #d9b25f;
  --gold-bright: #f2d489;
  --blood: #b23a3a;
  --blood-bright: #e05a4a;
  --ok: #6fbf73;
  --warn: #d9a749;
  --risky: #d97b3f;
  --fatal: #c94a3f;
  --blue: #5f9fd9;
  --serif: "Noto Serif TC", "Songti TC", "Source Han Serif TC", "PMingLiU", Georgia, serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #050409;
  color: var(--parchment);
  font-family: var(--sans);
  user-select: none;
}

#game-root { position: fixed; inset: 0; }
#scene { display: block; width: 100%; height: 100%; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud { position: absolute; inset: 0; pointer-events: none; }

#floor-badge {
  position: absolute;
  top: 26px;
  left: 30px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 10px 18px 10px 16px;
  background: linear-gradient(160deg, rgba(30, 27, 38, 0.92), rgba(12, 10, 18, 0.88));
  border: 1px solid rgba(217, 178, 95, 0.35);
  border-radius: 3px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
#floor-badge::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(217, 178, 95, 0.14);
  border-radius: 2px;
  pointer-events: none;
}
#floor-number {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(217, 178, 95, 0.45);
}
#floor-suffix { font-family: var(--serif); font-size: 15px; color: var(--gold); letter-spacing: 0.1em; }
#floor-name {
  margin-left: 10px;
  padding-left: 12px;
  border-left: 1px solid rgba(217, 178, 95, 0.25);
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--parchment-dim);
}

#hint-bar {
  position: absolute;
  top: 34px;
  right: 30px;
  display: flex;
  gap: 18px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(232, 220, 192, 0.42);
}
#hint-bar b { color: rgba(242, 212, 137, 0.85); font-weight: 600; }

#status-panel {
  position: absolute;
  left: 30px;
  bottom: 30px;
  width: 330px;
  padding: 16px 18px 14px;
  background: linear-gradient(160deg, rgba(26, 23, 33, 0.94), rgba(10, 9, 15, 0.9));
  border: 1px solid rgba(217, 178, 95, 0.28);
  border-radius: 3px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.hp-row { display: flex; align-items: center; gap: 10px; }
.hp-label { font-size: 11px; letter-spacing: 0.3em; color: var(--parchment-dim); }
.hp-track {
  position: relative;
  flex: 1;
  height: 14px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(217, 178, 95, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
#hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #d9553f, #8e2320);
  box-shadow: 0 0 16px rgba(224, 90, 74, 0.45) inset;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
#hp-text {
  min-width: 52px;
  text-align: right;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--parchment);
  font-variant-numeric: tabular-nums;
}

.stat-row { display: flex; align-items: center; gap: 14px; margin-top: 11px; }
.stat { display: flex; align-items: center; gap: 6px; font-family: var(--serif); font-size: 16px; }
.stat-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-family: var(--sans);
  font-size: 10px;
  border-radius: 2px;
}
.stat-icon.atk { background: rgba(194, 84, 60, 0.22); color: #e79a7a; border: 1px solid rgba(194, 84, 60, 0.45); }
.stat-icon.def { background: rgba(95, 159, 217, 0.18); color: #93c4ea; border: 1px solid rgba(95, 159, 217, 0.4); }

.keys { margin-left: auto; display: flex; gap: 10px; }
.key-chip { display: flex; align-items: center; gap: 5px; font-family: var(--serif); font-size: 15px; }
.key-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.key-dot.yellow { background: #e2c060; box-shadow: 0 0 8px rgba(226, 192, 96, 0.65); }
.key-dot.blue { background: #63a6e0; box-shadow: 0 0 8px rgba(99, 166, 224, 0.65); }

/* ---------- 怪物價目表 ---------- */

#monster-card {
  position: absolute;
  right: 30px;
  top: 50%;
  transform: translateY(-50%);
  width: 250px;
  padding: 16px 18px;
  background: linear-gradient(165deg, rgba(28, 24, 34, 0.95), rgba(9, 8, 13, 0.93));
  border: 1px solid rgba(217, 178, 95, 0.3);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#monster-card .mc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#mc-name { font-family: var(--serif); font-size: 19px; color: var(--gold-bright); letter-spacing: 0.06em; }
.verdict {
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.verdict.easy { color: var(--ok); background: rgba(111, 191, 115, 0.1); }
.verdict.ok { color: #b9c56a; background: rgba(185, 197, 106, 0.1); }
.verdict.risky { color: var(--risky); background: rgba(217, 123, 63, 0.12); }
.verdict.deadly { color: var(--fatal); background: rgba(201, 74, 63, 0.14); }
.verdict.blocked { color: #8b8577; background: rgba(139, 133, 119, 0.1); }

.mc-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 11px;
  padding-bottom: 9px;
  border-bottom: 1px dashed rgba(217, 178, 95, 0.2);
  font-size: 12px;
  color: var(--parchment-dim);
  letter-spacing: 0.04em;
}
.mc-stats b { color: var(--parchment); font-family: var(--serif); font-size: 14px; }

.mc-result { margin-top: 10px; }
.mc-cost { font-size: 13px; color: var(--parchment-dim); }
.mc-cost b { font-family: var(--serif); font-size: 22px; color: var(--blood-bright); margin-left: 2px; }
.mc-remain { margin-top: 3px; font-size: 12px; color: rgba(232, 220, 192, 0.55); }
.mc-remain b { color: var(--parchment); font-family: var(--serif); font-size: 15px; }
.mc-note { margin-top: 9px; font-size: 11.5px; line-height: 1.55; color: rgba(232, 220, 192, 0.42); }
#monster-card.lethal .mc-cost b { color: #ff6b5a; text-shadow: 0 0 14px rgba(255, 90, 74, 0.55); }

/* ---------- 提示 ---------- */

#prompt {
  position: absolute;
  left: 50%;
  bottom: 132px;
  transform: translateX(-50%);
  padding: 9px 18px;
  background: rgba(10, 9, 15, 0.86);
  border: 1px solid rgba(217, 178, 95, 0.35);
  border-radius: 2px;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--parchment);
  white-space: nowrap;
}
#prompt kbd {
  display: inline-block;
  min-width: 20px;
  margin-right: 7px;
  padding: 1px 5px;
  background: rgba(217, 178, 95, 0.16);
  border: 1px solid rgba(217, 178, 95, 0.45);
  border-radius: 2px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--gold-bright);
  text-align: center;
}

#toasts {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.toast {
  padding: 8px 18px;
  background: rgba(10, 9, 15, 0.9);
  border: 1px solid rgba(217, 178, 95, 0.28);
  border-left: 2px solid var(--gold);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--parchment);
  animation: toastIn 0.25s ease both, toastOut 0.35s ease 1.9s both;
}
.toast.warn { border-left-color: var(--fatal); color: #f0b7ad; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

#floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: #ff8c74;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
  animation: floatUp 0.9s cubic-bezier(0.2, 0.8, 0.3, 1) both;
  white-space: nowrap;
}
.floater.heal { color: #86d68a; }
.floater.gold { color: var(--gold-bright); }
.floater.small { font-size: 15px; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -60%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.98); }
}

#floor-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: var(--serif);
  font-size: 40px;
  letter-spacing: 0.3em;
  color: var(--gold-bright);
  text-shadow: 0 0 40px rgba(217, 178, 95, 0.5), 0 4px 20px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  animation: banner 2.6s ease both;
}
@keyframes banner {
  0% { opacity: 0; letter-spacing: 0.6em; }
  22% { opacity: 1; letter-spacing: 0.3em; }
  72% { opacity: 1; }
  100% { opacity: 0; letter-spacing: 0.34em; }
}

/* ---------- 畫面 ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 42%, rgba(36, 30, 46, 0.94), rgba(4, 3, 8, 0.985) 72%);
  z-index: 20;
}
.screen.backdrop-soft { background: rgba(4, 3, 8, 0.72); backdrop-filter: blur(3px); }

.title-inner { text-align: center; max-width: 640px; padding: 0 24px; }
.ornament { color: var(--gold); font-size: 20px; letter-spacing: 0.6em; opacity: 0.8; }
h1 {
  margin: 14px 0 6px;
  font-family: var(--serif);
  font-size: clamp(44px, 7vw, 76px);
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--parchment);
  text-shadow: 0 0 60px rgba(217, 178, 95, 0.28), 0 6px 30px rgba(0, 0, 0, 0.9);
}
.title-colon { color: var(--gold); margin: 0 0.05em; }
.tagline {
  margin: 0 0 40px;
  font-size: 14px;
  letter-spacing: 0.26em;
  color: var(--parchment-dim);
}

.btn {
  display: block;
  margin: 0 auto 12px;
  padding: 13px 46px;
  min-width: 240px;
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.24em;
  color: var(--parchment);
  background: rgba(30, 27, 38, 0.7);
  border: 1px solid rgba(217, 178, 95, 0.35);
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn:hover { background: rgba(217, 178, 95, 0.13); border-color: rgba(242, 212, 137, 0.7); color: var(--gold-bright); }
.btn.primary {
  background: linear-gradient(180deg, rgba(217, 178, 95, 0.22), rgba(217, 178, 95, 0.06));
  border-color: rgba(242, 212, 137, 0.6);
  color: var(--gold-bright);
}
.btn.primary:hover { background: linear-gradient(180deg, rgba(217, 178, 95, 0.34), rgba(217, 178, 95, 0.1)); }
.btn.ghost { background: transparent; }
.text-link {
  margin-top: 26px;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(217, 178, 95, 0.3);
  padding: 2px 0;
  color: rgba(232, 220, 192, 0.55);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.2em;
  cursor: pointer;
}
.text-link:hover { color: var(--gold-bright); }

.title-help {
  margin-top: 42px;
  font-size: 12.5px;
  line-height: 2;
  color: rgba(232, 220, 192, 0.4);
  letter-spacing: 0.05em;
}

.panel {
  width: min(440px, 88vw);
  padding: 38px 42px;
  text-align: center;
  background: linear-gradient(165deg, rgba(26, 23, 33, 0.97), rgba(8, 7, 12, 0.97));
  border: 1px solid rgba(217, 178, 95, 0.28);
  border-radius: 3px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.panel.wide { width: min(620px, 92vw); text-align: left; }
.panel h2 {
  margin: 8px 0 10px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--parchment);
}
.panel-sub { margin: 0 0 26px; font-size: 13px; color: var(--parchment-dim); letter-spacing: 0.08em; }
.panel-note { margin: 0 0 26px; font-size: 12px; color: rgba(232, 220, 192, 0.4); }
.panel.death h2 { color: #d98c7d; }

.guide-list { margin: 22px 0; padding-left: 0; list-style: none; }
.guide-list li {
  position: relative;
  margin-bottom: 13px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.75;
  color: rgba(232, 220, 192, 0.78);
}
.guide-list li::before { content: "✦"; position: absolute; left: 0; top: 0; color: var(--gold); font-size: 11px; }
.guide-list b { color: var(--gold-bright); font-weight: 600; }
.guide-foot {
  margin: 24px 0 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(217, 178, 95, 0.14);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--parchment-dim);
  text-align: center;
}

.ending-text {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 2.1;
  letter-spacing: 0.06em;
  color: rgba(232, 220, 192, 0.82);
}
.ending-stats {
  margin: 28px 0 30px;
  padding: 16px 0;
  border-top: 1px solid rgba(217, 178, 95, 0.16);
  border-bottom: 1px solid rgba(217, 178, 95, 0.16);
  display: flex;
  justify-content: space-around;
  font-size: 12px;
  color: var(--parchment-dim);
  letter-spacing: 0.1em;
}
.ending-stats b { display: block; margin-top: 5px; font-family: var(--serif); font-size: 20px; color: var(--gold-bright); }

#loading { z-index: 40; }
.loading-inner { text-align: center; }
.loading-inner p { font-size: 12px; letter-spacing: 0.28em; color: var(--parchment-dim); }
.spinner {
  width: 30px; height: 30px;
  margin: 0 auto 20px;
  border: 1px solid rgba(217, 178, 95, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  #hint-bar { display: none; }
  #status-panel { width: 260px; left: 16px; bottom: 16px; }
  #floor-badge { top: 16px; left: 16px; }
  #monster-card { right: 12px; width: 200px; }
}
