/* Walking Arm Trebuchet Simulator Stylesheet */

:root {
  --bg-primary: #0a0f1d;
  --bg-secondary: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-focus: #ca8a04;

  --accent-gold: #facc15;
  --accent-brass: #ca8a04;
  --accent-orange: #ea580c;
  --accent-cyan: #38bdf8;
  --accent-red: #ef4444;
  --accent-green: #22c55e;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* Header */
.app-header {
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.preset-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.select-preset, .select-speed {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.select-preset:hover, .select-preset:focus,
.select-speed:hover, .select-speed:focus {
  border-color: var(--accent-gold);
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-secondary:hover {
  background-color: #334155;
  border-color: var(--accent-gold);
}

/* App Main Layout */
.app-main {
  display: flex;
  flex: 1;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Simulation Section (Left) */
.simulation-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: #050b14;
  overflow: hidden;
}

/* Floating HUD (Top Left) */
.canvas-telemetry-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.hud-pill {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.hud-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-gold);
}

/* Small Red Warning Badges on Right Side of Canvas */
.canvas-warning-badges {
  position: absolute;
  top: 14px;
  right: 14px;
  left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 20;
  pointer-events: auto;
}

.warning-badge-item {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(220, 38, 38, 0.92);
  border: 1px solid #ef4444;
  color: #fff;
  padding: 4px 10px 4px 8px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.45);
  backdrop-filter: blur(8px);
  cursor: pointer;
  animation: pulse-warning-badge 2.2s infinite ease-in-out;
  transition: transform 0.15s ease, background 0.15s ease;
  user-select: none;
  width: fit-content;
}

.warning-badge-item:hover {
  background: rgba(239, 68, 68, 0.98);
  transform: scale(1.06);
}

.warning-badge-item:active {
  transform: scale(0.95);
}

.warning-badge-item.hidden {
  display: none !important;
}

@keyframes pulse-warning-badge {
  0%, 100% {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    border-color: #ef4444;
  }
  50% {
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.85);
    border-color: #fca5a5;
  }
}

.warning-badge-icon {
  font-size: 13px;
  line-height: 1;
}

.warning-badge-label {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Tooltip popover on hover/focus - expands toward the left */
.warning-badge-tooltip {
  display: none;
  position: absolute;
  right: calc(100% + 10px);
  left: auto;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid #ef4444;
  border-radius: 8px;
  padding: 8px 12px;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  width: 250px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  z-index: 30;
  pointer-events: none;
  text-align: left;
}

.warning-badge-item:hover .warning-badge-tooltip,
.warning-badge-item:active .warning-badge-tooltip {
  display: block;
}

.canvas-view-toolbar {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px 10px;
  z-index: 10;
}

.cam-btn-group, .toggles-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.08);
}

.view-btn.active {
  background-color: var(--accent-brass);
  color: #000000;
  font-weight: 600;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background-color: var(--border-color);
  margin: 0 4px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-label input {
  cursor: pointer;
  accent-color: var(--accent-gold);
}

/* Canvas Container */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#sim-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Playback Control Bar */
.playback-bar {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 16px;
  z-index: 10;
  flex-shrink: 0;
}

.playback-actions-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-control.btn-play {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #ffffff;
  border-color: #b91c1c;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.35);
}

.btn-control.btn-play:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  border-color: #ef4444;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45);
}

.btn-control.btn-play:active {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: none;
}

.btn-control {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-control:hover {
  background-color: #334155;
  border-color: var(--accent-gold);
}

.btn-icon-only {
  padding: 8px;
}

/* Timeline */
.timeline-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 50px;
}

.timeline-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: #334155;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  accent-color: var(--accent-gold);
}

.timeline-slider::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
  border-radius: 3px;
  border: none;
}

.timeline-slider::-moz-range-track {
  background: transparent;
  height: 6px;
  border-radius: 3px;
  border: none;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  margin-top: -5px; /* (6px track - 16px thumb) / 2 = -5px vertical centering */
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.timeline-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.speed-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.speed-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Right Sidebar */
.sidebar-section {
  width: 395px;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-primary);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.70rem;
  font-weight: 600;
  padding: 11px 1px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  text-align: center;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-text-short {
  display: none;
}

.tab-text-full {
  display: inline;
}

.tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  background-color: rgba(250, 204, 21, 0.05);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
}

.tab-content.active {
  display: block;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.metric-card.highlight {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(202, 138, 4, 0.15), rgba(30, 41, 59, 0.8));
  border-color: var(--accent-brass);
}

.metric-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.metric-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 4px 0;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.metric-card.highlight .metric-value {
  font-size: 1.8rem;
}

.metric-unit {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.metric-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.metric-card.card-warning {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.22), rgba(30, 41, 59, 0.9));
  border-color: #ef4444;
}

.metric-card.card-warning {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.metric-card.card-warning:hover {
  transform: translateY(-2px);
  border-color: #fca5a5;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

.metric-card.card-warning:active {
  transform: translateY(0);
}

.metric-card.card-warning .metric-value {
  color: #f87171;
}

.metric-card.card-success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.16), rgba(30, 41, 59, 0.85));
  border-color: #22c55e;
}

.metric-card.card-success .metric-value {
  color: #4ade80;
}

.status-warning {
  color: #f87171;
  font-weight: 700;
}

.status-safe {
  color: #4ade80;
  font-weight: 600;
}

/* Chart Section */
.chart-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 10px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.chart-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.chart-nav {
  display: flex;
  gap: 4px;
}

.chart-tab-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.chart-tab-btn.active {
  background-color: var(--accent-brass);
  color: #000000;
  border-color: var(--accent-brass);
  font-weight: 600;
}

.chart-canvas-wrap {
  width: 100%;
  height: 150px;
  position: relative;
}

.chart-canvas {
  width: 100%;
  height: 100%;
  display: none;
}

.chart-canvas.active {
  display: block;
}

/* Parameter Forms */
.param-group {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
}

.group-title {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  margin-bottom: 12px;
}

.param-row {
  margin-bottom: 12px;
  touch-action: pan-y;
}

.param-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.param-val-disp {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent-gold);
  cursor: pointer;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  background: rgba(251, 191, 36, 0.05);
  transition: all 0.15s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.param-val-disp:hover {
  background: rgba(251, 191, 36, 0.20);
  border-color: rgba(251, 191, 36, 0.65);
  color: #fef08a;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.25);
}

.param-val-disp:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 1px;
}

/* Inline Direct-Value Editor */
.param-val-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.param-val-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-gold);
  background: #090d16;
  border: 1.5px solid var(--accent-gold);
  border-radius: 4px;
  padding: 1px 6px;
  width: 76px;
  text-align: right;
  outline: none;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.param-val-input:focus {
  border-color: #fef08a;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.55);
}

.param-val-input.input-error-shake {
  animation: inputShake 0.3s ease-in-out;
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  color: #ef4444;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
}

.param-val-unit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  user-select: none;
}

.param-row input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #334155;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  accent-color: var(--accent-gold);
  touch-action: pan-y;
  transition: box-shadow 0.15s ease, accent-color 0.15s ease;
}

.param-row input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 6px;
  border-radius: 3px;
  border: none;
}

.param-row input[type="range"]::-moz-range-track {
  background: transparent;
  height: 6px;
  border-radius: 3px;
  border: none;
}

.param-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  margin-top: -5px; /* (6px track - 16px thumb) / 2 = -5px vertical centering */
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.param-row input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.param-row input[type="range"].slider-touch-active::-webkit-slider-thumb {
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
  transform: scale(1.15);
}

.param-row input[type="range"].slider-touch-active::-moz-range-thumb {
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
  transform: scale(1.15);
}

.param-row input[type="range"].slider-in-error::-webkit-slider-thumb {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.param-row input[type="range"].slider-in-error::-moz-range-thumb {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.param-row input[type="range"].slider-in-error.slider-touch-active::-webkit-slider-thumb {
  background: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
  transform: scale(1.15);
}

.param-row input[type="range"].slider-in-error.slider-touch-active::-moz-range-thumb {
  background: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
  transform: scale(1.15);
}

.param-row input[type="range"].slider-touch-active {
  accent-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.param-row input[type="range"].slider-in-error {
  accent-color: #ef4444;
}

.param-row input[type="range"].slider-in-error.slider-touch-active {
  accent-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.param-row.has-error .param-val-disp {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.param-row.has-error .param-val-disp:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.7);
  color: #fca5a5;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.25);
}

.param-desc {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.save-preset-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-text {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  outline: none;
}

.input-text:focus {
  border-color: var(--accent-gold);
}

.btn-primary {
  background: var(--accent-brass);
  color: #000000;
  border: none;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

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

.hidden {
  display: none !important;
}

/* Responsive Layout & Mobile Styles */
@media (max-width: 900px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .app-header {
    height: 48px;
    padding: 0 10px;
    flex-shrink: 0;
  }

  .header-brand {
    gap: 8px;
  }

  .brand-icon {
    width: 26px;
    height: 26px;
  }

  .brand-title {
    font-size: 0.92rem;
    letter-spacing: 0.2px;
  }

  .brand-subtitle {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .preset-label {
    display: none;
  }

  .select-preset {
    max-width: 135px;
    padding: 5px 6px;
    font-size: 0.75rem;
  }

  .btn-label {
    display: none;
  }

  .btn-secondary {
    padding: 6px 8px;
  }

  .modal-readme-box {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
  }

  .modal-readme-btn {
    width: 100%;
    justify-content: center;
  }

  .app-main {
    display: flex;
    flex-direction: column;
    height: calc(100% - 48px);
    height: calc(100dvh - 48px);
    overflow: hidden;
  }

  /* Top Half: Simulation Canvas & Playback Bar (Fixed, never scrolls) */
  .simulation-section {
    flex: 0 0 50%;
    height: 50%;
    max-height: 50%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: #050b14;
    position: relative;
  }

  .canvas-container {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
  }

  #sim-canvas {
    touch-action: none;
    width: 100%;
    height: 100%;
    display: block;
  }

  /* Canvas Overlays on Mobile */
  .canvas-telemetry-hud {
    top: 6px;
    left: 6px;
    gap: 4px;
    display: flex;
    flex-direction: column;
  }

  .hud-pill {
    padding: 2px 6px;
    border-radius: 6px;
  }

  .hud-label {
    font-size: 0.50rem;
  }

  .hud-value {
    font-size: 0.76rem;
  }

  .canvas-view-toolbar {
    bottom: 6px;
    right: 6px;
    padding: 3px 6px;
    gap: 4px;
  }

  .canvas-warning-badges {
    top: 8px;
    right: 8px;
    left: auto;
    align-items: flex-end;
    gap: 6px;
  }

  .warning-badge-item {
    padding: 3px 8px 3px 6px;
    font-size: 10px;
    border-radius: 12px;
  }

  .warning-badge-label {
    font-size: 10px;
  }

  .warning-badge-tooltip {
    right: 0;
    left: auto;
    top: calc(100% + 6px);
    transform: none;
    width: 220px;
    font-size: 10px;
    padding: 6px 10px;
  }

  .toolbar-divider, .toggles-group {
    display: none; /* Hide dense checkboxes on mobile screen */
  }

  .view-btn {
    padding: 3px 6px;
    font-size: 0.68rem;
  }

  /* Compact Playback Bar directly underneath canvas in the top half */
  .playback-bar {
    flex: 0 0 auto;
    flex-direction: column;
    padding: 4px 8px 6px;
    gap: 4px;
    height: auto;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
  }

  .timeline-container {
    width: 100%;
    gap: 6px;
  }

  .timeline-slider {
    height: 6px;
  }

  .timeline-time {
    font-size: 0.68rem;
    min-width: 40px;
  }

  .playback-actions-row {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }

  .playback-buttons {
    gap: 3px;
  }


  .btn-control {
    padding: 6px 6px;
  }

  .control-text {
    display: none;
  }

  .speed-selector {
    gap: 4px;
  }

  .speed-label {
    display: none;
  }

  .select-speed {
    padding: 4px 6px;
    font-size: 0.74rem;
  }

  /* Bottom Half: Settings & Tabs (Only this section scrolls) */
  .sidebar-section {
    flex: 1 1 50%;
    height: 50%;
    max-height: 50%;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-left: none;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
  }

  .sidebar-tabs {
    flex: 0 0 auto;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-text-full {
    display: none;
  }
  .tab-text-short {
    display: inline;
  }

  .tab-btn {
    flex: 1;
    min-width: 60px;
    padding: 9px 3px;
    font-size: 0.74rem;
    text-align: center;
  }

  .tab-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px 28px;
  }

  /* Metrics Grid on Mobile */
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    padding: 8px;
  }

  .metric-card.highlight .metric-value {
    font-size: 1.35rem;
  }

  .metric-value {
    font-size: 1.05rem;
  }

  /* Thumb-friendly parameter sliders with safe touch spacing */
  .param-row {
    margin-bottom: 15px;
    touch-action: pan-y;
  }

  .param-row input[type="range"] {
    height: 8px;
    margin: 8px 0;
    touch-action: pan-y;
  }

}

@media (max-width: 420px) {
  .brand-title {
    font-size: 0.82rem;
  }

  .select-preset {
    max-width: 110px;
  }


  .btn-control {
    padding: 6px 5px;
  }

  .timeline-time {
    font-size: 0.65rem;
    min-width: 36px;
  }
}
