:root {
  --bg: #c5dce8;
  --ink: #1a2a22;
  --muted: #4a6258;
  --long: #1ecf7a;
  --long-deep: #0a8f4f;
  --short: #ff3b4a;
  --short-deep: #a01222;
  --panel: rgba(245, 250, 246, 0.78);
  --line: rgba(26, 42, 34, 0.14);
  --font-display: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-body: "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#boot-veil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(197, 220, 232, 0.92);
  color: #1a2a22;
  font: 700 16px/1.4 var(--font-display);
  letter-spacing: 0.04em;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#boot-veil[hidden] {
  display: none;
}

#boot-veil[data-failed="1"] {
  background: rgba(160, 18, 34, 0.92);
  color: #fff;
  pointer-events: auto;
}

#battle-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#battle-canvas:active {
  cursor: grabbing;
}

.hud-top,
.hud-left,
.hud-right,
.hud-bottom {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.hud-top,
.hud-bottom,
.symbol-panel,
.controls,
.symbol-panel select,
.symbol-panel button,
.controls input {
  pointer-events: auto;
}

.hud-top {
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(180deg, rgba(197, 220, 232, 0.88), transparent);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  pointer-events: auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem 0.75rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.legend .dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.35rem;
  border-radius: 2px;
  vertical-align: middle;
}

.legend .dot.infantry {
  background: #9aa7b0;
}
.legend .dot.apc {
  background: #6b8f5a;
}
.legend .dot.tank {
  background: #c4a35a;
}
.legend .dot.air {
  background: #ffcc66;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  font-size: 1.75rem;
  filter: drop-shadow(0 0 12px rgba(30, 207, 122, 0.45));
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.symbol-panel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(10px);
}

.symbol-panel label {
  color: var(--muted);
  font-size: 0.75rem;
}

.symbol-panel select,
.symbol-panel button {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--ink);
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
}

.symbol-panel select option {
  color: #1a2a22;
  background: #f2f7f3;
}

.symbol-panel button {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.symbol-panel button:hover {
  border-color: var(--long);
  background: rgba(30, 207, 122, 0.12);
}

.symbol-panel button.airdrop {
  border-color: rgba(255, 204, 102, 0.55);
  color: #8a5a00;
  background: rgba(255, 236, 180, 0.55);
}

.symbol-panel button.airdrop:hover:not(:disabled) {
  border-color: #ffcc66;
  background: rgba(255, 204, 102, 0.28);
  color: #5c3a00;
}

.symbol-panel button.airdrop:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.force-mix {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
}

.hud-left,
.hud-right {
  top: 50%;
  transform: translateY(-50%);
  width: min(210px, 32vw);
  padding: 1rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.hud-left {
  left: 0;
  border-left: none;
  border-radius: 0 12px 12px 0;
  box-shadow: inset 3px 0 0 var(--long);
}

.hud-right {
  right: 0;
  text-align: right;
  border-right: none;
  border-radius: 12px 0 0 12px;
  box-shadow: inset -3px 0 0 var(--short);
}

.side-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.long-side .side-pct {
  color: var(--long);
}

.short-side .side-pct {
  color: var(--short);
}

.side-pct {
  margin-top: 0.25rem;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 600;
  line-height: 1.1;
  opacity: 0.85;
}

.side-meta {
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.hud-bottom {
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem 1.5rem 1.25rem;
  background: linear-gradient(0deg, rgba(197, 220, 232, 0.92), transparent);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.airdrop-chip {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: #8a5a00;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 204, 102, 0.55);
  background: rgba(255, 236, 180, 0.72);
}

.airdrop-chip[hidden] {
  display: none;
}

.crate-tooltip {
  position: fixed;
  z-index: 12;
  max-width: min(320px, 88vw);
  padding: 0.65rem 0.85rem 0.7rem;
  pointer-events: none;
  color: #e8f0f4;
  background: rgba(12, 14, 16, 0.92);
  border: 1px solid rgba(255, 204, 102, 0.45);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.crate-tooltip[hidden] {
  display: none;
}

.crate-tooltip-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffcc66;
}

.crate-tooltip-detail {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.crate-tooltip-items {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0.45rem 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
}

.crate-tooltip-items li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.28rem 0;
}

.crate-tooltip-items li span:first-child {
  color: var(--muted);
}

.crate-tooltip-items li span:last-child {
  text-align: right;
  color: #e8f0f4;
}

.crate-tooltip-hint span:last-child {
  color: #ffcc66;
}

#battle-status {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

#frontline-info {
  color: var(--ink);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-top: 0.65rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.controls input[type="range"] {
  width: 120px;
  accent-color: var(--long);
}

.disclaimer {
  margin: 0.7rem 0 0;
  font-size: 0.7rem;
  color: rgba(138, 155, 171, 0.75);
}

@media (max-width: 720px) {
  .hud-top {
    flex-direction: column;
    align-items: stretch;
  }

  .header-right {
    align-items: stretch;
  }

  .legend {
    justify-content: flex-start;
    font-size: 0.65rem;
  }

  .hud-left,
  .hud-right {
    top: auto;
    bottom: 9.5rem;
    transform: none;
    width: auto;
    max-width: 42%;
    padding: 0.7rem 0.8rem;
  }

  .side-pct {
    font-size: 0.95rem;
  }

  .side-meta,
  .force-mix {
    display: none;
  }
}
