@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=Manrope:wght@400;600&display=swap');

:root {
  --bg: #0b0c12;
  --panel: rgba(255, 255, 255, 0.03);
  --card: rgba(255, 255, 255, 0.06);
  --accent: #ff4d6d;
  --accent-2: #00f5a0;
  --accent-3: #2d9cf8;
  --text: #f5f7fb;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --glow: 0 14px 60px rgba(255, 77, 109, 0.35);
  --card-blur: blur(14px);
}

* { box-sizing: border-box; }
body.page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 20%, rgba(255,77,109,0.12), transparent 25%),
    radial-gradient(circle at 82% 18%, rgba(0,245,160,0.12), transparent 26%),
    radial-gradient(circle at 60% 70%, rgba(45,156,248,0.1), transparent 40%),
    linear-gradient(140deg, #090a0f 0%, #0b0c12 55%, #0c0f18 100%);
  color: var(--text);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  position: relative;
}

.noise {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(12, 13, 17, 0.8);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.brand {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
}
.brand img {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(0,0,0,0.2);
  padding: 4px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
.brand h1 {
  margin: 0;
  letter-spacing: 0.04em;
  font-family: 'Space Grotesk', 'Manrope', sans-serif;
}
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 8px;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 18px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 12px;
}
.nav a:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.container {
  width: 100%;
  margin: 0;
  padding: 0 24px 60px;
}

.layout {
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  gap: 14px;
  align-items: start;
  padding: 24px 16px 32px;
}
.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 180px;
}

/* Enhanced Desktop Menu Styles - Gaming Theme */
@media (min-width: 901px) {
  .sidebar .menu-group {
    background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), 
                inset 0 1px 0 rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar .menu-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 
                0 0 20px rgba(255,77,109,0.15),
                inset 0 1px 0 rgba(255,255,255,0.15);
    border-color: rgba(255,77,109,0.3);
  }
  
  .sidebar .menu-group.expanded {
    background: linear-gradient(145deg, rgba(255,77,109,0.08), rgba(255,255,255,0.03));
    border-color: rgba(255,77,109,0.4);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5), 
                0 0 30px rgba(255,77,109,0.2),
                inset 0 1px 0 rgba(255,255,255,0.2);
  }
  
  .menu-toggle {
    width: 100%;
    border: none;
    background: linear-gradient(135deg, rgba(255,77,109,0.15), rgba(0,245,160,0.08));
    color: var(--text);
    padding: 14px 16px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .menu-title {
    flex: 1;
  }
  
  .menu-persist-checkbox {
    display: flex;
    align-items: center;
    margin-left: 8px;
    position: relative;
  }
  
  .menu-persist-input {
    display: none;
  }
  
  .menu-persist-label {
    font-size: 12px;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s ease;
    margin-right: 10px;
    filter: grayscale(0);
    color: #ff4d6d;
    text-shadow: 0 0 6px rgba(255,77,109,0.4);
    /* Verberg de emoji */
    font-size: 0;
    width: 16px;
    height: 16px;
    display: block;
    position: relative;
  }
  
  /* Custom pin icon met CSS */
  .menu-persist-label::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: currentColor;
    border-radius: 50% 50% 50% 0;
    transform: translate(-50%, -50%) rotate(-45deg);
  }
  
  .menu-persist-label::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    z-index: 1;
  }
  
  .menu-persist-input:checked + .menu-persist-label {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.1);
    text-shadow: 0 0 8px rgba(0,245,160,0.6);
    color: #00f5a0;
  }
  
  .menu-persist-label:hover {
    opacity: 0.8;
    transform: scale(1.05);
  }
  
  .menu-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .menu-toggle:hover::before {
    opacity: 1;
  }
  
  .menu-toggle:hover {
    background: linear-gradient(135deg, rgba(255,77,109,0.25), rgba(0,245,160,0.15));
    transform: translateX(2px);
  }
  
  .menu-toggle::after {
    content: '▼';
    font-size: 10px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    margin-right: 8px;
  }
  
  .menu-toggle.expanded::after {
    transform: rotate(180deg);
  }
  
  .menu-items {
    display: none;
    flex-direction: column;
    padding: 8px 0;
    background: rgba(0,0,0,0.2);
    position: relative;
  }
  
  .menu-items::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,77,109,0.3), transparent);
  }
  
  .menu-items a {
    color: var(--muted);
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    position: relative;
    font-weight: 500;
    font-size: 13px;
    margin: 2px 8px;
    border-radius: 8px;
  }
  
  .menu-items a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
  }
  
  .menu-items a:hover {
    color: var(--text);
    background: linear-gradient(135deg, rgba(255,77,109,0.15), rgba(0,245,160,0.08));
    transform: translateX(8px);
  }
  
  .menu-items a:hover::before {
    height: 70%;
  }
  
  .menu-items a.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(255,77,109,0.25), rgba(0,245,160,0.15));
    box-shadow: 0 0 15px rgba(255,77,109,0.2);
    transform: translateX(4px);
  }
  
  .menu-items a.active::before {
    height: 70%;
    box-shadow: 0 0 10px var(--accent);
  }
  
  .menu-items.open {
    display: flex;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
}

.panel {
  margin-bottom: 20px;
  position: relative;
}
.panel.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 28px;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto 24px;
}
.eyebrow { text-transform: uppercase; color: var(--accent-2); letter-spacing: 0.12em; font-size: 12px; margin: 0; }
.lede { color: var(--muted); line-height: 1.6; color: white; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.card {
  position: relative;
  overflow: hidden;
}

.card h3 { margin-top: 0; position: relative; z-index: 1; }
.card form, .card p, .card ul { position: relative; z-index: 1; margin-top: 0px; }
.card.wide { grid-column: span 2; }

input, button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 15px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:focus { outline: 1px solid var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,77,109,0.18); }

.btn { cursor: pointer; border: none; font-weight: 700; letter-spacing: 0.02em; }
.btn.primary { background: linear-gradient(120deg, var(--accent), #ff6f91); color: #fff; box-shadow: var(--glow); }
.btn.ghost { background: linear-gradient(120deg, transparent, rgba(0,245,160,0.2)); border: 1px solid var(--accent-2); color: var(--accent-2); }
.btn:hover { transform: translateY(-1px); }

.hero-list { list-style: none; padding: 0; margin: 12px 0 0; color: white; }
.hero-list li { margin: 6px 0; }

.alert {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.alert.error { border-color: rgba(230,57,70,0.4); color: #ff9a9a; background: rgba(230,57,70,0.06); }

.chance {
  position: relative;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}
.chance .bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  opacity: 0.6;
}
.chance span {
  position: relative;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}
.toast {
  min-width: 220px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(20, 22, 30, 0.9);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast.success { border-color: rgba(0,245,160,0.4); color: #c8ffe8; }
.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}
.toast.info { border-color: rgba(45,156,248,0.4); color: #cfe6ff; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.card.stat {
  border-radius: 6px;
}
.card.stat.wide { grid-column: span 2; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}
th, td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
th { text-align: left; color: var(--muted); }
#travel-overlay {
  position: fixed;
  inset: auto 16px 16px auto;
  display: none;
  z-index: 9999;
  max-width: 320px;
  pointer-events: none;
}
#travel-overlay.visible { display: block; }

#travel-overlay .travel-overlay__card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 36px rgba(0,0,0,0.35);
  pointer-events: auto; /* als je later interactie wil */
}

#travel-overlay .travel-overlay__image {
  min-height: 120px;
  background-image: url('/assets/images/travel.png');
  background-size: cover;
  background-position: center;
}

#travel-overlay .travel-overlay__content {
  padding: 10px;
}

#travel-overlay h3 { margin: 4px 0; font-size: 16px; }
#travel-overlay p { margin: 2px 0; }
.travel-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}
#travel-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
#travel-modal.open {
  display: flex;
}
.travel-modal__card {
  position: relative;
  width: min(520px, 92vw);
  max-height: calc(100vh - 80px);
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  color: var(--text);
  display: grid;
  gap: 10px;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.travel-modal__header h3 {
  margin: 0;
  font-size: 20px;
}
.travel-modal__header p {
  margin: 4px 0 0;
  color: var(--muted);
}
.travel-modal__modes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}
.travel-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.travel-modal__actions .btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 10px;
}
.travel-mode-row {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.travel-mode-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,77,109,0.18);
}
.travel-mode-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.travel-mode-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-weight: 700;
}
.travel-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Mobile First Responsive Design */

/* Hamburger Menu Button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  z-index: 1001;
  width: 44px;
  height: 44px;
  background: rgba(12, 13, 17, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  backdrop-filter: blur(14px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mobile-menu-toggle:hover {
  background: rgba(255, 77, 109, 0.1);
  border-color: var(--accent);
}

.mobile-menu-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.mobile-menu-overlay.active {
  display: block;
}

.mobile-menu-container {
  position: fixed;
  top: 0;
  right: -100%;
  width: 85%;
  max-width: 400px;
  height: 100vh;
  background: rgba(12, 13, 17, 0.95);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  transition: right 0.3s ease;
  z-index: 1001;
  backdrop-filter: blur(20px);
}

.mobile-menu-overlay.active .mobile-menu-container {
  right: 0;
}

.mobile-menu-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text);
}

.mobile-menu-close {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: background 0.2s ease;
}

.mobile-menu-close:hover {
  background: rgba(255, 77, 109, 0.2);
}

.mobile-menu-content {
  padding: 20px 0;
}

.mobile-menu-section {
  margin-bottom: 24px;
}

.mobile-menu-section-title {
  padding: 12px 20px;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-menu-links {
  display: flex;
  flex-direction: column;
}

.mobile-menu-links a {
  padding: 16px 20px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
}

.mobile-menu-links a:hover {
  background: rgba(255, 77, 109, 0.1);
  padding-left: 24px;
}

.mobile-menu-links a.active {
  background: rgba(255, 77, 109, 0.15);
  border-left: 3px solid var(--accent);
}

/* Mobile menu icons - removed since icons are already in HTML */

/* Responsive Breakpoints */

/* Large Desktop */
@media (min-width: 1400px) {
  .layout { 
    grid-template-columns: 220px 1fr 220px; 
    max-width: 100%;
    margin: 0 auto;
  }
  .sidebar { min-width: 220px; }
}

/* Desktop */
@media (min-width: 1101px) and (max-width: 1399px) {
  .layout { grid-template-columns: 200px 1fr 200px; }
  .sidebar { min-width: 200px; }
}

/* Tablet Landscape */
@media (min-width: 901px) and (max-width: 1100px) {
  .layout { 
    grid-template-columns: 180px 1fr 180px; 
    gap: 12px;
    padding: 20px 12px 28px;
  }
  .sidebar { min-width: 180px; }
  .container { padding: 0 16px 40px; }
}

/* Tablet Portrait */
@media (min-width: 601px) and (max-width: 900px) {
  .layout { 
    grid-template-columns: 1fr; 
    gap: 16px;
    padding: 16px 12px 24px;
  }
  .sidebar { 
    position: relative; 
    top: 0; 
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .sidebar .menu-group {
    margin-bottom: 0;
  }
  .container { padding: 0 12px 32px; }
  .topbar { padding: 12px 16px; }
  .brand img { width: 40px; height: 40px; }
  .brand h1 { font-size: 20px; }
  .brand p { font-size: 12px; }
}

/* Mobile Landscape */
@media (min-width: 481px) and (max-width: 600px) {
  .layout { 
    grid-template-columns: 1fr; 
    gap: 12px;
    padding: 12px 8px 20px;
  }
  .sidebar { 
    display: none; 
  }
  .mobile-menu-toggle {
    display: flex;
    margin-top: 79px !important;
  }
  .container { padding: 0 8px 24px; }
  .topbar { 
    padding: 12px 16px 12px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .brand {
    flex: 1;
  }
  .brand img { width: 36px; height: 36px; }
  .brand h1 { font-size: 18px; }
  .brand p { font-size: 11px; }
  .card-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Special case for ALL production modules - 2 columns */
  .gunpowder-mine .card-grid,
  .gunpowder-factory .card-grid,
  .lead-mine .card-grid,
  .lead-factory .card-grid,
  .bulletfactory .card-grid,
  .gunpowdermine .card-grid,
  .gunpowderfactory .card-grid,
  .leadmine .card-grid,
  .leadfactory .card-grid,
  .gp-grid,
  .gpf-grid,
  .lf-grid,
  .bf-grid,
  .lead-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .gunpowder-mine .card,
  .gunpowder-factory .card,
  .lead-mine .card,
  .lead-factory .card,
  .bulletfactory .card,
  .gunpowdermine .card,
  .gunpowderfactory .card,
  .leadmine .card,
  .lead-factory .card,
  .gp-card,
  .gpf-card,
  .lf-card,
  .bf-card,
  .lead-card {
    min-width: 0; /* Allow cards to shrink */
  }
  
  input, button {
    padding: 14px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Mobile Portrait */
@media (max-width: 480px) {
  .layout { 
    grid-template-columns: 1fr; 
    gap: 8px;
    padding: 8px 4px 16px;
    margin-top: 0;
  }
  .sidebar { 
    display: none; 
  }
  .mobile-menu-toggle {
    display: flex;
    position: fixed;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    margin-left: 0;
  }
  .brand {
    display: none;
  }
  .container { 
    padding: 12px 8px 20px; 
    padding-top: 52px;
  }
  .topbar { 
    padding: 8px 12px;
    height: 40px;
    justify-content: flex-start;
    gap: 12px;
  }
  .brand {
    display: none;
  }
  .card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  /* Special case for ALL production modules - 2 columns */
  .gunpowder-mine .card-grid,
  .gunpowder-factory .card-grid,
  .lead-mine .card-grid,
  .lead-factory .card-grid,
  .bulletfactory .card-grid,
  .gunpowdermine .card-grid,
  .gunpowderfactory .card-grid,
  .leadmine .card-grid,
  .leadfactory .card-grid,
  .gp-grid,
  .gpf-grid,
  .lf-grid,
  .bf-grid,
  .lead-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .gunpowder-mine .card,
  .gunpowder-factory .card,
  .lead-mine .card,
  .lead-factory .card,
  .bulletfactory .card,
  .gunpowdermine .card,
  .gunpowderfactory .card,
  .leadmine .card,
  .lead-factory .card,
  .gp-card,
  .gpf-card,
  .lf-card,
  .bf-card,
  .lead-card {
    min-width: 0; /* Allow cards to shrink */
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .panel.hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  input, button {
    padding: 16px 18px;
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 12px;
  }
  .btn {
    padding: 16px 18px;
    font-size: 16px;
    font-weight: 600;
  }
  .toast-stack {
    top: 16px;
    right: 16px;
    left: 16px;
  }
  .toast {
    min-width: auto;
    max-width: none;
  }
  .travel-modal__card {
    width: min(480px, 95vw);
    margin: 0 auto;
  }
  #travel-overlay {
    inset: auto 8px 8px auto;
    max-width: calc(100vw - 16px);
  }
}

/* Extra Small Mobile */
@media (max-width: 320px) {
  .topbar { padding: 12px; }
  .brand img { width: 28px; height: 28px; }
  .brand h1 { font-size: 14px; }
  .mobile-menu-toggle {
    width: 40px;
    height: 40px;
    top: 12px;
    right: 12px;
  }
  .mobile-menu-container {
    width: 90%;
  }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  .menu-items a:hover {
    transform: none;
  }
  .menu-items a:active {
    background: rgba(255,255,255,0.08);
    transform: translateX(2px);
  }
  .btn:hover {
    transform: none;
  }
  .btn:active {
    transform: translateY(1px);
  }
  .mobile-menu-links a:hover {
    background: rgba(255, 77, 109, 0.15);
    padding-left: 20px;
  }
  .mobile-menu-links a:active {
    background: rgba(255, 77, 109, 0.25);
  }
}

/* Landscape orientation fixes */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .mobile-menu-container {
    height: 100vh;
    max-height: 100vh;
  }
  .mobile-menu-header {
    padding: 12px 16px;
  }
  .mobile-menu-section-title {
    padding: 8px 16px;
    font-size: 12px;
  }
  .mobile-menu-links a {
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .brand img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Dark mode support for system preference */
@media (prefers-color-scheme: dark) {
  /* Already dark, but ensure good contrast */
  :root {
    --bg: #0b0c12;
    --text: #f5f7fb;
  }
}

/* Global Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #0f172a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  width: min(700px, 90vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  gap: 12px;
}

.modal-footer {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,0.08);
  gap: 12px;
}

.modal-body {
  padding: 20px;
  display: grid;
  gap: 14px;
}

h4.modal-title {
  color: #f8fafc;
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  margin: 0;
}

.modal-close {
  width: 25px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.modal-close:hover {
  background: rgba(255,255,255,0.1);
  color: #f8fafc;
}

.modal .btn {
  min-width: 140px;
  height: 48px;
  font-weight: 700;
}

.modal-footer .btn {
  flex: 1;
}

/* Modal field styles for forms */
.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field span {
  color: #cbd5e1;
  font-size: 13px;
}

.modal-field.modal-field--full {
  grid-column: 1 / -1;
}

.modal-field input,
.modal-field select,
.modal-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
  font-family: inherit;
}

.modal-field input:focus,
.modal-field select:focus,
.modal-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,77,109,0.2);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
