:root {
  --camo-1: #1b2419;
  --camo-2: #2c3a27;
  --camo-3: #3f5233;
  --khaki: #c9b273;
  --khaki-dim: #9c8a58;
  --red: #b23b2f;
  --red-bright: #d94a38;
  --ink: #f2efe4;
  --ink-dim: #b9b3a0;
  --blue: #6fa8c9;
  --shadow: 0 10px 30px rgba(0, 0, 0, .55);
  --font: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0d1109;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  background:
    radial-gradient(circle at 20% 10%, rgba(63, 82, 51, .35), transparent 55%),
    radial-gradient(circle at 85% 90%, rgba(178, 59, 47, .18), transparent 50%),
    #0d1109;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  background: #12180f;
  image-rendering: auto;
  touch-action: none;
  cursor: crosshair;
}

.hidden { display: none !important; }

/* ============ HUD ============ */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .8);
}

.hud-left { display: flex; flex-direction: column; gap: 6px; max-width: 320px; }
.hud-center { text-align: center; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.hp-bar {
  position: relative;
  height: 20px;
  border: 2px solid rgba(0, 0, 0, .6);
  border-radius: 4px;
  background: rgba(20, 16, 14, .8);
  overflow: hidden;
}
.hp-fill {
  position: absolute; inset: 0 100% 0 0;
  background: linear-gradient(180deg, #e2564a, #a32b20);
  transition: right .18s ease-out;
}
.hp-chip {
  position: absolute; inset: 0 100% 0 0;
  background: rgba(242, 239, 228, .5);
  transition: right .5s ease-out .18s;
}
.hp-text {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-top: 2px; color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.hp-text .armor { color: var(--blue); }

.xp-bar {
  height: 8px; border-radius: 4px;
  background: rgba(20, 16, 14, .8);
  border: 1px solid rgba(0, 0, 0, .5);
  overflow: hidden;
}
.xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--khaki-dim), var(--khaki));
  transition: width .2s ease-out;
}
.xp-text { font-size: 11px; color: var(--ink-dim); margin-top: 2px; }

.floor { font-size: 15px; font-weight: 700; color: var(--khaki); letter-spacing: 1px; }
.weapon { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }

.boons { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 320px; }
.boon-pip {
  width: 26px; height: 26px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; background: rgba(20, 16, 14, .78);
  border: 1px solid var(--khaki-dim);
}
.boon-pip .lvl {
  position: absolute; transform: translate(10px, 10px);
  font-size: 9px; color: var(--khaki); font-weight: 700;
}

.hud-btns { display: flex; gap: 6px; pointer-events: auto; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  background: rgba(20, 16, 14, .78);
  border: 1px solid rgba(201, 178, 115, .5);
  color: var(--ink); font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: rgba(63, 82, 51, .9); }

/* ============ Toast ============ */
.toast-area {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; z-index: 25; width: min(90vw, 560px);
}
.toast {
  background: rgba(14, 18, 11, .9);
  border-left: 4px solid var(--khaki);
  border-radius: 4px;
  padding: 7px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toastIn .25s ease-out;
  max-width: 100%;
}
.toast.good { border-left-color: #7fbf6a; }
.toast.bad { border-left-color: var(--red-bright); }
.toast.gold { border-left-color: var(--khaki); color: var(--khaki); }
.toast.fade { opacity: 0; transition: opacity .4s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ Overlay ============ */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(20, 28, 16, .86), rgba(6, 8, 5, .96));
  backdrop-filter: blur(3px);
  overflow: auto;
}

.overlay-card {
  width: min(760px, 96vw);
  background: linear-gradient(180deg, rgba(37, 48, 31, .96), rgba(20, 26, 16, .98));
  border: 1px solid rgba(201, 178, 115, .35);
  border-radius: 12px;
  padding: 24px 26px;
  box-shadow: var(--shadow);
  animation: cardIn .28s ease-out;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.overlay-card h2 { margin: 0 0 10px; font-size: 24px; color: var(--khaki); }
.overlay-card h3 { margin: 0 0 8px; font-size: 15px; color: var(--khaki); }

.title-badge {
  display: inline-block; font-size: 12px; letter-spacing: 3px;
  color: var(--khaki); border: 1px solid var(--khaki-dim);
  border-radius: 999px; padding: 3px 14px; margin-bottom: 8px;
}

.game-title {
  margin: 6px 0 4px;
  font-size: clamp(34px, 7vw, 58px);
  letter-spacing: 6px;
  color: #e8dfc2;
  text-shadow: 0 0 24px rgba(201, 178, 115, .35), 0 4px 0 rgba(0, 0, 0, .5);
}
.subtitle { color: var(--ink-dim); font-size: 14px; margin: 0 0 16px; line-height: 1.7; }

.menu-card { text-align: center; }
.menu-stats {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  margin: 4px 0 18px; font-size: 13px; color: var(--ink-dim);
}
.menu-stats span b { color: var(--khaki); }

.menu-buttons { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.menu-buttons.row { flex-direction: row; flex-wrap: wrap; }

.btn {
  cursor: pointer;
  font-family: var(--font);
  font-size: 15px;
  padding: 11px 20px;
  border-radius: 8px;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(63, 82, 51, .95), rgba(34, 45, 28, .95));
  border: 1px solid rgba(201, 178, 115, .45);
  transition: transform .1s ease, filter .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(1.15); box-shadow: 0 0 0 1px rgba(201, 178, 115, .4) inset; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #c9b273, #9c8a58);
  color: #232011; font-weight: 700; font-size: 16px;
  border-color: #e2d3a2;
}
.btn.danger { background: linear-gradient(180deg, #a13a2e, #6d251c); border-color: #d0705f; }
.menu-foot { margin-top: 16px; font-size: 12px; color: #8b866f; }

.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 18px; }
.help-grid ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.9; color: var(--ink-dim); }
.help-grid b { color: var(--khaki); }
@media (max-width: 640px) { .help-grid { grid-template-columns: 1fr; } }

.heat-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.heat-item {
  display: grid; grid-template-columns: 30px 1fr auto;
  gap: 10px; align-items: center; text-align: left;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  background: rgba(12, 16, 10, .6);
  border: 1px solid rgba(201, 178, 115, .18);
}
.heat-item:hover { border-color: rgba(201, 178, 115, .5); }
.heat-item.on { background: rgba(178, 59, 47, .22); border-color: var(--red-bright); }
.heat-item .hbox {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--khaki-dim);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--khaki);
}
.heat-item .hname { font-size: 14px; color: var(--ink); }
.heat-item .hdesc { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.heat-item .hval { font-size: 12px; color: var(--khaki); }
.heat-foot { font-size: 13px; color: var(--ink-dim); text-align: center; margin-bottom: 14px; }
.heat-foot b { color: var(--khaki); }

.result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin: 14px 0 20px;
}
.result-cell {
  background: rgba(12, 16, 10, .6);
  border: 1px solid rgba(201, 178, 115, .2);
  border-radius: 8px; padding: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.result-cell .k { font-size: 12px; color: var(--ink-dim); }
.result-cell .v { font-size: 19px; color: var(--khaki); font-variant-numeric: tabular-nums; }

.pause-tip { margin-top: 14px; font-size: 12.5px; color: var(--ink-dim); line-height: 1.8; }

/* ============ 触屏操作 ============ */
.touch-controls {
  position: absolute; inset: auto 0 0 0; height: 40vh;
  pointer-events: none; z-index: 30;
}
.stick {
  position: absolute; left: 26px; bottom: 26px;
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(20, 16, 14, .45);
  border: 2px solid rgba(201, 178, 115, .35);
  pointer-events: auto; touch-action: none;
}
.stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(201, 178, 115, .55);
}
.touch-buttons {
  position: absolute; right: 22px; bottom: 26px;
  display: flex; align-items: flex-end; gap: 12px; pointer-events: auto;
}
.tbtn {
  width: 76px; height: 76px; border-radius: 50%;
  font-size: 14px; color: var(--ink); font-family: var(--font);
  background: rgba(20, 16, 14, .6);
  border: 2px solid rgba(201, 178, 115, .4);
  touch-action: none;
}
.tbtn:active { background: rgba(201, 178, 115, .5); }
.tbtn.skill { width: 62px; height: 62px; border-color: rgba(111, 168, 201, .6); }
.tbtn.dash { width: 62px; height: 62px; border-color: rgba(178, 59, 47, .7); }

.rotate-hint {
  position: absolute; inset: auto 0 50% 0; text-align: center;
  font-size: 13px; color: var(--khaki); z-index: 35; pointer-events: none;
}

@media (max-width: 720px) {
  #hud { padding: 6px 8px; grid-template-columns: 1fr auto; }
  .hud-center { display: none; }
  .boons { max-width: 180px; }
  .overlay-card { padding: 18px; }
}
