* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* ============================================================
    Epilepsy / Photosensitivity Warning Overlay
    Shown before the UI is enabled. Blocks all interaction
    until the user acknowledges it.
    ============================================================ */
#epilepsy-warning-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000010;
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  font-family: 'Courier New', monospace;
  color: #e0e0ff;
  animation: epilepsyFadeIn 0.3s ease-out;
}
#epilepsy-warning-overlay.hidden {
  display: none;
}
#epilepsy-warning-content {
  background: rgba(10, 10, 30, 0.98);
  border: 3px solid #ffaa00;
  border-radius: 10px;
  padding: 32px 40px;
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow:
    0 0 40px rgba(255, 170, 0, 0.5),
    0 0 80px rgba(255, 170, 0, 0.25);
  text-align: center;
}
.epilepsy-warning-icon {
  font-size: 64px;
  color: #ffaa00;
  text-shadow:
    0 0 12px #ffaa00,
    0 0 24px rgba(255, 170, 0, 0.6);
  margin-bottom: 8px;
  line-height: 1;
  animation: epilepsyPulse 1.8s ease-in-out infinite;
}
#epilepsy-warning-title {
  font-size: 26px;
  color: #ffaa00;
  margin-bottom: 18px;
  letter-spacing: 2px;
  text-shadow: 0 0 10px rgba(255, 170, 0, 0.6);
}
body {
  background-color: #000010;
  color: #e0e0ff;
  font-family: 'Courier New', monospace;
  display: block;
  min-height: 100vh;
  overflow: hidden;
  /* PWA: prevent pull-to-refresh and text selection during gameplay */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#game-container {
  position: relative;
  border: 2px solid #2a2a5a;
  box-shadow: 0 0 30px rgba(80, 80, 255, 0.3);
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

#game-canvas {
  display: block;
  background-color: #000010;
  cursor: crosshair;
  /* Prevent iOS long-press context menu on canvas */
  -webkit-touch-callout: none;
  touch-action: none;
  /* Center within the flex container's remaining space */
  margin: auto;
  flex: 0 0 auto;
  order: 2;
  /* Ensure the canvas doesn't exceed the container's available space. */
  max-width: 100%;
  max-height: 100%;
}

/* ── New compact TimeControl widget ───────────────────────────────────── */
.time-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.06), rgba(0, 100, 255, 0.06));
  border: 1px solid #2a2a5a;
  border-radius: 5px;
  padding: 4px 6px;
}

.tc-btn {
  background: transparent;
  color: #00ffff;
  border: 1px solid #2a2a5a;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  line-height: 1;
  min-width: 28px;
}

.tc-btn:hover:not(:disabled) {
  background: rgba(0, 255, 255, 0.15);
  border-color: #00ffff;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

.tc-btn:active:not(:disabled) {
  background: rgba(0, 255, 255, 0.3);
}

.tc-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tc-btn-icon {
  font-size: 13px;
  padding: 4px 8px;
}

.tc-slider {
  width: 130px;
  accent-color: #00ffff;
  margin: 0 2px;
  cursor: pointer;
}

.tc-label {
  display: inline-block;
  min-width: 52px;
  text-align: center;
  color: #00ffff;
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  background: rgba(0, 0, 16, 0.5);
  border: 1px solid #2a2a5a;
  border-radius: 3px;
}

.tc-label-paused {
  color: #ffaa00;
  text-shadow: 0 0 4px #ffaa00;
}

.tc-label-hyper {
  color: #ff60ff;
  text-shadow: 0 0 4px #ff60ff;
}

.tc-hint {
  font-size: 10px;
  color: #6080a0;
  margin-left: auto;
}

/* ── Hamburger / game menu ───────────────────────────────────────────── */
.game-menu-wrap {
  position: relative;
  margin-left: auto;
}

#game-menu-button {
  background: transparent;
  color: #c0c0e0;
  border: 1px solid #4040a0;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

#game-menu-button:hover,
#game-menu-button.active {
  color: #00ffff;
  border-color: #00ffff;
  background: rgba(0, 255, 255, 0.12);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.35);
}

.game-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  bottom: auto;
  left: auto;
  background: rgba(5, 5, 20, 0.97);
  border: 1px solid #00ffff;
  border-radius: 4px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.7),
    0 0 14px rgba(0, 255, 255, 0.25);
  padding: 4px;
  z-index: 50;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: gmDropdownIn 0.12s ease-out;
}

.game-menu-dropdown.hidden {
  display: none;
}

@keyframes gmDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gm-item {
  background: transparent;
  color: #c0c0e0;
  border: none;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  text-align: left;
  transition: all 0.12s;
  letter-spacing: 0.3px;
}

.gm-item:hover {
  background: rgba(0, 255, 255, 0.15);
  color: #00ffff;
  padding-left: 16px;
}

.gm-item.gm-warn:hover {
  background: rgba(255, 170, 68, 0.18);
  color: #ffaa44;
}

.gm-item.gm-danger:hover {
  background: rgba(255, 102, 102, 0.18);
  color: #ff6666;
}

.gm-divider {
  height: 1px;
  background: #2a2a5a;
  margin: 4px 0;
}
/* ── Game-menu audio section ─────────────────────────────────────────── */
#gm-audio-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.gm-audio-header {
  font-size: 9px;
  font-weight: bold;
  color: #ffcc44;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 6px 12px 4px;
  opacity: 0.85;
}
.gm-mute-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: #c0c0e0;
  border: none;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  text-align: left;
  transition: all 0.12s;
  letter-spacing: 0.3px;
}
.gm-mute-item:hover {
  background: rgba(0, 255, 255, 0.15);
  color: #00ffff;
  padding-left: 16px;
}
.gm-mute-icon {
  font-size: 15px;
  line-height: 1;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.gm-mute-item:hover .gm-mute-icon {
  transform: scale(1.15);
}
.gm-mute-label {
  flex: 1;
}
.gm-mute-hint {
  display: inline-block;
  background: #1a1a3a;
  color: #00ffff;
  border: 1px solid #4040a0;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: bold;
  min-width: 16px;
  text-align: center;
  font-family: inherit;
  opacity: 0.75;
}
.gm-mute-item.gm-muted {
  color: #ff8888;
}
.gm-mute-item.gm-muted .gm-mute-hint {
  color: #ff8888;
  border-color: #ff8888;
}
.gm-mute-item.gm-muted:hover {
  background: rgba(255, 136, 136, 0.15);
  color: #ffaaaa;
}
/* Volume slider row */
.gm-volume-item {
  padding: 6px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: default;
  transition: opacity 0.15s;
}
.gm-volume-item.gm-volume-dim {
  opacity: 0.45;
}
.gm-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #c0c0e0;
  letter-spacing: 0.3px;
}
.gm-volume-icon {
  font-size: 14px;
  line-height: 1;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.gm-volume-text {
  flex: 1;
}
.gm-volume-value {
  color: #00ffff;
  font-weight: bold;
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  background: rgba(0, 0, 16, 0.5);
  border: 1px solid #2a2a5a;
  border-radius: 3px;
  padding: 1px 6px;
}
/* Custom-styled slider with gradient fill */
.gm-volume-slider {
  --gm-vol-pct: 35%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(
    to right,
    #00ffff 0%,
    #00ffff var(--gm-vol-pct),
    #1a1a3a var(--gm-vol-pct),
    #1a1a3a 100%
  );
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.gm-volume-slider:hover {
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}
.gm-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00ffff;
  border: 2px solid #050514;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.6);
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}
.gm-volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.9);
}
.gm-volume-slider::-webkit-slider-thumb:active {
  transform: scale(1.1);
  background: #ffffff;
}
.gm-volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #00ffff;
  border: 2px solid #050514;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.6);
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}
.gm-volume-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.9);
}
.gm-volume-slider:focus-visible {
  box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.4);
}

/* Hide the legacy hint label since the new widget is more compact. */
#speed-hint {
  font-size: 10px;
  color: #6080a0;
  letter-spacing: 0.5px;
}

/* Treat clear/capture as abilities (same visual weight). */

/* Legacy: kept for any code paths that style this class directly. */
.freeplay-ability-btn.ability-always {
  color: #00ffcc;
  border-color: #00ffcc;
}
/* Legacy free-play ability buttons are now hidden — the AbilitiesMenu
    dropup handles all UI. Stub buttons remain in the DOM only so that
    keyboard hotkeys, cheats, and existing wiring continue to work. */
#abilities-legacy-buttons {
  display: none !important;
}

#speed-label {
  min-width: 80px;
  color: #00ffff;
  font-weight: bold;
}

#speed-hint {
  font-size: 11px;
  color: #8080a0;
}

/* ── Fullscreen button ─────────────────────────────────────────────────── */
#fullscreen-button {
  background: transparent;
  color: #8080c0;
  border: 1px solid #4040a0;
  padding: 4px 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  line-height: 1;
}

#fullscreen-button:hover {
  color: #00ffff;
  border-color: #00ffff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}

#step-forward-button {
  background: transparent;
  color: #ffcc44;
  border: 1px solid #ffcc44;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  font-weight: bold;
}

#step-forward-button:hover {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 10px #ffcc44;
}

#step-forward-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#step-forward-button:disabled:hover {
  background: transparent;
  color: #ffcc44;
  box-shadow: none;
}

#restart-level-button {
  background: transparent;
  color: #ffaa44;
  border: 1px solid #ffaa44;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.2s;
}

#restart-level-button:hover {
  background: #ffaa44;
  color: #000010;
  box-shadow: 0 0 10px #ffaa44;
}

/* ── Restart Level button ──────────────────────────────────────────────── */
#restart-level-button {
  background: linear-gradient(135deg, rgba(255, 136, 200, 0.15), rgba(180, 80, 255, 0.15));
  color: #ff88c8;
  border: 1px solid #ff88c8;
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.25s ease;
  font-weight: bold;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  text-shadow: 0 0 6px rgba(255, 136, 200, 0.4);
}

#restart-level-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 136, 200, 0.3), transparent);
  transition: left 0.5s ease;
}

#restart-level-button:hover {
  background: linear-gradient(135deg, #ff88c8, #b450ff);
  color: #000010;
  box-shadow:
    0 0 14px #ff88c8,
    0 0 24px rgba(180, 80, 255, 0.5);
  transform: translateY(-1px);
  text-shadow: none;
}

#restart-level-button:hover::before {
  left: 100%;
}

#restart-level-button:active {
  transform: translateY(0);
  box-shadow: 0 0 8px #ff88c8;
}

#restart-level-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: transparent;
}

#restart-level-button:disabled:hover {
  background: transparent;
  color: #ff88c8;
  box-shadow: none;
  transform: none;
}

/* ── PWA install / update banners ──────────────────────────────────────── */
#pwa-install-banner,
#pwa-update-banner,
#pwa-version-banner {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 5, 20, 0.96);
  border: 1px solid #00ffff;
  border-radius: 8px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #e0e0ff;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
  z-index: 9999;
  transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

#pwa-install-banner.pwa-banner-visible,
#pwa-update-banner.pwa-banner-visible,
#pwa-version-banner.pwa-banner-visible {
  bottom: 16px;
}
/* ── Update / version banners: extra flair ─────────────────────────── */
#pwa-update-banner,
#pwa-version-banner {
  background:
    linear-gradient(135deg, rgba(255, 204, 68, 0.12), rgba(255, 128, 255, 0.1)),
    rgba(5, 5, 20, 0.97);
  border: 1px solid #ffcc44;
  border-radius: 10px;
  padding: 12px 20px;
  gap: 14px;
  color: #ffe9a8;
  box-shadow:
    0 0 24px rgba(255, 204, 68, 0.45),
    0 0 48px rgba(255, 128, 255, 0.18),
    inset 0 0 0 1px rgba(255, 204, 68, 0.25);
  animation: pwaUpdateGlow 2.4s ease-in-out infinite;
  overflow: hidden;
  position: fixed;
}
/* Animated shimmer sweep across the update banners */
#pwa-update-banner::before,
#pwa-version-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 50%,
    transparent 100%
  );
  transform: skewX(-20deg);
  animation: pwaUpdateShimmer 3.2s ease-in-out infinite;
  pointer-events: none;
}
#pwa-update-banner .pwa-banner-text,
#pwa-version-banner .pwa-banner-text {
  color: #ffe9a8;
  font-weight: bold;
  letter-spacing: 0.6px;
  text-shadow: 0 0 6px rgba(255, 204, 68, 0.5);
  position: relative;
  z-index: 1;
}
@keyframes pwaUpdateGlow {
  0%,
  100% {
    box-shadow:
      0 0 24px rgba(255, 204, 68, 0.45),
      0 0 48px rgba(255, 128, 255, 0.18),
      inset 0 0 0 1px rgba(255, 204, 68, 0.25);
    border-color: #ffcc44;
  }
  50% {
    box-shadow:
      0 0 32px rgba(255, 204, 68, 0.65),
      0 0 64px rgba(255, 128, 255, 0.32),
      inset 0 0 0 1px rgba(255, 204, 68, 0.45);
    border-color: #ffe080;
  }
}
@keyframes pwaUpdateShimmer {
  0% {
    left: -60%;
  }
  60%,
  100% {
    left: 130%;
  }
}

.pwa-banner-icon {
  font-size: 20px;
}

.pwa-banner-text strong {
  color: #00ffff;
}

#pwa-install-btn,
#pwa-update-btn,
#pwa-version-btn {
  background: #00ffff;
  color: #000010;
  border: none;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

#pwa-install-btn:hover,
#pwa-update-btn:hover,
#pwa-version-btn:hover {
  background: #ffffff;
  box-shadow: 0 0 10px #00ffff;
}
/* Reload buttons get the gold/magenta treatment */
#pwa-update-btn,
#pwa-version-btn {
  background: linear-gradient(135deg, #ffcc44, #ff80ff);
  color: #1a0a20;
  padding: 6px 16px;
  border-radius: 4px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 11px;
  position: relative;
  z-index: 1;
  box-shadow:
    0 0 8px rgba(255, 204, 68, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}
#pwa-update-btn:hover,
#pwa-version-btn:hover {
  background: linear-gradient(135deg, #ffe080, #ffa0ff);
  transform: translateY(-1px);
  box-shadow:
    0 0 16px rgba(255, 204, 68, 0.8),
    0 0 28px rgba(255, 128, 255, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  filter: brightness(1.08);
}
#pwa-update-btn:active,
#pwa-version-btn:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

#pwa-install-dismiss,
#pwa-update-dismiss,
#pwa-version-dismiss {
  background: transparent;
  color: #8080a0;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
  position: relative;
  z-index: 1;
}

#pwa-install-dismiss:hover,
#pwa-update-dismiss:hover,
#pwa-version-dismiss:hover {
  color: #e0e0ff;
}

/* ── Network indicator ─────────────────────────────────────────────────── */
#pwa-network-indicator {
  display: none !important;
}

@keyframes offlinePulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ── Standalone / installed app tweaks ────────────────────────────────────
    When running as an installed PWA (no browser chrome), give the game
    container a bit more breathing room and hide the GitHub footer link
    since there's no browser address bar to navigate from.              */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .overlay-footer {
    display: none;
  }
}

@media (max-width: 1180px) {
  #speed-hint {
    display: none;
    /* too long for small screens */
  }
  #tool-hint {
    display: none;
    /* too long for small screens */
  }
}

/* ── Touch / mobile layout ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  #draw-tools {
    gap: 10px;
    padding: 6px 8px;
  }

  .mode-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  /* Larger tap targets for touch */
  #clear-defenses-button,
  #help-button,
  #howtoplay-ingame-button,
  #ingame-settings-button,
  #fullscreen-button {
    padding: 6px 12px;
    min-height: 36px;
  }
}

@media (max-width: 480px) {
  #overlay-content {
    padding: 24px 16px;
    max-width: 95vw;
  }

  #overlay-title {
    font-size: 32px;
  }

  #overlay-message {
    font-size: 13px;
  }

  #start-button {
    padding: 12px 28px;
    font-size: 17px;
  }
}

/* ---------- Hotkey Help Overlay ---------- */
#hotkey-help-overlay {
  z-index: 15;
}

#hotkey-help-content {
  background: rgba(5, 5, 20, 0.96);
  border: 2px solid #00ffff;
  border-radius: 8px;
  padding: 26px 36px;
  max-width: 720px;
  width: 90%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.4);
  color: #e0e0ff;
  font-family: 'Courier New', monospace;
}

#hotkey-help-content h2 {
  color: #00ffff;
  text-align: center;
  margin-bottom: 16px;
  text-shadow: 0 0 10px #00ffff;
  font-size: 24px;
}

#hotkey-help-content h3 {
  color: #ffff66;
  font-size: 14px;
  margin: 14px 0 8px;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#hotkey-help-content h3:first-child {
  margin-top: 0;
}

.hk-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.hk-col {
  min-width: 0;
}

.hk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}

.hk-row span {
  color: #c0c0d0;
  flex: 1;
}

.hk-row kbd {
  display: inline-block;
  background: #1a1a3a;
  color: #00ffff;
  border: 1px solid #4040a0;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 1px 0 #000;
}

.hk-hint {
  text-align: center;
  margin-top: 16px;
  color: #8080a0;
  font-size: 12px;
}

.hk-hint kbd {
  background: #1a1a3a;
  color: #00ffff;
  border: 1px solid #4040a0;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 11px;
}

@media (max-width: 600px) {
  .hk-grid {
    grid-template-columns: 1fr;
  }
}

#clear-defenses-button {
  background: transparent;
  color: #ff8888;
  border: 1px solid #ff8888;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

#clear-defenses-button:hover {
  background: #ff8888;
  color: #000010;
  box-shadow: 0 0 10px #ff8888;
}

#clear-defenses-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#clear-defenses-button:disabled:hover {
  background: transparent;
  color: #ff8888;
  box-shadow: none;
}

/* ---------- Pattern Capture Button ---------- */
#pattern-capture-button {
  background: transparent;
  color: #ffcc44;
  border: 1px solid #ffcc44;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  font-weight: bold;
}

#pattern-capture-button:hover {
  background: rgba(255, 204, 68, 0.15);
  box-shadow: 0 0 8px rgba(255, 204, 68, 0.4);
}

#pattern-capture-button.active {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 12px #ffcc44;
}

/* ---------- Exit to Menu Button ---------- */
#exit-to-menu-button {
  background: transparent;
  color: #ff6666;
  border: 1px solid #ff6666;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.2s;
  margin-left: auto;
}

#exit-to-menu-button:hover {
  background: #ff6666;
  color: #000010;
  box-shadow: 0 0 10px #ff6666;
}

#draw-tools {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 12px;
  background: #050514;
  border-top: 1px solid #2a2a5a;
  font-size: 12px;
  color: #e0e0ff;
  flex-wrap: wrap;
}

#draw-tools .tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

#draw-tools label {
  color: #a0a0c0;
  font-size: 11px;
}

.mode-btn {
  background: transparent;
  color: #00ffff;
  border: 1px solid #00ffff;
  padding: 3px 10px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.mode-btn:hover {
  background: rgba(0, 255, 255, 0.15);
}

.mode-btn.active {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 8px #00ffff;
}

#line-width {
  width: 80px;
  accent-color: #00ffff;
}

#line-width-label {
  min-width: 14px;
  color: #00ffff;
  font-weight: bold;
}

#line-dash,
#pattern-presets {
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 2px 4px;
  font-family: inherit;
  font-size: 11px;
  border-radius: 3px;
}
/* ── Line dash dropup widget ─────────────────────────────────────────── */
.dash-dropup-wrap {
  position: relative;
  display: inline-block;
}
.dash-dropup-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 2px 8px 2px 6px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  min-width: 80px;
  white-space: nowrap;
}
.dash-dropup-trigger:hover {
  background: rgba(0, 255, 255, 0.1);
  border-color: #00ffff;
}
.dash-dropup-wrap.open .dash-dropup-trigger {
  border-color: #00ffff;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.35);
}
.dash-dropup-arrow {
  color: #00ffff;
  font-size: 9px;
  transition: transform 0.15s;
  margin-left: auto;
}
.dash-dropup-wrap.open .dash-dropup-arrow {
  transform: rotate(180deg);
}
.dash-dropup-panel {
  position: absolute;
  /* Drop DOWN: align north edge of panel to south edge of trigger. */
  top: calc(100% + 4px);
  right: 0;
  left: auto;
  bottom: auto;
  background: rgba(5, 5, 20, 0.97);
  border: 1px solid #00ffff;
  border-radius: 4px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.6),
    0 0 10px rgba(0, 255, 255, 0.2);
  padding: 3px;
  z-index: 50;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: dashDropupIn 0.12s ease-out;
}
.dash-dropup-panel.hidden {
  display: none;
}
@keyframes dashDropupIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.dash-option {
  background: transparent;
  color: #c0c0e0;
  border: none;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  text-align: left;
  transition: all 0.1s;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.dash-option:hover {
  background: rgba(0, 255, 255, 0.15);
  color: #00ffff;
}
.dash-option.active {
  color: #00ffff;
  background: rgba(0, 255, 255, 0.1);
  font-weight: bold;
}

#pattern-editor {
  border: 1px solid #4040a0;
  background: #000010;
  cursor: pointer;
  image-rendering: pixelated;
  /* Larger interactive area in the overlay. */
  width: 360px;
  height: 360px;
  max-width: 80vmin;
  max-height: 60vh;
}

.pattern-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---------- Pattern preset row + collapsible editor ---------- */
.pattern-preset-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#pattern-editor-toggle {
  background: transparent;
  color: #00ffff;
  border: 1px solid #00ffff;
  padding: 4px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  white-space: nowrap;
  font-weight: bold;
}

#pattern-editor-toggle:hover {
  background: rgba(0, 255, 255, 0.15);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}

#pattern-editor-toggle.active {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 10px #00ffff;
}

#pattern-editor-toggle-group {
  display: flex;
  align-items: center;
}

/* ---------- Pattern Editor Overlay ---------- */
#pattern-editor-overlay {
  z-index: 13;
}

#pattern-editor-content {
  text-align: center;
  padding: 28px 36px;
  border: 2px solid #00ffff;
  background: rgba(10, 10, 30, 0.96);
  border-radius: 8px;
  max-width: 90vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.4);
  animation: editorOverlayIn 0.18s ease-out;
}
#pattern-editor-content::-webkit-scrollbar {
  width: 8px;
}
#pattern-editor-content::-webkit-scrollbar-track {
  background: #0a0a20;
}
#pattern-editor-content::-webkit-scrollbar-thumb {
  background: #00ffff;
  border-radius: 4px;
}

#pattern-editor-title {
  font-size: 28px;
  color: #00ffff;
  margin-bottom: 6px;
  text-shadow: 0 0 10px #00ffff;
  letter-spacing: 1px;
}

#pattern-editor-subtitle {
  color: #a0a0c0;
  font-size: 13px;
  margin-bottom: 18px;
  font-style: italic;
}

#pattern-editor-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.pattern-editor-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.pattern-editor-hints {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 6px 24px;
  font-size: 12px;
  color: #c0c0d0;
  justify-content: center;
}

.pattern-editor-hints kbd {
  display: inline-block;
  background: #1a1a3a;
  color: #00ffff;
  border: 1px solid #4040a0;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  min-width: 18px;
  text-align: center;
  margin-right: 6px;
}

.pattern-editor-hint-clickable {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition:
    background 0.15s,
    color 0.15s,
    transform 0.1s;
  user-select: none;
}

.pattern-editor-hint-clickable:hover {
  background: rgba(0, 255, 255, 0.12);
  color: #ffffff;
  transform: translateY(-1px);
}

.pattern-editor-hint-clickable:active {
  transform: translateY(0);
  background: rgba(0, 255, 255, 0.22);
}

.pattern-editor-hint-clickable:focus-visible {
  outline: 1px solid #00ffff;
  outline-offset: 2px;
}

.pattern-editor-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.pattern-editor-buttons button {
  padding: 8px 20px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.15s;
}

#pattern-editor-close {
  background: transparent;
  color: #00ffff;
  border: 2px solid #00ffff;
}

#pattern-editor-close:hover {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 12px #00ffff;
}

.pattern-editor-buttons #pattern-clear {
  background: transparent;
  color: #ff8888;
  border: 2px solid #ff8888;
  padding: 8px 20px;
  font-size: 14px;
}

.pattern-editor-buttons #pattern-clear:hover {
  background: #ff8888;
  color: #000010;
  box-shadow: 0 0 12px #ff8888;
}

@keyframes editorOverlayIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Editor Save/Metadata Section ---------- */
.editor-save-section {
  margin-top: 14px;
  padding: 14px;
  background: rgba(20, 20, 50, 0.6);
  border: 1px solid #4040a0;
  border-radius: 6px;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.editor-save-header {
  font-size: 13px;
  font-weight: bold;
  color: #ffcc44;
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.editor-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-bottom: 12px;
}

.editor-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #c0c0d0;
}

.editor-meta-row-wide {
  grid-column: 1 / -1;
}

.editor-meta-row span {
  min-width: 70px;
  color: #a0a0c0;
  font-size: 11px;
  text-align: right;
}

.editor-meta-row input[type='text'],
.editor-meta-row input[type='number'],
.editor-meta-row select {
  flex: 1;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
  min-width: 0;
}

.editor-meta-row input:focus,
.editor-meta-row select:focus {
  outline: none;
  border-color: #ffcc44;
  box-shadow: 0 0 4px rgba(255, 204, 68, 0.4);
}

.editor-save-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.editor-action-btn {
  background: transparent;
  color: #00ffcc;
  border: 1px solid #00ffcc;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
}

.editor-action-btn:hover {
  background: rgba(0, 255, 204, 0.15);
  box-shadow: 0 0 6px rgba(0, 255, 204, 0.4);
}

.editor-action-primary {
  background: rgba(255, 204, 68, 0.15);
  color: #ffcc44;
  border-color: #ffcc44;
}

.editor-action-primary:hover {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 10px #ffcc44;
}

.editor-save-status {
  font-size: 11px;
  font-weight: bold;
  transition: color 0.2s;
  margin-left: auto;
  text-align: right;
}

/* ---------- Editor JSON I/O Section ---------- */
.editor-json-section {
  margin-top: 10px;
  padding: 0;
  background: rgba(15, 15, 40, 0.6);
  border: 1px solid #2a2a5a;
  border-radius: 6px;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
}

.editor-json-header {
  font-size: 13px;
  font-weight: bold;
  color: #88ddff;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 1px;
}

.editor-json-toggle {
  background: transparent;
  color: #88ddff;
  border: 1px solid #88ddff;
  padding: 2px 10px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.editor-json-toggle:hover {
  background: rgba(136, 221, 255, 0.15);
}

.editor-json-body {
  padding: 0 14px 14px;
}

.editor-json-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.editor-json-textarea {
  width: 100%;
  background: #050514;
  color: #88ff88;
  border: 1px solid #4040a0;
  padding: 8px 10px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  border-radius: 4px;
  resize: vertical;
  min-height: 120px;
  box-sizing: border-box;
  line-height: 1.4;
}

.editor-json-textarea:focus {
  outline: none;
  border-color: #88ddff;
  box-shadow: 0 0 6px rgba(136, 221, 255, 0.3);
}

.editor-json-hint {
  font-size: 10px;
  color: #8080a0;
  margin: 6px 0 0;
  font-style: italic;
}

.editor-json-hint code {
  background: #050514;
  color: #ffcc44;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 9px;
}

#pattern-clear {
  background: transparent;
  color: #ff8888;
  border: 1px solid #ff8888;
  padding: 2px 8px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
}

#pattern-clear:hover {
  background: #ff8888;
  color: #000010;
}

#tool-hint {
  font-size: 10px;
  color: #8080a0;
  margin-left: auto;
  align-self: center;
}

/* ---------- Fill Pattern Swatch Grid ---------- */
.fill-pattern-picker {
  position: relative;
  display: inline-block;
}

.fill-pattern-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 3px 10px 3px 4px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  min-width: 130px;
}

.fill-pattern-trigger:hover {
  background: rgba(0, 255, 255, 0.12);
  border-color: #00ffff;
}

.fill-pattern-picker.open .fill-pattern-trigger {
  border-color: #00ffff;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

.fill-pattern-trigger-label {
  flex: 1;
  text-align: left;
  letter-spacing: 0.5px;
}

.fill-pattern-trigger-arrow {
  color: #00ffff;
  font-size: 10px;
  transition: transform 0.15s;
}

.fill-pattern-picker.open .fill-pattern-trigger-arrow {
  transform: rotate(180deg);
}

.fill-pattern-grid {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: auto;
  bottom: auto;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 4px;
  max-width: 380px;
  min-width: 320px;
  padding: 4px;
  background: rgba(5, 5, 20, 0.97);
  border: 1px solid #00ffff;
  border-radius: 4px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.6),
    0 0 12px rgba(0, 255, 255, 0.2);
}

.fill-pattern-picker:not(.open) .fill-pattern-grid {
  display: none !important;
}

.fill-pattern-picker.open .fill-pattern-grid {
  display: grid;
}

.fill-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  color: #c0c0d0;
  border: 1px solid #4040a0;
  padding: 3px 4px;
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.fill-swatch:hover {
  background: rgba(0, 255, 255, 0.12);
  border-color: #00ffff;
}

.fill-swatch.active {
  background: rgba(0, 255, 255, 0.25);
  border-color: #00ffff;
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.5);
  color: #00ffff;
}

.fill-swatch-preview {
  width: 32px;
  height: 18px;
  border: 1px solid #2a2a5a;
  background-color: #000010;
  background-size: 4px 4px;
  image-rendering: pixelated;
}

.fill-swatch-label {
  font-size: 9px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Pattern preview backgrounds — using CSS gradients to mimic fills */
.fp-solid {
  background-color: #00ff88;
}

.fp-checker {
  background-image:
    linear-gradient(45deg, #00ff88 25%, transparent 25%),
    linear-gradient(-45deg, #00ff88 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #00ff88 75%),
    linear-gradient(-45deg, transparent 75%, #00ff88 75%);
  background-size: 6px 6px;
  background-position:
    0 0,
    0 3px,
    3px -3px,
    -3px 0;
}

.fp-stripes-h {
  background-image: repeating-linear-gradient(
    0deg,
    #00ff88 0,
    #00ff88 2px,
    transparent 2px,
    transparent 4px
  );
}

.fp-stripes-v {
  background-image: repeating-linear-gradient(
    90deg,
    #00ff88 0,
    #00ff88 2px,
    transparent 2px,
    transparent 4px
  );
}

.fp-diagonal {
  background-image: repeating-linear-gradient(
    45deg,
    #00ff88 0,
    #00ff88 2px,
    transparent 2px,
    transparent 6px
  );
}

.fp-dots-sparse {
  background-image: radial-gradient(#00ff88 1px, transparent 1.5px);
  background-size: 6px 6px;
}

.fp-dots-dense {
  background-image: radial-gradient(#00ff88 1px, transparent 1.5px);
  background-size: 4px 4px;
}

.fp-grid {
  background-image:
    linear-gradient(#00ff88 1px, transparent 1px),
    linear-gradient(90deg, #00ff88 1px, transparent 1px);
  background-size: 6px 6px;
}

.fp-cross {
  background-image:
    linear-gradient(#00ff88 1px, transparent 1px),
    linear-gradient(90deg, #00ff88 1px, transparent 1px);
  background-size: 8px 8px;
}

.fp-random50 {
  background-image:
    radial-gradient(#00ff88 0.8px, transparent 1.2px),
    radial-gradient(#00ff88 0.8px, transparent 1.2px);
  background-size:
    5px 5px,
    5px 5px;
  background-position:
    0 0,
    2px 3px;
}

.fp-random25 {
  background-image: radial-gradient(#00ff88 0.8px, transparent 1.2px);
  background-size: 7px 7px;
}

/* ---------- Draw tool action group (Clear / Capture) ---------- */
.tool-group-actions {
  border-left: 1px dashed #2a2a5a;
  padding-left: 14px;
  margin-left: 4px;
}

.tool-group-actions button {
  font-size: 11px;
  padding: 4px 10px;
}

/* ---------- Abilities group ---------- */
.tool-group-abilities {
  border-left: 2px solid #ffcc44;
  padding-left: 14px;
  margin-left: 4px;
  background: rgba(255, 204, 68, 0.06);
  border-radius: 0 4px 4px 0;
  padding-right: 8px;
}

.tool-group-abilities label {
  color: #ffcc44 !important;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 10px !important;
}

.tool-group-abilities .freeplay-ability-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
}

#help-button {
  background: transparent;
  color: #00ffff;
  border: 1px solid #00ffff;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

#help-button:hover {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 10px #00ffff;
}

#guide-button {
  background: transparent;
  color: #ff80ff;
  border: 2px solid #ff80ff;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#guide-button:hover {
  background: #ff80ff;
  color: #000010;
  box-shadow: 0 0 20px #ff80ff;
}

#help-close-button,
#guide-close-button {
  background: transparent;
  color: #00ffff;
  border: 2px solid #00ffff;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#guide-close-button:hover {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 20px #00ffff;
}

#guide-content {
  text-align: left;
  padding: 30px 40px;
  border: 2px solid #ff80ff;
  background: rgba(10, 10, 30, 0.95);
  border-radius: 8px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px rgba(255, 128, 255, 0.3);
}

#guide-title,
#guide-overlay-title {
  font-size: 32px;
  color: #ff80ff;
  margin-bottom: 16px;
  text-shadow: 0 0 10px #ff80ff;
  text-align: center;
  flex-shrink: 0;
}

#guide-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 12px;
  color: #d0d0e0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.55;
}

#guide-body h1,
#guide-body h2,
#guide-body h3,
#guide-body h4 {
  color: #00ffff;
  margin: 18px 0 10px;
  text-shadow: 0 0 4px rgba(0, 255, 255, 0.4);
}

#guide-body h1 {
  font-size: 22px;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 6px;
}

#guide-body h2 {
  font-size: 18px;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 4px;
}

#guide-body h3 {
  font-size: 15px;
}

#guide-body p {
  margin: 8px 0;
}

#guide-body ul,
#guide-body ol {
  margin: 8px 0 8px 24px;
}

#guide-body li {
  margin: 3px 0;
}

#guide-body code {
  background: #050514;
  color: #00ff88;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

#guide-body pre {
  background: #050514;
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  padding: 10px 12px;
  margin: 10px 0;
  overflow-x: auto;
}

#guide-body pre code {
  background: transparent;
  color: #00ff88;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}

#guide-body strong {
  color: #ffff80;
}

#guide-body em {
  color: #ff80ff;
}

#guide-body hr {
  border: none;
  border-top: 1px dashed #2a2a5a;
  margin: 16px 0;
}

#guide-body a {
  color: #00ffff;
}

#guide-body::-webkit-scrollbar {
  width: 8px;
}

#guide-body::-webkit-scrollbar-track {
  background: #0a0a20;
}

#guide-body::-webkit-scrollbar-thumb {
  background: #ff80ff;
  border-radius: 4px;
}

.guide-buttons {
  margin-top: 16px;
  text-align: center;
  flex-shrink: 0;
}

/* ---------- How-to-Play / README Guide Overlay ---------- */
#help-overlay {
  z-index: 11;
}

#help-content {
  text-align: left;
  padding: 30px 40px;
  border: 2px solid #00ffcc;
  background: rgba(10, 10, 30, 0.95);
  border-radius: 8px;
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px rgba(0, 255, 204, 0.25);
}

#help-title,
#help-overlay-title {
  font-size: 32px;
  color: #00ffcc;
  margin-bottom: 16px;
  text-shadow: 0 0 10px #00ffcc;
  text-align: center;
  flex-shrink: 0;
}

#help-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 12px;
  color: #d0d0e0;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.55;
}

/* Reuse the same markdown typography rules for #help-body */
#help-body h1,
#help-body h2,
#help-body h3,
#help-body h4 {
  color: #00ffcc;
  margin: 18px 0 10px;
  text-shadow: 0 0 4px rgba(0, 255, 204, 0.4);
}

#help-body h1 {
  font-size: 22px;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 6px;
}

#help-body h2 {
  font-size: 18px;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 4px;
}

#help-body h3 {
  font-size: 15px;
}

#help-body p {
  margin: 8px 0;
}

#help-body ul,
#help-body ol {
  margin: 8px 0 8px 24px;
}

#help-body li {
  margin: 3px 0;
}

#help-body code {
  background: #050514;
  color: #00ffcc;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

#help-body pre {
  background: #050514;
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  padding: 10px 12px;
  margin: 10px 0;
  overflow-x: auto;
}

#help-body pre code {
  background: transparent;
  color: #00ffcc;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
}

#help-body strong {
  color: #ffff80;
}

#help-body em {
  color: #00ffcc;
}

#help-body hr {
  border: none;
  border-top: 1px dashed #2a2a5a;
  margin: 16px 0;
}

#help-body a {
  color: #00ffcc;
}

#help-body::-webkit-scrollbar {
  width: 8px;
}

#help-body::-webkit-scrollbar-track {
  background: #0a0a20;
}

#help-body::-webkit-scrollbar-thumb {
  background: #00ffcc;
  border-radius: 4px;
}

#howtoplay-button {
  background: transparent;
  color: #00ffcc;
  border: 2px solid #00ffcc;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#howtoplay-button:hover {
  background: #00ffcc;
  color: #000010;
  box-shadow: 0 0 20px #00ffcc;
}

#howtoplay-ingame-button {
  background: transparent;
  color: #00ffcc;
  border: 1px solid #00ffcc;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

#howtoplay-ingame-button:hover {
  background: #00ffcc;
  color: #000010;
  box-shadow: 0 0 10px #00ffcc;
}

/* ---------- Pattern Zoo Overlay ---------- */
#pattern-zoo-overlay {
  z-index: 12;
}

#pattern-zoo-content {
  position: relative;
  background: rgba(5, 5, 20, 0.97);
  border: 2px solid #ff80ff;
  border-radius: 8px;
  padding: 20px 24px;
  width: 95vw;
  max-width: 1400px;
  height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(255, 128, 255, 0.3);
  color: #e0e0ff;
  font-family: 'Courier New', monospace;
}

#pattern-zoo-header {
  flex-shrink: 0;
  text-align: center;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

#pattern-zoo-title {
  font-size: 28px;
  color: #ff80ff;
  text-shadow: 0 0 12px #ff80ff;
  letter-spacing: 2px;
  margin: 0 0 4px;
}

#pattern-zoo-subtitle {
  font-size: 12px;
  color: #a0a0c0;
  font-style: italic;
  margin: 0;
}

#pattern-zoo-toolbar {
  flex-shrink: 0;
  background: rgba(20, 20, 50, 0.6);
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pz-filter-row,
.pz-global-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 12px;
}

.pz-filter-row label,
.pz-global-row label {
  color: #a0a0c0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pz-select {
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
}

.pz-select:hover {
  border-color: #6060c0;
}

.pz-tool-btn {
  background: transparent;
  color: #00ffcc;
  border: 1px solid #00ffcc;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
}

.pz-tool-btn:hover {
  background: rgba(0, 255, 204, 0.15);
  box-shadow: 0 0 6px rgba(0, 255, 204, 0.4);
}

#pattern-zoo-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 4px 8px 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  align-content: start;
}

#pattern-zoo-grid::-webkit-scrollbar {
  width: 10px;
}

#pattern-zoo-grid::-webkit-scrollbar-track {
  background: #0a0a20;
}

#pattern-zoo-grid::-webkit-scrollbar-thumb {
  background: #ff80ff;
  border-radius: 5px;
}

.pz-card {
  background: rgba(15, 15, 35, 0.9);
  border: 1px solid #4040a0;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.pz-card:hover {
  border-color: #ff80ff;
  box-shadow: 0 0 14px rgba(255, 128, 255, 0.4);
  transform: translateY(-2px);
}

.pz-card-canvas-wrap {
  background: #000010;
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  padding: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.pz-card-canvas {
  width: 100%;
  height: auto;
  max-width: 160px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pz-card-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}

.pz-card-name {
  font-size: 13px;
  font-weight: bold;
  color: #ff80ff;
  text-shadow: 0 0 4px rgba(255, 128, 255, 0.4);
}

.pz-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pz-tag {
  display: inline-block;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 2px;
  background: #1a1a3a;
  color: #c0c0d0;
  border: 1px solid #2a2a5a;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pz-tag-cat {
  color: #00ffff;
  border-color: #00ffff;
}

.pz-cat-spaceship {
  color: #ffff66;
  border-color: #ffff66;
}

.pz-cat-oscillator {
  color: #00ff88;
  border-color: #00ff88;
}

.pz-cat-still_life {
  color: #88aaff;
  border-color: #88aaff;
}

.pz-cat-gun {
  color: #ff6666;
  border-color: #ff6666;
}

.pz-cat-methuselah {
  color: #ffaa44;
  border-color: #ffaa44;
}

.pz-cat-puffer {
  color: #ff80ff;
  border-color: #ff80ff;
}

.pz-cat-misc {
  color: #c0c0d0;
  border-color: #6060c0;
}

.pz-tag-period {
  color: #ffcc44;
  border-color: #ffcc44;
}

.pz-tag-dir {
  color: #00ffcc;
  border-color: #00ffcc;
}

.pz-tag-custom {
  color: #ffcc44 !important;
  border-color: #ffcc44 !important;
  background: rgba(255, 204, 68, 0.15) !important;
  font-weight: bold;
}

.pz-card-custom {
  border-color: #ffcc44;
  box-shadow: 0 0 6px rgba(255, 204, 68, 0.15);
}

.pz-card-custom:hover {
  border-color: #ffcc44;
  box-shadow: 0 0 16px rgba(255, 204, 68, 0.5);
}

.pz-card-edit {
  color: #ffcc44 !important;
  border-color: #ffcc44 !important;
}

.pz-card-edit:hover {
  background: rgba(255, 204, 68, 0.2) !important;
}

.pz-card-delete {
  color: #ff6666 !important;
  border-color: #ff6666 !important;
  max-width: 36px;
}

.pz-card-delete:hover {
  background: rgba(255, 102, 102, 0.2) !important;
}

.pz-card-size {
  color: #8080a0;
  font-size: 10px;
}

.pz-card-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pz-card-btn {
  flex: 1;
  min-width: 28px;
  background: transparent;
  color: #00ffcc;
  border: 1px solid #00ffcc;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.pz-card-btn:hover {
  background: rgba(0, 255, 204, 0.2);
}

.pz-card-place {
  color: #ffcc44 !important;
  border-color: #ffcc44 !important;
}

.pz-card-place:hover {
  background: rgba(255, 204, 68, 0.2) !important;
}

#pattern-zoo-footer {
  flex-shrink: 0;
  text-align: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2a2a5a;
}

#pattern-zoo-close-button {
  background: transparent;
  color: #ff80ff;
  border: 2px solid #ff80ff;
  padding: 8px 24px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
}

#pattern-zoo-close-button:hover {
  background: #ff80ff;
  color: #000010;
  box-shadow: 0 0 14px #ff80ff;
}

.pz-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #8080a0;
  font-style: italic;
  padding: 40px;
  font-size: 14px;
}

/* ---------- Pattern Zoo Detail View ---------- */
#pattern-zoo-detail {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 16, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 5;
  padding: 20px;
}

#pattern-zoo-detail.hidden {
  display: none;
}

#pz-detail-content {
  background: rgba(5, 5, 20, 0.97);
  border: 2px solid #00ffcc;
  border-radius: 8px;
  padding: 24px 32px;
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(0, 255, 204, 0.4);
  color: #e0e0ff;
}

#pz-detail-content::-webkit-scrollbar {
  width: 8px;
}

#pz-detail-content::-webkit-scrollbar-thumb {
  background: #00ffcc;
  border-radius: 4px;
}

#pz-detail-back {
  background: transparent;
  color: #00ffcc;
  border: 1px solid #00ffcc;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  margin-bottom: 16px;
  font-weight: bold;
  transition: all 0.15s;
}

#pz-detail-back:hover {
  background: rgba(0, 255, 204, 0.15);
  box-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.pz-detail-title {
  color: #00ffcc;
  font-size: 28px;
  text-shadow: 0 0 10px #00ffcc;
  margin: 0 0 4px;
}

.pz-detail-id {
  color: #8080a0;
  font-size: 11px;
  margin-bottom: 18px;
}

.pz-detail-id code {
  background: #050514;
  color: #ffcc44;
  padding: 1px 6px;
  border-radius: 2px;
}

.pz-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

@media (max-width: 720px) {
  .pz-detail-layout {
    grid-template-columns: 1fr;
  }
}

.pz-detail-canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#pz-detail-canvas {
  width: 100%;
  height: auto;
  max-width: 400px;
  border: 1px solid #00ffcc;
  background: #000010;
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 0 14px rgba(0, 255, 204, 0.2);
}

.pz-detail-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  font-size: 12px;
}

.pz-detail-controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #a0a0c0;
}

.pz-detail-controls input[type='range'] {
  width: 100px;
  accent-color: #00ffcc;
  vertical-align: middle;
}

.pz-detail-controls span {
  color: #00ffcc;
  font-weight: bold;
  min-width: 36px;
  display: inline-block;
}

.pz-detail-place-btn {
  color: #ffcc44 !important;
  border-color: #ffcc44 !important;
  margin-left: auto;
}

.pz-detail-place-btn:hover {
  background: rgba(255, 204, 68, 0.2) !important;
  box-shadow: 0 0 8px rgba(255, 204, 68, 0.5) !important;
}

.pz-detail-stats {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #a0a0c0;
}

.pz-detail-stats strong {
  color: #00ffcc;
}

.pz-detail-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.5;
}

.pz-detail-row {
  padding: 4px 0;
  border-bottom: 1px dotted #2a2a5a;
}

.pz-detail-row strong {
  color: #00ffcc;
  margin-right: 6px;
}

.pz-detail-row em {
  color: #8080a0;
}

.pz-detail-desc {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(20, 20, 50, 0.5);
  border-left: 3px solid #00ffcc;
  border-radius: 3px;
  font-style: italic;
  color: #c0c0d0;
  font-size: 12px;
  line-height: 1.6;
}

/* ---------- Pattern Zoo button in main menu / toolbar ---------- */
#pattern-zoo-button {
  background: transparent;
  color: #ff80ff;
  border: 2px solid #ff80ff;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#pattern-zoo-button:hover {
  background: #ff80ff;
  color: #000010;
  box-shadow: 0 0 20px #ff80ff;
}

#pattern-zoo-ingame-button {
  background: transparent;
  color: #ff80ff;
  border: 1px solid #ff80ff;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

#pattern-zoo-ingame-button:hover {
  background: #ff80ff;
  color: #000010;
  box-shadow: 0 0 10px #ff80ff;
}

/* ---------- Level Designer ---------- */
#level-designer-button {
  background: transparent;
  color: #ffcc44;
  border: 2px solid #ffcc44;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#level-designer-button:hover {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 20px #ffcc44;
}

#level-designer-ingame-button {
  background: transparent;
  color: #ffcc44;
  border: 1px solid #ffcc44;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

#level-designer-ingame-button:hover {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 10px #ffcc44;
}

#level-designer-overlay {
  z-index: 13;
}

#level-designer-content {
  background: rgba(5, 5, 20, 0.97);
  border: 2px solid #ffcc44;
  border-radius: 8px;
  padding: 20px 24px;
  width: 97vw;
  max-width: 1600px;
  height: 94vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(255, 204, 68, 0.3);
  color: #e0e0ff;
  font-family: 'Courier New', monospace;
}

#ld-header {
  flex-shrink: 0;
  text-align: center;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

#ld-title {
  font-size: 26px;
  color: #ffcc44;
  text-shadow: 0 0 12px #ffcc44;
  letter-spacing: 2px;
  margin: 0 0 4px;
}

#ld-subtitle {
  font-size: 12px;
  color: #a0a0c0;
  font-style: italic;
  margin: 0;
}

#ld-toolbar {
  flex-shrink: 0;
  background: rgba(20, 20, 50, 0.6);
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.ld-tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.ld-tool-group label {
  color: #a0a0c0;
  font-size: 11px;
}

.ld-mode-btn {
  background: transparent;
  color: #ffcc44;
  border: 1px solid #ffcc44;
  padding: 4px 10px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  font-weight: bold;
}

.ld-mode-btn:hover {
  background: rgba(255, 204, 68, 0.15);
}

.ld-mode-btn.active {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 8px #ffcc44;
}

/* ── Paint target switch (Defense vs Barrier) ──────────────── */
#ld-paint-target-group {
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.06), rgba(160, 160, 160, 0.06));
  border: 1px solid #2a2a5a;
  border-radius: 6px;
  padding: 6px 10px;
  gap: 8px;
}

#ld-paint-target-group label {
  color: #ffcc44;
  font-weight: bold;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ld-target-switch {
  display: inline-flex;
  gap: 4px;
  background: rgba(5, 5, 20, 0.6);
  border: 1px solid #2a2a5a;
  border-radius: 5px;
  padding: 3px;
  position: relative;
}

.ld-target-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: #8080a0;
  border: 1px solid transparent;
  padding: 5px 12px 5px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}

.ld-target-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.ld-target-btn:hover {
  color: #c0c0e0;
  border-color: #4040a0;
}

.ld-target-btn:hover::before {
  opacity: 0.3;
}

.ld-target-icon {
  font-size: 18px;
  line-height: 1;
  filter: grayscale(0.5);
  transition:
    filter 0.2s ease,
    transform 0.2s ease;
}

.ld-target-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  gap: 1px;
}

.ld-target-name {
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.ld-target-desc {
  font-size: 9px;
  color: #6060a0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.8;
}

/* Defense (cyan/green) active state */
.ld-target-btn[data-target='defense'].active {
  color: #00ff88;
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.18), rgba(0, 255, 200, 0.08));
  border-color: #00ff88;
  box-shadow:
    0 0 10px rgba(0, 255, 136, 0.35),
    inset 0 0 8px rgba(0, 255, 136, 0.1);
  text-shadow: 0 0 6px rgba(0, 255, 136, 0.6);
}

.ld-target-btn[data-target='defense'].active .ld-target-icon {
  filter: grayscale(0) drop-shadow(0 0 4px #00ff88);
  transform: scale(1.1);
}

.ld-target-btn[data-target='defense'].active .ld-target-desc {
  color: #00cc66;
  opacity: 1;
}

/* Barrier (gray/stone) active state */
.ld-target-btn[data-target='barrier'].active {
  color: #d0d0d0;
  background: linear-gradient(135deg, rgba(180, 180, 180, 0.22), rgba(120, 120, 120, 0.1));
  border-color: #a0a0a0;
  box-shadow:
    0 0 10px rgba(180, 180, 180, 0.3),
    inset 0 0 8px rgba(160, 160, 160, 0.15);
  text-shadow: 0 0 6px rgba(220, 220, 220, 0.5);
}

.ld-target-btn[data-target='barrier'].active .ld-target-icon {
  filter: grayscale(0) drop-shadow(0 0 4px #c0c0c0);
  transform: scale(1.1);
}

.ld-target-btn[data-target='barrier'].active .ld-target-desc {
  color: #a0a0a0;
  opacity: 1;
}
/* Enemy (red) active state */
.ld-target-btn[data-target='enemy'].active {
  color: #ff5566;
  background: linear-gradient(135deg, rgba(255, 60, 80, 0.2), rgba(255, 100, 100, 0.08));
  border-color: #ff3344;
  box-shadow:
    0 0 10px rgba(255, 60, 80, 0.4),
    inset 0 0 8px rgba(255, 60, 80, 0.12);
  text-shadow: 0 0 6px rgba(255, 80, 100, 0.6);
}
.ld-target-btn[data-target='enemy'].active .ld-target-icon {
  filter: grayscale(0) drop-shadow(0 0 4px #ff5566);
  transform: scale(1.1);
}
.ld-target-btn[data-target='enemy'].active .ld-target-desc {
  color: #ff8888;
  opacity: 1;
}
/* Fire (orange) active state */
.ld-target-btn[data-target='fire'].active {
  color: #ff8844;
  background: linear-gradient(135deg, rgba(255, 120, 40, 0.22), rgba(255, 180, 60, 0.1));
  border-color: #ff6622;
  box-shadow:
    0 0 12px rgba(255, 120, 40, 0.45),
    inset 0 0 8px rgba(255, 120, 40, 0.15);
  text-shadow: 0 0 6px rgba(255, 140, 60, 0.6);
}
.ld-target-btn[data-target='fire'].active .ld-target-icon {
  filter: grayscale(0) drop-shadow(0 0 6px #ff6622);
  transform: scale(1.1);
  animation: fireFlicker 1.4s ease-in-out infinite;
}
.ld-target-btn[data-target='fire'].active .ld-target-desc {
  color: #ffaa66;
  opacity: 1;
}
@keyframes fireFlicker {
  0%,
  100% {
    filter: grayscale(0) drop-shadow(0 0 6px #ff6622);
  }
  50% {
    filter: grayscale(0) drop-shadow(0 0 10px #ff8844);
  }
}
/* Erase (pink/red) active state */
.ld-target-btn[data-target='erase'].active {
  color: #ff88aa;
  background: linear-gradient(135deg, rgba(255, 100, 140, 0.18), rgba(255, 80, 80, 0.08));
  border-color: #ff6688;
  box-shadow:
    0 0 10px rgba(255, 100, 140, 0.35),
    inset 0 0 8px rgba(255, 100, 140, 0.12);
  text-shadow: 0 0 6px rgba(255, 120, 160, 0.6);
}
.ld-target-btn[data-target='erase'].active .ld-target-icon {
  filter: grayscale(0) drop-shadow(0 0 4px #ff88aa);
  transform: scale(1.1);
}
.ld-target-btn[data-target='erase'].active .ld-target-desc {
  color: #ffaabb;
  opacity: 1;
}

.ld-tool-group input[type='number'] {
  width: 60px;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
}

.ld-tool-group input[type='range'] {
  width: 80px;
  accent-color: #ffcc44;
}

#ld-brush-label {
  color: #ffcc44;
  font-weight: bold;
  min-width: 14px;
}

.ld-tool-group select {
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
}

.ld-btn {
  background: transparent;
  color: #00ffcc;
  border: 1px solid #00ffcc;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
}

.ld-btn:hover {
  background: rgba(0, 255, 204, 0.15);
  box-shadow: 0 0 6px rgba(0, 255, 204, 0.4);
}

.ld-btn-primary {
  background: rgba(255, 204, 68, 0.15);
  color: #ffcc44;
  border-color: #ffcc44;
}

.ld-btn-primary:hover {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 12px #ffcc44;
}

.ld-btn-danger {
  color: #ff6666;
  border-color: #ff6666;
}

.ld-btn-danger:hover {
  background: #ff6666;
  color: #000010;
}

#ld-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  min-height: 0;
}

#ld-canvas-wrap {
  background: #000010;
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  min-height: 0;
}

#ld-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
  max-width: 100%;
  max-height: 100%;
}

#ld-sidebar {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
}

#ld-sidebar::-webkit-scrollbar {
  width: 8px;
}

#ld-sidebar::-webkit-scrollbar-thumb {
  background: #ffcc44;
  border-radius: 4px;
}

.ld-section {
  background: rgba(15, 15, 35, 0.7);
  border: 1px solid #2a2a5a;
  border-radius: 4px;
  padding: 10px 12px;
}

.ld-section h3 {
  font-size: 12px;
  color: #ffcc44;
  margin: 0 0 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid #2a2a5a;
  padding-bottom: 4px;
}

.ld-section label {
  display: block;
  font-size: 11px;
  color: #c0c0d0;
  margin: 5px 0;
}

.ld-section input[type='text'],
.ld-section input[type='number'],
.ld-section textarea,
.ld-section select {
  width: 100%;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
  margin-top: 2px;
  box-sizing: border-box;
}

.ld-section textarea {
  resize: vertical;
  min-height: 50px;
}

.ld-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  margin-top: 6px;
}

.ld-checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.ld-checkboxes input[type='checkbox'] {
  accent-color: #ffcc44;
}

.ld-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.ld-stats strong {
  color: #ffcc44;
}

#ld-level-select {
  width: 100%;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 4px;
  font-family: inherit;
  font-size: 11px;
  border-radius: 3px;
  margin-bottom: 6px;
}

.ld-button-row {
  display: flex;
  gap: 6px;
}

.ld-button-row .ld-btn {
  flex: 1;
  font-size: 11px;
  padding: 4px 8px;
}

#ld-footer {
  flex-shrink: 0;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2a2a5a;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#ld-status {
  font-size: 12px;
  font-weight: bold;
  margin-left: auto;
  transition: color 0.2s;
}

@media (max-width: 900px) {
  #ld-main {
    grid-template-columns: 1fr;
  }

  #ld-sidebar {
    max-height: 300px;
  }
}

/* ---------- Level Designer Settings Tab ---------- */
#ld-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 2px solid #2a2a5a;
  padding-bottom: 6px;
}

.ld-tab {
  background: transparent;
  color: #8080c0;
  border: 1px solid #2a2a5a;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.ld-tab:hover {
  color: #c0c0e0;
  border-color: #4040a0;
  background: rgba(64, 64, 160, 0.15);
}

.ld-tab.active {
  background: rgba(255, 204, 68, 0.12);
  color: #ffcc44;
  border-color: #ffcc44;
  border-bottom-color: transparent;
  box-shadow: 0 0 8px rgba(255, 204, 68, 0.25);
}

.ld-tab-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.ld-tab-panel.active {
  display: flex;
}

#ld-tab-map {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
}

#ld-tab-map.active {
  display: flex;
}

#ld-tab-settings {
  overflow-y: auto;
  padding: 10px 4px;
}

#ld-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ld-settings-intro {
  background: rgba(20, 20, 50, 0.6);
  border-left: 3px solid #ffcc44;
  padding: 10px 14px;
  font-size: 12px;
  color: #c0c0d0;
  line-height: 1.5;
  margin: 0;
  font-style: italic;
  border-radius: 0 3px 3px 0;
}

.ld-settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#ld-settings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ld-settings-section-header {
  font-size: 11px;
  font-weight: bold;
  color: #ffcc44;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 14px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2a2a5a;
}

.ld-settings-section-header:first-child {
  margin-top: 0;
}

.ld-settings-row {
  display: grid;
  grid-template-columns: 1fr 280px 80px;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(15, 15, 35, 0.5);
  border-radius: 3px;
}

.ld-settings-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ld-settings-controls input[type='range'] {
  flex: 1;
  min-width: 60px;
  accent-color: #ffcc44;
}

.ld-settings-num {
  width: 70px;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 11px;
  border-radius: 3px;
  text-align: right;
}

.ld-settings-num:focus {
  outline: none;
  border-color: #ffcc44;
  box-shadow: 0 0 4px rgba(255, 204, 68, 0.4);
}

.ld-unlimited-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: bold;
  color: #ffcc44;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.ld-unlimited-label input[type='checkbox'] {
  accent-color: #ffcc44;
  cursor: pointer;
  width: 13px;
  height: 13px;
}

.ld-unlimited-label:hover {
  color: #ffe080;
  text-shadow: 0 0 4px rgba(255, 204, 68, 0.5);
}

.ld-settings-row:hover {
  background: rgba(20, 20, 50, 0.7);
}

.ld-settings-row label {
  color: #c0c0d0;
  font-weight: normal;
  cursor: pointer;
}

.ld-settings-row input[type='checkbox'] {
  accent-color: #ffcc44;
  vertical-align: middle;
}

.ld-settings-value {
  color: #ffcc44;
  text-align: right;
  font-weight: bold;
  font-size: 12px;
}

.ld-settings-row-check {
  grid-template-columns: 1fr;
}

.ld-settings-row-check label {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Tools panel ─────────────────────────────────────────────── */
#ld-tab-tools {
  overflow-y: auto;
  padding: 10px 4px;
}

#ld-tools-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ld-tool-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ld-tool-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(20, 20, 50, 0.6);
  border: 1px solid #2a2a5a;
  border-radius: 3px;
}

.ld-tool-toggle-row input[type='checkbox'] {
  accent-color: #ffcc44;
  cursor: pointer;
}

.ld-tool-toggle-row label {
  flex: 1;
  font-size: 12px;
  color: #e0e0ff;
  cursor: pointer;
}

.ld-pattern-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  flex-wrap: wrap;
}

.ld-pattern-controls input[type='text'] {
  flex: 1;
  min-width: 140px;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
}

.ld-pattern-allow-list {
  max-height: 380px;
  overflow-y: auto;
  background: rgba(10, 10, 30, 0.5);
  border: 1px solid #2a2a5a;
  border-radius: 3px;
  padding: 6px;
}

.ld-pattern-allow-list::-webkit-scrollbar {
  width: 8px;
}

.ld-pattern-allow-list::-webkit-scrollbar-thumb {
  background: #ffcc44;
  border-radius: 4px;
}

.ld-pattern-allow-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 2px;
}

.ld-pattern-allow-row:hover {
  background: rgba(255, 204, 68, 0.08);
}

.ld-pattern-allow-row input[type='checkbox'] {
  accent-color: #ffcc44;
  cursor: pointer;
}

.ld-pattern-allow-row label {
  flex: 1;
  font-size: 11px;
  color: #c0c0d0;
  cursor: pointer;
}

/* ── Theme panel ─────────────────────────────────────────────── */
#ld-tab-theme {
  overflow-y: auto;
  padding: 10px 4px;
}

#ld-theme-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#ld-theme-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ld-theme-row {
  display: grid;
  grid-template-columns: 1fr 28px 50px 1fr 32px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(20, 20, 50, 0.6);
  border: 1px solid #2a2a5a;
  border-radius: 3px;
  font-size: 12px;
}

.ld-theme-row label {
  color: #c0c0d0;
  cursor: pointer;
}

.ld-theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  border: 1px solid #4040a0;
  display: inline-block;
}

.ld-theme-row input[type='color'] {
  width: 100%;
  height: 24px;
  border: 1px solid #4040a0;
  background: #0a0a20;
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
}

.ld-theme-text {
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 3px 6px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  border-radius: 3px;
  min-width: 0;
}

.ld-theme-text:focus {
  outline: none;
  border-color: #ffcc44;
  box-shadow: 0 0 4px rgba(255, 204, 68, 0.4);
}

.ld-theme-clear {
  background: transparent;
  color: #ff8888;
  border: 1px solid #ff8888;
  padding: 2px 8px;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
}

.ld-theme-clear:hover {
  background: #ff8888;
  color: #000010;
}

/* ---------- Story Mode ---------- */
#story-button {
  background: transparent;
  color: #ffaa00;
  border: 2px solid #ffaa00;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#story-button:hover {
  background: #ffaa00;
  color: #000010;
  box-shadow: 0 0 20px #ffaa00;
}

.story-dialogue {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 24px;
  background: rgba(5, 5, 20, 0.92);
  border: 2px solid #00ffff;
  border-radius: 6px;
  padding: 16px 22px;
  color: #e0e0ff;
  font-family: 'Courier New', monospace;
  font-size: 15px;
  line-height: 1.5;
  box-shadow: 0 0 25px rgba(0, 255, 255, 0.4);
  z-index: 12;
  cursor: pointer;
  animation: dlgFadeIn 0.25s ease-out;
}

.story-dialogue.hidden {
  display: none;
}

.story-dlg-name {
  font-weight: bold;
  font-size: 16px;
  color: #00ffff;
  margin-bottom: 6px;
  text-shadow: 0 0 6px currentColor;
}

.story-dlg-text {
  color: inherit;
}

.story-dlg-hint {
  margin-top: 10px;
  font-size: 11px;
  color: #8080a0;
  text-align: right;
  font-style: italic;
  animation: dlgBlink 1.4s infinite;
}

@keyframes dlgFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dlgBlink {
  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

.story-banner {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5, 5, 20, 0.85);
  border: 1px solid #ffaa00;
  padding: 10px 28px;
  color: #ffaa00;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 0 10px #ffaa00;
  border-radius: 4px;
  z-index: 11;
  animation: bannerSlide 0.6s ease-out;
}

.story-banner.hidden {
  display: none;
}

@keyframes bannerSlide {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------- Story Progress Badge ---------- */
.story-progress {
  position: absolute;
  top: 50px;
  right: 12px;
  background: rgba(5, 5, 20, 0.85);
  border: 1px solid #00ffff;
  border-radius: 4px;
  padding: 8px 14px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  z-index: 9;
  min-width: 140px;
  max-width: 240px;
  pointer-events: none;
}

.story-progress.hidden {
  display: none;
}

.story-progress .sp-chap {
  font-weight: bold;
  color: inherit;
  font-size: 12px;
  margin-bottom: 4px;
}

.story-progress .sp-perks {
  font-size: 16px;
  letter-spacing: 4px;
  color: #ffcc44;
}

/* ---------- Perk Selection Overlay ---------- */
#perk-overlay {
  z-index: 14;
}

#perk-content {
  text-align: center;
  padding: 36px 40px;
  border: 2px solid #ffcc44;
  background: rgba(10, 10, 30, 0.96);
  border-radius: 8px;
  max-width: 1000px;
  width: 95%;
  box-shadow: 0 0 40px rgba(255, 204, 68, 0.3);
}

#perk-title {
  font-size: 32px;
  color: #ffcc44;
  margin-bottom: 8px;
  text-shadow: 0 0 12px #ffcc44;
  letter-spacing: 2px;
}

#perk-subtitle {
  color: #c0c0d0;
  font-size: 14px;
  margin-bottom: 24px;
}

#perk-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 0 0 16px 0;
}

.perk-card {
  background: rgba(5, 5, 20, 0.9);
  border: 2px solid #4040a0;
  border-radius: 6px;
  padding: 22px 16px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.perk-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 20px currentColor;
  background: rgba(20, 20, 50, 0.95);
}

.perk-card.perk-stat {
  color: #88ddff;
}

.perk-card.perk-pattern {
  color: #ff80ff;
}

.perk-card.perk-ability {
  color: #ffcc44;
}

.perk-icon {
  font-size: 42px;
  margin-bottom: 8px;
  line-height: 1;
  text-shadow: 0 0 12px currentColor;
}

.perk-type {
  font-size: 10px;
  color: #8080a0;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.perk-name {
  font-size: 16px;
  font-weight: bold;
  color: currentColor;
  margin-bottom: 8px;
}

.perk-desc {
  font-size: 12px;
  color: #c0c0d0;
  line-height: 1.4;
}

.perk-skip {
  margin-top: 8px;
}

#perk-skip-button {
  background: transparent;
  color: #8080a0;
  border: 1px solid #4040a0;
  padding: 6px 18px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

#perk-skip-button:hover {
  color: #c0c0d0;
  border-color: #6060c0;
}

@media (max-width: 720px) {
  #perk-cards {
    grid-template-columns: 1fr;
  }
}

/* ---------- In-Play Settings Button ---------- */
#ingame-settings-button {
  background: transparent;
  color: #ffcc88;
  border: 1px solid #ffcc88;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}

#ingame-settings-button:hover {
  background: #ffcc88;
  color: #000010;
  box-shadow: 0 0 10px #ffcc88;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 16, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.overlay.hidden {
  display: none;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ── Fullscreen safety: ensure overlays render above the fullscreen
    element and fill it correctly. The Fullscreen API only shows the
    fullscreened element and its descendants, so overlays MUST live
    inside #game-container. These rules harden that case. */
#game-container:fullscreen,
#game-container:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
}

#game-container:fullscreen .overlay,
#game-container:-webkit-full-screen .overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
}

#overlay-content,
.overlay-content {
  text-align: center;
  padding: 28px 32px;
  border: 2px solid #4040a0;
  background: rgba(10, 10, 30, 0.9);
  border-radius: 8px;
  max-width: 680px;
  width: 92vw;
}

#overlay-title {
  font-size: 38px;
  color: #00ffff;
  margin-bottom: 14px;
  text-shadow: 0 0 10px #00ffff;
  letter-spacing: 1px;
}

#overlay-message {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 18px;
}

/* ---------- Compact Tabbed Main Menu ---------- */
#menu-tabs {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 14px;
  border-bottom: 2px solid #2a2a5a;
  padding-bottom: 6px;
}

.menu-tab {
  background: transparent;
  color: #8080c0;
  border: 1px solid #2a2a5a;
  padding: 8px 22px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
  font-weight: bold;
  letter-spacing: 1px;
}

.menu-tab:hover {
  color: #c0c0e0;
  border-color: #4040a0;
  background: rgba(64, 64, 160, 0.18);
}

.menu-tab.active {
  background: rgba(0, 255, 255, 0.14);
  color: #00ffff;
  border-color: #00ffff;
  border-bottom-color: transparent;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

#menu-tab-panels {
  min-height: 200px;
}

.menu-tab-panel {
  display: none;
  animation: menuPanelFadeIn 0.18s ease-out;
}

.menu-tab-panel.active {
  display: block;
}

@keyframes menuPanelFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu-blurb {
  font-size: 14px;
  line-height: 1.6;
  color: #c0c0d0;
  margin: 0 0 18px;
  text-align: center;
}

.menu-hint {
  font-size: 12px;
  color: #8080a0;
  margin: 14px 0 0;
  text-align: center;
  font-style: italic;
}

.menu-hint strong {
  color: #00ffff;
  font-style: normal;
}

.menu-button-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.menu-primary-btn {
  background: #00ffff;
  color: #000010;
  border: none;
  padding: 14px 32px;
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  letter-spacing: 1px;
  min-width: 200px;
}

.menu-primary-btn:hover {
  background: #ffffff;
  box-shadow: 0 0 20px #00ffff;
  transform: translateY(-2px);
}

.menu-story-btn {
  background: transparent;
  color: #ffaa00;
  border: 2px solid #ffaa00;
}

.menu-story-btn:hover {
  background: #ffaa00;
  color: #000010;
  box-shadow: 0 0 20px #ffaa00;
}

.menu-secondary-btn {
  background: transparent;
  color: #00ffff;
  border: 1.5px solid #00ffff;
  padding: 8px 18px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.18s;
  letter-spacing: 0.5px;
}

.menu-secondary-btn:hover {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 12px #00ffff;
  transform: translateY(-1px);
}

#menu-level-catalog-mount {
  margin-top: 14px;
}

/* Override the catalog section styling when mounted in the library tab,
   since it no longer needs its own border (the tab provides it). */
#menu-level-catalog-mount .level-catalog-section {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

#start-button {
  background: #00ffff;
  color: #000010;
  border: none;
  padding: 15px 40px;
  font-size: 20px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
}

#start-button:hover {
  background: #ffffff;
  box-shadow: 0 0 20px #00ffff;
}

#settings-button,
#settings-back-button,
#settings-reset-button {
  background: transparent;
  color: #00ffff;
  border: 2px solid #00ffff;
  padding: 10px 24px;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  font-weight: bold;
  transition: all 0.2s;
  margin: 8px 6px 0 6px;
}

#settings-button:hover,
#settings-back-button:hover,
#settings-reset-button:hover {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 20px #00ffff;
}

#settings-list {
  text-align: left;
  margin: 20px 0;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 8px;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 180px 60px;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  font-size: 14px;
}

.setting-row-checks {
  grid-template-columns: 1fr 220px 60px;
}

.setting-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.setting-checkboxes label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.setting-checkboxes input[type='checkbox'] {
  accent-color: #00ffff;
}

.setting-select {
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  width: 100%;
}

.setting-row label {
  color: #e0e0ff;
}

.setting-row input[type='range'] {
  width: 100%;
  accent-color: #00ffff;
}

.setting-value {
  color: #00ffff;
  text-align: right;
  font-weight: bold;
}

/* Slider + unlimited checkbox side-by-side */
.setting-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.setting-slider-row input[type='range'] {
  flex: 1;
  min-width: 0;
}

.unlimited-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  font-weight: bold;
  color: #ffcc44;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.unlimited-label input[type='checkbox'] {
  accent-color: #ffcc44;
  cursor: pointer;
  width: 14px;
  height: 14px;
}

.unlimited-label:hover {
  color: #ffe080;
  text-shadow: 0 0 6px rgba(255, 204, 68, 0.6);
}

.settings-buttons {
  margin-top: 20px;
}

/* ---------- Settings Tabs ---------- */
#settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid #2a2a5a;
  padding-bottom: 8px;
}

.settings-tab {
  background: transparent;
  color: #8080c0;
  border: 1px solid #2a2a5a;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: all 0.15s;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.settings-tab:hover {
  color: #c0c0e0;
  border-color: #4040a0;
  background: rgba(64, 64, 160, 0.15);
}

.settings-tab.active {
  background: rgba(0, 255, 255, 0.12);
  color: #00ffff;
  border-color: #00ffff;
  border-bottom-color: transparent;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.25);
}

.settings-tab-panel {
  display: none;
}

.settings-tab-panel.active {
  display: block;
}

.settings-tab-desc {
  font-size: 12px;
  color: #8080a0;
  margin: 0 0 14px;
  line-height: 1.5;
  font-style: italic;
}

.setting-section-header {
  font-size: 11px;
  font-weight: bold;
  color: #ffcc44;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2a2a5a;
}

.setting-section-note {
  font-size: 10px;
  color: #8080a0;
  font-weight: normal;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- Aging Matrix Layout ---------- */
.aging-matrix {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #2a2a5a;
  border: 1px solid #4040a0;
  border-radius: 4px;
  padding: 2px;
  margin: 12px 0;
  font-size: 12px;
}

.aging-matrix-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr;
  gap: 2px;
}

.aging-matrix-header {
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.aging-matrix-cell {
  background: #0a0a20;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
}

.aging-matrix-label {
  font-weight: bold;
  color: #c0c0d0;
  font-size: 12px;
}

.aging-matrix-region-friendly {
  color: #00ff88;
  text-shadow: 0 0 6px rgba(0, 255, 136, 0.4);
  text-align: center;
  font-size: 11px;
}

.aging-matrix-region-enemy {
  color: #ff5050;
  text-shadow: 0 0 6px rgba(255, 80, 80, 0.4);
  text-align: center;
  font-size: 11px;
}

.aging-matrix-region-neutral {
  color: #ffcc44;
  text-shadow: 0 0 6px rgba(255, 204, 68, 0.4);
  text-align: center;
  font-size: 11px;
}

.aging-matrix-type-defense {
  color: #00ff88;
  font-size: 11px;
}

.aging-matrix-type-missile {
  color: #ff5050;
  font-size: 11px;
}

.aging-matrix-cell .setting-value {
  font-size: 11px;
  text-align: right;
  align-self: flex-end;
}

/* Make slider rows inside matrix cells more compact */
.aging-matrix-cell .setting-slider-row {
  gap: 4px;
}

.aging-matrix-cell .setting-slider-row input[type='range'] {
  min-width: 60px;
}

.aging-matrix-cell .unlimited-label {
  font-size: 11px;
}

.aging-matrix-cell .unlimited-label input[type='checkbox'] {
  width: 12px;
  height: 12px;
}

@media (max-width: 720px) {
  .aging-matrix-row {
    grid-template-columns: 1fr;
  }

  .aging-matrix-header {
    display: none;
  }

  .aging-matrix-cell.aging-matrix-label {
    border-top: 2px solid #4040a0;
    margin-top: 4px;
  }
}

/* ---------- Profiles & JSON I/O ---------- */
.profile-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.profile-row label {
  min-width: 140px;
  color: #a0a0c0;
  font-size: 13px;
}

.profile-row .setting-select,
.profile-input {
  flex: 1;
  min-width: 180px;
  background: #0a0a20;
  color: #e0e0ff;
  border: 1px solid #4040a0;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
}

.profile-btn {
  background: transparent;
  color: #00ffff;
  border: 1px solid #00ffff;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
  white-space: nowrap;
}

.profile-btn:hover {
  background: rgba(0, 255, 255, 0.15);
  box-shadow: 0 0 6px rgba(0, 255, 255, 0.4);
}

.profile-btn-primary {
  background: rgba(0, 255, 255, 0.2);
}

.profile-btn-primary:hover {
  background: #00ffff;
  color: #000010;
  box-shadow: 0 0 12px #00ffff;
}

.profile-btn-danger {
  color: #ff8888;
  border-color: #ff8888;
}

.profile-btn-danger:hover {
  background: #ff8888;
  color: #000010;
  box-shadow: 0 0 10px #ff8888;
}

.json-io-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.json-status {
  font-size: 12px;
  font-weight: bold;
  margin-left: auto;
  transition: color 0.2s;
}

.json-textarea {
  width: 100%;
  background: #050514;
  color: #00ff88;
  border: 1px solid #4040a0;
  padding: 10px 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  border-radius: 4px;
  resize: vertical;
  min-height: 160px;
  box-sizing: border-box;
}

.json-textarea:focus {
  outline: none;
  border-color: #00ffff;
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.3);
}

/* ---------- Settings About / GitHub ---------- */
.settings-about {
  font-size: 13px;
  color: #c0c0d0;
  line-height: 1.7;
  margin-top: 8px;
}

.settings-about p {
  margin: 6px 0;
}

.github-link-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #00ffff;
  text-decoration: none;
  font-weight: bold;
  transition:
    color 0.15s,
    text-shadow 0.15s;
}

.github-link-inline:hover {
  color: #ffffff;
  text-shadow: 0 0 8px #00ffff;
}

.github-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  vertical-align: middle;
}

/* ---------- Main Menu GitHub Footer ---------- */
.overlay-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid #2a2a5a;
}

/* ── Curated Level Catalog on Main Menu ──────────────────────────────── */
.level-catalog-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed #2a2a5a;
  text-align: left;
}

.level-catalog-heading {
  font-size: 16px;
  color: #ffcc44;
  text-shadow: 0 0 8px rgba(255, 204, 68, 0.4);
  letter-spacing: 1.5px;
  text-align: center;
  margin: 0 0 12px;
  font-weight: bold;
}

.level-catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.level-catalog-list::-webkit-scrollbar {
  width: 8px;
}

.level-catalog-list::-webkit-scrollbar-track {
  background: #0a0a20;
}

.level-catalog-list::-webkit-scrollbar-thumb {
  background: #ffcc44;
  border-radius: 4px;
}

.level-catalog-card {
  display: block;
  background: rgba(15, 15, 35, 0.85);
  border: 1px solid #4040a0;
  border-radius: 6px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  transition: all 0.18s ease;
  cursor: pointer;
}

.level-catalog-card:hover {
  border-color: #ffcc44;
  background: rgba(40, 30, 10, 0.9);
  box-shadow:
    0 0 14px rgba(255, 204, 68, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.5);
  transform: translateY(-2px);
}

.level-catalog-card:active {
  transform: translateY(0);
}

.level-catalog-name {
  font-size: 14px;
  font-weight: bold;
  color: #ffcc44;
  margin-bottom: 4px;
  text-shadow: 0 0 4px rgba(255, 204, 68, 0.3);
  letter-spacing: 0.5px;
}

.level-catalog-desc {
  font-size: 11px;
  color: #c0c0d0;
  line-height: 1.4;
  margin-bottom: 6px;
  font-style: italic;
}

.level-catalog-meta {
  font-size: 10px;
  color: #8080a0;
  letter-spacing: 0.5px;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #8080c0;
  text-decoration: none;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  transition:
    color 0.2s,
    text-shadow 0.2s;
  padding: 6px 12px;
  border: 1px solid #2a2a5a;
  border-radius: 4px;
}

.github-link:hover {
  color: #00ffff;
  border-color: #00ffff;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.15);
}

.github-link .github-icon {
  width: 18px;
  height: 18px;
}

#settings-list::-webkit-scrollbar {
  width: 8px;
}

#settings-list::-webkit-scrollbar-track {
  background: #0a0a20;
}

#settings-list::-webkit-scrollbar-thumb {
  background: #4040a0;
  border-radius: 4px;
}

.pz-tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Threshold display overlay (top-right) */
.threshold-display {
  position: absolute;
  top: 50px;
  right: 12px;
  background: rgba(10, 10, 30, 0.82);
  border: 1px solid #4040a0;
  border-radius: 4px;
  padding: 6px 10px;
  color: #e0e0ff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.threshold-display.hidden {
  display: none;
}

.threshold-row {
  display: flex;
  gap: 4px;
  align-items: baseline;
  line-height: 1.4;
}

.threshold-label {
  color: #a0a0c0;
  min-width: 70px;
}

.threshold-value {
  color: #ffffff;
  font-weight: bold;
  min-width: 28px;
  text-align: right;
}

.threshold-divider {
  color: #606080;
}

.threshold-min {
  color: #ffcc44;
  font-weight: bold;
}

.threshold-max {
  color: #ff5555;
  font-weight: bold;
}

.threshold-hint {
  color: #606080;
  font-size: 10px;
  font-style: italic;
  margin-left: 4px;
}

/* When the player is near the threshold, flash a warning */
.threshold-row.threshold-warning .threshold-value {
  color: #ff4444;
  animation: threshold-pulse 0.6s ease-in-out infinite alternate;
}

.threshold-row.threshold-safe .threshold-value {
  color: #44ff44;
}

@keyframes threshold-pulse {
  from {
    text-shadow: 0 0 4px #ff4444;
  }

  to {
    text-shadow: 0 0 12px #ff8888;
  }
}

#epilepsy-warning-body {
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  color: #d0d0e0;
  margin-bottom: 20px;
}
#epilepsy-warning-body p {
  margin: 10px 0;
}
#epilepsy-warning-body strong {
  color: #ffdd66;
}
.epilepsy-warning-tip {
  margin-top: 16px !important;
  padding: 10px 14px;
  background: rgba(0, 255, 255, 0.08);
  border-left: 3px solid #00ffff;
  border-radius: 0 4px 4px 0;
  font-size: 13px !important;
  color: #c0e0ff !important;
}
.epilepsy-warning-tip em {
  color: #00ffff;
  font-style: normal;
  font-weight: bold;
}
.epilepsy-warning-checkbox {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #c0c0d0;
  cursor: pointer;
  margin: 18px 0 20px;
  padding: 10px;
  background: rgba(64, 64, 160, 0.12);
  border-radius: 4px;
  user-select: none;
  transition: background 0.15s;
}
.epilepsy-warning-checkbox:hover {
  background: rgba(64, 64, 160, 0.22);
}
.epilepsy-warning-checkbox input[type='checkbox'] {
  accent-color: #ffaa00;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.epilepsy-warning-buttons {
  display: flex;
  justify-content: center;
}
#epilepsy-warning-accept {
  background: #ffaa00;
  color: #000010;
  border: none;
  padding: 14px 36px;
  font-size: 16px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 1px;
  transition: all 0.2s;
  box-shadow: 0 0 16px rgba(255, 170, 0, 0.4);
}
#epilepsy-warning-accept:hover {
  background: #ffcc44;
  box-shadow:
    0 0 24px #ffaa00,
    0 0 40px rgba(255, 170, 0, 0.5);
  transform: translateY(-1px);
}
#epilepsy-warning-accept:active {
  transform: translateY(0);
}
@keyframes epilepsyFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes epilepsyPulse {
  0%,
  100% {
    text-shadow:
      0 0 12px #ffaa00,
      0 0 24px rgba(255, 170, 0, 0.6);
  }
  50% {
    text-shadow:
      0 0 18px #ffaa00,
      0 0 36px rgba(255, 170, 0, 0.9);
  }
}
@media (max-width: 600px) {
  #epilepsy-warning-content {
    padding: 24px 20px;
  }
  #epilepsy-warning-title {
    font-size: 20px;
  }
  .epilepsy-warning-icon {
    font-size: 48px;
  }
  #epilepsy-warning-body {
    font-size: 13px;
  }
}

/* ── Abilities dropup menu ─────────────────────────────────────────── */
.abilities-menu-wrap {
  position: relative;
  display: inline-block;
}

.abilities-menu-btn {
  background: transparent;
  color: #ffcc44;
  border: 1px solid #ffcc44;
  padding: 4px 10px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
  letter-spacing: 0.5px;
}

.abilities-menu-btn:hover,
.abilities-menu-btn.active {
  background: rgba(255, 204, 68, 0.15);
  box-shadow: 0 0 8px rgba(255, 204, 68, 0.4);
}

.abilities-menu-dropup {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  bottom: auto;
  left: auto;
  background: rgba(5, 5, 20, 0.97);
  border: 1px solid #ffcc44;
  border-radius: 4px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.7),
    0 0 14px rgba(255, 204, 68, 0.25);
  padding: 4px;
  z-index: 50;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: abilitiesDropupIn 0.14s ease-out;
}

.abilities-menu-dropup.hidden {
  display: none;
}

@keyframes abilitiesDropupIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ability-menu-item {
  background: transparent;
  color: #ffcc44;
  border: 1px solid transparent;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  text-align: left;
  transition: all 0.12s;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ability-menu-item:hover:not(:disabled) {
  background: rgba(255, 204, 68, 0.18);
  color: #ffe080;
  padding-left: 16px;
}

.ability-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ability-menu-item.ability-always {
  color: #00ffcc;
}

.ability-menu-item.ability-always:hover:not(:disabled) {
  background: rgba(0, 255, 204, 0.18);
  color: #66ffe0;
}

.ability-menu-icon {
  flex-shrink: 0;
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.ability-menu-label {
  flex: 1;
}

.ability-menu-cd {
  font-size: 10px;
  color: #ff8888;
  font-weight: bold;
}

.ability-menu-divider {
  height: 1px;
  background: #2a2a5a;
  margin: 4px 2px;
}

/* Quick-access "last used" ability button */
.ability-quick-btn {
  background: linear-gradient(135deg, rgba(255, 204, 68, 0.18), rgba(255, 170, 0, 0.1));
  color: #ffcc44;
  border: 1px solid #ffcc44;
  padding: 4px 10px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  font-weight: bold;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
}

.ability-quick-btn:hover:not(:disabled) {
  background: #ffcc44;
  color: #000010;
  box-shadow: 0 0 10px #ffcc44;
}

.ability-quick-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ability-quick-icon {
  font-size: 14px;
  line-height: 1;
}

.ability-quick-label {
  font-size: 11px;
}

/* Wrapper to hold the canvas centered in the remaining flex space.
    Since we can't add HTML easily, we make the canvas's flex-basis 0
    and rely on margin:auto for centering. The canvas's intrinsic
    width/height (set in JS) act as min sizes. */
#game-container > #game-canvas {
  /* Canvas centering handled by margin:auto on #game-canvas above */
}
/* ── Draw mode dropdown selector ─────────────────────────────────────── */
.mode-dropdown-wrap {
  position: relative;
  display: inline-block;
}
.mode-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.08), rgba(0, 200, 255, 0.04));
  color: #00ffff;
  border: 1px solid #00ffff;
  padding: 4px 10px 4px 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
  min-width: 130px;
  white-space: nowrap;
  font-weight: bold;
}
.mode-dropdown-trigger:hover {
  background: rgba(0, 255, 255, 0.18);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}
.mode-dropdown-wrap.open .mode-dropdown-trigger {
  background: rgba(0, 255, 255, 0.22);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}
.mode-dropdown-icon {
  font-size: 14px;
  line-height: 1;
}
#mode-dropdown-label {
  flex: 1;
  text-align: left;
  letter-spacing: 0.5px;
}
.mode-dropdown-arrow {
  color: #00ffff;
  font-size: 10px;
  transition: transform 0.15s;
  margin-left: auto;
}
.mode-dropdown-wrap.open .mode-dropdown-arrow {
  transform: rotate(180deg);
}
.mode-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  bottom: auto;
  background: rgba(5, 5, 20, 0.97);
  border: 1px solid #00ffff;
  border-radius: 4px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.7),
    0 0 12px rgba(0, 255, 255, 0.25);
  padding: 4px;
  z-index: 50;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: modeDropdownIn 0.12s ease-out;
}
.mode-dropdown-panel.hidden {
  display: none;
}
@keyframes modeDropdownIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.mode-option {
  background: transparent;
  color: #c0c0e0;
  border: 1px solid transparent;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  text-align: left;
  transition: all 0.12s;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-option:hover {
  background: rgba(0, 255, 255, 0.15);
  color: #00ffff;
}
.mode-option.active {
  background: rgba(0, 255, 255, 0.2);
  color: #00ffff;
  border-color: #00ffff;
  box-shadow: inset 0 0 4px rgba(0, 255, 255, 0.3);
}
.mode-option-icon {
  font-size: 14px;
  line-height: 1;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.mode-option-label {
  flex: 1;
  font-weight: bold;
}
.mode-option-key {
  display: inline-block;
  background: #1a1a3a;
  color: #00ffff;
  border: 1px solid #4040a0;
  border-radius: 2px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: bold;
  min-width: 14px;
  text-align: center;
}

.pwa-banner-dont-show {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #aaa;
  cursor: pointer;
  user-select: none;
}
