/* main.css - themed CSS for LandLocked */

/* ===== FONT IMPORTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=IBM+Plex+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

/* ===== ROOT VARIABLES (Dark Hacker Terminal Theme) ===== */
:root {
  /* Color Palette — mapped from legacy variable names */
  --earth-brown: #004d66;
  --earth-brown-dark: #002a3a;
  --earth-brown-light: #0099cc;
  --parchment: #0a0a0f;
  --parchment-light: #0d1117;
  --ink: #e6edf3;
  --ink-light: #8b949e;

  /* Accent Colors */
  --accent-sky: #00d4ff;
  --accent-sand: #0099cc;
  --accent-gold: #00d4ff;

  /* Legacy colors for compatibility */
  --neutral-ink: #e6edf3;
  --shadow-wash: #8b949e;
  --sky-accent: #00d4ff;
  --accent-copper: #0099cc;
  --warning: #ffaa00;
  --success: #00ff88;
  --danger: #ff3344;
  --beige-light: #161b22;
  --beige-warm: #1c2128;
  --dark-blue-earthy: #00d4ff;
  --dark-blue-deep: #0099cc;

  /* UI Backgrounds (Dark Terminal) */
  --ui-bg: rgba(13, 17, 23, 0.96);
  --ui-bg-light: rgba(22, 27, 34, 0.92);
  --ui-bg-solid: #0d1117;

  /* Hacker Terminal Tokens */
  --neon-primary: #00d4ff;
  --neon-glow: rgba(0, 212, 255, 0.15);
  --neon-secondary: #0099cc;
  --neon-muted: #004d66;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-accent: #00d4ff;
  --text-dim: #484f58;
  --bg-primary: #0a0a0f;
  --bg-secondary: #0d1117;
  --bg-tertiary: #161b22;
  --bg-surface: #1c2128;
  --bg-overlay: rgba(10, 10, 15, 0.92);

  /* Typography */
  --font-heading: 'Share Tech Mono', 'Fira Code', 'Courier New', monospace;
  --font-body: 'IBM Plex Mono', 'Fira Code', monospace;
  --font-label: 'Inter', 'Segoe UI', sans-serif;

  /* Shadows & Effects */
  --card-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
  --card-shadow-hover: 0 20px 50px rgba(0, 0, 0, 0.5);
  --button-shadow: 0 4px 15px rgba(0, 212, 255, 0.15);
  --glow-active: 0 0 12px rgba(0, 212, 255, 0.25);
  --glow-focus: 0 0 8px rgba(0, 212, 255, 0.2);

  /* Gradients */
  --gradient-warm: linear-gradient(135deg, #004d66 0%, #002a3a 100%);
  --gradient-panel: linear-gradient(180deg, rgba(13, 17, 23, 0.96) 0%, rgba(22, 27, 34, 0.92) 100%);
  --gradient-button: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(0, 212, 255, 0.05) 100%);

  /* Layout */
  --top-bar-height: 60px;
  --context-panel-height: 290px;
  --border-radius-sm: 2px;
  --border-radius-md: 2px;
  --border-radius-lg: 4px;

  /* Transitions */
  --transition-fast: 200ms ease;
  --transition-medium: 300ms ease;

  /* Resource Colors (Neon-Tinted) */
  --resource-gold: #ffd700;
  --resource-food: #00ff88;
  --resource-wood: #cc8844;
  --resource-planks: #dda855;
  --resource-bread: #ffcc66;
  --resource-gem-ruby: #ff3344;
  --resource-gem-emerald: #00ff88;
  --resource-gem-sapphire: #3388ff;
}

/* ===== SCROLLBAR (Terminal) ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0a0a0f; }
::-webkit-scrollbar-thumb { background: #004d66; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #0099cc; }

/* ===== GLOBAL STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--parchment);
  overflow: hidden;
  /* Prevent double-tap zoom on UI elements while allowing single-tap */
  touch-action: manipulation;
  width: 100vw;
  height: 100vh;
  position: relative;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
}

h1 { font-size: 2.5rem; line-height: 1.2; }
h2 { font-size: 2rem; line-height: 1.3; }
h3 { font-size: 1.5rem; line-height: 1.4; }
h4 { font-size: 1.25rem; line-height: 1.4; }
h5 { font-size: 1.1rem; line-height: 1.5; }
h6 { font-size: 1rem; line-height: 1.5; }

body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 77, 102, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 40% 80%, rgba(0, 77, 102, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.game-interface,
#loginScreen {
  position: relative;
  z-index: 1;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #020c12 0%, #041824 50%, #020c12 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  overflow: hidden;
}

/* Auth background effects */
.auth-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 75% 25%, rgba(0, 212, 255, 0.1), transparent 50%),
    radial-gradient(circle at 25% 75%, rgba(0, 212, 255, 0.06), transparent 40%);
  pointer-events: none;
}

.auth-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    transparent,
    transparent 50%,
    rgba(0, 0, 0, 0.04) 50%,
    rgba(0, 0, 0, 0.04)
  );
  background-size: 100% 4px;
}

.auth-matrix {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.auth-matrix-col {
  position: absolute;
  top: 0;
  font-size: 11px;
  font-family: var(--font-heading);
  color: rgba(0, 212, 255, 0.07);
  writing-mode: vertical-lr;
  animation: auth-matrix-rain linear infinite;
  user-select: none;
}

@keyframes auth-matrix-rain {
  0%   { transform: translateY(-100%); opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

.login-container {
  position: relative;
  background: linear-gradient(180deg,
      rgba(13, 17, 23, 0.95) 0%,
      rgba(10, 10, 15, 0.98) 100%);
  padding: 40px;
  border-radius: 2px;
  border: 1px solid #004d66;
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
    0 4px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.game-title {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 48px;
  color: #00d4ff;
  margin-bottom: 10px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(0, 212, 255, 0.3);
}

.game-subtitle {
  font-size: 16px;
  color: rgba(230, 237, 243, 0.7);
  margin-bottom: 30px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.input-field {
  padding: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #004d66;
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 16px;
  color: #e6edf3;
  transition: all var(--transition-medium);
}

.input-field::placeholder {
  color: var(--ink-light);
}

.input-field:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.login-help {
  margin-top: 15px;
  font-size: 14px;
  color: rgba(230, 237, 243, 0.7);
}

.link {
  color: var(--accent-gold);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.link:hover {
  color: #00d4ff;
  text-decoration: underline;
}

/* Coordinate Links */
a.coordinate-link,
.coordinate-link {
  color: #00d4ff;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
}

a.coordinate-link:hover,
.coordinate-link:hover {
  color: #33dfff;
  text-decoration: underline;
}

.error-message {
  margin-top: 15px;
  color: #ff3344;
  font-size: 14px;
  min-height: 20px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ===== GAME INTERFACE ===== */
.game-interface {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ===== TOP BAR ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--top-bar-height);
  background: linear-gradient(180deg, rgba(10, 10, 15, 0.98) 0%, rgba(13, 17, 23, 0.98) 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(0, 77, 102, 0.3);
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
}

.game-title-small {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 24px;
  color: #00d4ff;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
}

.game-title-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.game-title-link:hover {
  opacity: 0.8;
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.resource-display {
  display: flex;
  gap: 12px;
}

.resource {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e6edf3;
  font-size: 16px;
  font-weight: 600;
  padding: 8px 16px;
  background: rgba(0, 77, 102, 0.15);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all var(--transition-medium);
  cursor: pointer;
}

.resource:hover {
  background: rgba(0, 77, 102, 0.3);
  border-color: rgba(0, 77, 102, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 4px 12px rgba(0, 212, 255, 0.15);
  transform: translateY(-2px);
}

.resource-icon {
  font-size: 20px;
}

.resource-tooltip {
  position: fixed;
  background: #0d1117;
  border: 1px solid var(--dark-blue-earthy);
  border-radius: 2px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  padding: 12px 14px;
  min-width: 240px;
  max-width: 320px;
  z-index: 1500;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.resource-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.resource-tooltip .tooltip-title {
  font-weight: 700;
  color: var(--dark-blue-earthy);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.resource-tooltip .tooltip-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 77, 102, 0.2);
}

.resource-tooltip .tooltip-subtitle {
  font-size: 13px;
  text-transform: uppercase;
  color: rgba(0, 212, 255, 0.8);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.resource-tooltip .tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  color: var(--dark-blue-earthy);
  padding: 4px 0;
}

.resource-tooltip .tooltip-note {
  font-size: 12px;
  color: rgba(0, 212, 255, 0.85);
  margin-top: 4px;
}

.resource-tooltip .tooltip-warning {
  margin-top: 6px;
  padding: 8px;
  border-radius: 2px;
  background: rgba(255, 51, 68, 0.1);
  border: 1px solid rgba(255, 51, 68, 0.4);
  color: #ff3344;
  font-weight: 600;
}

.resource-tooltip .tooltip-success {
  margin-top: 6px;
  padding: 8px;
  border-radius: 2px;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.4);
  color: #00ff88;
  font-weight: 600;
  text-align: center;
}

.user-email {
  color: rgba(230, 237, 243, 0.9);
  font-size: 14px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 212, 255, 0.2);
  cursor: pointer;
}

/* ===== ATTACKS INDICATOR ===== */
.attacks-container {
  position: relative;
  align-self: center;
}

.attacks-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 51, 68, 0.2);
  border: 1px solid rgba(255, 51, 68, 0.5);
  color: #e6edf3;
  padding: 8px 14px;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  height: auto;
  transition: all var(--transition-fast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.attacks-toggle:hover {
  background: rgba(255, 51, 68, 0.3);
  border-color: rgba(255, 51, 68, 0.7);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 3px 12px rgba(255, 51, 68, 0.3);
}

.attacks-toggle.attacks-idle {
  background: rgba(255, 51, 68, 0.06);
  border-color: rgba(255, 51, 68, 0.2);
  color: #484f58;
}

.attacks-toggle.attacks-idle:hover {
  background: rgba(255, 51, 68, 0.12);
  border-color: rgba(255, 51, 68, 0.3);
  color: #8b949e;
  transform: translateY(-1px);
  box-shadow: none;
}

.attacks-icon {
  font-size: 16px;
}

.attacks-count {
  background: rgba(255, 51, 68, 0.8);
  color: #e6edf3;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 2px;
  min-width: 18px;
  text-align: center;
}

.attacks-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 320px;
  max-width: 400px;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.98) 0%, rgba(10, 10, 15, 0.98) 100%);
  border: 1px solid rgba(255, 51, 68, 0.5);
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-medium);
  z-index: 1000;
  overflow: hidden;
  max-height: 400px;
}

.attacks-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.attacks-dropdown-header {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(230, 237, 243, 0.6);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 51, 68, 0.3);
}

.attacks-list {
  max-height: 350px;
  overflow-y: auto;
}

.no-attacks {
  padding: 20px;
  text-align: center;
  color: rgba(230, 237, 243, 0.5);
  font-style: italic;
  font-size: 14px;
}

.attack-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 77, 102, 0.2);
  color: #e6edf3;
  transition: background var(--transition-fast);
}

.attack-item:hover {
  background: rgba(0, 77, 102, 0.2);
}

.attack-item:last-child {
  border-bottom: none;
}

.attack-direction {
  font-size: 12px;
  font-weight: 600;
  color: rgba(230, 237, 243, 0.7);
  margin-bottom: 6px;
}

.attack-target {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #e6edf3;
}

.attack-eta {
  font-size: 12px;
  color: rgba(0, 212, 255, 0.9);
  font-weight: 600;
}

.attacks-dropdown-divider {
  height: 1px;
  background: rgba(255, 51, 68, 0.3);
  margin: 8px 0;
}

.attacks-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #e6edf3;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.attacks-dropdown-item:hover {
  background: rgba(0, 77, 102, 0.2);
}

.attacks-dropdown-item .menu-item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.attacks-dropdown-item .menu-item-text {
  flex: 1;
}

/* ===== MENU DROPDOWN ===== */
.menu-container {
  position: relative;
}

.menu-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 77, 102, 0.3);
  border: 1px solid rgba(0, 77, 102, 0.5);
  color: #e6edf3;
  padding: 8px 16px;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all var(--transition-fast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.menu-toggle:hover {
  background: rgba(0, 77, 102, 0.4);
  border-color: rgba(0, 77, 102, 0.7);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 3px 12px rgba(0, 212, 255, 0.15);
}

.menu-icon {
  font-size: 16px;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.98) 0%, rgba(10, 10, 15, 0.98) 100%);
  border: 1px solid rgba(0, 77, 102, 0.5);
  border-radius: var(--border-radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-medium);
  z-index: 1000;
  overflow: hidden;
}

.menu-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.menu-header {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(230, 237, 243, 0.6);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(0, 77, 102, 0.3);
}

.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: #e6edf3;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  border-bottom: 1px solid rgba(0, 77, 102, 0.15);
  text-decoration: none;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: rgba(0, 77, 102, 0.2);
  padding-left: 20px;
  text-decoration: none;
}

.menu-item-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.menu-item-text {
  flex: 1;
}

.menu-item-danger {
  color: #ff3344;
}

.menu-item-danger:hover {
  background: rgba(255, 51, 68, 0.15);
}

.menu-divider {
  height: 1px;
  background: rgba(0, 77, 102, 0.3);
  margin: 4px 0;
}

/* ===== CANVAS CONTAINER ===== */
.canvas-container {
  position: absolute;
  top: var(--top-bar-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--top-bar-height) - var(--context-panel-height));
  overflow: hidden;
  background: var(--earth-brown);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#gameCanvas:active {
  cursor: grabbing;
}

/* ===== TILE HOVER TOOLTIP ===== */
.tile-hover-tooltip {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(135deg, rgba(0, 77, 102, 0.95) 0%, rgba(0, 42, 58, 0.95) 100%);
  border: 1px solid rgba(0, 77, 102, 0.5);
  border-radius: 2px;
  padding: 8px 14px;
  color: #e6edf3;
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* ===== WORKER HOVER TOOLTIP ===== */
.worker-tooltip {
  position: fixed;
  background: rgba(10, 10, 15, 0.95);
  border: 1px solid #00ff88;
  border-radius: 2px;
  padding: 12px;
  pointer-events: none;
  z-index: 10000;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-family: var(--font-body);
  color: #e6edf3;
}

.worker-tooltip .tooltip-content {
  font-size: 13px;
  line-height: 1.4;
}

/* ===== UNIT HOVER TOOLTIP ===== */
.unit-tooltip {
  position: fixed;
  background: rgba(10, 10, 15, 0.95);
  border: 1px solid #004d66;
  border-radius: 2px;
  padding: 12px;
  pointer-events: none;
  z-index: 10000;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-family: var(--font-body);
  color: #e6edf3;
}

.unit-tooltip .tooltip-content {
  font-size: 13px;
  line-height: 1.4;
}

/* ===== CONTEXT PANEL ===== */
.context-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--context-panel-height);
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.95) 0%, rgba(13, 17, 23, 0.98) 100%);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(0, 77, 102, 0.3);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  padding: 0;
  z-index: 100;
  display: flex;
  overflow: hidden;
}

.minimap-container {
  width: var(--context-panel-height);
  height: var(--context-panel-height);
  background: #000;
  border-right: 1px solid rgba(0, 212, 255, 0.3);
  position: relative;
  flex-shrink: 0;
}

#minimapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.context-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 14px 4px 14px;
  overflow: hidden;
}

.context-content .tile-grid {
  flex: 1;
  min-height: 0;
}

.tile-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 0.45fr) 420px;
  gap: 8px;
  width: 100%;
  max-height: 100%;
  align-content: start;
  grid-auto-rows: 1fr;
}

.tile-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 2px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 6px 12px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow: visible;
}

#tileStatsCard {
  /* fills available space */
}

.card-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(230, 237, 243, 0.7);
}

.card-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  color: #e6edf3;
  font-size: 13px;
}

.summary-title {
  font-family: var(--font-heading);
  font-size: 16px;
  letter-spacing: 0.03em;
  color: #e6edf3;
  margin-bottom: 2px;
}

.summary-subtitle {
  color: rgba(230, 237, 243, 0.7);
  font-size: 11px;
  margin-bottom: 8px;
}

/* New styles for stacked tile details */
.tile-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  margin-bottom: 0;
  background: none;
  border: none;
}

.tile-detail-item .label {
  color: rgba(230, 237, 243, 0.6);
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 0;
}

.tile-detail-item .value {
  color: #e6edf3;
  font-weight: 600;
  font-size: 12px;
}

/* Context panel specific overrides for dark background */
.context-panel h2,
.context-panel h3,
.context-panel h4 {
  color: #e6edf3;
}

.context-panel p,
.context-panel label {
  color: rgba(230, 237, 243, 0.85);
}

.tile-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-right: 6px;
}

.stat-item {
  background: none;
  padding: 2px 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(0, 212, 255, 0.06);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  box-shadow: none;
  transition: none;
}

.stat-item:hover {
  background: none;
  border-color: rgba(0, 212, 255, 0.1);
  box-shadow: none;
}

.stat-label {
  color: var(--neon-primary);
  font-family: var(--font-heading);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
  line-height: 1;
}

.stat-value {
  color: #e6edf3 !important;
  font-size: 12px !important;
  font-weight: normal;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
  text-shadow: none;
}

.placeholder {
  color: rgba(230, 237, 243, 0.6);
  font-size: 12px;
}

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

.resource-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  border: 1px solid rgba(0, 212, 255, 0.15);
}

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

.resource-row .value {
  font-weight: 700;
  color: #e6edf3;
}

.forces-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.force-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 2px;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.force-item .label {
  color: rgba(230, 237, 243, 0.6);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.force-item .value {
  color: #e6edf3;
  font-weight: 700;
  font-size: 13px;
}

.tile-actions-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 212, 255, 0.25);
  background: linear-gradient(165deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  max-height: calc(var(--context-panel-height) - 28px);
  overflow: hidden;
}

.actions-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.actions-title {
  color: #e6edf3;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions-subtitle {
  color: rgba(230, 237, 243, 0.6);
  font-size: 12px;
  line-height: 1.2;
}

.tile-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
  gap: 10px;
  align-content: start;
  max-height: 170px;
  overflow-y: auto;
  overflow-x: visible;
  padding-right: 4px;
  padding-top: 8px;
}

.actions-card .tile-actions {
  max-height: none;
}

.tile-actions .btn {
  position: relative;
  min-height: 48px;
  max-height: 50px;
  width: 100%;
  max-width: 50px;
  aspect-ratio: 1 / 1;
  padding: 0;
  display: flex;
  overflow: visible;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
  border-radius: 2px;
  font-weight: 700;
}

.tile-actions .btn:hover:not(:disabled) {
  transform: none;
}

.tile-actions .btn:active:not(:disabled) {
  transform: none;
}

.tile-actions .btn-primary:hover:not(:disabled),
.tile-actions .btn-secondary:hover:not(:disabled) {
  transform: none;
}


.tile-actions .cost-info {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11px;
  color: var(--parchment);
  background: rgba(0, 0, 0, 0.22);
  padding: 4px 6px;
  border-radius: 2px;
  border: 1px solid rgba(0, 212, 255, 0.25);
}

.tile-actions .warning-text {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11px;
  color: var(--danger);
  font-weight: bold;
}

.tile-actions .btn[data-badge]:after {
  content: attr(data-badge);
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 2px 4px;
  border-radius: 2px;
  background: #ff3344;
  color: #e6edf3;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.neutral {
  color: #8b949e;
}

.gold-icon {
  color: #00d4ff;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  /* ===== DRAWER PANEL ===== */
  :root {
    --context-panel-height: 44px; /* collapsed — canvas-container uses this */
  }

  .context-panel {
    height: var(--context-panel-height);
    flex-direction: column;
    overflow: hidden;
    transition: height 300ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  .context-panel.panel-expanded {
    height: 55vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Show the drag handle on mobile */
  .panel-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 30px;
    min-height: 30px;
    flex-shrink: 0;
    cursor: pointer;
    touch-action: none;
    border-bottom: 1px solid rgba(0, 77, 102, 0.3);
    background: rgba(0, 0, 0, 0.2);
  }

  .panel-handle-bar {
    width: 40px;
    height: 4px;
    background: var(--neon-muted);
    border-radius: 2px;
  }

  .context-content {
    padding: 8px;
  }

  .tile-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .actions-card {
    max-width: none;
  }

  .minimap-container {
    display: none;
  }

  .tile-content {
    width: 100%;
    flex: none;
  }

  .tile-actions-panel {
    max-height: none;
  }

  .tile-actions.terminal-actions {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  /* Touch targets */
  .btn,
  .btn-small {
    min-height: 44px;
  }
}

.collection-ready {
  color: var(--success);
  font-weight: bold;
}

.collection-timer {
  color: var(--warning);
}

.warning-text {
  color: var(--warning);
  font-size: 12px;
}

.cost-info {
  color: var(--dark-blue-earthy);
  font-size: 14px;
  background: rgba(0, 77, 102, 0.1);
  padding: 8px 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 77, 102, 0.2);
}

/* ===== TERMINAL CONTEXT PANEL OVERRIDES ===== */

/* Terminal section headers */
.terminal-header {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--neon-primary);
  padding: 4px 0 6px 0;
  margin-bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.terminal-header .header-tag {
  color: var(--text-secondary);
  font-size: 12px;
}

.terminal-header .header-coords {
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 1px;
}

/* Terminal labels (key: value rows) */
.terminal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1px 0;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.6;
}

.terminal-row .t-label {
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
  min-width: 90px;
}

.terminal-row .t-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

.terminal-row .t-value.t-accent {
  color: var(--neon-primary);
}

.terminal-row .t-value.t-neutral {
  color: var(--text-secondary);
}

.terminal-row .t-value.t-you {
  color: var(--neon-primary);
}

/* Target Data two-column layout */
#tileSummary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 10px;
  align-content: start;
}

#tileSummary .t-label {
  min-width: 72px;
}

/* ASCII resource bars */
.ascii-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.4;
}

.ascii-bar-row .bar-label {
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 11px;
  min-width: 40px;
}

.ascii-bar-row .bar-track {
  flex: 1;
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 0px;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-dim);
}

.ascii-bar-row .bar-fill {
  color: var(--neon-primary);
}

.ascii-bar-row .bar-empty {
  color: var(--text-dim);
  opacity: 0.3;
}

.ascii-bar-row .bar-percent {
  color: var(--text-primary);
  font-size: 11px;
  min-width: 32px;
  text-align: right;
  font-weight: 600;
}

/* Blinking cursor */
@keyframes terminal-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.blinking-cursor {
  animation: terminal-blink 1s step-end infinite;
  color: var(--neon-primary);
  font-weight: bold;
}

/* Terminal status line */
.terminal-status-line {
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-secondary);
  padding: 4px 0 0 0;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  flex-shrink: 0;
}

/* Bracket-style action buttons */
.tile-actions.terminal-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-content: start;
  overflow-y: auto;
  padding: 1px 2px;
}

.btn-terminal {
  background: transparent;
  border: 1px solid var(--neon-muted);
  color: var(--neon-primary);
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 1.5px;
  padding: 6px 10px;
  cursor: pointer;
  text-transform: uppercase;
  white-space: nowrap;
  text-align: center;
  border-radius: 0;
  box-shadow: none;
  transition: all var(--transition-fast);
  width: 100%;
  flex-shrink: 0;
  max-width: none;
  aspect-ratio: auto;
}

.btn-terminal:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.08);
  border-color: var(--neon-primary);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
  text-shadow: 0 0 6px rgba(0, 212, 255, 0.4);
  transform: none;
}

.btn-terminal:active:not(:disabled) {
  background: rgba(0, 212, 255, 0.15);
  transform: none;
}

.btn-terminal:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: var(--text-dim);
  border-color: var(--text-dim);
}

.btn-terminal.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(255, 51, 68, 0.3);
}

.btn-terminal.btn-danger:hover:not(:disabled) {
  background: rgba(255, 51, 68, 0.08);
  border-color: var(--danger);
  box-shadow: 0 0 8px rgba(255, 51, 68, 0.2);
  text-shadow: 0 0 6px rgba(255, 51, 68, 0.4);
}

/* Minimap terminal header */
.minimap-header {
  font-family: var(--font-heading);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--neon-primary);
  padding: 4px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--neon-muted);
  flex-shrink: 0;
}

.minimap-header .header-tag {
  color: var(--text-secondary);
  font-size: 9px;
}

.minimap-status {
  font-family: var(--font-heading);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 3px 8px;
  border-top: 1px solid var(--neon-muted);
  flex-shrink: 0;
}

/* Override minimap container for terminal style */
.minimap-container {
  display: flex;
  flex-direction: column;
}

#minimapCanvas {
  flex: 1;
  min-height: 0;
}

/* Terminal tile-card overrides */
.tile-card {
  border-color: var(--neon-muted);
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 10px;
  gap: 4px;
}

/* Terminal actions card fills its grid column */
.actions-card {
  min-width: 0;
  max-width: 100%;
}

/* Terminal status annotations */
.terminal-annotation {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 1px;
  flex-shrink: 0;
  color: var(--text-dim);
  padding: 2px 0;
}

.terminal-annotation.active {
  color: var(--neon-primary);
}

.terminal-annotation.warning {
  color: var(--warning);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-primary {
  background: linear-gradient(135deg, var(--earth-brown) 0%, var(--earth-brown-dark) 100%);
  color: #e6edf3;
  border: none;
  border-radius: 2px;
  padding: 0.875rem 2rem;
  font-family: var(--font-heading);
  font-weight: 600;
  box-shadow: var(--button-shadow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 212, 255, 0.15);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--earth-brown);
  border: 1px solid var(--earth-brown);
  border-radius: 2px;
  padding: 0.75rem 2rem;
  font-family: var(--font-heading);
  font-weight: 600;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--earth-brown);
  color: #e6edf3;
  transform: translateY(-2px);
}

.btn-danger {
  background: linear-gradient(135deg, #ff3344 0%, #cc2233 100%);
  color: #e6edf3;
  border: 1px solid rgba(255, 51, 68, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(255, 51, 68, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff4455 0%, #dd3344 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(255, 51, 68, 0.3);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-large {
  padding: 14px 28px;
  font-size: 16px;
}

/* ===== CARDS & PANELS ===== */
.card, .info-card {
  background: var(--ui-bg-light);
  border: 1px solid rgba(0, 77, 102, 0.15);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-4px);
}

.panel-header {
  border-bottom: 1px solid rgba(0, 77, 102, 0.15);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.panel-header h2 {
  color: var(--earth-brown);
}

/* ===== FORMS & INPUTS ===== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--parchment-light);
  border: 1px solid rgba(0, 77, 102, 0.2);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  transition: all 0.3s ease;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--earth-brown);
  box-shadow: 0 0 0 3px rgba(0, 77, 102, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-light);
  opacity: 1;
}

label {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
  display: block;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-help-text {
  font-size: 0.875rem;
  color: var(--ink-light);
  margin-top: 0.25rem;
}

/* ===== MODALS ===== */
.modal-overlay {
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: blur(4px);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--parchment);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  border-bottom: 1px solid rgba(0, 77, 102, 0.15);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  color: var(--earth-brown);
  margin: 0;
}

.modal-body {
  color: var(--ink);
  line-height: 1.6;
}

.modal-footer {
  border-top: 1px solid rgba(0, 77, 102, 0.15);
  padding-top: 1rem;
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* ===== TABLES ===== */
table {
  width: 100%;
  background: var(--parchment-light);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border-collapse: collapse;
}

thead {
  background: var(--earth-brown);
  color: #e6edf3;
}

thead th {
  padding: 1rem;
  text-align: left;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody td {
  padding: 0.875rem 1rem;
  border-top: 1px solid rgba(0, 77, 102, 0.1);
  color: var(--ink);
}

tbody tr:nth-child(even) {
  background: rgba(0, 77, 102, 0.05);
}

tbody tr:hover {
  background: rgba(0, 77, 102, 0.1);
  transition: background 0.2s ease;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  bottom: calc(var(--context-panel-height) + 20px);
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, rgba(10, 10, 15, 0.95) 0%, rgba(13, 17, 23, 0.92) 100%);
  color: #e6edf3;
  padding: 14px 22px;
  border-radius: 2px;
  border: 1px solid rgba(0, 77, 102, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.3);
  min-width: 200px;
  opacity: 0;
  transform: translateX(400px);
  transition: all var(--transition-medium) ease-out;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.hide {
  opacity: 0;
  transform: translateX(400px);
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-info {
  border-left: 4px solid var(--accent-glow);
}

/* ===== LOADING SCREEN ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg,
      rgba(10, 10, 15, 0.98) 0%,
      rgba(13, 17, 23, 0.95) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.loading-content {
  text-align: center;
  color: #e6edf3;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(0, 77, 102, 0.2);
  border-top-color: var(--accent-gold);
  border-right-color: var(--accent-copper);
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
  margin: 0 auto 20px;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 18px;
  margin-bottom: 20px;
}

.progress-bar {
  width: 300px;
  height: 10px;
  background: rgba(0, 77, 102, 0.2);
  border: 1px solid rgba(0, 77, 102, 0.3);
  border-radius: 2px;
  overflow: hidden;
  margin: 10px auto 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg,
      var(--accent-gold) 0%,
      var(--accent-copper) 100%);
  width: 0%;
  transition: width var(--transition-medium) ease;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .top-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px;
  }

  .top-bar-left,
  .top-bar-center,
  .top-bar-right {
    flex-basis: 100%;
    justify-content: center;
  }

  .game-title-small {
    font-size: 20px;
  }

  .resource-display {
    gap: 10px;
  }

  .resource {
    font-size: 14px;
  }

  .context-panel {
    height: auto;
    min-height: 250px;
    max-height: 40vh;
    flex-direction: column;
  }

  .context-content {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 12px;
    padding: 10px;
  }

  .tile-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .minimap-container {
    display: none;
  }

  .tile-stats {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .tile-actions {
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    grid-auto-rows: 52px;
  }

  .tile-actions-panel {
    max-height: none;
  }

  .canvas-container {
    height: calc(100vh - var(--top-bar-height) - var(--context-panel-height));
  }

  .toast-container {
    bottom: calc(var(--context-panel-height) + 20px);
    right: 10px;
    left: 10px;
  }
}

/* Resource warning indicator for maintenance system */
.resource-warning {
  background-color: rgba(255, 51, 68, 0.2) !important;
  border: 1px solid #ff3344 !important;
  animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ===== UPGRADE MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.upgrade-modal {
  background: #0d1117;
  border: none;
  border-radius: 4px;
  width: 95%;
  max-width: 1100px;
  max-height: 95vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  animation: scaleIn 0.3s forwards;
}

@keyframes scaleIn {
  to {
    transform: scale(1);
  }
}

.modal-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, #004d66 0%, #002a3a 100%);
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal-header-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.modal-icon {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

.modal-header-text h2 {
  font-family: var(--font-heading);
  color: #e6edf3;
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  margin: 4px 0 0 0;
  font-weight: 400;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 24px;
  color: #e6edf3;
  cursor: pointer;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 2px;
  transition: all 0.2s;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.modal-content {
  padding: 28px 32px;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

/* Split Columns Layout */
.upgrade-cols {
  display: flex;
  flex-direction: row;
  height: 100%;
  gap: 20px;
}

.upgrade-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-right: 10px;
  /* Space for scrollbar */
}

.track-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.track-container h3 {
  font-family: var(--font-heading);
  color: var(--dark-blue-deep);
  margin-bottom: 16px;
  font-size: 18px;
  border-bottom: 1px solid rgba(0, 77, 102, 0.2);
  padding-bottom: 8px;
  text-align: center;
}

/* Vertical Track (Down to Up) */
.track {
  display: flex;
  flex-direction: column-reverse;
  /* Items added 1..N appear Bottom..Top */
  align-items: center;
  gap: 0;
  /* Gap handled by connectors */
  padding: 20px 0;
  flex: 1;
  justify-content: flex-start;
  /* Aligns content to bottom because of reverse */
}

.node {
  flex-shrink: 0;
  width: 220px;
  /* Wider for description */
  padding: 12px;
  background: rgba(22, 27, 34, 0.5);
  border: 1px solid rgba(0, 77, 102, 0.3);
  border-radius: 2px;
  text-align: center;
  position: relative;
  transition: all 0.2s ease;
  cursor: default;
  z-index: 2;
  /* Sit above connectors */
}

.node.available {
  background: #0d1117;
  border-color: var(--success);
  border-style: dashed;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 255, 136, 0.2);
}

.node.available:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 255, 136, 0.3);
  background: #161b22;
}

.node.purchased {
  background: var(--earth-brown);
  color: #e6edf3;
  border-color: var(--earth-brown-dark);
}

.node.locked {
  background: rgba(0, 0, 0, 0.05);
  /* Grayed out */
  opacity: 0.6;
  border-color: transparent;
}

.node.locked .node-title {
  color: #484f58;
}

.node-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--earth-brown-dark);
}

.node.purchased .node-title {
  color: #e6edf3;
}

.node-desc {
  font-size: 11px;
  color: #8b949e;
  line-height: 1.3;
  margin-bottom: 4px;
  font-style: italic;
}

.node.purchased .node-desc {
  color: rgba(255, 255, 255, 0.9);
}

.node-cost {
  font-size: 12px;
  font-weight: 600;
  color: var(--earth-brown-dark);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

/* Vertical Connector */
.connector-vertical {
  width: 4px;
  height: 40px;
  /* Spacing between nodes */
  background: rgba(0, 77, 102, 0.2);
  margin: 0;
  z-index: 1;
}

.connector-vertical.active {
  background: var(--earth-brown);
}

/* Branching Logic for Vertical Layout */
.branches {
  display: flex;
  flex-direction: row;
  /* Horizontal branches */
  gap: 12px;
  justify-content: center;
  padding-top: 10px;
}

.branch-node {
  width: 100px;
  /* Smaller cards for branches */
  padding: 8px;
}

.branch-node .node-title {
  font-size: 12px;
}

.node-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.branch-node .node-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.branch-node .node-desc {
  display: none;
  /* Hide desc in small cards to save space, or show tooltip? Keep simple for now */
}

/* Affordability styles */
.node.cannot-afford {
  background: rgba(0, 0, 0, 0.05);
  /* Similar to locked */
  cursor: not-allowed;
  border-color: rgba(0, 77, 102, 0.1);
  border-style: solid;
}

.node.cannot-afford .node-title {
  color: #484f58;
}

.node.cannot-afford:hover {
  transform: none;
  box-shadow: none;
  background: rgba(0, 0, 0, 0.05);
}

/* Loading state for building/upgrading */
.node.loading {
  background: linear-gradient(135deg, rgba(255, 170, 0, 0.15), rgba(255, 170, 0, 0.1));
  border-color: rgba(255, 170, 0, 0.5);
  animation: pulse-loading 1.5s ease-in-out infinite;
  cursor: wait !important;
}

.node.loading .node-icon {
  /* Animation removed - icon stays static during recruitment */
}

@keyframes pulse-loading {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 170, 0, 0.6);
  }
}

@keyframes bounce-icon {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.node-warning {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  margin-top: 4px;
}

/* ===== COURIER STATS PANEL (Right Sidebar) ===== */
.courier-stats-panel {
  position: fixed;
  top: 60px;
  right: 0;
  width: 380px;
  height: calc(100vh - 60px - 250px);
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.95) 0%, rgba(13, 17, 23, 0.98) 100%);
  backdrop-filter: blur(8px);
  border-left: 1px solid rgba(0, 77, 102, 0.3);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 99;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.courier-stats-panel .panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 77, 102, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.courier-stats-panel .panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.courier-stats-panel .panel-icon {
  font-size: 24px;
}

.courier-stats-panel .panel-title-text {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: #ffaa00;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.courier-stats-panel .panel-close-btn {
  background: none;
  border: none;
  color: rgba(230, 237, 243, 0.6);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

.courier-stats-panel .panel-close-btn:hover {
  color: #ffaa00;
}

.courier-stats-panel .panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.courier-stats-panel .panel-body-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.courier-stats-panel .panel-content::-webkit-scrollbar {
  width: 8px;
}

.courier-stats-panel .panel-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.courier-stats-panel .panel-content::-webkit-scrollbar-thumb {
  background: rgba(255, 170, 0, 0.4);
  border-radius: 4px;
}

.courier-stats-panel .panel-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 170, 0, 0.6);
}

.fleet-summary-card {
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid #ffaa00;
  border-radius: 2px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  color: rgba(230, 237, 243, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #e6edf3;
}

.stat-value.status-traveling {
  color: #ffaa00;
}

.stat-value.status-recruiting {
  color: #00d4ff;
}

.stat-value.status-idle {
  color: #00ff88;
}

.courier-cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.courier-card {
  background: rgba(0, 42, 58, 0.3);
  border: 1px solid #002a3a;
  border-radius: 2px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.courier-card:hover {
  border-color: #ffaa00;
  box-shadow: 0 4px 12px rgba(255, 170, 0, 0.2);
}

.courier-card.focused {
  border-color: #00d4ff;
  box-shadow: 0 0 16px rgba(0, 212, 255, 0.4);
}

.courier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.courier-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.courier-emoji {
  font-size: 20px;
}

.courier-name {
  font-weight: 700;
  font-size: 16px;
  color: #e6edf3;
}

.courier-status {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.courier-status.status-traveling {
  background: #ffaa00;
  color: #0a0a0f;
}

.courier-status.status-idle {
  background: #00ff88;
  color: #0a0a0f;
}

.courier-status.status-recruiting {
  background: #00d4ff;
  color: #0a0a0f;
}

/* Idle reason display */
.idle-reason-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 170, 0, 0.15);
  border: 1px solid rgba(255, 170, 0, 0.4);
  border-radius: 2px;
  margin-bottom: 8px;
}

.idle-icon {
  font-size: 16px;
}

.idle-text {
  font-size: 12px;
  color: #ffaa00;
  line-height: 1.3;
}

/* Action type colors */
.info-value.action-pickup {
  color: #00ff88;
  font-weight: 700;
}

.info-value.action-deliver {
  color: #ffaa00;
  font-weight: 700;
}

.info-value.action-none {
  color: rgba(230, 237, 243, 0.5);
  font-style: italic;
}

/* Waypoint badges in route */
.waypoint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
  margin-bottom: 4px;
}

.waypoint-pickup {
  background: rgba(0, 255, 136, 0.2);
  border: 1px solid rgba(0, 255, 136, 0.5);
  color: #00ff88;
}

.waypoint-deliver {
  background: rgba(255, 170, 0, 0.2);
  border: 1px solid rgba(255, 170, 0, 0.5);
  color: #ffaa00;
}

.waypoint-current {
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.6);
  border-color: #00d4ff !important;
  position: relative;
}

.waypoint-current::before {
  content: '▶';
  position: absolute;
  left: -12px;
  color: #00d4ff;
  font-size: 10px;
}

.courier-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.info-label {
  color: rgba(230, 237, 243, 0.7);
}

.info-value {
  color: #e6edf3;
  font-weight: 600;
}

.cargo-section {
  padding-top: 8px;
  border-top: 1px solid rgba(0, 77, 102, 0.3);
}

.cargo-header {
  font-size: 12px;
  color: rgba(230, 237, 243, 0.7);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cargo-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.cargo-fill {
  height: 100%;
  background: linear-gradient(90deg, #00ff88 0%, #ffaa00 50%, #ff3344 100%);
  transition: width 0.3s ease;
}

.cargo-items {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.cargo-item {
  font-size: 12px;
  color: #e6edf3;
  text-align: center;
  padding: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.route-section {
  padding-top: 8px;
  border-top: 1px solid rgba(0, 77, 102, 0.3);
}

.route-header {
  font-size: 12px;
  color: rgba(230, 237, 243, 0.7);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.route-waypoints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.waypoint {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 3px;
  color: #0a0a0f;
  font-weight: 600;
}

.waypoint-pickup {
  background: #00ff88;
}

.waypoint-deliver {
  background: #ffaa00;
}

.courier-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 77, 102, 0.3);
}

.courier-actions button {
  padding: 8px 12px;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-view-route {
  background: #00d4ff;
  color: #0a0a0f;
}

.btn-view-route:hover {
  background: #00d4ff;
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.4);
}

.btn-delete-courier {
  background: rgba(255, 51, 68, 0.2);
  color: #ff3344;
  border: 1px solid #ff3344;
}

.btn-delete-courier:hover {
  background: #ff3344;
  color: #0a0a0f;
  box-shadow: 0 2px 8px rgba(255, 51, 68, 0.4);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: rgba(230, 237, 243, 0.7);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: #e6edf3;
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.5;
}

.empty-hint {
  font-size: 12px;
  color: #ffaa00;
  font-weight: 600;
}

@media (max-width: 1024px) {
  .courier-stats-panel {
    width: 320px;
  }
}

@media (max-width: 768px) {
  .courier-stats-panel {
    width: 100%;
    max-width: 100vw;
  }
}

/* Courier actions button layout - 3 buttons */
.courier-actions .btn-view-route {
  grid-column: 1 / -1; /* Span full width */
}

.courier-actions .btn-edit-route {
  grid-column: 1 / 2;
}

.courier-actions .btn-delete-courier {
  grid-column: 2 / 3;
}

.btn-edit-route {
  background: #ffaa00;
  color: #0a0a0f;
}

.btn-edit-route:hover {
  background: #cc8800;
  box-shadow: 0 2px 8px rgba(255, 170, 0, 0.4);
}

/* ============================================================================
   STRUCTURE DEVELOPMENT MODAL - TERMINAL DESIGN
   ============================================================================ */

/* Modal */
.upgrade-modal-v2 {
  background: #0a0a0f;
  border: 1px solid var(--neon-primary);
  border-radius: 4px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 50px rgba(0, 212, 255, 0.1);
  overflow: hidden;
}

/* Header */
.upgrade-header {
  background: #0a0a0f;
  border-bottom: 1px solid var(--neon-primary);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

.upgrade-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 55%;
  height: 1px;
  background: linear-gradient(to right, var(--neon-primary), transparent);
  opacity: 0.5;
}

.upgrade-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.upgrade-header-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--neon-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 212, 255, 0.1);
  font-size: 20px;
  flex-shrink: 0;
  animation: icon-pulse 2s ease-in-out infinite;
}

@keyframes icon-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.upgrade-header h2 {
  color: var(--neon-primary);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px 0;
  font-family: var(--font-heading);
  letter-spacing: 0.2em;
  text-shadow: 0 0 5px rgba(0, 212, 255, 0.5), 0 0 10px rgba(0, 212, 255, 0.3);
}

.upgrade-title-coords {
  font-size: 11px;
  font-family: var(--font-heading);
  color: var(--neon-primary);
  letter-spacing: 0.12em;
  margin: 2px 0 4px;
  opacity: 0.75;
}

.upgrade-header-meta {
  display: flex;
  gap: 24px;
  font-size: 11px;
  font-family: var(--font-body);
  color: rgba(0, 212, 255, 0.6);
}

.upgrade-close {
  background: transparent;
  border: 1px solid var(--neon-primary);
  color: var(--neon-primary);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 2px;
  flex-shrink: 0;
}

.upgrade-close:hover {
  background: var(--neon-primary);
  color: #0a0a0f;
}

/* Body */
.upgrade-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--neon-primary) #0a0a0f;
}

.upgrade-body::-webkit-scrollbar { width: 6px; }
.upgrade-body::-webkit-scrollbar-track { background: #0a0a0f; border-left: 1px solid rgba(0, 212, 255, 0.2); }
.upgrade-body::-webkit-scrollbar-thumb { background: var(--neon-primary); }
.upgrade-body::-webkit-scrollbar-thumb:hover { background: var(--neon-secondary); }

/* Container */
.upgrade-container { width: 100%; }

/* Grid */
.upgrade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

/* Terminal log */
.upgrade-terminal-log {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px dashed rgba(0, 212, 255, 0.3);
  font-size: 11px;
  font-family: var(--font-body);
  color: rgba(0, 212, 255, 0.4);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Cards */
.upgrade-card {
  position: relative;
  background: rgba(2, 12, 18, 0.85);
  border: 1px solid transparent;
  padding: 20px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 190px;
  cursor: pointer;
  overflow: hidden;
}

/* ASCII corner brackets */
.ascii-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  transition: all 0.2s ease;
}

.ascii-corner.tl { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.ascii-corner.tr { top: -1px; right: -1px; border-top: 2px solid; border-right: 2px solid; }
.ascii-corner.bl { bottom: -1px; left: -1px; border-bottom: 2px solid; border-left: 2px solid; }
.ascii-corner.br { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; }

/* Cyan (available) */
.upgrade-card.theme-cyan .ascii-corner { border-color: var(--neon-primary); }
.upgrade-card.theme-cyan:hover { box-shadow: 0 0 15px rgba(0, 212, 255, 0.1); border-color: rgba(0, 212, 255, 0.2); }
.upgrade-card.theme-cyan:hover .ascii-corner { border-color: #fff; box-shadow: 0 0 8px var(--neon-primary); }
.upgrade-card.theme-cyan:hover .upgrade-card-name { color: var(--neon-primary); }

/* Green (completed) */
.upgrade-card.theme-green { background: rgba(0, 255, 136, 0.03); border-color: rgba(0, 255, 136, 0.2); }
.upgrade-card.theme-green .ascii-corner { border-color: var(--success); }

/* Red (locked) */
.upgrade-card.theme-red { background: rgba(26, 5, 5, 0.5); border-color: rgba(255, 51, 68, 0.1); }
.upgrade-card.theme-red .ascii-corner { border-color: var(--danger); opacity: 0.5; }
.upgrade-card.theme-red .upgrade-card-name { color: var(--danger); text-shadow: 0 0 5px rgba(255, 51, 68, 0.5); }

/* Hatched overlay for locked */
.upgrade-card-hatch {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: repeating-linear-gradient(
    45deg,
    var(--danger) 0, var(--danger) 1px,
    transparent 0, transparent 10px
  );
}

/* Card header (icon + badge) */
.upgrade-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.upgrade-card-icon {
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 0 5px rgba(0, 212, 255, 0.5));
}

.upgrade-card.theme-red .upgrade-card-icon { filter: grayscale(0.6); opacity: 0.7; transition: all 0.2s; }
.upgrade-card.theme-red:hover .upgrade-card-icon { filter: none; opacity: 1; }
.upgrade-card.theme-green .upgrade-card-icon { filter: drop-shadow(0 0 5px rgba(0, 255, 136, 0.5)); }

.upgrade-card-badge {
  font-size: 10px;
  font-family: var(--font-heading);
  letter-spacing: 1.5px;
  border: 1px solid var(--neon-primary);
  padding: 2px 8px;
  background: rgba(0, 212, 255, 0.05);
  color: var(--neon-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.upgrade-card-badge.badge-locked { border-color: var(--danger); color: var(--danger); font-weight: 700; background: transparent; }
.upgrade-card-badge.badge-active { border-color: var(--success); color: var(--success); }

/* Card name */
.upgrade-card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-heading);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0;
  transition: color 0.2s;
}

/* Card description */
.upgrade-card-desc {
  font-size: 12px;
  color: #4a6b6c;
  font-family: var(--font-body);
  margin: 0;
  flex: 1;
}

.upgrade-card.theme-red .upgrade-card-desc { color: rgba(255, 51, 68, 0.6); }
.upgrade-card.theme-green .upgrade-card-desc { color: rgba(0, 255, 136, 0.7); }

.capacity-delta {
  font-size: 11px;
  color: var(--success);
  font-family: var(--font-body);
  margin: 0;
}

/* Card bottom row */
.upgrade-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 212, 255, 0.2);
}

.upgrade-card.theme-red .upgrade-card-bottom { border-top-color: rgba(255, 51, 68, 0.2); }
.upgrade-card.theme-green .upgrade-card-bottom { border-top-color: rgba(0, 255, 136, 0.2); }

/* Cost */
.upgrade-card-cost {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  color: var(--text-primary);
}

/* Build/Upgrade button */
.upgrade-btn {
  background: transparent;
  border: 1px solid var(--neon-primary);
  color: var(--neon-primary);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}

.upgrade-btn:hover {
  background: var(--neon-primary);
  color: #0a0a0f;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.4);
}

.upgrade-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.upgrade-btn.danger:hover {
  background: var(--danger);
  color: #0a0a0f;
  box-shadow: 0 0 12px rgba(255, 51, 68, 0.4);
}

/* Need badge (locked state) */
.upgrade-need-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  background: rgba(255, 51, 68, 0.1);
  padding: 4px 8px;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
  animation: need-pulse 2s ease-in-out infinite;
}

@keyframes need-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Blinking terminal cursor inside buttons */
.btn-cursor {
  animation: btn-cursor-blink 1s step-end infinite;
}
@keyframes btn-cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Warning text */
.upgrade-warning {
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
  font-family: var(--font-heading);
}

/* Status complete */
.upgrade-status-complete {
  font-size: 11px;
  color: var(--success);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: var(--font-heading);
}

/* Current structure banner */
.upgrade-current {
  background: rgba(0, 212, 255, 0.05);
  border: 1px solid var(--neon-primary);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.upgrade-current-icon { font-size: 40px; }

.upgrade-current-info h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--neon-primary);
  margin: 0 0 4px 0;
  font-family: var(--font-heading);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.upgrade-current-level {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-body);
}

/* Footer */
.upgrade-footer {
  border-top: 1px solid var(--neon-primary);
  background: #0a0a0f;
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-family: var(--font-heading);
  flex-shrink: 0;
}

.upgrade-footer-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--neon-primary);
  letter-spacing: 1px;
}

.status-pulse-container {
  position: relative;
  width: 8px;
  height: 8px;
}

.status-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--neon-primary);
  opacity: 0.75;
  animation: upgrade-status-ping 1.5s ease-out infinite;
}

@keyframes upgrade-status-ping {
  0% { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(2.8); opacity: 0; }
}

.status-pulse-dot {
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: var(--neon-primary);
}

.upgrade-footer-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 212, 255, 0.3);
  padding: 6px 16px;
  background: rgba(0, 212, 255, 0.05);
  box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.05);
}

.balance-label {
  color: #4a6b6c;
  font-weight: 700;
}

.balance-amount {
  font-size: 18px;
  color: var(--text-primary);
  font-weight: 700;
}

/* ============================================================================
   TRANSFER MODAL STYLES
   ============================================================================ */

.transfer-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.transfer-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px;
  background: #161b22;
  border-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.transfer-endpoint {
  text-align: center;
}

.transfer-label {
  font-size: 12px;
  color: #8b949e;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.transfer-location {
  font-size: 16px;
  font-weight: 600;
  color: #e6edf3;
}

.transfer-arrow {
  font-size: 24px;
  color: #00d4ff;
  font-weight: bold;
}

.transfer-resources {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.resource-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #161b22;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.resource-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.resource-icon {
  font-size: 20px;
}

.resource-label {
  font-size: 14px;
  font-weight: 600;
  color: #e6edf3;
}

.resource-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.resource-available,
.resource-space {
  font-size: 12px;
  color: #8b949e;
  min-width: 80px;
}

.resource-space {
  text-align: right;
}

.resource-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.resource-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #004d66;
  background: #0d1117;
  border-radius: 2px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.resource-btn:hover {
  background: #161b22;
}

.resource-btn.max {
  width: auto;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 600;
}

.resource-input {
  width: 60px;
  height: 32px;
  border: 1px solid #004d66;
  border-radius: 2px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.resource-input:focus {
  outline: none;
  border-color: #00d4ff;
}

.transfer-actions {
  display: flex;
  justify-content: center;
}

.transfer-max-btn {
  padding: 10px 24px;
  background: #004d66;
  color: #e6edf3;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.transfer-max-btn:hover {
  background: #006680;
}

.transfer-preview {
  padding: 16px;
  background: #161b22;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  min-height: 60px;
}

.preview-empty,
.preview-loading {
  text-align: center;
  color: #8b949e;
  font-size: 14px;
}

.preview-error {
  text-align: center;
  color: #ff3344;
  font-size: 14px;
  font-weight: 600;
}

.preview-valid {
  display: flex;
  justify-content: space-around;
}

.preview-stat {
  text-align: center;
}

.preview-stat.highlight {
  color: #00d4ff;
}

.preview-label {
  font-size: 12px;
  color: #8b949e;
  display: block;
  margin-bottom: 4px;
}

.preview-value {
  font-size: 18px;
  font-weight: 700;
  color: #e6edf3;
}

.preview-stat.highlight .preview-value {
  color: #00d4ff;
}

.transfer-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

.cancel-btn,
.execute-btn {
  flex: 1;
  padding: 14px 24px;
  border-radius: 2px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cancel-btn {
  background: #161b22;
  border: 1px solid #004d66;
  color: #8b949e;
}

.cancel-btn:hover {
  background: #1c2128;
}

.execute-btn {
  background: linear-gradient(135deg, #004d66 0%, #002a3a 100%);
  border: none;
  color: #e6edf3;
}

.execute-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #006680 0%, #004d66 100%);
}

.execute-btn:disabled {
  background: #1c2128;
  cursor: not-allowed;
}

/* ============================================================================
   FORGE MODAL STYLES
   ============================================================================ */

.gem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.gem-card {
  background: #161b22;
  border: 1px solid #004d66;
  border-radius: 2px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.gem-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gem-card.selected {
  border-color: var(--success);
  background: rgba(0, 255, 136, 0.1);
  box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.2);
}

.gem-card.preview {
  border-color: #ffaa00;
  background: rgba(255, 170, 0, 0.1);
}

.gem-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 8px;
}

.gem-badge {
  display: inline-block;
  background: var(--earth-brown);
  color: #e6edf3;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 10px;
  margin-bottom: 8px;
}

.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.stat-bar {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.stat-fill {
  height: 100%;
  transition: width 0.3s;
}

.gem-recipe {
  margin-top: 8px;
  font-size: 10px;
  color: #8b949e;
  font-style: italic;
}

.cooldown-warning {
  background: rgba(255, 51, 68, 0.1);
  border: 1px solid var(--danger);
  padding: 12px;
  border-radius: 2px;
  text-align: center;
  margin-bottom: 16px;
  color: var(--danger);
  font-weight: bold;
}

.cooldown-ready {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid var(--success);
  padding: 12px;
  border-radius: 2px;
  text-align: center;
  margin-bottom: 16px;
  color: var(--success);
  font-weight: bold;
}

#mixPreview {
  margin: 20px 0;
  padding: 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

#mixActions {
  text-align: center;
}

#mixActions .btn {
  min-width: 200px;
  padding: 12px 24px;
  font-size: 16px;
}

/* ===== PANEL HANDLE (base - hidden on desktop) ===== */
.panel-handle {
  display: none;
}

/* ===== HOVER SUPPRESSION ON TOUCH DEVICES ===== */
/* Prevents hover states from sticking after a tap on iOS/Android */
@media (hover: none) {
  .resource:hover,
  .menu-item:hover,
  .btn:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ===== LANDSCAPE COMPACT MODE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --top-bar-height: 40px;
    --context-panel-height: 36px;
  }

  .top-bar {
    height: 40px;
  }
}
