/* ============================================================
   我的王国 · 横版产线卡牌原型
   ============================================================ */

:root {
  --bg: #0d0b09;
  --wood: #2a2019;
  --wood-2: #35281e;
  --wood-3: #43331f;
  --edge: #5c452c;
  --edge-2: #7d5f3a;
  --parch: #efe2c4;
  --muted: #9c8a6d;
  --dim: #6b5c47;
  --gold: #e8b44a;
  --blue: #4f8fd6;
  --red: #c8503f;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Courier New", ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #17130f 0%, #060504 72%);
  font-family: var(--sans);
  color: var(--parch);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body { display: grid; place-items: center; }

#stage {
  --h: min(100vh, calc(100vw * 16 / 9));
  height: var(--h);
  width: calc(var(--h) * 9 / 16);
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

@media (max-width: 700px) {
  #stage { border-radius: 0; box-shadow: none; }
}

img { image-rendering: pixelated; }

/* ---------------- 屏幕 ---------------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.screen.is-on { opacity: 1; pointer-events: auto; }

.kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

/* ---------------- 按钮 ---------------- */
.btn-main {
  width: 100%;
  padding: 15px;
  border: 2px solid #8a6a3c;
  border-radius: 6px;
  background: linear-gradient(180deg, #6a4d28 0%, #48331b 100%);
  box-shadow: inset 0 2px 0 rgba(255, 226, 170, 0.22), inset 0 -3px 0 rgba(0, 0, 0, 0.32), 0 3px 0 #2a1d10;
  color: #ffe9bb;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-main:hover { filter: brightness(1.12); }
.btn-main:active { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 226, 170, 0.18), 0 1px 0 #2a1d10; }
.btn-main:disabled { filter: grayscale(0.7) brightness(0.72); cursor: default; }

.btn-ghost {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--edge);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--parch); border-color: var(--edge-2); }

.gold-box {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 8px;
  border: 2px solid var(--edge);
  border-radius: 5px;
  background: #1e1710;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.04em;
}
.gold-box img { width: 18px; height: 18px; }
.gold-box.small { padding: 4px 10px 4px 6px; font-size: 13px; }
.gold-box.small img { width: 15px; height: 15px; }

/* ---------------- 主菜单 ---------------- */
#screen-menu {
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background:
    radial-gradient(ellipse at 50% 34%, rgba(74, 104, 48, 0.30) 0%, transparent 58%),
    radial-gradient(ellipse at 50% 100%, rgba(30, 22, 12, 0.9) 0%, transparent 60%);
}
.menu-inner { width: 100%; display: flex; flex-direction: column; align-items: center; }

.menu-castle {
  width: 132px;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.55));
}
.menu-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: #f5e8c8;
  text-shadow: 0 3px 0 #6b4a1e, 0 6px 12px rgba(0, 0, 0, 0.6);
}
.menu-sub { font-size: 11px; letter-spacing: 0.24em; color: var(--dim); margin-top: 10px; }

.brief {
  width: 100%;
  margin: 30px 0 28px;
  border: 2px solid var(--edge);
  border-radius: 6px;
  background: rgba(42, 32, 25, 0.85);
  padding: 4px 14px;
}
.brief-row {
  display: flex; justify-content: space-between;
  padding: 11px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(92, 69, 44, 0.55);
}
.brief-row:last-child { border-bottom: none; }
.brief-row span { color: var(--muted); }
.brief-row b { font-weight: 600; color: var(--parch); }

.menu-foot { margin-top: 22px; font-size: 10px; letter-spacing: 0.1em; color: #4a3f31; }

/* ---------------- 地图 ---------------- */
.map-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 20px 12px;
  flex: 0 0 auto;
}
.map-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column-reverse;
  justify-content: center;
  padding: 0 18px 30px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 60%, rgba(74, 104, 48, 0.16) 0%, transparent 62%);
}
.map-layer { display: flex; flex-direction: column; gap: 7px; }
.layer-cap {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; letter-spacing: 0.16em; color: var(--dim);
}
.layer-cap i {
  font-style: normal; font-size: 9px;
  color: var(--gold);
  border: 1px solid rgba(232, 180, 74, 0.4);
  border-radius: 3px; padding: 0 4px;
}
.map-row { display: flex; gap: 9px; }

.map-node {
  flex: 1 1 0;
  min-width: 0;
  border: 2px solid var(--edge);
  border-radius: 6px;
  background: rgba(42, 32, 25, 0.9);
  padding: 10px 11px 11px;
  color: var(--parch);
  font-family: var(--sans);
  text-align: left;
  cursor: default;
  transition: all 0.16s ease;
}
.map-node .mn-kind { font-size: 9px; letter-spacing: 0.16em; color: var(--dim); display: block; margin-bottom: 4px; }
.map-node .mn-name { font-size: 15px; font-weight: 600; display: block; }
.map-node .mn-hp { font-size: 10px; color: var(--muted); margin-top: 5px; display: block; font-family: var(--mono); }

.map-node.is-start { flex: 0 0 100%; opacity: 0.5; padding: 8px 11px; }
.map-node.is-start .mn-name { font-size: 12px; }

.map-node.is-live { cursor: pointer; border-color: var(--edge-2); background: rgba(58, 44, 30, 0.95); }
.map-node.is-live:hover { border-color: var(--gold); transform: translateY(-2px); }
.map-node.is-live.k-battle { border-color: #6a86ab; }
.map-node.is-live.k-elite { border-color: #ab6a6a; }
.map-node.is-live.k-rest { border-color: #6a9a86; }

.map-node.is-past { opacity: 0.40; }
.map-node.is-chosen { opacity: 0.5; border-color: var(--gold); }
.map-node.is-locked { opacity: 0.34; }

.map-node.boss-node {
  flex: 0 0 100%;
  border-color: #8a5a3a;
  background: linear-gradient(180deg, #4a2a20 0%, #2a1f18 100%);
  padding: 13px;
}
.map-node.boss-node .mn-name { font-size: 17px; color: #f0c479; letter-spacing: 0.08em; }
.map-node.boss-node.is-live { border-color: var(--gold); }

.map-spacer { height: 22px; display: flex; align-items: center; justify-content: center; }
.map-spacer::before {
  content: ""; width: 2px; height: 100%;
  background: linear-gradient(180deg, transparent, var(--edge), transparent);
}

/* ---------------- 战斗：上半屏 ---------------- */
#screen-battle { background: #0d0b09; }

.arena {
  position: relative;
  width: 100%;
  aspect-ratio: 720 / 700;
  flex: 0 0 auto;
  overflow: hidden;
  border-bottom: 3px solid #1a1208;
}
#cv { display: block; width: 100%; height: 100%; }

/* ---------------- 战斗：下半屏 ---------------- */
.panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 10px 16px 12px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.10) 0 2px, transparent 2px 46px),
    linear-gradient(180deg, #2e2318 0%, #201811 100%);
  border-top: 2px solid #4a3a24;
  box-shadow: inset 0 2px 0 rgba(255, 220, 160, 0.06);
}

.p-top { display: flex; align-items: center; gap: 10px; }

.node-chip {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 2px;
}

.draw-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 104px;
  padding: 7px 14px;
  border: 2px solid #8a6a3c;
  border-radius: 6px;
  background: linear-gradient(180deg, #7a5a2e 0%, #4e361a 100%);
  box-shadow: inset 0 2px 0 rgba(255, 226, 170, 0.25), 0 3px 0 #241809;
  color: #ffe9bb;
  font-family: var(--sans);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.draw-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 2px 0 rgba(255, 226, 170, 0.2), 0 1px 0 #241809; }
.draw-btn:disabled { filter: grayscale(0.65) brightness(0.62); cursor: default; }
.db-title { font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-indent: 0.16em; }
.db-cost { display: flex; align-items: center; gap: 3px; font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--gold); }
.db-cost img { width: 13px; height: 13px; }
.db-cost i { font-style: normal; }

/* 流水线 */
.pipe {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px;
  padding: 6px 10px;
  border: 1px solid rgba(92, 69, 44, 0.6);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.pipe .pp { display: flex; align-items: center; gap: 4px; }
.pipe .pp b { font-family: var(--mono); font-size: 11px; color: var(--parch); font-weight: 700; }
.pipe .pp.ready b { color: var(--gold); }
.pipe .arrow { color: var(--dim); font-size: 9px; }
.pipe .pl-label { margin-right: 2px; color: var(--dim); }

/* 手牌 */
.hand { display: flex; gap: 8px; }
.hand-slot {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  aspect-ratio: 5 / 7.4;
  border-radius: 7px;
  position: relative;
}
.hand-slot.empty {
  border: 2px dashed rgba(92, 69, 44, 0.55);
  background: rgba(0, 0, 0, 0.16);
}
.hand-slot.empty::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 220, 150, 0.05), transparent 62%);
}

.hcard {
  width: 100%; height: 100%;
  border: 2px solid #6d5735;
  border-radius: 7px;
  background: linear-gradient(180deg, #3d2d1d 0%, #241a12 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  font-family: var(--sans);
  box-shadow: inset 0 2px 0 rgba(255, 225, 170, 0.12), 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.hcard.is-new { animation: cardIn 0.3s cubic-bezier(0.2, 0.8, 0.3, 1) backwards; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.92); }
  to { opacity: 1; transform: none; }
}
.hcard:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5); }
.hcard:active { transform: translateY(-1px) scale(0.98); }
.hcard.r-rare { border-color: #c08a3a; background: linear-gradient(180deg, #4a3620 0%, #2a1d12 100%); }

.hcard-art {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 4px 4px 0;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 214, 140, 0.10) 0%, transparent 64%);
}
.hcard-art img {
  max-width: 88%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5));
}
.hcard-name {
  flex: 0 0 auto;
  padding: 3px 2px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #f0e2c6;
  text-align: center;
  background: rgba(0, 0, 0, 0.28);
  border-top: 1px solid rgba(255, 220, 150, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hcard.r-rare .hcard-name { color: #ffd98a; }

.hcard-desc {
  display: none;
  position: absolute;
  left: 0; right: 0; bottom: 100%;
  margin-bottom: 6px;
  padding: 7px 9px;
  border: 2px solid var(--edge-2);
  border-radius: 6px;
  background: rgba(18, 14, 10, 0.97);
  color: var(--parch);
  font-size: 10px;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  z-index: 5;
  pointer-events: none;
}
.hcard:hover .hcard-desc { display: block; }

/* 底部状态 */
.p-bottom { display: flex; align-items: center; gap: 8px; }
.pstat {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 4px;
  border: 1px solid rgba(92, 69, 44, 0.5);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.2);
}
.pstat b { font-family: var(--mono); font-size: 13px; color: var(--parch); font-weight: 700; }
.pstat b.is-ramped { color: #7fd6a0; }
.pstat span { font-size: 9px; letter-spacing: 0.1em; color: var(--dim); }

.speed-btn {
  flex: 0 0 auto;
  width: 48px; height: 40px;
  border: 2px solid var(--edge);
  border-radius: 5px;
  background: #1e1710;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.speed-btn.is-fast { color: var(--gold); border-color: var(--gold); }

/* ---------------- 结算 ---------------- */
#screen-settle { padding: 44px 30px; justify-content: center; align-items: center; }
.settle-inner { width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; }
.settle-castle { width: 120px; margin-bottom: 16px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6)); }
.settle-title {
  font-size: 26px; font-weight: 700;
  letter-spacing: 0.14em; text-indent: 0.14em;
  color: #f5e8c8;
  text-shadow: 0 3px 0 #6b4a1e;
}
.settle-sub { font-size: 12px; color: var(--muted); margin-top: 9px; }

.settle-stats {
  width: 100%;
  margin: 26px 0 0;
  border-top: 2px solid var(--edge);
  border-bottom: 2px solid var(--edge);
}
.ss-row {
  display: flex; justify-content: space-between;
  padding: 11px 2px;
  font-size: 12px;
  border-bottom: 1px solid rgba(92, 69, 44, 0.45);
}
.ss-row:last-child { border-bottom: none; }
.ss-row span { color: var(--muted); }
.ss-row b { font-family: var(--mono); font-weight: 700; max-width: 60%; text-align: right; line-height: 1.5; }

/* ---------------- 弹层 ---------------- */
.overlay {
  position: absolute; inset: 0;
  background: rgba(5, 4, 3, 0.82);
  display: grid; place-items: center;
  padding: 28px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 20;
}
.overlay.is-on { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%;
  border: 3px solid var(--edge-2);
  border-radius: 8px;
  background: linear-gradient(180deg, #362820 0%, #1e1710 100%);
  padding: 26px 22px 18px;
  text-align: center;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: inset 0 2px 0 rgba(255, 220, 160, 0.1), 0 18px 40px rgba(0, 0, 0, 0.6);
}
.sheet-icon { width: 56px; margin: 0 auto 6px; }
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: 0.1em; }
.sheet-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* ---------------- Toast ---------------- */
.toast {
  position: absolute;
  left: 50%; top: 57%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 9px 18px;
  border: 2px solid #8a6a3c;
  border-radius: 6px;
  background: rgba(30, 23, 16, 0.94);
  color: #ffe9bb;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
  white-space: nowrap;
}
.toast.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
