* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }

/* ==================== MOBILE-FIRST BASE STYLES ==================== */
:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --bottom-nav-height: 70px;
  --header-height: 56px;
  --primary: #10b981;
  --primary-hover: #059669;
  --accent-color: #10b981;
  --bg-color: #111827;
  --comic-dark: #1a1a1a;
  --comic-panel: #262626;
  --card-bg: #262626;
  --border-color: #000000;
  --text-color: #e0e0e0;
  --muted-color: #9ca3af;
}

body {
  font-family: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  padding: 12px;
  padding-top: calc(var(--header-height) + var(--safe-area-top) + 12px);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 24px);
  padding-left: calc(var(--safe-area-left) + 12px);
  padding-right: calc(var(--safe-area-right) + 12px);
  color: var(--text-color);
  background: var(--bg-color);
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  position: relative;
}

/* Halftone pattern overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
  background-image: radial-gradient(circle, #333 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Gradient overlay at bottom */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(to bottom, transparent 0%, transparent 60%, rgba(0,0,0,0.4) 100%);
}

/* Comic text outline utility */
.text-outline-black {
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

/* Comic box shadows */
.shadow-comic {
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
}
.shadow-comic-sm {
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

/* Mobile Header - Comic Style */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-height) + var(--safe-area-top));
  padding-top: var(--safe-area-top);
  background: var(--comic-dark);
  border-bottom: 4px solid #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: calc(var(--safe-area-left) + 16px);
  padding-right: calc(var(--safe-area-right) + 16px);
  z-index: 1000;
}

.mobile-header h1 {
  font-size: 26px;
  margin: 0;
  font-family: 'Bangers', cursive;
  color: var(--primary);
  letter-spacing: 3px;
  text-shadow:
    2px 2px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000;
  -webkit-text-stroke: 1px black;
}

.mobile-header-actions {
  display: flex;
  gap: 12px;
}

.mobile-header-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s;
}

.mobile-header-btn .material-symbols-outlined {
  font-size: 24px;
  font-weight: bold;
  text-shadow: 2px 2px 0 rgba(0,0,0,1);
}

.mobile-header-btn:hover {
  color: #34d399;
}

.mobile-header-btn:active {
  color: #34d399;
}

/* Update Available Banner */
.update-banner {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-area-top));
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-bottom: 3px solid #000;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 999;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.update-banner.visible {
  transform: translateY(0);
  opacity: 1;
}

.update-banner-text {
  font-family: 'Bangers', cursive;
  font-size: 16px;
  color: white;
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 1px;
}

.update-banner-btn {
  background: #fff;
  color: #059669;
  border: 2px solid #000;
  border-radius: 4px;
  padding: 6px 14px;
  font-family: 'Bangers', cursive;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
  transition: all 0.1s;
  white-space: nowrap;
}

.update-banner-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.update-banner-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  text-shadow: 1px 1px 0 #000;
}

/* Refresh button glow when update available */
.mobile-menu-refresh.update-available {
  animation: updatePulse 1.5s ease-in-out infinite;
  color: #10b981 !important;
}

@keyframes updatePulse {
  0%, 100% {
    box-shadow: 0 0 5px #10b981, 0 0 10px #10b981;
  }
  50% {
    box-shadow: 0 0 15px #10b981, 0 0 25px #10b981;
  }
}

/* Bottom Navigation - Comic Style */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: var(--comic-dark);
  border-top: 4px solid #000;
  display: flex;
  z-index: 1000;
  padding: 8px;
  padding-bottom: calc(8px + var(--safe-area-bottom));
  gap: 8px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  text-decoration: none;
  font-size: 11px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 4px;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  border: 2px solid #000;
  background: #333;
  border-radius: 4px;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  transition: all 0.1s;
  text-shadow: none;
}

.nav-item:hover {
  background: #444;
}

.nav-item:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.nav-item.active {
  background: var(--primary);
  color: white;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

/* Mode Toggle (Complex/Simple) */
.nav-mode-toggle {
  display: flex;
  flex: 2;
  border: 2px solid #000;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  background: #333;
}

.nav-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: #333;
  color: var(--primary);
  border: none;
  border-right: 2px solid #000;
  cursor: pointer;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.1s;
}

.nav-toggle-btn:last-child {
  border-right: none;
}

.nav-toggle-btn:hover {
  background: #444;
}

.nav-toggle-btn.active {
  background: var(--primary);
  color: white;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.nav-item-icon {
  font-size: 16px;
  margin-bottom: 2px;
  display: none;
}

.nav-item-label {
  font-size: 11px;
  line-height: 1;
}

/* Layouts Toggle Container (for switching between Standard/Power/Data/Structure) */
.layouts-toggle-container {
  position: sticky;
  top: calc(var(--header-height) + var(--safe-area-top));
  background: #222;
  padding: 12px;
  z-index: 100;
  border-bottom: 4px solid #000;
  margin: -12px -12px 12px -12px;
}

.layouts-toggle-container .toggle-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.layouts-toggle-container .toggle-btn {
  flex: 1;
  min-width: 70px;
  padding: 10px 12px;
  font-size: 12px;
}

/* Comic title style */
h1 {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 24px;
  font-family: 'Bangers', cursive;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 2px 2px 0px rgba(0,0,0,1);
}

.muted { color: var(--muted-color); font-size: 14px; line-height: 1.4; margin-bottom: 16px; }

.main-container {
  border: none;
  padding: 0;
  border-radius: 2px;
  background: #222;
  border: 4px solid #000;
  border-top: 0;
  position: relative;
  z-index: 1;
  padding: 12px;
}

/* Single column layout for mobile */
.two-column-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Comic Style Section Boxes */
.section-box {
  background: var(--comic-panel);
  border: 4px solid #000;
  border-radius: 2px;
  padding: 16px;
  padding-top: 28px;
  margin-bottom: 16px;
  margin-top: 12px;
  overflow: visible;
  position: relative;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
}

.section-title {
  position: absolute;
  top: -16px;
  left: 16px;
  background: #222;
  border: 1px solid var(--primary);
  padding: 4px 10px;
  margin: 0;
  font-family: 'Bangers', cursive;
  font-size: 16px;
  font-weight: normal;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--primary);
  transform: rotate(-2deg);
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.section-title::after {
  content: none;
}

.section-box.collapsed .section-title::after {
  transform: none;
}

.section-content {
  padding: 0;
  transition: none;
  overflow: visible;
}

.section-box.collapsed .section-content {
  max-height: none;
  padding-top: 0;
  padding-bottom: 0;
}

label {
  display: block;
  color: #d1d5db;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 12px;
}

label span {
  display: block;
  margin-bottom: 4px;
  margin-left: 2px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
}

/* Input styling */
input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px; /* Prevents iOS zoom on focus */
  font-family: 'Roboto Condensed', sans-serif;
  background: #333;
  color: #fff;
  border: 2px solid #000;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px; /* Touch-friendly */
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2310b981'%3E%3Cpath d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3), 2px 2px 0px 0px rgba(0,0,0,1);
}

/* Hide number input spinners by default */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Compact input fields - still touch friendly */
.compact-input {
  width: 90px !important;
}

.compact-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.compact-row label {
  margin-bottom: 0;
  flex: 1;
  min-width: 80px;
}

.compact-row-tight {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.compact-row-tight label {
  margin-bottom: 0;
}

.three-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.three-inputs label {
  margin-bottom: 0;
}

input[type="checkbox"], input[type="radio"] {
  width: 24px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.inline-group {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.inline-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  min-height: 44px; /* Touch target */
}

.two-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.two-inputs label {
  margin-bottom: 0;
}

/* Mobile-optimized buttons - Comic Style */
button {
  padding: 12px 20px;
  font-size: 14px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  cursor: pointer;
  border-radius: 0;
  border: 2px solid #000;
  background: var(--primary);
  color: white;
  width: 100%;
  margin-bottom: 10px;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  transition: all 0.1s;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

@media (min-width: 640px) {
  button {
    width: auto;
    margin-right: 8px;
    margin-bottom: 0;
  }
}

/* Desktop layout adjustments */
@media (min-width: 768px) {
  .main-container {
    max-width: 1200px;
    margin: 0; /* Align to left instead of centered */
    margin-left: 20px; /* Small left margin */
  }

  .two-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }

  .section-box {
    max-width: 100%;
  }

  .layout-container {
    max-width: 1200px;
    margin-left: 20px; /* Align to left */
    margin-right: 0;
  }

  /* Screen tabs alignment with main content */
  #screenTabsContainer {
    max-width: 1200px;
    margin-left: 20px; /* Align to left */
    margin-right: 0;
    box-sizing: border-box;
  }

  #screenTabsContainer .screen-tabs {
    padding-left: 0;
  }

  /* Canvas tabs alignment with canvas container */
  #canvasTabsContainer {
    max-width: 1200px;
    margin-left: 20px;
    margin-right: 0;
    box-sizing: border-box;
  }

  /* Bottom nav constrained width - align with left content */
  .bottom-nav {
    max-width: 600px;
    left: 20px; /* Align with left margin of content */
    transform: none;
    border-radius: 8px 8px 0 0;
    border-left: 4px solid #000;
    border-right: 4px solid #000;
  }

  .nav-item {
    flex: 0 1 100px;
  }

  /* Canvas options constrained inputs */
  #canvasContainer .section-box {
    max-width: 500px;
  }

  #canvasContainer .section-content input,
  #canvasContainer .section-content select,
  #canvasContainer .section-content button {
    max-width: 100%;
  }

  /* Layout canvases - no max-width constraint on desktop */
  #standardCanvas, #structureCanvas, #powerCanvas, #dataCanvas {
    max-width: none;
  }

  /* Layout container - no overflow scroll on desktop */
  .layout-container {
    overflow-x: visible;
  }

}

.button-row {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result {
  margin-top: 32px;
  background: var(--comic-panel);
  padding: 16px;
  padding-top: 24px;
  border: 4px solid #000;
  border-radius: 2px;
  color: #e0e0e0;
  font-size: 13px;
  overflow: visible;
  font-family: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  line-height: 1.6;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
  position: relative;
}

.result-section {
  margin-bottom: 16px;
}

.result-section-title {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  margin-bottom: 4px;
  margin-top: 12px;
  color: var(--primary);
}

.result-row {
  margin: 2px 0;
}

.result-row strong {
  font-weight: 600;
  color: #ffffff;
}

.result-indent {
  margin-left: 20px;
}

canvas {
  border: 2px solid #000;
  margin-top: 12px;
  display: block;
  background: #fff;
}

/* Layout canvases - responsive on mobile */
#standardCanvas, #structureCanvas, #powerCanvas, #dataCanvas {
  max-width: 100%;
  height: auto;
}

/* Canvas view can be responsive */
#canvasView {
  max-width: 100%;
  height: auto;
  background: #000;
}

/* Canvas view wrapper responsive on mobile */
#canvasViewWrapper {
  max-width: 100%;
}

#canvasContainer {
  overflow-x: hidden;
}

/* Layout container overflow handling for mobile */
.layout-container {
  overflow-x: auto;
  overflow-y: visible;
}

canvas:focus {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.layout-container {
  margin-top: 32px;
  padding: 16px;
  padding-top: 24px;
  background: var(--comic-panel);
  border: 4px solid #000;
  border-radius: 0; /* Removed to fix diagonal line artifacts on Windows */
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
  position: relative;
  overflow: visible;
}

.layout-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.layout-title > span,
.layout-title-text {
  position: absolute;
  top: -16px;
  left: 16px;
  background: #222;
  border: 1px solid var(--primary);
  padding: 4px 10px;
  padding-right: 32px;
  font-family: 'Bangers', cursive;
  font-size: 16px;
  font-weight: normal;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--primary);
  transform: rotate(-2deg);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  z-index: 20;
}

.undo-redo-buttons {
  display: flex;
  gap: 8px;
  margin-left: 16px;
  margin-top: 20px;
}

.undo-redo-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-family: 'Roboto Condensed', sans-serif;
  background: #333;
  color: #e0e0e0;
  border: 2px solid #000;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

.undo-redo-btn:hover:not(:disabled) {
  background: #444;
}

.undo-redo-btn:active:not(:disabled) {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.undo-redo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Collapse/Expand button for layout containers */
.layout-collapse-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  min-width: 16px;
  max-width: 16px;
  min-height: 16px;
  max-height: 16px;
  aspect-ratio: 1 / 1;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 10px;
  color: var(--primary);
  cursor: pointer;
  line-height: 0;
  transition: transform 0.2s ease;
  box-sizing: border-box;
  overflow: hidden;
}

.layout-collapse-btn.collapsed {
  transform: translateY(-50%) rotate(-90deg);
}

.layout-collapse-btn:hover {
  background: var(--primary);
  color: #000;
}

/* Desktop: position collapse button between text and right edge of header */
@media (min-width: 768px) {
  .layout-collapse-btn {
    right: 3px;
  }
}

.layout-content {
  overflow: hidden;
}

.layout-content.collapsed {
  display: none;
}

.layout-container.collapsed {
  padding-bottom: 20px;
}

.canvas-zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 16px;
}

.zoom-btn {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: bold;
  font-family: 'Roboto Condensed', sans-serif;
  background: #333;
  color: #e0e0e0;
  border: 2px solid #000;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.1s;
  min-width: 32px;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

.zoom-btn:hover {
  background: #444;
}

.zoom-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

#canvasZoomInput {
  width: 55px;
  padding: 6px;
  font-size: 12px;
  text-align: center;
  background: #333;
  color: #fff;
  border: 2px solid #000;
  border-radius: 0;
  font-family: 'Bangers', cursive;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

#canvasZoomInput:focus {
  outline: none;
  border-color: var(--primary);
}

.zoom-percent {
  font-size: 12px;
  color: #ccc;
}

.warn {
  color: #ff6b6b;
  font-weight: bold;
  font-size: 13px;
  margin-top: 12px;
}

.hint {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.secondary-button {
  width: 100%;
  padding: 10px;
  background: #333;
  color: var(--primary);
  border: 2px solid #000;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow: none;
  margin-bottom: 0;
  min-height: auto;
}

.secondary-button:hover {
  background: #444;
}

.secondary-button:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.secondary-button.active {
  background: var(--primary);
  color: #fff;
  border: 2px solid #000 !important;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1) !important;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.canvas-with-options {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1200px) {
  .canvas-with-options {
    grid-template-columns: 1fr;
  }
}

.bumper-controls {
  margin-top: 10px;
  padding: 10px;
  background: #333;
  border-radius: 4px;
}

.bumper-column-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.bumper-column-input input {
  width: 80px;
}

.weight-display {
  margin-top: 12px;
  padding: 10px;
  background: #1a1a1a;
  border-radius: 4px;
  font-size: 12px;
}

.weight-item {
  padding: 4px 0;
  border-bottom: 1px solid #333;
}

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

/* Structure Manual Mode Toggle */
.structure-mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #333;
  border-radius: 6px;
}

.structure-mode-hint {
  font-size: 12px;
  color: #888;
  margin-left: auto;
}

.structure-selection-info {
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #10b981;
  display: none;
}

.structure-selection-info.visible {
  display: block;
}

/* Structure Layout with info panel below */
.structure-layout-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.structure-canvas-area {
  width: 100%;
}

.structure-info-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-top: 8px;
  padding-right: 5px;
  padding-bottom: 5px;
}

.structure-info-box {
  background: var(--comic-panel);
  border: 1px solid #555;
  border-radius: 2px;
  padding: 16px;
  padding-top: 28px;
  margin-top: 12px;
  overflow: visible;
  position: relative;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
  font-size: 12px;
}

.structure-info-box.weights { border-color: #4a9eff; }
.structure-info-box.plates { border-color: #6fc276; }
.structure-info-box.ground-support { border-color: #00CED1; }
.structure-info-box.floor-frames { border-color: #4ecdc4; }
.structure-info-box.total-weight { border-color: #FFD700; }

.structure-info-title {
  position: absolute;
  top: -16px;
  left: 16px;
  background: #222;
  padding: 4px 10px;
  margin: 0;
  font-family: 'Bangers', cursive;
  font-size: 16px;
  font-weight: normal;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transform: rotate(-2deg);
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

.structure-info-title.weights { color: #4a9eff; border: 1px solid #4a9eff; }
.structure-info-title.plates { color: #6fc276; border: 1px solid #6fc276; }
.structure-info-title.ground-support { color: #00CED1; border: 1px solid #00CED1; }
.structure-info-title.floor-frames { color: #4ecdc4; border: 1px solid #4ecdc4; }
.structure-info-title.total-weight { color: #FFD700; border: 1px solid #FFD700; }


.weight-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #333;
}

.weight-row:last-child {
  border-bottom: none;
}

.weight-label {
  color: #aaa;
}

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

.plates-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.plates-label {
  color: #aaa;
}

.plates-value {
  font-weight: 600;
  color: #fff;
}

.plates-total {
  border-top: 1px solid #3a5a3a;
  margin-top: 6px;
  padding-top: 6px;
}

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

  /* Constrain bumper toggle buttons width on mobile */
  #useBumpersBtn, #use4WayBumpersBtn {
    max-width: 120px;
    flex: none;
  }

  #manualBumperToggle {
    max-width: 140px;
    font-size: 10px;
    padding: 6px 8px;
  }
}

/* Toggle Buttons - Comic Style */
.toggle-group, .unit-toggle-group {
  display: flex;
  gap: 8px;
}

/* Toggle buttons */
.toggle-btn, .unit-toggle-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  background: #333;
  color: #9ca3af;
  border: 2px solid #000;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.1s;
  min-width: 44px;
  min-height: 44px;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  width: auto;
  margin-bottom: 0;
}

.toggle-btn:hover, .unit-toggle-btn:hover {
  color: #fff;
  background: #444;
}

/* Slider toggle (merged toggle buttons) */
.slider-toggle {
  display: flex;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  background: #333;
}

.slider-toggle-btn {
  padding: 10px 14px;
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  background: transparent;
  color: #9ca3af;
  border: none;
  border-right: 2px solid #000;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  min-height: 44px;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-shadow: none;
  box-shadow: none;
  width: auto;
  margin-bottom: 0;
}

/* Desktop: constrain toggle width */
@media (min-width: 769px) {
  .slider-toggle {
    display: inline-flex;
  }
  .slider-toggle-btn {
    flex: none;
  }
}

.slider-toggle-btn:last-child {
  border-right: none;
}

.slider-toggle-btn.active {
  background: var(--primary);
  color: #fff;
  border-right: 2px solid #000;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.slider-toggle-btn.active:last-child {
  border-right: none;
}

.slider-toggle-btn:hover:not(.active) {
  background: #444;
  color: #fff;
}

/* Number input with spinner arrows */
.number-input-with-arrows {
  display: flex;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  background: #333;
}

.number-input-with-arrows input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 14px;
  padding: 6px 4px;
  text-align: center;
  min-width: 40px;
  width: 45px;
  box-shadow: none;
  min-height: auto;
}

.number-input-with-arrows input:focus {
  outline: none;
  box-shadow: none;
}

.number-input-arrows {
  display: flex;
  flex-direction: column;
  border-left: 2px solid #000;
  background: #222;
  width: 28px;
}

.number-input-arrows button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  margin: 0;
  min-height: 20px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: none;
  text-shadow: none;
  transition: background 0.1s;
}

.number-input-arrows button:first-child {
  border-bottom: 2px solid #000;
}

.number-input-arrows button:hover {
  background: #333;
}

.number-input-arrows button:active {
  background: #444;
  transform: none;
}

.toggle-btn:active, .unit-toggle-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.toggle-btn.active, .unit-toggle-btn.active {
  background: var(--primary);
  color: #fff;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.toggle-btn.active:hover, .unit-toggle-btn.active:hover {
  background: var(--primary-hover);
}

.unit-toggles-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.toggle-label, .unit-toggle-label {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #9ca3af;
  margin-right: 6px;
}

/* Modal Dialog Styles - Comic Style */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

#requestItemModal {
  z-index: 10001;
}

#customAlertModal {
  z-index: 10002;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--comic-panel);
  border: 4px solid #000;
  border-radius: 2px;
  padding: 16px;
  max-width: 420px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 6px 6px 0px 0px rgba(0, 0, 0, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #000;
}

.modal-title {
  font-size: 18px;
  font-family: 'Bangers', cursive;
  font-weight: normal;
  letter-spacing: 1px;
  color: var(--primary);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.modal-close {
  background: none;
  border: 2px solid #000;
  color: #ff6b6b;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 28px;
  text-align: center;
  border-radius: 2px;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

.modal-close:hover {
  background: #ff6b6b;
  color: #fff;
}

.modal-close:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.modal-body {
  margin-bottom: 12px;
}

.manage-custom-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid #444;
  padding-bottom: 8px;
}

.manage-tab {
  flex: 1;
  padding: 8px 12px;
  background: #333;
  border: 2px solid #000;
  color: #888;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-shadow: none;
}

.manage-tab.active {
  background: var(--primary);
  color: #000;
}

.manage-tab:hover:not(.active) {
  background: #444;
  color: #fff;
}

.manage-tab-content {
  min-height: 100px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #444;
}

/* Ensure modal footer buttons stay side-by-side on mobile */
.modal-footer button {
  width: auto;
  flex-shrink: 0;
  min-width: 100px;
}

.modal-input-group {
  margin-bottom: 8px;
}

.modal-input-group label {
  display: block;
  margin-bottom: 3px;
  color: #e0e0e0;
  font-size: 11px;
  font-weight: 500;
}

.modal-input-group input[type="text"],
.modal-input-group input[type="number"],
.modal-input-group textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: 'Roboto Condensed', sans-serif;
  background: #333;
  color: #fff;
  border: 2px solid #000;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

.modal-input-group textarea {
  min-height: 60px;
  resize: vertical;
}

.modal-input-group input:focus,
.modal-input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3), 2px 2px 0px 0px rgba(0,0,0,1);
}

.modal-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cp-tab-content {
  min-height: 100px;
}

/* Compact inline toggle for custom panel modal */
.cp-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid #444;
}

.cp-toggle-row label.cp-toggle-label {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #ccc;
  margin: 0;
}

.cp-mini-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  margin-left: 12px;
}

.cp-mini-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cp-mini-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #555;
  border: 2px solid #000;
  border-radius: 12px;
  transition: background 0.15s;
}

.cp-mini-toggle-slider:before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: #888;
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.cp-mini-toggle input:checked + .cp-mini-toggle-slider {
  background: var(--primary);
}

.cp-mini-toggle input:checked + .cp-mini-toggle-slider:before {
  transform: translateX(20px) translateY(-50%);
  background: #ccc;
}

.modal-input-group .hint {
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

.checkbox-group,
.modal-checkbox-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.checkbox-group input[type="checkbox"],
.modal-checkbox-group input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.checkbox-group label,
.modal-checkbox-group label {
  color: #e0e0e0;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: 2px solid #000;
  padding: 8px 16px;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  width: auto;
  margin-bottom: 0;
  min-height: auto;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.btn-secondary {
  background: #333;
  color: #e0e0e0;
  border: 2px solid #000;
  padding: 8px 16px;
  border-radius: 0;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow: none;
  width: auto;
  margin-bottom: 0;
  min-height: auto;
}

.btn-secondary:hover {
  background: #444;
}

.btn-secondary:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.btn-danger {
  background: #dc2626;
  color: white;
  border: 2px solid #000;
  padding: 10px 20px;
  border-radius: 0;
  cursor: pointer;
  font-size: 14px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
  width: auto;
  margin-bottom: 0;
  min-height: auto;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-danger:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.custom-item-list {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.custom-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #2a2a2a;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  margin-bottom: 8px;
}

.custom-item:last-child {
  margin-bottom: 0;
}

.custom-item:hover {
  background: #333;
}

.custom-item-name {
  flex: 1;
  color: #e0e0e0;
  font-size: 14px;
}

.custom-item-actions {
  display: flex;
  gap: 8px;
}

/* ==================== COMMUNITY BROWSER STYLES ==================== */

.community-item-list {
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
  overflow-x: hidden;
}

.community-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #2a2a2a;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  margin-bottom: 8px;
}

.community-item:last-child {
  margin-bottom: 0;
}

.community-item:hover {
  background: #333;
}

.community-item-info {
  flex: 1;
}

.community-item-name {
  color: #e0e0e0;
  font-size: 14px;
  font-weight: 700;
}

.community-item-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #888;
}

.download-count {
  color: #888;
}

.community-download-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  background: var(--primary) !important;
  color: #fff !important;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000 !important;
}

.community-download-btn:hover {
  background: var(--accent) !important;
}

/* Pending approval styling */
.pending-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  background: #f6ad55;
  color: #000;
  border-radius: 2px;
  margin-right: 8px;
  text-transform: uppercase;
}

.pending-item {
  border-color: #f6ad55;
}

.pending-item .custom-item-actions {
  flex-shrink: 0;
  gap: 4px;
}

.pending-item .custom-item-actions .btn-small {
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

/* Update count badge (admin view) */
.update-count {
  font-size: 11px;
  color: #888;
  margin-left: 8px;
  font-weight: 400;
}

.btn-small.approve {
  background: #48bb78;
  border-color: #000;
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.btn-small.approve:hover {
  background: #68d391;
}

.btn-small.test {
  background: #4299e1;
  border-color: #000;
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.btn-small.test:hover {
  background: #63b3ed;
}

/* Share button in modal footers */
#sharePanelBtn,
#shareProcessorBtn {
  background: #9f7aea;
  border-color: #000;
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

#sharePanelBtn:hover,
#shareProcessorBtn:hover {
  background: #b794f4;
}

.btn-small {
  padding: 4px 12px;
  font-size: 12px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  border-radius: 0;
  cursor: pointer;
  border: 2px solid #000;
  background: #333;
  color: #e0e0e0;
  transition: all 0.1s;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
}

.btn-small:hover {
  background: #555;
}

.btn-small.danger {
  background: #e53e3e;
  border-color: #000;
  color: white;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.btn-small.danger:hover {
  background: #c53030;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
  user-select: none;
}

.context-menu-item {
  padding: 8px 16px;
  cursor: pointer;
  color: #e0e0e0;
  font-size: 13px;
  transition: background 0.2s;
}

.context-menu-item:hover {
  background: #3a3a3a;
}

/* ==================== SCREEN TABS STYLES - Comic Style ==================== */
.screen-tabs-container {
  display: flex;
  align-items: flex-end;
  padding: 8px 8px 0 8px;
  gap: 8px;
  overflow-x: visible; /* Allow wrapping instead of scrolling */
  background: var(--comic-dark);
}

.screen-tabs {
  display: flex;
  gap: 4px; /* Reduced gap for tighter spacing */
  margin-bottom: 0;
  flex-wrap: wrap; /* Allow wrapping to new rows */
  border-bottom: none;
  padding-top: 14px; /* Offset for first row negative margin */
  padding-bottom: 0;
  align-items: flex-end;
}

.screen-tab {
  padding: 10px 16px;
  background: var(--comic-panel);
  border: 4px solid #000;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.1s;
  position: relative;
  top: 0;
  color: #fff;
  min-height: 44px;
  margin-top: -10px; /* Overlap tabs when they wrap - pulls rows up */
}

.screen-tab:hover {
  background: #333;
}

.screen-tab.active {
  background: var(--comic-panel);
  border-color: #000;
  color: var(--primary);
  z-index: 10;
}

.screen-tab-name {
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.screen-tab-edit {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  border-radius: 2px;
  width: auto;
  margin: 0;
  min-height: auto;
  min-width: auto;
  box-shadow: none;
}

.screen-tab-edit:hover {
  color: #fff;
}

.screen-tab-close {
  background: none !important;
  border: none !important;
  color: #ff6b6b;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
  border-radius: 2px;
  width: auto !important;
  margin: 0 !important;
  min-height: 24px;
  min-width: 24px;
  box-shadow: none !important;
  text-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen-tab-close:hover {
  color: #ff4444;
  background: rgba(255, 107, 107, 0.2) !important;
}

.screen-tab-close:active {
  transform: none;
}

.screen-tab-add {
  padding: 8px 12px;
  background: var(--primary);
  border: 4px solid #000;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.1s;
  position: relative;
  top: 4px;
  min-height: 44px;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.screen-tab-add:hover {
  background: var(--primary-hover);
}

.screen-tab-add:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}
/* ==================== END SCREEN TABS STYLES ==================== */

/* Header with config buttons */
.page-header {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  margin-bottom: 6px;
  padding-top: 50px; /* Space for background image title */
}

.page-header h1 {
  margin: 0;
}

.config-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px 12px;
  border-radius: 6px;
}

.config-buttons input[type="text"] {
  padding: 6px 10px;
  font-size: 12px;
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 4px;
  width: 150px;
}

.config-buttons input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.config-btn {
  padding: 8px 14px;
  font-size: 12px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  cursor: pointer;
  border-radius: 0;
  border: 2px solid #000;
  color: white;
  transition: all 0.1s;
  white-space: nowrap;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.config-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.config-btn.save {
  background: var(--primary);
}

.config-btn.save:hover {
  background: var(--primary-hover);
}

.config-btn.load {
  background: #3498db;
}

.config-btn.load:hover {
  background: #2980b9;
}

.config-btn.export-pdf {
  background: #8e44ad;
}

.config-btn.export-pdf:hover {
  background: #7d3c98;
}

.header-buttons-row {
  display: flex;
  align-items: center;
}

/* Hide desktop-only elements on mobile */
.desktop-only {
  display: none;
}

/* Mobile Menu Overlay - Comic Style */
.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.mobile-menu-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-menu {
  position: absolute;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 320px;
  height: 100%;
  background: var(--comic-dark);
  border-left: 4px solid #000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-menu-overlay.active .mobile-menu {
  transform: translateX(0);
}

/* Instant open when returning from modal - no transition */
.mobile-menu-overlay.instant,
.mobile-menu-overlay.instant .mobile-menu {
  transition: none;
}

.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  padding-top: calc(var(--safe-area-top) + 16px);
  border-bottom: 4px solid #000;
  font-size: 20px;
  font-family: 'Bangers', cursive;
  letter-spacing: 2px;
  color: var(--primary);
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.mobile-menu-close {
  width: 44px;
  height: 44px;
  border: 2px solid #000;
  background: transparent;
  color: #ff6b6b;
  font-size: 24px;
  cursor: pointer;
  border-radius: 0; /* Removed to fix diagonal line artifacts on Windows */
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-close:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.mobile-menu-refresh {
  width: 44px;
  height: 44px;
  border: 2px solid #000;
  background: transparent;
  color: var(--primary);
  font-size: 28px;
  cursor: pointer;
  border-radius: 0; /* Removed to fix diagonal line artifacts on Windows */
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-refresh:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.mobile-menu-content {
  padding: 16px 20px;
  padding-bottom: calc(var(--safe-area-bottom) + 20px);
}

.mobile-menu-section {
  margin-bottom: 24px;
}

.mobile-menu-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-color);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.mobile-menu-btn {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #333;
  border: 2px solid #000;
  border-radius: 0; /* Removed to fix diagonal line artifacts on Windows */
  color: var(--primary);
  font-size: 13px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  transition: all 0.1s;
  text-shadow: none;
  min-height: auto;
}

.mobile-menu-btn.accent {
  color: var(--accent-color);
}

.mobile-menu-btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.mobile-menu-btn-row .mobile-menu-btn {
  flex: 1;
  margin-bottom: 0;
  text-align: center;
}

.mobile-menu-btn:hover {
  background: var(--primary);
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.mobile-menu-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.mobile-menu-btn.install-btn {
  background: var(--primary);
  color: #fff;
  font-weight: normal;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.mobile-menu-info {
  font-size: 12px;
  color: var(--muted-color);
  margin-bottom: 4px;
}

/* View Containers - Mobile optimized */
.view-container {
  display: none;
}

.view-container.active {
  display: block;
}

/* Mobile canvas wrapper */
.mobile-canvas-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  border: 2px solid #000;
  border-radius: 2px;
  background: #000;
}

/* Landscape orientation hint */
.orientation-hint {
  display: none;
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--primary);
  border-radius: 2px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--primary);
}

@media (orientation: portrait) {
  .orientation-hint.show-in-portrait {
    display: block;
  }
}

/* Touch canvas controls */
.touch-zoom-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.touch-zoom-btn {
  flex: 1;
  min-width: 70px;
  padding: 12px;
  background: #333;
  border: 2px solid #000;
  border-radius: 0;
  color: var(--text-color);
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  transition: all 0.1s;
  font-size: 18px;
  cursor: pointer;
}

.touch-zoom-btn:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

/* Mobile-friendly context menus - Comic Style */
#panelContextMenu,
#bumperContextMenu {
  min-width: 250px !important;
  border-radius: 2px !important;
  border: 2px solid #000 !important;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1) !important;
  overflow: hidden;
}

#panelContextMenu > div,
#bumperContextMenu > div,
.context-menu-item {
  padding: 14px 16px;
  font-size: 14px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  min-height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #444;
}

/* Mobile hint text */
.mobile-hint {
  display: block;
  padding: 10px 16px;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid var(--primary);
  border-radius: 0; /* Removed to fix diagonal line artifacts on Windows */
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--primary);
}

/* Hide desktop hints, show mobile hints */
.hint:not(.mobile-hint) {
  display: none;
}

/* ==================== WELCOME PAGE ==================== */
.welcome-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #1a1a1a;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.welcome-page::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.15;
  background-image: radial-gradient(circle, #333 1px, transparent 1px);
  background-size: 20px 20px;
}

.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 32px 24px;
  max-width: 400px;
  width: 100%;
  border: 4px solid #000;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
  border-radius: 2px;
  background: rgba(38, 38, 38, 0.6);
}

.welcome-logo-container {
  margin-bottom: -4px;
}

.welcome-title {
  font-family: 'Bangers', cursive;
  font-size: 64px;
  color: var(--primary);
  letter-spacing: 8px;
  margin: 0;
  text-shadow:
    3px 3px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000;
  -webkit-text-stroke: 2px black;
}

.welcome-subtitle {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted-color);
  letter-spacing: 1px;
  margin: 0 0 4px 0;
}

.welcome-subtitle:last-of-type {
  margin-bottom: 32px;
}

.welcome-paren {
  color: var(--primary);
  font-weight: 700;
}

.welcome-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.welcome-btn {
  width: 100%;
  padding: 16px 20px;
  background: #333;
  border: 4px solid #000;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: 4px 4px 0px 0px rgba(0,0,0,1);
  transition: all 0.1s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.welcome-btn:active {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.welcome-btn-title {
  font-family: 'Bangers', cursive;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--primary);
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

.welcome-btn-desc {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 12px;
  color: var(--muted-color);
  font-weight: 400;
}

.welcome-btn-simple:hover {
  background: var(--primary);
}
.welcome-btn-simple:hover .welcome-btn-title {
  color: #fff;
}
.welcome-btn-simple:hover .welcome-btn-desc {
  color: rgba(255,255,255,0.8);
}

.welcome-btn-complex:hover {
  background: var(--primary);
}
.welcome-btn-complex:hover .welcome-btn-title {
  color: #fff;
}
.welcome-btn-complex:hover .welcome-btn-desc {
  color: rgba(255,255,255,0.8);
}

.welcome-btn-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  transition: all 0.1s;
  margin-bottom: 16px;
  width: 100%;
}

.welcome-btn-signin:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.welcome-btn-signin:hover {
  background: var(--primary);
  color: #fff;
}

.welcome-signin-desc {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 11px;
  color: var(--muted-color);
  margin: -8px 0 16px 0;
  text-align: center;
}

.welcome-btn-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--muted-color);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.2s;
  margin-bottom: 24px;
  width: 100%;
}

.welcome-btn-help:hover {
  color: #fff;
}

.welcome-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  font-family: 'Roboto Condensed', sans-serif;
}

/* Help Modal Content */
.help-content {
  color: var(--text-color);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  line-height: 1.8;
}

.help-section-title {
  font-family: 'Bangers', cursive;
  color: var(--primary);
  font-size: 18px;
  letter-spacing: 1.5px;
  margin: 20px 0 8px 0;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;
}

.help-content .help-section-title:first-child {
  margin-top: 0;
}

.help-list {
  margin: 0 0 12px 0;
  padding-left: 20px;
}

.help-list li {
  margin-bottom: 4px;
}

.help-text {
  margin: 0 0 8px 0;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px 0;
}

.help-table td {
  padding: 6px 10px;
  border: 1px solid #444;
  font-size: 12px;
}

.help-table td:first-child {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  width: 120px;
}

/* Desktop welcome page */
@media (min-width: 768px) {
  .welcome-content {
    max-width: 480px;
    padding: 48px 32px;
  }

  .welcome-title {
    font-size: 80px;
    letter-spacing: 12px;
  }

  .welcome-subtitle {
    font-size: 16px;
  }

  .welcome-buttons {
    flex-direction: row;
    gap: 16px;
  }

  .welcome-btn {
    flex: 1;
  }
}

/* ==================== AUTH MODAL ==================== */

.auth-modal-dialog {
  max-width: 360px;
}

/* Auth tabs - comic book slider toggle style */
.auth-tabs {
  display: flex;
  margin-bottom: 16px;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  background: #333;
}

.auth-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-right: 2px solid #000;
  color: #9ca3af;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 44px;
}

.auth-tab:last-child {
  border-right: none;
}

.auth-tab:hover:not(.active) {
  background: #444;
  color: #fff;
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

/* Auth error message */
.auth-error {
  background: rgba(220, 53, 69, 0.2);
  border: 2px solid #000;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  padding: 10px 12px;
  margin-bottom: 16px;
  color: #ff6b6b;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

/* Auth input fields - match app style */
#authModal .modal-input-group input[type="email"],
#authModal .modal-input-group input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: 'Roboto Condensed', sans-serif;
  background: #333;
  color: #fff;
  border: 2px solid #000;
  border-radius: 0;
  box-shadow: 2px 2px 0px 0px rgba(0,0,0,1);
  box-sizing: border-box;
}

#authModal .modal-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3), 2px 2px 0px 0px rgba(0,0,0,1);
}

#authModal .modal-input-group input::placeholder {
  color: #666;
}

/* Override browser autofill styling */
#authModal .modal-input-group input:-webkit-autofill,
#authModal .modal-input-group input:-webkit-autofill:hover,
#authModal .modal-input-group input:-webkit-autofill:focus,
#authModal .modal-input-group input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px #2a2a2a inset, 2px 2px 0px 0px rgba(0,0,0,1) !important;
  -webkit-text-fill-color: #fff !important;
  caret-color: #fff;
  transition: background-color 5000s ease-in-out 0s;
}

/* Auth submit button - comic book style */
.auth-submit-btn {
  width: 100%;
  padding: 14px 16px;
  margin-top: 12px;
  font-size: 14px;
  font-family: 'Roboto Condensed', sans-serif;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border: 2px solid #000;
  border-radius: 0;
  box-shadow: 3px 3px 0px 0px rgba(0,0,0,1);
  cursor: pointer;
  transition: all 0.1s;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000;
}

.auth-submit-btn:hover {
  background: var(--primary-hover);
}

.auth-submit-btn:active {
  box-shadow: none;
  transform: translate(3px, 3px);
}

.auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 3px 3px 0px 0px rgba(0,0,0,1);
}

/* Forgot password link */
.auth-forgot-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: var(--primary);
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}

.auth-forgot-link:hover {
  text-decoration: underline;
}

/* Account info when logged in */
.auth-account-info {
  text-align: center;
  padding: 16px 0;
}

.auth-account-email {
  color: #e0e0e0;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 15px;
  font-weight: 500;
}

.auth-account-actions {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* User menu button in header */
.user-menu-btn {
  position: relative;
}

.user-menu-btn.logged-in {
  color: var(--primary);
}

.user-menu-btn.logged-in::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  border: 2px solid #1a1a1a;
}

