:root {
  color-scheme: dark;
  --plant: #56c45a;
  --plant-2: #f5d84c;
  --zombie: #8d91a3;
  --zombie-2: #b172d8;
  --ink: #1d2430;
  --paper: rgba(255, 255, 255, 0.9);
  --panel: rgba(28, 35, 45, 0.86);
  --line: rgba(255, 255, 255, 0.22);
  --shadow: rgba(0, 0, 0, 0.34);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #74c8ee;
  color: #fff;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: #152131;
  background: #ffdf57;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

#hitFlash,
#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
  z-index: 3;
}

#hitFlash {
  background: radial-gradient(circle, rgba(255, 255, 255, 0) 42%, rgba(255, 90, 70, 0.42));
}

#vignette {
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 48%, rgba(20, 16, 31, 0.5));
  transition: opacity 260ms ease;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}

#crosshair span {
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

#crosshair span:nth-child(1),
#crosshair span:nth-child(2) {
  left: 15px;
  width: 2px;
  height: 9px;
}

#crosshair span:nth-child(1) {
  top: 1px;
}

#crosshair span:nth-child(2) {
  bottom: 1px;
}

#crosshair span:nth-child(3),
#crosshair span:nth-child(4) {
  top: 15px;
  height: 2px;
  width: 9px;
}

#crosshair span:nth-child(3) {
  left: 1px;
}

#crosshair span:nth-child(4) {
  right: 1px;
}

#worldBars {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  font-size: 0.72rem;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.78);
}

.world-bar {
  position: absolute;
  width: 118px;
  transform: translate(-50%, -100%);
  opacity: 0.96;
}

.world-bar .name {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
  color: #fff;
  white-space: nowrap;
}

.world-bar .name em {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.72);
  font-style: normal;
  font-size: 0.64rem;
}

.world-bar .bar-track {
  height: 7px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  background: rgba(8, 10, 12, 0.72);
}

.world-bar .hp,
.world-bar .armor-mini {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.world-bar .armor-track {
  height: 4px;
  margin-top: 2px;
}

.world-bar.enemy .hp {
  background: linear-gradient(90deg, #ff5548, #ffb347);
}

.world-bar.ally .hp {
  background: linear-gradient(90deg, #52df6d, #d9ff6d);
}

.world-bar.object .hp {
  background: linear-gradient(90deg, #ffd04e, #fff3a3);
}

.world-bar .armor-mini {
  background: linear-gradient(90deg, #5aa5ff, #92edff);
}

.world-bar.downed .hp {
  background: linear-gradient(90deg, #89909c, #d6d9df);
}

.hidden {
  display: none !important;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

.topbar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 24px));
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.team-score,
.mode-pill,
.objective,
.resource,
.left-status,
.skill,
.capture,
.boss,
  #minimap,
  .combat-feed,
  .faction-ops,
  .center-notice {
  border: 1px solid var(--line);
  background: rgba(26, 31, 42, 0.7);
  backdrop-filter: blur(8px);
}

.team-score {
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 800;
}

.team-score strong {
  font-size: 1.25rem;
}

.plants {
  border-color: rgba(116, 230, 100, 0.55);
}

.zombies {
  border-color: rgba(200, 142, 255, 0.55);
  text-align: right;
}

.mode-pill {
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  color: #ffef8b;
  font-weight: 800;
}

.objective {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
}

.left-status {
  position: absolute;
  left: 18px;
  bottom: 20px;
  width: 235px;
  padding: 12px;
  border-radius: 8px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 800;
  color: #f7f7f7;
}

.bar {
  position: relative;
  height: 14px;
  margin: 5px 0 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
}

.bar i {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  transition: width 120ms linear;
}

.health i {
  background: linear-gradient(90deg, #f64f59, #ffca4e);
}

.armor i {
  background: linear-gradient(90deg, #5aa5ff, #92edff);
}

.status-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 22px;
}

.status-tags span {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.76rem;
  font-weight: 800;
}

.faction-ops {
  position: absolute;
  left: 18px;
  bottom: 154px;
  width: 250px;
  padding: 11px;
  border-radius: 8px;
}

.ops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.ops-head span {
  padding: 3px 7px;
  border-radius: 999px;
  color: #182435;
  background: #ffdf57;
  text-shadow: none;
  font-size: 0.72rem;
  font-weight: 900;
}

.ops-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ops-grid div {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.ops-grid b,
.ops-grid span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-grid b {
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.68rem;
}

.ops-grid span {
  margin-top: 2px;
  color: #fff;
  font-size: 0.78rem;
}

body.team-plants .faction-ops {
  border-color: rgba(116, 230, 100, 0.62);
}

body.team-plants .ops-head span,
body.team-plants .skill i {
  background: #ffdf57;
}

body.team-plants .resource {
  border-color: rgba(255, 223, 87, 0.68);
}

body.team-zombies .faction-ops {
  border-color: rgba(190, 139, 255, 0.65);
}

body.team-zombies .ops-head span,
body.team-zombies .skill i {
  color: #fff;
  background: #bd85ff;
}

body.team-zombies .resource {
  border-color: rgba(189, 133, 255, 0.68);
}

.skill-strip {
  position: absolute;
  left: 50%;
  bottom: 18px;
  display: grid;
  grid-template-columns: 112px 112px 132px;
  gap: 8px;
  transform: translateX(-50%);
}

.skill {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 58px;
  padding: 8px 9px;
  overflow: hidden;
  color: #fff;
  background: rgba(31, 43, 54, 0.78);
  box-shadow: none;
}

.skill b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
}

.skill span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 0.82rem;
}

.skill i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 4px;
  background: #ffdf57;
}

.skill.ready {
  border-color: rgba(255, 223, 87, 0.85);
}

.skill.cooling {
  filter: saturate(0.65);
}

.compact {
  grid-template-columns: 28px 1fr;
}

.right-status {
  position: absolute;
  right: 18px;
  bottom: 20px;
  width: 250px;
}

.resource {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 900;
  text-align: right;
}

.placeable-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 8px;
}

.placeable {
  min-height: 58px;
  padding: 7px;
  color: #fff;
  background: rgba(29, 36, 48, 0.72);
  border: 1px solid var(--line);
  box-shadow: none;
  border-radius: 8px;
  text-align: left;
}

.placeable strong,
.placeable span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.placeable span {
  font-size: 0.72rem;
  opacity: 0.86;
}

.placeable.selected {
  border-color: #ffdf57;
  background: rgba(255, 223, 87, 0.24);
}

#minimap {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 180px;
  height: 180px;
  border-radius: 8px;
}

.capture,
.boss {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 40px));
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 800;
}

.capture {
  top: 98px;
}

.boss {
  top: 150px;
  border-color: rgba(255, 105, 84, 0.65);
}

.capture div,
.boss div {
  height: 10px;
  margin-top: 5px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 999px;
}

.capture i,
.boss i {
  display: block;
  height: 100%;
  width: 0;
  background: #ffdf57;
}

.boss i {
  background: #ff6b58;
}

.center-notice {
  position: absolute;
  top: 42%;
  left: 50%;
  min-width: min(460px, calc(100vw - 40px));
  padding: 13px 18px;
  border-radius: 8px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.98);
  text-align: center;
  font-size: 1.08rem;
  font-weight: 900;
  transition: opacity 160ms ease, transform 160ms ease;
}

.center-notice.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.combat-feed {
  position: absolute;
  right: 18px;
  top: 214px;
  width: 260px;
  min-height: 42px;
  max-height: 190px;
  padding: 8px 10px;
  overflow: hidden;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.combat-feed p {
  margin: 0 0 5px;
}

#panels {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  pointer-events: none;
}

.panel {
  display: none;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 50px var(--shadow);
  backdrop-filter: blur(14px);
}

.panel.active {
  display: block;
}

.panel.wide {
  width: min(980px, calc(100vw - 32px));
}

.brand h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.brand p {
  margin: 9px 0 0;
  color: #ffef8b;
  font-size: 1.15rem;
  font-weight: 900;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.local-note {
  margin: 16px 0 0;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.6;
}

.panel-note {
  margin: -4px 0 16px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.55;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.5rem;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.backBtn,
#switchFactionBtn,
#resumeBtn {
  min-width: 88px;
  padding: 0 13px;
  background: #e8f3ff;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.faction-card {
  display: grid;
  gap: 12px;
  min-height: 180px;
  padding: 18px;
  color: #fff;
  text-align: left;
  border: 1px solid var(--line);
  box-shadow: none;
}

.faction-card strong {
  font-size: 1.6rem;
}

.faction-card span {
  line-height: 1.5;
}

.plant-card {
  background: linear-gradient(145deg, rgba(69, 178, 85, 0.9), rgba(255, 213, 73, 0.8));
}

.zombie-card {
  background: linear-gradient(145deg, rgba(92, 96, 112, 0.95), rgba(147, 91, 184, 0.88));
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.character-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 7px;
  min-height: 188px;
  padding: 13px;
  color: #fff;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  box-shadow: none;
}

.character-card strong {
  font-size: 1.12rem;
}

.character-card em {
  font-style: normal;
  color: #ffef8b;
  font-size: 0.84rem;
}

.character-card span {
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.86rem;
}

.character-card small {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.compact-grid .character-card {
  min-height: 150px;
}

.map-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.area-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.area-item strong,
.area-item span {
  display: block;
}

.area-item span {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.85rem;
}

.area-item button {
  min-height: 38px;
  box-shadow: none;
}

.area-item.current {
  border-color: rgba(255, 223, 87, 0.82);
  background: rgba(255, 223, 87, 0.14);
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  font-weight: 800;
}

.setting-row:first-of-type {
  border-top: 0;
}

input[type="range"] {
  width: 210px;
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
}

.result-stats {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  line-height: 1.55;
}

@media (max-width: 760px) {
  .topbar {
    top: 8px;
  }

  #minimap,
  .combat-feed {
    display: none;
  }

  .left-status {
    left: 10px;
    bottom: 92px;
    width: 176px;
  }

  .faction-ops {
    top: 112px;
    right: 10px;
    bottom: auto;
    left: 10px;
    width: auto;
    padding: 8px;
  }

  .ops-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .ops-grid div {
    padding: 5px;
  }

  .ops-grid b {
    font-size: 0.62rem;
  }

  .ops-grid span {
    font-size: 0.68rem;
  }

  .right-status {
    right: 10px;
    bottom: 92px;
    width: 180px;
  }

  .skill-strip {
    bottom: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: calc(100vw - 20px);
  }

  .skill {
    min-height: 50px;
    padding: 6px;
  }

  .skill span {
    font-size: 0.73rem;
  }

  .capture {
    top: 218px;
  }

  .boss {
    top: 270px;
  }

  .menu-grid,
  .choice-row {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .brand h1 {
    font-size: 2.1rem;
  }
}
