:root {
  color-scheme: dark;
  --cyan: #5de8ff;
  --cyan-dark: #1687aa;
  --red: #ff5b54;
  --gold: #ffd36b;
  --panel: rgba(5, 15, 29, 0.88);
  --line: rgba(107, 197, 235, 0.32);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #07101a;
  color: #eaf7ff;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
}

canvas {
  display: block;
}

button,
a {
  font: inherit;
}

.glass {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(17, 44, 66, 0.2), transparent 50%),
    var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), inset 0 0 26px rgba(48, 151, 205, 0.05);
  backdrop-filter: blur(10px);
}

#battle-hud {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.top-bar {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  height: 70px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 8px 14px;
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 28px;
  box-shadow: 0 0 20px rgba(80, 220, 255, 0.25);
}

.brand small,
.command-info small {
  display: block;
  color: #83a7ba;
  font-size: 11px;
  margin-top: 3px;
}

.resource {
  min-width: 105px;
  padding-left: 18px;
  border-left: 1px solid rgba(120, 200, 230, 0.2);
}

.resource span {
  display: block;
  color: #8baab9;
  font-size: 11px;
  text-transform: uppercase;
}

.resource b {
  color: var(--cyan);
  font-size: 18px;
}

.back-to-map {
  position: fixed;
  z-index: 20;
  top: 90px;
  left: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--gold);
  text-decoration: none;
  font-size: 13px;
  pointer-events: auto;
}

.back-to-map:hover {
  color: var(--cyan);
  border-color: rgba(124, 236, 255, 0.55);
}

.top-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.top-actions button,
.top-actions a,
.orders button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #dff8ff;
  background: rgba(23, 61, 83, 0.65);
  border: 1px solid rgba(104, 205, 241, 0.3);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.top-actions button:hover,
.top-actions a:hover,
.orders button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.object-panel,
.mission-panel {
  position: absolute;
  top: 96px;
  width: 260px;
  border-radius: 8px;
  padding: 16px;
}

.object-panel {
  left: 14px;
}

.mission-panel {
  right: 14px;
}

.eyebrow {
  color: var(--cyan);
  font-size: 10px;
  letter-spacing: 0.16em;
  margin-bottom: 7px;
}

.object-panel h2,
.mission-panel h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.object-panel p:not(.eyebrow),
.mission-panel p:not(.eyebrow) {
  color: #9db6c2;
  font-size: 12px;
  line-height: 1.45;
}

.health-track {
  height: 6px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  margin: 8px 0 10px;
}

.health-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #34c978, #a9ec72);
  box-shadow: 0 0 10px rgba(70, 230, 140, 0.5);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 5px;
  margin-top: 12px;
}

.stats span {
  padding: 7px 4px;
  color: #7693a3;
  font-size: 9px;
  text-align: center;
  border: 1px solid rgba(105, 180, 220, 0.15);
  background: rgba(16, 43, 60, 0.4);
}

.stats b {
  display: block;
  color: #e5f7ff;
  font-size: 11px;
  margin-top: 2px;
}

.mission-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  font-size: 12px;
  color: #a8bfca;
}

.mission-row b {
  margin-left: auto;
  color: #fff;
}

.blue-dot,
.red-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.blue-dot {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.red-dot {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.minimap {
  position: absolute;
  right: 14px;
  bottom: 128px;
  width: 208px;
  padding: 8px;
  border-radius: 8px;
  text-align: center;
}

.minimap canvas {
  width: 190px;
  height: 190px;
  background: rgba(1, 7, 14, 0.75);
}

.minimap span {
  display: block;
  color: #7999aa;
  font-size: 9px;
  letter-spacing: 0.15em;
  margin-top: 5px;
}

.command-bar {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: min(980px, calc(100% - 450px));
  height: 105px;
  transform: translateX(-50%);
  border-radius: 9px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.portrait {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 44px;
  color: var(--cyan);
  background: radial-gradient(circle, rgba(43, 134, 170, 0.35), rgba(4, 15, 26, 0.8));
  border: 1px solid rgba(87, 210, 245, 0.3);
}

.command-info {
  width: 140px;
}

.build-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex: 1;
}

.build {
  position: relative;
  min-width: 105px;
  height: 78px;
  color: #d9eff8;
  border: 1px solid rgba(95, 187, 224, 0.25);
  border-radius: 5px;
  background: rgba(12, 36, 53, 0.72);
  cursor: pointer;
}

.build:hover:not(:disabled) {
  border-color: var(--cyan);
  background: rgba(18, 67, 88, 0.8);
  box-shadow: inset 0 0 20px rgba(55, 200, 240, 0.08);
}

.build:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.build b,
.build small {
  display: block;
}

.build b {
  font-size: 11px;
}

.build small {
  color: #7c9eae;
  font-size: 9px;
}

.build i {
  position: absolute;
  top: 3px;
  right: 5px;
  color: #658491;
  font-size: 9px;
  font-style: normal;
}

.unit-icon {
  display: block;
  color: var(--cyan);
  font-size: 26px;
  line-height: 30px;
}

.orders {
  display: grid;
  grid-template-columns: repeat(2, 40px);
  gap: 5px;
}

.orders button:last-child {
  grid-column: span 2;
  width: 85px;
}

#selection-box {
  position: absolute;
  display: none;
  border: 1px solid var(--cyan);
  background: rgba(65, 200, 240, 0.12);
}

#toast {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 18px;
  border-radius: 6px;
  background: rgba(5, 18, 29, 0.92);
  border: 1px solid rgba(87, 220, 255, 0.4);
  color: #dffaff;
  opacity: 0;
  transition: 0.25s;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#start-overlay,
#result-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(19, 54, 72, 0.35), rgba(2, 7, 13, 0.9));
}

.briefing {
  width: min(580px, calc(100% - 40px));
  padding: 38px;
  border-radius: 12px;
  text-align: center;
}

.briefing h1 {
  margin-bottom: 12px;
  font-size: 34px;
  letter-spacing: 0.05em;
}

.briefing > p:not(.eyebrow) {
  color: #a6c1ce;
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 22px 0;
  text-align: left;
}

.controls span {
  padding: 9px 12px;
  border: 1px solid rgba(90, 190, 225, 0.18);
  background: rgba(10, 30, 45, 0.58);
  color: #91adba;
  font-size: 12px;
}

.controls b {
  display: inline-block;
  width: 68px;
  color: var(--cyan);
}

.briefing button,
.briefing a {
  display: inline-block;
  margin: 5px;
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid rgba(90, 220, 255, 0.5);
  background: linear-gradient(180deg, #78e8ff, #25a7d4);
  color: #03121b;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.briefing a {
  background: transparent;
  color: #b9dbe9;
}

.hidden {
  display: none !important;
}

@media (max-width: 1050px) {
  .object-panel,
  .mission-panel {
    width: 220px;
  }
  .resource:nth-of-type(4),
  .resource:nth-of-type(5) {
    display: none;
  }
  .command-bar {
    width: calc(100% - 30px);
  }
  .minimap {
    display: none;
  }
}
