/* 荒野幸存者 —— 暗底暖光，纸牌桌游质感 */
:root {
  --ink: #efe6d2;
  --dim: #a89878;
  --gold: #ffd35c;
  --panel: #1c1814;
  --panel2: #241f19;
  --line: #4a3f30;
  --red: #e05545;
  --green: #6fd88a;
  --blue: #7ab8e0;
  --purple: #b48ae0;
}

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

html, body {
  height: 100%; overflow: hidden;
  background: #0b0908;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app { position: relative; width: 100%; height: 100%; }

#game {
  display: block; width: 100%; height: 100%;
  touch-action: none; cursor: crosshair;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute; inset: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 14px;
  pointer-events: none;
  font-size: 13px;
}
#hud button { pointer-events: auto; }

.hud-left { min-width: 190px; }
.hp-wrap { position: relative; }
.hp-bar {
  height: 15px; border-radius: 8px;
  background: rgba(0,0,0,.65);
  border: 1px solid var(--line);
  overflow: hidden;
}
.hp-bar i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #3f9a5c, #6fd88a);
  transition: width .12s linear;
}
.hp-txt {
  position: absolute; right: 7px; top: 0; line-height: 15px;
  font-size: 10.5px; font-weight: 700; color: #e8ffe8;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
  font-variant-numeric: tabular-nums;
}
.xp-bar {
  height: 5px; margin-top: 4px; border-radius: 3px;
  background: rgba(0,0,0,.6); overflow: hidden;
  border: 1px solid rgba(74,63,48,.7);
}
.xp-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #7a5ac0, #b48ae0);
  transition: width .12s linear;
}
.hud-line { margin-top: 5px; color: var(--dim); font-size: 12px; }
.hud-line .lv {
  display: inline-block; min-width: 18px; text-align: center;
  background: var(--purple); color: #1a1020; font-weight: 800;
  border-radius: 4px; padding: 0 4px; font-size: 11px;
}
.hud-line .sep { opacity: .4; margin: 0 3px; }

.hud-mid { text-align: center; flex: 1; padding-top: 2px; }
.hud-mid .wave {
  font-size: 19px; font-weight: 800; letter-spacing: 2px;
  color: var(--gold); text-shadow: 0 2px 10px rgba(255,211,92,.3);
}
.wave-sub { color: var(--dim); font-size: 11.5px; margin-top: 1px; font-variant-numeric: tabular-nums; }

.hud-right { text-align: right; }
.hud-right .kill { color: var(--dim); font-size: 12px; margin-bottom: 7px; }
.hud-right .kill span { color: var(--ink); font-weight: 700; }
.btn-row { display: flex; gap: 6px; justify-content: flex-end; }
#hud button {
  width: 30px; height: 30px; padding: 0;
  border-radius: 7px; border: 1px solid var(--line);
  background: rgba(28,24,20,.85); color: var(--ink);
  font-size: 13px; cursor: pointer; line-height: 1;
}
#hud button:hover { border-color: var(--gold); }

/* ---------- 提示 ---------- */
#toast {
  position: absolute; left: 50%; bottom: 68px; transform: translate(-50%, 14px);
  background: rgba(18,15,12,.94);
  border: 1px solid var(--line); border-left: 3px solid var(--gold);
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-left-color: var(--red); color: #ffb3a8; }

/* ---------- 遮罩与面板 ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,5,4,.82);
  backdrop-filter: blur(6px);
  padding: 16px;
  overflow-y: auto;
}
.overlay.hidden, .hidden { display: none !important; }

.panel {
  background: linear-gradient(170deg, var(--panel2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 26px 70px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06);
  padding: 22px;
  width: min(96vw, 780px);
  max-height: 92vh;
  overflow-y: auto;
}
.panel h1 {
  font-size: 30px; letter-spacing: 6px; font-weight: 900;
  background: linear-gradient(180deg, #fff6d8, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-align: center;
}
.panel h2 { font-size: 20px; letter-spacing: 1px; }
.panel h3.sect { font-size: 12px; color: var(--dim); font-weight: 500; margin: 18px 0 8px; letter-spacing: 2px; }
.panel .sub { color: var(--dim); font-size: 12.5px; margin-top: 6px; }
.panel .hint { color: #7d6c4e; font-size: 11.5px; margin-top: 12px; text-align: center; line-height: 1.7; }

button {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: #322a20; border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 16px; cursor: pointer;
  transition: border-color .12s, filter .12s, transform .06s;
}
button:hover:not(:disabled) { border-color: var(--gold); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary {
  width: 100%; margin-top: 16px; padding: 13px;
  background: linear-gradient(180deg, #b8432f, #8a2f22);
  border-color: #c96a52; font-size: 16px; font-weight: 700; letter-spacing: 4px;
}
button.primary:hover { filter: brightness(1.15); }

.menu-panel { text-align: center; }
.menu-panel .best { color: var(--gold); font-size: 12.5px; margin-top: 10px; }

/* ---------- 角色选择 ---------- */
.char-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.char {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 6px; background: #221d17; border-radius: 10px;
  border: 1px solid var(--line);
}
.char.sel { border-color: var(--gold); background: #2e2719; box-shadow: 0 0 0 1px var(--gold) inset; }
.ch-icon { font-size: 24px; line-height: 1.1; }
.ch-name { font-size: 13px; font-weight: 700; }
.ch-hp { font-size: 10.5px; color: var(--dim); }
.ch-desc { font-size: 10px; color: #8d7d60; line-height: 1.45; text-align: center; }

/* ---------- 商店 ---------- */
.shop-panel { width: min(96vw, 860px); }
.shop-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.money { font-size: 19px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.card-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.card {
  display: flex; flex-direction: column; gap: 5px;
  padding: 12px 10px; min-height: 168px;
  background: linear-gradient(170deg, #2a2419, #201b15);
  border: 1px solid var(--line); border-radius: 11px;
  text-align: left; position: relative;
  transition: transform .1s, border-color .12s;
}
.card:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--gold); }
.card .c-icon { font-size: 26px; line-height: 1; }
.card .c-name { font-size: 13.5px; font-weight: 700; }
.card .c-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.card .c-tags span {
  font-size: 9.5px; padding: 1px 5px; border-radius: 4px;
  background: rgba(255,255,255,.07); color: var(--dim);
}
.card .c-desc { font-size: 10.5px; color: #a08f70; line-height: 1.55; flex: 1; }
.card .c-cost {
  font-size: 12px; font-weight: 700; color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.card.t1 { border-left: 3px solid #8d8d8d; }
.card.t2 { border-left: 3px solid #7ab8e0; }
.card.t3 { border-left: 3px solid #d8a04a; }
.card.special { border-left-color: var(--purple); background: linear-gradient(170deg, #2a2138, #1e1a26); }
.card.poor .c-cost { color: var(--red); }
.card.sold { opacity: .35; }

.shop-actions { display: flex; gap: 8px; margin-top: 14px; }
.shop-actions button { flex: 0 0 auto; }
.shop-actions button.primary { flex: 1; margin-top: 0; }

/* ---------- 装备栏 ---------- */
.loadout { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lo-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 9px; }
.lo-row label { flex: 0 0 34px; font-size: 11px; color: var(--dim); padding-top: 5px; }
.slots { display: flex; gap: 6px; flex-wrap: wrap; }
.slot {
  display: inline-flex; align-items: center; gap: 4px;
  background: #221d17; border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 7px; font-size: 11px;
}
.slot b { font-size: 14px; }
.slot em { font-style: normal; color: var(--ink); }
.slot.empty { color: #5a4d38; border-style: dashed; font-size: 10.5px; padding: 5px 10px; }
.slot .del {
  font-style: normal; color: #6d5c42; cursor: pointer;
  margin-left: 2px; font-size: 11px; padding: 0 2px;
}
.slot .del:hover { color: var(--red); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  font-size: 10.5px; padding: 3px 7px; border-radius: 6px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  color: #c4b494;
}
.chip.perk { border-color: rgba(180,138,224,.35); color: #d2b8f0; background: rgba(180,138,224,.1); }
.chip.muted { color: #5a4d38; border-color: transparent; background: none; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 10.5px; color: var(--dim); }
.stat-row b { color: var(--ink); font-size: 12px; margin-right: 2px; }

/* ---------- 升级 ---------- */
.perk-panel { width: min(96vw, 640px); text-align: center; }
.perk-panel .card-row { grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
.perk-panel .card { min-height: 158px; }

/* ---------- 结算 ---------- */
.dead-panel { width: min(96vw, 560px); text-align: center; }
.dead-title {
  font-size: 26px; letter-spacing: 4px;
  background: linear-gradient(180deg, #ffb3a8, #d84a3a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.dead-panel .best { color: var(--gold); font-size: 12.5px; margin-top: 6px; }
.dead-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin: 18px 0 14px;
}
.dead-grid div {
  background: rgba(255,255,255,.04); border-radius: 9px; padding: 10px 4px;
  display: flex; flex-direction: column; gap: 3px;
}
.dead-grid b { font-size: 18px; color: var(--gold); font-variant-numeric: tabular-nums; }
.dead-grid span { font-size: 10px; color: var(--dim); }
.dead-build { justify-content: center; margin-bottom: 6px; }
.dead-panel button { margin-top: 8px; }
.dead-panel button.primary { margin-top: 14px; }

.panel.tiny { width: min(80vw, 300px); text-align: center; }
.help-panel { width: min(96vw, 560px); }
.help-panel ul { margin: 14px 0 0 18px; }
.help-panel li { font-size: 12.5px; line-height: 1.85; color: #c4b494; margin-bottom: 5px; }
.help-panel li b { color: var(--gold); }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .panel { padding: 16px; border-radius: 13px; }
  .panel h1 { font-size: 23px; letter-spacing: 3px; }
  .char-grid { grid-template-columns: repeat(2, 1fr); }
  .card-row { grid-template-columns: repeat(2, 1fr); }
  .perk-panel .card-row { grid-template-columns: 1fr; }
  .perk-panel .card { min-height: 0; }
  .card { min-height: 0; padding: 10px; }
  .card .c-icon { font-size: 21px; }
  .card .c-desc { font-size: 10px; }
  #hud { padding: 8px 10px; font-size: 12px; }
  .hud-left { min-width: 140px; }
  .hud-mid .wave { font-size: 15px; letter-spacing: 1px; }
  .dead-grid { grid-template-columns: repeat(2, 1fr); }
  .lo-row { flex-direction: column; gap: 5px; }
  .lo-row label { padding-top: 0; }
}
