:root {
  color-scheme: dark;
  font-family: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --bg: #0f1115;
  --bg-panel: #161b28;
  --bg-panel-alt: #1a1f2b;
  --border: #2a3242;
  --border-highlight: #37a0f2;
  --text: #eaeef2;
  --accent: #37a0f2;
  --danger: #e74c3c;
  --warning: #f39c12;
  --layout-max-width: 1100px;
  --layout-padding: clamp(12px, 1.6vw, 20px);
  --view-padding: clamp(10px, 1.4vw, 16px);
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  height: 100%;
}

body {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100vw;
  background: #10141f;
}

.view-area {
  width: 100%;
  box-sizing: border-box;
}

.hud-top,
.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  pointer-events: none;
}

.hud-top {
  top: clamp(12px, 2vh, 28px);
  height: 0;
}

.hud-bottom {
  bottom: 0;
  height: 0;
  --hotkeys-gap: clamp(12px, 2vh, 20px);
}



.hud-cluster {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  pointer-events: auto;
  max-width: clamp(480px, 50vw, 640px);
  position: absolute;
  left: clamp(24px, 4vw, 48px);
  top: 0;
}

.hud-top #wave-info {
  position: absolute;
  right: clamp(24px, 4vw, 48px);
  top: 0;
  width: clamp(240px, 22vw, 320px);
}




.hud-bottom .minimap-panel {
  left: clamp(24px, 4vw, 48px);
  bottom: calc(var(--hotkeys-gap) + 24px);
  width: clamp(234px, 19.8vw, 324px);
}

.hud-bottom .unit-panel {
  left: 50%;
  bottom: calc(var(--hotkeys-gap) + 24px);
  transform: translateX(-50%);
  width: min(640px, 60vw);
}

.hud-bottom .command-panel {
  right: clamp(24px, 4vw, 48px);
  bottom: calc(var(--hotkeys-gap) + 24px);
  width: clamp(240px, 18vw, 320px);
}

 

 .minimap-panel {
  align-items: center;
}

.minimap-frame {
  width: clamp(220px, 22vw, 320px);
  height: clamp(220px, 22vw, 320px);
  position: absolute;
  top: 12px;
  left: 12px;
  pointer-events: none;
}

#minimap {
  width: clamp(220px, 22vw, 320px);
  height: clamp(220px, 22vw, 320px);
  background: #0f121b;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.resource-group {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
  align-self: flex-start;
}

.status-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: auto;
  align-self: flex-start;
}

.status-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(18, 22, 33, 0.82);
  border: 1px solid rgba(55, 64, 87, 0.4);
  color: #cbd6e8;
  flex: 0 1 130px;
  min-width: 110px;
}

.panel {
  display: flex;
  flex-direction: column;
}

.status-chip__label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(156, 170, 195, 0.75);
}

/* Wave info card is positioned via #wave-info.wave-card rules below */

.hud-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
  pointer-events: auto;
  flex: 0 0 auto;
}

.wave-card {
  background: rgba(18, 22, 33, 0.9);
  border: 1px solid rgba(55, 64, 87, 0.6);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  color: #d7cfef;
  min-height: 96px;
  pointer-events: auto;
}

/* Pin battle info card to top-right independent of left cluster width */
#wave-info.wave-card {
  position: absolute;
  top: 0;
  right: clamp(24px, 4vw, 48px);
  margin: 0;
  width: clamp(240px, 22vw, 320px);
  max-width: clamp(240px, 22vw, 320px);
  z-index: 6;
}

#wave-info-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wave-card.is-boss {
  border-color: rgba(255, 99, 71, 0.75);
  box-shadow: 0 0 28px rgba(255, 99, 71, 0.35);
}
.wave-card.is-urgent:not(.is-boss) {
  border-color: rgba(243, 156, 18, 0.7);
  box-shadow: 0 0 22px rgba(243, 156, 18, 0.28);
}

.wave-card.hidden {
  display: none;
}

.wave-card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #99a3b8;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wave-card .wave-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  font-size: 11px;
  color: #c7cfdd;
}
.wave-card .em { color: var(--accent); font-weight: 700; }
.wave-card .muted { color: #9aa6bd; font-weight: 600; }
.wave-card .boss { color: var(--danger); font-weight: 700; }
.wave-card .title-row span { font-weight: 600; }

.wave-card .wave-progress {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(23, 28, 40, 0.8);
  overflow: hidden;
  margin-top: 6px;
}

.wave-card .wave-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, rgba(55, 160, 242, 0.8), rgba(55, 160, 242, 0.25));
}


.wave-skip-btn {
  margin-top: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(55, 160, 242, 0.6);
  background: linear-gradient(135deg, rgba(55, 160, 242, 0.28), rgba(24, 32, 48, 0.9));
  color: #e7f3ff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.wave-skip-btn:hover:not(:disabled) {
  border-color: rgba(120, 200, 255, 0.9);
  box-shadow: 0 0 14px rgba(55, 160, 242, 0.35);
  transform: translateY(-1px);
}

.wave-skip-btn:disabled {
  cursor: not-allowed;
  border-color: rgba(64, 74, 98, 0.6);
  background: rgba(18, 22, 33, 0.6);
  color: rgba(155, 165, 182, 0.7);
  box-shadow: none;
  transform: none;
}

.wave-skip-btn.ready {
  border-color: rgba(120, 224, 180, 0.9);
  background: linear-gradient(135deg, rgba(76, 201, 240, 0.35), rgba(48, 196, 160, 0.55));
  color: #102931;
  box-shadow: 0 0 18px rgba(76, 201, 240, 0.35);
}

.resource-panel {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-right: 0;
  flex-wrap: wrap;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(14, 18, 28, 0.78);
  border: 1px solid rgba(55, 64, 87, 0.55);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.resource-panel .resource {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #f3f6ff;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(55, 64, 87, 0.55);
  background: rgba(18, 22, 33, 0.78);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.28);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.resource-panel .resource.is-ready {
  border-color: rgba(76, 201, 240, 0.75);
  box-shadow: 0 0 18px rgba(76, 201, 240, 0.25);
  background: radial-gradient(circle at top, rgba(45, 125, 255, 0.55), rgba(18, 22, 33, 0.85));
}
.resource-panel .resource.is-warning {
  border-color: rgba(243, 156, 18, 0.66);
  box-shadow: 0 0 16px rgba(243, 156, 18, 0.25);
  background: radial-gradient(circle at top, rgba(243, 156, 18, 0.35), rgba(18, 22, 33, 0.9));
}
.resource-panel .resource.is-critical {
  border-color: rgba(231, 76, 60, 0.9);
  background: radial-gradient(circle at top, rgba(231, 76, 60, 0.45), rgba(18, 22, 33, 0.9));
  box-shadow: 0 0 18px rgba(231, 76, 60, 0.32);
  animation: pulse-critical 1.4s infinite;
}
.resource-panel .resource.is-highlight {
  border-color: rgba(130, 177, 255, 0.6);
  box-shadow: 0 0 14px rgba(130, 177, 255, 0.18);
}
.resource-panel .resource span {
  font-weight: 600;
  color: #ecf2ff;
}
.resource-panel .resource img {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.45));
}

.shipyard-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid rgba(55, 64, 87, 0.7);
  background: rgba(18, 22, 33, 0.9);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
  box-sizing: border-box;
  pointer-events: auto;
}

.shipyard-display.over-capacity {
  border-color: rgba(243, 156, 18, 0.65);
  box-shadow: 0 8px 20px rgba(243, 156, 18, 0.25);
}

.shipyard-display img {
  width: 18px;
  height: 18px;
}

.shipyard-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.shipyard-text .label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(181, 194, 219, 0.75);
}

#dockyard-usage {
  font-size: 14px;
  font-weight: 600;
  color: #f2f6ff;
}

@media (max-width: 1220px) {
  .hud-top {
    flex-wrap: wrap;
    gap: 18px;
  }

  .hud-top #wave-info {
    width: 100%;
    max-width: none;
  }

  .resource-group {
    justify-content: space-between;
  }
}

#dockyard-usage.over-capacity {
  color: #f39c12;
}

@keyframes pulse-critical {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hud-top {
    flex-direction: column;
    gap: 14px;
  }

  .resource-group {
    gap: 10px;
  }

  .resource-panel,
  .shipyard-display {
    width: 100%;
    justify-content: center;
  }

  .status-chip-row {
    gap: 8px;
  }

  .status-chip {
    flex: 1 1 110px;
  }

}

@media (max-width: 1180px) {
  :root {
    --layout-max-width: 1120px;
    --layout-padding: clamp(10px, 1.8vw, 20px);
    --view-padding: clamp(10px, 1.8vw, 16px);
  }

  .resource-panel .resource {
    padding: 6px 10px;
  }

  #minimap,
  .minimap-frame {
    width: clamp(200px, 24vw, 300px);
    height: clamp(200px, 24vw, 300px);
  }
}

@media (max-width: 980px) {
  :root {
    --layout-padding: clamp(10px, 3vw, 18px);
    --view-padding: clamp(10px, 3vw, 16px);
  }

  .view-area {
    border-radius: 14px;
  }

  .command-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-help {
    max-width: min(520px, 90vw);
    margin: 0 auto;
  }
}

@media (max-width: 720px) {
  :root {
    --layout-padding: clamp(8px, 4vw, 16px);
    --view-padding: clamp(8px, 4vw, 14px);
  }

  .resource-group {
    gap: 8px;
  }

  .resource-panel {
    flex-direction: column;
    gap: 8px;
  }

  .resource-panel .resource {
    width: 100%;
    justify-content: space-between;
  }

  .shipyard-display {
    width: 100%;
    justify-content: space-between;
  }

  #minimap,
  .minimap-frame {
    width: clamp(180px, 32vw, 220px);
    height: clamp(180px, 32vw, 220px);
  }

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

@media (max-width: 560px) {
  .command-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.view-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 1 1 auto;
  width: 100vw;
  max-width: 100vw;
  --battlefield-top-offset: clamp(8px, 1.5vh, 18px);
  padding: var(--battlefield-top-offset) var(--view-padding) 0;
  min-height: 100vh;
  box-sizing: border-box;
  gap: clamp(14px, 2vw, 20px);
}

.battlefield {
  position: relative;
  --available-battlefield-height: calc(100vh - var(--battlefield-top-offset));
  --battlefield-width: min(100%, calc(var(--available-battlefield-height) * 2 / 1));
  width: var(--battlefield-width);
  height: min(calc(100vw * 0.5), var(--available-battlefield-height));
  max-height: var(--available-battlefield-height);
  margin: 0 auto;
  border: 1px solid var(--border);
  background: #121722;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 2 / 1;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #111621;
  border: 1px solid #0b0f18;
  border-radius: 10px;
  user-select: none;
}

.camera-overlay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 12px;
  background: rgba(15, 17, 25, 0.75);
  border: 1px solid rgba(55, 64, 87, 0.7);
  border-radius: 6px;
  font-size: 12px;
  color: #c7cfdd;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}


.scene-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 14, 0.82);
  backdrop-filter: blur(4px);
  z-index: 40;
}

.scene-panel {
  width: min(520px, 92vw);
  padding: 32px 36px;
  background: linear-gradient(180deg, rgba(25, 29, 42, 0.95) 0%, rgba(14, 17, 26, 0.95) 100%);
  border: 1px solid rgba(55, 64, 87, 0.6);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  color: #d7dff3;
}

.scene-panel--gameover {
  width: min(460px, 92vw);
  padding: 32px 36px 30px;
  background: linear-gradient(180deg, rgba(32, 18, 22, 0.95) 0%, rgba(12, 9, 15, 0.95) 100%);
  border: 1px solid rgba(231, 76, 60, 0.35);
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.scene-panel--gameover h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f7e4e7;
}

.scene-panel--gameover p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #f0d6d9;
}

.gameover-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(231, 76, 60, 0.3);
  background: rgba(24, 12, 18, 0.75);
  font-size: 13px;
  color: #f5e9eb;
}

.gameover-stats .stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.gameover-stats .stat-row strong {
  font-weight: 600;
  color: #ffe7ea;
}

.gameover-actions {
  justify-content: flex-end;
  gap: 12px;
}

.gameover-actions .scene-btn {
  min-width: 120px;
}

.lobby-shell {
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 24px;
  border-radius: 14px;
  background: rgba(16, 20, 32, 0.92);
  border: 1px solid rgba(55, 64, 87, 0.65);
  box-shadow: 0 20px 36px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.lobby-hero {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-tag {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(174, 189, 216, 0.75);
}

.lobby-title {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f6f9ff;
}

.lobby-blurb {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #b5c1d8;
}

.lobby-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-menu__item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(18, 23, 36, 0.86);
  border: 1px solid rgba(55, 64, 87, 0.55);
  color: #d7dff3;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
  text-align: left;
}

.lobby-menu__item strong {
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #f3f7ff;
}

.lobby-menu__item span {
  font-size: 12px;
  color: #aeb7c9;
}

.lobby-menu__item:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: rgba(55, 160, 242, 0.7);
  box-shadow: 0 18px 30px rgba(55, 160, 242, 0.18);
}

.lobby-menu__item--primary {
  background: linear-gradient(135deg, rgba(55, 160, 242, 0.28), rgba(14, 18, 28, 0.85));
  border-color: rgba(55, 160, 242, 0.65);
  color: #f6fbff;
}

.lobby-menu__item--primary:hover {
  box-shadow: 0 22px 34px rgba(55, 160, 242, 0.25);
}

.lobby-menu__item--locked {
  cursor: not-allowed;
  opacity: 0.6;
  background: rgba(12, 16, 26, 0.78);
}

.lobby-menu__item--locked strong {
  color: #b2b9c9;
}

.menu-lock {
  position: absolute;
  right: 14px;
  top: 12px;
  font-size: 14px;
}

@media (max-width: 560px) {
  .lobby-shell {
    padding: 20px 16px;
    gap: 16px;
    width: min(380px, 94vw);
  }

  .lobby-title {
    font-size: clamp(20px, 5.4vw, 26px);
  }

  .lobby-menu__item {
    padding: 10px 12px;
    border-radius: 8px;
  }
}

.scene-panel h1,
.scene-panel h2 {
  margin: 0 0 16px;
  font-size: 28px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #eaeef2;
}

.scene-panel p {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.6;
  color: #aeb7c9;
}

.scene-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.scene-btn {
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid rgba(55, 64, 87, 0.6);
  background: rgba(26, 32, 47, 0.8);
  color: #d7dff3;
  font-size: 14px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.scene-btn:hover {
  border-color: var(--border-highlight);
  color: var(--border-highlight);
}

.scene-btn.primary {
  background: #2f7de1;
  border-color: #2f7de1;
  color: #ffffff;
}

.scene-btn.primary:hover {
  background: #3d8bf0;
  border-color: #3d8bf0;
}

.scene-btn.subtle {
  background: transparent;
  border-color: rgba(55, 64, 87, 0.4);
  color: #9aa5bd;
}

.scene-btn.subtle:hover {
  border-color: var(--border-highlight);
  color: var(--border-highlight);
}

.setting-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Settings tabs */
.settings-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px 0;
}

.settings-tab {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(55, 64, 87, 0.6);
  background: rgba(18, 23, 36, 0.7);
  color: #c7cfdd;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: none;
}

.settings-tab:hover {
  border-color: var(--border-highlight);
  color: var(--border-highlight);
}

.settings-tab.active {
  background: linear-gradient(135deg, rgba(55, 160, 242, 0.15), rgba(18, 23, 36, 0.7));
  border-color: rgba(55, 160, 242, 0.6);
  color: #e7f3ff;
}

.settings-section {
  margin-bottom: 10px;
}

.help-card {
  padding: 12px;
  border: 1px solid rgba(55, 64, 87, 0.6);
  border-radius: 8px;
  background: rgba(18, 22, 33, 0.6);
  font-size: 13px;
  color: #c7cfdd;
}

.help-card strong {
  display: block;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #eaeef2;
  font-size: 12px;
}

.help-card ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  list-style: disc;
}

.help-card li {
  font-size: 12px;
  color: #9aa5bd;
}

/* Difficulty picker */
.difficulty-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.difficulty-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(55, 64, 87, 0.55);
  background: rgba(18, 23, 36, 0.86);
  color: #d7dff3;
  cursor: pointer;
  transition: transform 0.15s ease, border 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.difficulty-card:hover {
  transform: translateY(-2px);
  border-color: rgba(55, 160, 242, 0.7);
  box-shadow: 0 14px 24px rgba(55, 160, 242, 0.18);
}

.difficulty-card.is-active {
  border-color: var(--border-highlight);
  box-shadow: 0 0 18px rgba(55, 160, 242, 0.22);
}

.difficulty-card .difficulty-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.difficulty-card img {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 0 6px rgba(0,0,0,0.35));
}

.difficulty-card .difficulty-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.difficulty-card .difficulty-text strong {
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #f3f7ff;
}

.difficulty-card .difficulty-text .desc {
  font-size: 12px;
  color: #aeb7c9;
}

.difficulty-card .difficulty-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(55, 64, 87, 0.6);
  background: rgba(22, 26, 40, 0.8);
  color: #eaf2ff;
}

/* Theming by difficulty */
.difficulty-card[data-difficulty='normal'] .difficulty-badge {
  border-color: rgba(55, 160, 242, 0.6);
  color: #dff1ff;
}

.difficulty-card[data-difficulty='hard'] {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.12), rgba(18, 23, 36, 0.86));
}
.difficulty-card[data-difficulty='hard'] .difficulty-badge {
  border-color: rgba(243, 156, 18, 0.6);
  color: #ffe9c8;
}

.difficulty-card[data-difficulty='extreme'] {
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.12), rgba(18, 23, 36, 0.86));
}
.difficulty-card[data-difficulty='extreme'] .difficulty-badge {
  border-color: rgba(231, 76, 60, 0.6);
  color: #ffe2df;
}

@media (max-width: 560px) {
  .difficulty-card {
    padding: 10px 12px;
  }
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: #c7cfdd;
}

.setting-row input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: #2f7de1;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.setting-control input[type='range'] {
  flex: 1;
}

.flex-spacer {
  flex: 1;
}



.unit-panel {
  min-height: auto;
}

.unit-panel.is-hidden {
  display: none;
}

.unit-panel .panel-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unit-hotkeys {
  font-size: 12px;
  font-weight: 500;
  color: #9aa5bd;
  letter-spacing: 0.03em;
  text-transform: none;
  line-height: 1.4;
  text-align: center;
}

.hud-bottom .unit-hotkeys--floating {
  position: absolute;
  left: 50%;
  bottom: var(--hotkeys-gap);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(55, 64, 87, 0.5);
  background: rgba(16, 20, 32, 0.78);
  color: #c7cfdd;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  max-width: min(90vw, 840px);
  pointer-events: auto;
  backdrop-filter: blur(4px);
}



.panel-title {
  margin: 0;
  padding: 6px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #1d2334 0%, #151b28 100%);
}

.panel-body {
  flex: 1;
  position: relative;
  padding: 12px;
  box-sizing: border-box;
}

.hud-bottom .panel {
  position: absolute;
  background: transparent;
  border: none;
  box-shadow: none;
  pointer-events: auto;
}

.hud-bottom .panel-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: #c7cfdd;
  padding: 0;
}

/* Make command panel header look clickable when used as Options button */
.command-panel .panel-title[role="button"] {
  cursor: pointer;
}
.command-panel .panel-title[role="button"]:hover {
  color: var(--border-highlight);
}

.hud-bottom .panel-body {
  padding: 0;
}

.hud-bottom .minimap-panel {
  left: 24px;
  bottom: 16px;
  width: 270px;
}

.minimap-panel {
  align-items: center;
}

/* .minimap-frame removed (unused) */

#minimap {
  width: 100%;
  aspect-ratio: 2 / 1;
  background: #0f121b;
  border-radius: 6px;
  border: 1px solid var(--border);
  box-sizing: border-box;
}

/* Mini YouTube player overlay over minimap */
.music-widget {
  width: 100%;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0; /* remove internal padding to align width with minimap */
  border-radius: 10px;
  background: rgba(16, 20, 32, 0.82);
  border: 1px solid rgba(55, 64, 87, 0.6);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  box-sizing: border-box;
  position: relative; /* for overlay event player */
}

.music-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.yt-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  box-sizing: border-box;
}

/* .yt-event overlay removed */

.music-widget .yt-frame iframe {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9;
}

/* Event video panel removed */

.music-controls {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-self: flex-end;
}

.music-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(55, 64, 87, 0.6);
  background: rgba(22, 26, 40, 0.8);
  color: #d7dff3;
  cursor: pointer;
  padding: 0;
}

.music-btn:hover {
  border-color: var(--border-highlight);
  color: var(--border-highlight);
}

.music-title {
  font-size: 11px;
  color: #aeb7c9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}




.unit-panel-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(55, 64, 87, 0.45);
  background: rgba(18, 22, 33, 0.65);
  min-height: 0;
  max-height: min(420px, 48vh);
  overflow-y: auto;
  overflow-x: hidden;
}

.unit-detail.enemy-focus .unit-avatar {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
}

.unit-detail.enemy-focus .unit-meta strong {
  color: #ffe7ea;
}

.enemy-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.enemy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #f1f5ff;
}

.enemy-header span {
  font-size: 11px;
  color: #9aa5bd;
}

.enemy-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 11px;
  color: #c7cfdd;
}

.enemy-stats .stat-line {
  display: flex;
  justify-content: space-between;
}

.enemy-stats .label {
  color: #9aa5bd;
}

.enemy-stats .value {
  color: #f1f5ff;
}

.unit-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.unit-panel-body .unit-detail {
  gap: 6px;
  padding: 2px 0;
  font-size: 12px;
  flex: 1;
  min-height: 0;
}

.unit-summary-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.unit-panel-body .unit-summary-header {
  gap: 8px;
}

.unit-avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: rgba(47, 125, 225, 0.15);
  border: 1px solid rgba(55, 160, 242, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #eaeef2;
  letter-spacing: 0.08em;
  overflow: hidden;
}

.unit-panel-body .unit-avatar {
  width: 40px;
  height: 40px;
}

.unit-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.unit-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.unit-panel-body .unit-meta strong {
  font-size: 14px;
}

.unit-panel-body .unit-meta span {
  font-size: 11px;
}

.unit-meta strong {
  font-size: 16px;
  color: #f1f5ff;
}

.unit-meta span {
  font-size: 12px;
  color: #8f99ad;
}

.unit-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #aeb7c9;
}

.unit-meta-line--secondary {
  color: #9aa5bd;
}

.unit-meta-line + .unit-meta-line {
  margin-top: 2px;
}

.unit-era-pill,
.unit-rarity-text,
.unit-fusion-tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(55, 64, 87, 0.35);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.unit-era-pill {
  background: rgba(55, 64, 87, 0.45);
  color: #dbe5f7;
}

.unit-rarity-text {
  padding: 2px 10px;
  color: inherit;
}

.unit-rarity-text.rarity-common { background: rgba(111, 143, 214, 0.24); color: #6f8fd6; }
.unit-rarity-text.rarity-rare { background: rgba(47, 131, 255, 0.24); color: #2f83ff; }
.unit-rarity-text.rarity-unique { background: rgba(181, 72, 255, 0.24); color: #b548ff; }
.unit-rarity-text.rarity-legendary { background: rgba(255, 143, 31, 0.26); color: #ff8f1f; }
.unit-rarity-text.rarity-mythic { background: rgba(255, 80, 54, 0.26); color: #ff5036; }

.unit-rarity-text.rarity-primordial { background: rgba(42, 255, 192, 0.32); color: #0b5f45; }
.unit-tier-text {
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(55, 64, 87, 0.25);
  font-weight: 600;
  color: #c6d1e4;
  letter-spacing: 0.03em;
}

.unit-fusion-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #b7c4dc;
}

.unit-fusion-tier {
  padding: 2px 12px;
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  /* Improve legibility on vibrant gradients */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  -webkit-text-stroke: 0.4px rgba(0, 0, 0, 0.35);
}

.unit-fusion-tier--base {
  background: rgba(55, 64, 87, 0.55);
  color: #e4ecfb;
}

.unit-fusion-tier--charged {
  background: linear-gradient(135deg, rgba(55, 160, 242, 0.95), rgba(92, 210, 255, 0.9));
  color: #ffffff;
}

.unit-fusion-tier--advanced {
  background: linear-gradient(135deg, rgba(246, 255, 138, 0.95), rgba(242, 200, 64, 0.9));
  color: #1b0e00;
  color: #ffffff;
}

.unit-fusion-tier--prime {
  background: linear-gradient(135deg, rgba(255, 141, 214, 0.95), rgba(255, 99, 146, 0.92));
  color: #ffffff;
}

.unit-weapon-label {
  font-weight: 500;
  color: #a6b7d6;
}

.unit-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  font-size: 12px;
  color: #d7dff3;
}

.unit-panel-body .unit-stats {
  gap: 6px 10px;
  font-size: 11px;
}

.unit-stats .stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-panel-body .unit-stats .stat-row {
  gap: 6px;
}

.unit-stats .stat-row img {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.35));
}

.unit-panel-body .unit-stats .stat-row img {
  width: 16px;
  height: 16px;
}

.unit-stats .stat-row span {
  flex: 1;
  color: #9aa5bd;
}

.unit-stats .stat-row strong {
  color: #f1f5ff;
}

.unit-panel-body .selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 6px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.unit-panel-body .selection-grid .grid-item {
  position: relative;
  padding: 6px 4px;
  border-radius: 6px;
  border: 1px solid rgba(47, 125, 225, 0.35);
  background: rgba(23, 27, 40, 0.75);
  text-align: center;
  font-size: 10px;
  color: #d0d8eb;
  overflow: hidden;
}

.unit-panel-body .selection-grid .grid-item strong {
  display: block;
  font-size: 11px;
  color: #f1f5ff;
  margin-bottom: 4px;
}

.unit-panel-body .selection-grid .grid-item span {
  display: block;
  color: #8f99ad;
}

.unit-panel-body .selection-grid .grid-item.highlight {
  border-color: rgba(241, 196, 15, 0.6);
  box-shadow: 0 0 8px rgba(241, 196, 15, 0.4);
}

.unit-panel-body .placeholder {
  margin: 0;
  color: #6f7689;
  text-align: center;
}

.placeholder {
  margin: 0;
  color: #6f7689;
}

.command-panel .panel-body {
  padding: 12px 14px;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 10px;
  justify-items: stretch;
}

.command-button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid rgba(47, 125, 225, 0.35);
  background: rgba(19, 24, 36, 0.85);
  color: #d7dff3;
  cursor: pointer;
  transition: transform 0.1s ease, border 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
  text-align: center;
}

.command-button .command-icon img {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.35));
}

.command-button .command-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9aa5bd;
}

.command-button .command-hotkey {
  font-size: 10px;
  color: var(--border-highlight);
  letter-spacing: 0.08em;
}

.command-button:hover {
  border-color: var(--border-highlight);
  background: rgba(29, 36, 52, 0.9);
  transform: translateY(-1px);
}

.command-button:active,
.command-button.active {
  border-color: var(--border-highlight);
  background: rgba(47, 125, 225, 0.25);
}

.command-button.ready {
  border-color: rgba(55, 160, 242, 0.9);
  animation: pulse 1.2s ease-in-out infinite;
}

.command-button:focus-visible {
  outline: 2px solid var(--border-highlight);
  outline-offset: 2px;
}

.command-button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.command-button:disabled:hover {
  border-color: rgba(47, 125, 225, 0.35);
  background: rgba(19, 24, 36, 0.85);
}

.tooltip {
  position: absolute;
  background: rgba(15, 17, 21, 0.95);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  z-index: 10;
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(55, 160, 242, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(55, 160, 242, 0.8));
  }
}
.attack-summary {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.attack-summary .attack-icon {
  width: 20px;
  height: 20px;
  cursor: help;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.35));
}

.attack-summary .attack-tooltip {
  position: absolute;
  left: 50%;
  bottom: 140%;
  transform: translateX(-50%);
  min-width: 220px;
  padding: 8px 10px;
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid rgba(55, 64, 87, 0.5);
  border-radius: 6px;
  font-size: 12px;
  color: #d7dff3;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
}

.attack-summary:hover .attack-tooltip {
  opacity: 1;
}
.hud-help {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #f1f5ff;
  background: rgba(15, 19, 30, 0.7);
  padding: 8px 16px;
  border: 1px solid rgba(55, 64, 87, 0.6);
  border-radius: 8px;
  pointer-events: none;
  text-align: center;
  max-width: min(520px, 80vw);
  white-space: normal;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 50;
}

.hud-help.is-visible {
  opacity: 1;
}

.multi-selection {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.multi-selection__grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  grid-auto-flow: row;
  width: 100%;
  align-items: stretch;
}
.unit-card {
  background: rgba(18, 24, 37, 0.7);
  border: 1px solid rgba(110, 130, 170, 0.3);
  border-radius: 6px;
  padding: 4px 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 48px;
}
.unit-card.unit-card--mini {
  min-height: 46px;
  gap: 2px;
  align-items: center;
  text-align: center;
  padding: 3px 2px;
}
.unit-card.unit-card--compact {
  padding: 4px 6px;
}
.unit-card__text {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 10px;
  color: #bfc9d8;
  line-height: 1.2;
}
.unit-card__text strong {
  font-size: 11px;
  color: #f1f5ff;
}
.unit-card__era {
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7e8aa8;
}
.unit-card__name {
  font-size: 11px;
  color: #f1f5ff;
  line-height: 1.25;
}
.unit-card__tags {
  display: flex;
  gap: 4px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  font-size: 9px;
  line-height: 1.2;
  color: #bac6d8;
}
.unit-card__tier {
  font-weight: 600;
  color: #a9c4ff;
}
.unit-card__fusion {
  font-weight: 500;
  color: #f7dca5;
}
.rarity-badge {
  font-weight: 600;
}
.rarity-common {
  color: #6f8fd6;
}
.rarity-rare {
  color: #2f83ff;
}
.rarity-unique {
  color: #b548ff;
}
.rarity-legendary {
  color: #ff8f1f;
}
.rarity-mythic {
  color: #ff5036;
}
.rarity-primordial {
  color: #21f7ba;
}
#hud-bottom .minimap-panel,
#hud-bottom .unit-panel,
#hud-bottom .command-panel {
  position: absolute;
}
