/* 能源站防线 — 明亮近未来 HUD */
:root {
  --font: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #243038;
  --ink-soft: #4a5960;
  --paper: rgba(247, 242, 232, 0.88);
  --paper-solid: #f7f3ea;
  --line: rgba(40, 50, 55, 0.12);
  --teal: #1f9b8d;
  --teal-deep: #14766c;
  --orange: #e37a1c;
  --orange-deep: #c25f0e;
  --danger: #d1493a;
  --ok: #2a9a5b;
  --shadow: 0 8px 28px rgba(40, 40, 30, 0.16);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #1c262c;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, #3a5a62 0%, #1c262c 55%);
}

#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  min-height: 58px;
  background: linear-gradient(180deg, rgba(247,243,234,0.96), rgba(236,230,216,0.92));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  z-index: 5;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 8.5em;
}
.brand h1 {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0.04em;
}
.brand small {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
}

.meters {
  display: flex;
  gap: 10px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 40px;
  min-width: 108px;
}
.meter .label {
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
}
.meter .value {
  font-size: 18px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.meter.supply .value { color: var(--orange-deep); }
.meter.core .value { color: var(--teal-deep); }
.meter.core.hurt .value { color: var(--danger); animation: pulse 0.45s ease; }
.meter.wave .value { color: var(--ink); }

@keyframes pulse {
  0% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

button, .btn {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: var(--ink);
  background: #fff;
  border-radius: 12px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
  box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset, 0 1px 3px rgba(0,0,0,0.12);
  border: 1px solid var(--line);
  transition: transform 0.08s ease, filter 0.12s ease, background 0.12s;
  touch-action: manipulation;
  user-select: none;
}
button:hover, .btn:hover { filter: brightness(1.03); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

button.active, .btn.active {
  background: #fff4e4;
  border-color: rgba(227,122,28,0.45);
  color: var(--orange-deep);
}

.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal-deep); }
.btn-orange { background: var(--orange); color: #fff; border-color: var(--orange-deep); }
.btn-ghost { background: rgba(255,255,255,0.7); }
.btn-danger { background: #fff; color: var(--danger); border-color: rgba(209,73,58,0.35); }

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

.glass {
  background: var(--paper);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.6);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

#panel-wave {
  position: absolute;
  top: 12px;
  left: 12px;
  width: min(290px, calc(100% - 24px));
  padding: 12px 14px 14px;
  pointer-events: none;
  z-index: 3;
}

#panel-inspect {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(300px, calc(100% - 24px));
  padding: 12px 14px 14px;
  z-index: 3;
  max-height: calc(100% - 96px);
  overflow: auto;
}

#wave-actions {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 3;
  flex-wrap: wrap;
  justify-content: center;
  width: max-content;
  max-width: calc(100% - 24px);
}

#wave-actions button {
  min-width: 148px;
  min-height: 48px;
  font-size: 15px;
  box-shadow: var(--shadow);
}

.panel-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 650;
}

.wave-name {
  font-size: 17px;
  font-weight: 750;
  margin-bottom: 4px;
}

.wave-hint {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-bottom: 8px;
}

.path-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 6px 0;
  font-size: 13px;
}
.path-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 4.6em;
  text-align: center;
}
.path-tag.bank { background: #e07a2f; }
.path-tag.maint { background: #2a9b8f; }
.enemy-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.7);
  border-radius: 999px;
  padding: 2px 8px;
  margin: 0 4px 4px 0;
  font-weight: 650;
  font-size: 12px;
}

.inspect-empty {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.inspect-title {
  font-size: 16px;
  font-weight: 750;
  margin-bottom: 4px;
}
.inspect-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin-bottom: 10px;
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.card-row.single { grid-template-columns: 1fr; }

.choice-card {
  text-align: left;
  padding: 10px 10px 12px;
  min-height: 88px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.choice-card .price {
  color: var(--orange-deep);
  font-weight: 800;
  font-size: 15px;
}
.choice-card .name { font-size: 14px; font-weight: 750; }
.choice-card .desc { font-size: 11px; color: var(--ink-soft); line-height: 1.4; font-weight: 500; }

.hint-keys {
  margin-top: 10px;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

#overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 28, 32, 0.42);
  z-index: 8;
  padding: 24px;
}
#overlay.show { display: flex; }

.modal {
  width: min(460px, 100%);
  background: var(--paper-solid);
  border-radius: 20px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
  text-align: center;
}
.modal h2 { font-size: 28px; margin-bottom: 8px; }
.modal .sub { color: var(--ink-soft); font-size: 13px; letter-spacing: 0.16em; margin-bottom: 14px; }
.modal p { font-size: 14px; line-height: 1.65; color: var(--ink); margin-bottom: 10px; }
.modal .stats { font-size: 13px; color: var(--ink-soft); margin: 12px 0 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal.win h2 { color: var(--teal-deep); }
.modal.lose h2 { color: var(--danger); }

#toast-host {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -120%);
  z-index: 4;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.toast {
  background: rgba(40, 16, 12, 0.86);
  color: #ffe8e2;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in 0.85s ease forwards;
}
@keyframes toast-in {
  0% { opacity: 0; transform: translateY(8px); }
  20% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}

.help-line {
  position: absolute;
  left: 12px;
  bottom: 16px;
  font-size: 11px;
  color: #fff;
  background: rgba(20, 24, 28, 0.5);
  padding: 5px 10px;
  border-radius: 999px;
  z-index: 2;
  pointer-events: none;
}

@media (max-width: 860px) {
  .brand h1 { font-size: 15px; }
  #panel-wave, #panel-inspect {
    width: min(250px, calc(50% - 16px));
    padding: 10px;
  }
  .meter { min-width: 90px; padding: 4px 10px; }
  .meter .value { font-size: 16px; }
}
@media (max-width: 640px) {
  #topbar { padding: 6px 8px; gap: 8px; min-height: 50px; }
  .brand { display: none; }
  #panel-wave { top: auto; bottom: 72px; left: 8px; width: calc(50% - 12px); }
  #panel-inspect { top: auto; bottom: 72px; right: 8px; width: calc(50% - 12px); max-height: 36vh; }
  #wave-actions { bottom: 10px; }
  #wave-actions button { min-width: 120px; }
  .help-line { display: none; }
}
