/* Far Rover Demo - Photorealistic Mars Theme */

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/fonts/IBMPlexMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/fonts/IBMPlexMono-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --bg-primary: #0a0806;
  --bg-glass: rgba(10, 8, 6, 0.75);
  --bg-glass-solid: rgba(15, 12, 10, 0.9);
  --text-primary: #f0e8e0;
  --text-secondary: #a89888;
  --text-muted: #706050;
  
  --accent: #e67e22;
  --accent-hover: #f39c12;
  --accent-glow: rgba(230, 126, 34, 0.4);
  --success: #40d070;
  --success-glow: rgba(64, 208, 112, 0.3);
  --warning: #e0a030;
  --danger: #e04040;
  --danger-glow: rgba(224, 64, 64, 0.3);
  
  --glass-border: rgba(255, 240, 220, 0.08);
  --glass-border-light: rgba(255, 240, 220, 0.15);
  --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #0a0806;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Full-viewport Mars horizon background */
#game-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('assets/art/bg-horizon.png');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

/* Glass panel base */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  box-shadow: var(--glass-shadow);
}

/* Buttons */
button {
  cursor: pointer;
  font-size: 13px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  transition: all 0.15s;
  min-height: 36px;
  font-weight: 500;
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

button:hover:not(:disabled) {
  background: rgba(40, 35, 30, 0.9);
  border-color: var(--glass-border-light);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #c05a10);
  border: 1px solid rgba(255, 150, 80, 0.3);
  color: white;
  font-weight: 600;
}

.primary-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  transform: translateY(-1px);
}

.glow-btn {
  box-shadow: 0 0 20px var(--accent-glow);
}

.secondary-btn {
  background: var(--bg-glass-solid);
}

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

.secondary-btn.danger:hover {
  background: var(--danger);
  color: white;
}

/* === TITLE SCREEN === */
.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 20px;
}

.title-screen h1 {
  font-size: 4rem;
  margin-bottom: 0.8rem;
  background: linear-gradient(135deg, var(--accent), #f0a040, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 60px var(--accent-glow);
}

.title-screen .pitch {
  font-size: 1.1rem;
  max-width: 550px;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.goal-box {
  padding: 16px 24px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 12px;
}

.goal-icon { font-size: 1.8rem; }
.goal-text { text-align: left; font-size: 0.95rem; }

#start-btn {
  font-size: 1.15rem;
  padding: 14px 45px;
}

/* === BUILD SCREEN === */
.build-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 15px;
  overflow: hidden;
}

.build-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.build-header h2 {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-indicator {
  background: rgba(230, 126, 34, 0.2);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--accent);
  border: 1px solid rgba(230, 126, 34, 0.3);
}

.build-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.sensors-section, .rules-section, .reference-section {
  padding: 14px;
  overflow-y: auto;
}

.sensors-section h3, .rules-section h3, .reference-section h3 {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 0.95rem;
}

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

.rules-header h3 { margin-bottom: 0; }

.sensor-count, .rule-note {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: normal;
}

.sensor-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sensor-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(30, 25, 20, 0.6);
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-size: 0.9rem;
}

.sensor-item.always-on {
  opacity: 0.6;
  cursor: default;
}

.sensor-item.selectable:hover {
  background: rgba(50, 40, 30, 0.8);
  border-color: var(--accent);
}

.sensor-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.sensor-check {
  color: var(--success);
  font-weight: bold;
  width: 18px;
}

.sensor-name { font-weight: 500; flex: 1; }
.sensor-desc, .sensor-note { font-size: 0.8rem; color: var(--text-secondary); }

/* Rules */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(30, 25, 20, 0.6);
  border-radius: 6px;
  flex-wrap: wrap;
  border: 1px solid transparent;
}

.rule-slot.illegal {
  border: 2px solid var(--danger);
}

.rule-number {
  font-weight: bold;
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  color: var(--accent);
}

.rule-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.rule-content select {
  padding: 8px 10px;
  border-radius: 5px;
  border: 1px solid var(--glass-border);
  background: rgba(15, 12, 10, 0.9);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 140px;
}

.rule-content select:focus {
  border-color: var(--accent);
  outline: none;
}

.rule-arrow {
  font-size: 1.1rem;
  color: var(--accent);
}

.battery-n {
  width: 88px;
  min-width: 88px;
  height: 44px;
  padding: 8px;
  border-radius: 5px;
  border: 1px solid var(--glass-border);
  background: rgba(15, 12, 10, 0.9);
  color: var(--text-primary);
  text-align: center;
  font-size: 1.35rem;
  font-weight: 600;
}

.rule-controls {
  display: flex;
  gap: 4px;
}

.rule-controls button {
  padding: 4px 10px;
  min-height: 30px;
  font-size: 0.95rem;
}

.rule-warning {
  width: 100%;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 6px;
}

.preset-btn {
  background: linear-gradient(135deg, #4080d0, #2050a0);
  color: white;
  padding: 6px 12px;
  font-size: 12px;
  border: 1px solid rgba(100, 150, 255, 0.3);
}

.preset-btn:hover {
  background: linear-gradient(135deg, #5090e0, #4080d0);
}

/* Reference */
.reference-section {
  grid-column: 1 / -1;
}

.reference-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.reference-col h4 {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.85rem;
}

.reference-col ul {
  list-style: none;
  font-size: 0.85rem;
}

.reference-col li {
  margin-bottom: 5px;
  padding-left: 10px;
  border-left: 2px solid var(--glass-border);
  color: var(--text-secondary);
}

.reference-col li strong {
  color: var(--text-primary);
}

.build-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  margin-top: 12px;
  flex-shrink: 0;
}

#launch-btn {
  font-size: 1rem;
  padding: 12px 40px;
}
.launch-why {
  align-self: center;
  color: var(--warn, #3FD8FF);
  font-size: 0.85rem;
}
.battery-max-hint {
  margin-left: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary, #9aa);
}

/* === OPERATE VIEW === */
.operate-view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 168px 1fr 186px;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 8px;
}

.operate-view.orbital-ops {
  display: block;
  padding: 0;
  gap: 0;
  font-family: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.orbital-ops .map-container {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.orbital-ops .map-grid {
  background: #121314;
}

.orbital-ops .hud-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 0;
  padding: 10px 28px 18px;
  background: linear-gradient(to bottom, rgba(8, 10, 12, 0.82) 0%, rgba(8, 10, 12, 0.35) 70%, transparent 100%);
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  pointer-events: none;
}

.orbital-ops .hud-bar > * {
  pointer-events: auto;
}

.hud-left {
  justify-self: start;
}

.hud-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.orbital-ops .hud-brand {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #e8ecee;
  padding: 0;
}

.hud-ops {
  font-size: 0.78rem;
  color: #96a0a6;
  letter-spacing: 0.12em;
}

.hud-sat {
  margin-top: 4px;
  font-size: 0.7rem;
  color: #8a949a;
  letter-spacing: 0.08em;
}

.hud-center {
  justify-self: center;
  text-align: center;
  padding-top: 0;
}

.orbital-ops .tick-indicator {
  display: block;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e8ecee;
  line-height: 1.1;
}

.hud-playback {
  font-size: 0.7rem;
  color: #8a949a;
  letter-spacing: 0.16em;
  margin-top: 2px;
}

.hud-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 6px;
}

.orbital-ops .hud-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1.5px solid #eb5046;
  border-radius: 4px;
  color: #f06056;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  font-weight: 500;
}

.orbital-ops .hud-feed {
  border: none;
  margin: 0;
  padding: 0;
  color: #96a0a6;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.orbital-left {
  position: absolute;
  top: 78px;
  left: 18px;
  z-index: 30;
  width: 286px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}

.sensor-layers-panel {
  background: rgba(10, 12, 14, 0.58);
  border: 1px solid rgba(120, 135, 145, 0.35);
  border-radius: 6px;
  padding: 12px 10px 14px;
}

.orbital-ops .instrument-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: #96a0a6;
  margin: 0 6px 8px;
}

.orbital-ops .instrument-stack {
  gap: 8px;
  margin-bottom: 10px;
}

.orbital-ops .instrument-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 10px;
  background: rgba(16, 18, 20, 0.58);
  border: 1px solid rgba(70, 78, 84, 0.62);
  border-radius: 5px;
  color: #afb6ba;
  font-family: inherit;
  text-transform: none;
  cursor: pointer;
}

.orbital-ops .instrument-toggle:focus-visible {
  outline: 2px solid rgba(220, 228, 232, 0.95);
  outline-offset: 2px;
}

.orbital-ops .instrument-toggle.standby-only {
  cursor: pointer;
  opacity: 0.92;
}

.orbital-ops .instrument-toggle.active {
  background: rgba(38, 44, 48, 0.82);
  border: 2px solid rgba(210, 220, 225, 0.9);
  color: #e8ecee;
  box-shadow: inset 0 0 0 1px rgba(96, 214, 120, 0.25);
}

.instrument-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
}

.orbital-ops .instrument-name {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.instrument-state {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: #6e767a;
}

.orbital-ops .instrument-toggle.active .instrument-state {
  color: #60d678;
}

.orbital-ops .instrument-toggle.active .instrument-dot {
  background: #60d678;
}

.layer-ico {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  opacity: 0.85;
  background: center / 18px no-repeat;
}

.ico-cam {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23e8ecee' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Crect x='3' y='8' width='18' height='12' rx='2'/%3E%3Ccircle cx='12' cy='14' r='3.5'/%3E%3Cpath d='M8 8V6h3'/%3E%3C/svg%3E");
}

.ico-lidar {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2396a0a6' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Cpath d='M4 14c4-6 12-6 16 0'/%3E%3Cpath d='M7 16c3-4 7-4 10 0'/%3E%3Ccircle cx='12' cy='18' r='1.4' fill='%2396a0a6'/%3E%3C/svg%3E");
}

.ico-thermal {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2396a0a6' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Cpath d='M12 4v10'/%3E%3Crect x='10' y='3' width='4' height='11' rx='2'/%3E%3Cpath d='M9 16.5a3 3 0 1 0 6 0'/%3E%3C/svg%3E");
}

.ico-spectral {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%2396a0a6' stroke-width='1.8' viewBox='0 0 24 24'%3E%3Cpath d='M4 18 L12 5 L20 18 Z'/%3E%3C/svg%3E");
}

.telemetry-block {
  border-top: 1px solid rgba(120, 135, 145, 0.35);
  padding-top: 10px;
}

.tel-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  padding: 3px 8px;
  color: #96a0a6;
}

.tel-row span:last-child {
  color: #e8ecee;
  font-variant-numeric: tabular-nums;
}

.orbital-ops .rules-panel {
  max-height: none;
  background: rgba(10, 12, 14, 0.5);
}

.orbital-ops .info-panel {
  position: absolute;
  top: 78px;
  right: 12px;
  bottom: 88px;
  z-index: 30;
  width: 186px;
  max-height: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.orbital-ops .info-panel .glass-panel {
  background: rgba(8, 12, 16, 0.72);
}

.tracking-strip {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 28;
  background: rgba(8, 10, 12, 0.62);
  border: 1px solid rgba(120, 135, 145, 0.32);
  border-radius: 4px;
  padding: 7px 16px;
  font-size: 0.78rem;
  color: #d6dce0;
  letter-spacing: 0.06em;
  white-space: nowrap;
  min-height: 2.2em;
  min-width: 42em;
  max-width: min(72vw, 920px);
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  pointer-events: none;
}

.credits-line {
  position: absolute;
  left: 18px;
  bottom: 6px;
  z-index: 26;
  font-size: 0.58rem;
  color: rgba(170, 178, 184, 0.7);
  letter-spacing: 0.04em;
  max-width: 48%;
  pointer-events: none;
}

.visual-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Top HUD bar */
.hud-bar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 6px 12px;
  background: rgba(8, 12, 16, 0.62);
  backdrop-filter: blur(12px);
  border-radius: 4px;
  border: 1px solid rgba(220, 230, 230, 0.08);
}

.hud-brand {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: #e8e0d4;
  font-weight: 700;
  padding-right: 10px;
}

.hud-feed {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: #9aa8a8;
  padding-right: 10px;
  border-right: 1px solid rgba(220, 230, 230, 0.1);
  margin-right: 8px;
}

.hud-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: #f0e8e0;
  padding: 0 12px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e04040;
  box-shadow: 0 0 8px rgba(224, 64, 64, 0.7);
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.hud-compass {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(220, 230, 230, 0.22);
  border-radius: 50%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-size: 0.55rem;
  color: #d8d0c4;
  letter-spacing: 0.06em;
  padding-top: 2px;
}

.hud-section {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  border-right: 1px solid var(--glass-border);
}

.hud-section:last-child {
  border-right: none;
}

.hud-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hud-icon {
  font-size: 1rem;
}

.hud-value {
  font-weight: 600;
  font-size: 0.95rem;
}

.tick-indicator {
  color: var(--accent);
}

.battery-gauge {
  width: 50px;
  height: 10px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.battery-gauge .battery-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--warning), var(--success));
  transition: width 0.3s;
}

/* Rules Panel (left) */
.rules-panel {
  padding: 10px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: relative;
  z-index: 20;
  background: rgba(8, 12, 16, 0.55);
}

.rules-panel h3 {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.rule-line {
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 0.8rem;
  background: rgba(30, 25, 20, 0.5);
  display: flex;
  align-items: flex-start;
  gap: 6px;
  border-left: 3px solid transparent;
  line-height: 1.3;
}

.rule-line.fired {
  background: linear-gradient(90deg, rgba(230, 126, 34, 0.4), rgba(230, 126, 34, 0.15));
  border-left-color: var(--accent);
}

.rule-line.checked-false {
  opacity: 0.42;
}

.live-rule-reason {
  margin: 0 0 8px;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--accent);
  background: rgba(230, 126, 34, 0.14);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  min-height: 1.2em;
}

.live-sensors {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  font-size: 0.75rem;
}

.live-sensor {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted, #9aa3ad);
}

.live-sensor strong {
  color: var(--text, #e8f2f6);
  font-weight: 600;
}

.live-sensor-cam {
  grid-column: 1 / -1;
}

.rule-indicator {
  color: var(--accent);
  font-size: 0.75rem;
  width: 10px;
  flex-shrink: 0;
}

.action-name {
  color: var(--accent);
}

.hosted-notify-ping {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.hosted-notify-ping.ice-confirm {
  color: var(--accent);
  border-color: rgba(255, 138, 31, 0.55);
  background: rgba(255, 138, 31, 0.14);
}
.hosted-notify-ping.trace-ice {
  color: #3FD8FF;
  border-color: rgba(63, 216, 255, 0.5);
  background: rgba(63, 216, 255, 0.12);
}
.notify-ping-badge {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.68rem;
  white-space: nowrap;
}
.notify-ping-badge.ice-confirm {
  color: var(--accent);
  background: rgba(255, 138, 31, 0.16);
}
.notify-ping-badge.trace-ice {
  color: #3FD8FF;
  background: rgba(63, 216, 255, 0.14);
}
.rule-line.notified {
  border-left-color: #3FD8FF;
}

/* Map Container (center) */
.map-container {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.map-grid {
  position: relative;
  width: 100%;
  height: 100%;
  background: #2a1a12;
}

.orbital-grain,
.orbital-scanlines,
.orbital-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.orbital-grain {
  opacity: 0.012;
  mix-blend-mode: normal;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

.map-grid.optical-on .orbital-grain {
  opacity: 0.016;
}

.orbital-scanlines {
  opacity: 0.01;
  mix-blend-mode: normal;
  background: repeating-linear-gradient(
    to bottom,
    rgba(20, 10, 6, 0.10) 0px,
    rgba(20, 10, 6, 0.10) 1px,
    transparent 1px,
    transparent 4px
  );
}

.orbital-vignette {
  background: radial-gradient(ellipse at center, transparent 80%, rgba(12, 6, 4, 0.10) 100%);
}

.rover-tag {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, 0);
  pointer-events: none;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  color: #f0ebe4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
}

.instrument-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.instrument-label {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.instrument-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  min-height: 30px;
  padding: 5px 8px;
  background: rgba(10, 14, 18, 0.45);
  border: 1px solid rgba(220, 230, 230, 0.08);
  border-radius: 3px;
  color: #c8c0b4;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.instrument-toggle .instrument-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a4038;
  flex-shrink: 0;
}

.instrument-toggle.active {
  border-color: rgba(126, 200, 212, 0.45);
  color: #e8f4f4;
  background: rgba(20, 36, 40, 0.55);
}

.instrument-toggle.active .instrument-dot {
  background: #40d070;
  box-shadow: 0 0 6px rgba(64, 208, 112, 0.6);
}

.instrument-note {
  margin-left: auto;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: none;
}

.orbital-ops .minimap {
  display: none;
}

.rover-cam {
  position: absolute;
  right: 228px;
  bottom: 52px;
  width: 300px;
  z-index: 12;
  background: rgba(10, 12, 14, 0.84);
  border: 1px solid rgba(150, 162, 170, 0.78);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  cursor: grab;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}

.rover-cam.dragging {
  cursor: grabbing;
}

.rover-cam-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #e8ecee;
  padding: 8px 12px 6px;
  background: transparent;
}

.rover-cam-nav {
  color: #96a0a6;
  font-size: 0.68rem;
}

#rover-cam-canvas {
  display: block;
  width: calc(100% - 16px);
  height: 168px;
  margin: 0 8px;
  background: #2a1a12;
}

.rover-cam-modes {
  display: flex;
  gap: 4px;
  padding: 4px 10px 2px;
}

.cam-mode-btn {
  flex: 1;
  min-height: 28px;
  padding: 3px 4px;
  border: 1px solid rgba(150, 162, 170, 0.45);
  border-radius: 3px;
  background: rgba(16, 18, 20, 0.55);
  color: #9aa4aa;
  font-family: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.cam-mode-btn.active,
.cam-mode-btn[aria-pressed="true"] {
  color: #e8ecee;
  border-color: rgba(210, 220, 225, 0.9);
  background: rgba(38, 44, 48, 0.9);
}

.cam-mode-btn:focus-visible {
  outline: 2px solid rgba(220, 228, 232, 0.95);
  outline-offset: 1px;
}

.rover-cam-meta {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: #96a0a6;
  background: transparent;
}

.game-canvas {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: block;
  touch-action: none;
  position: relative;
  z-index: 1;
}

.map-grid[data-renderer="3d"] {
  position: relative;
  overflow: hidden;
  background: #2a1a12;
}

.map-grid[data-renderer="3d"] .game-canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 1;
}

.view-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
}

.view-tool-btn {
  flex: 1;
  font-size: 0.75rem;
  padding: 6px 8px;
  background: rgba(30, 25, 20, 0.6);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  cursor: pointer;
}

.view-tool-btn:hover {
  background: rgba(50, 40, 30, 0.8);
}

.grid-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Info Panel (right) */
.info-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  position: relative;
  z-index: 20;
}

.orbital-ops .info-panel .glass-panel,
.orbital-ops .minimap {
  background: rgba(8, 12, 16, 0.58);
  border-radius: 4px;
}

.sensors-panel, .controls-panel {
  padding: 12px;
}

.sensors-panel h3 {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.orbital-ops .sensors-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.orbital-ops .controls-panel {
  flex: 0 0 auto;
}

.sensor-readings {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sensor-reading {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  align-items: start;
  gap: 6px;
  font-size: 0.8rem;
  min-height: 2.85em;
  padding: 4px 0;
  border-bottom: 1px solid var(--glass-border);
}

.sensor-reading .sensor-value {
  text-align: right;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.sensor-reading:last-child {
  border-bottom: none;
}

.sensor-reading .sensor-label {
  white-space: nowrap;
}

.sensor-reading .warning {
  color: var(--warning);
  font-weight: 600;
}

/* Controls */
.speed-controls {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.speed-btn {
  flex: 1;
  padding: 8px;
  font-size: 0.9rem;
  min-height: 34px;
}

.speed-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pause-btn {
  width: 100%;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), #c05a10);
  color: white;
  font-weight: 600;
}

.step-btn, .uplink-btn, .end-run-btn {
  width: 100%;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.step-btn.hidden {
  display: none;
}

.uplink-btn {
  background: rgba(30, 60, 80, 0.7);
  border: 1px solid #40a0c0;
  color: #60c0e0;
}

.uplink-btn:hover:not(:disabled) {
  background: #40a0c0;
  color: white;
}

.uplink-btn.used, .uplink-btn:disabled {
  border-color: var(--glass-border);
  color: var(--text-muted);
  background: var(--bg-glass);
}

.end-run-btn {
  background: var(--bg-glass);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: 0.8rem;
}

.end-run-btn:hover {
  background: var(--danger);
  color: white;
}

/* Minimap (bottom left) */
.minimap {
  position: fixed;
  bottom: 15px;
  left: 15px;
  padding: 8px;
  z-index: 50;
}

#minimap-canvas {
  display: block;
  border-radius: 4px;
}

.minimap-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}

.build-warnings {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.build-warning {
  color: var(--warning);
  font-size: 0.85rem;
  line-height: 1.35;
}

.autopause-mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.autopause-mode select {
  background: rgba(15, 12, 10, 0.55);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 4px 8px;
  min-height: 32px;
}

.orbital-ops .return-crater-note {
  bottom: 58px;
}

.return-crater-note {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass-solid);
  border: 1px solid rgba(230, 160, 80, 0.4);
  color: var(--warning);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 90;
  font-size: 0.85rem;
}

/* Auto-pause Toast (slim glass notification) */
.auto-pause-toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass-solid);
  backdrop-filter: blur(16px);
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid rgba(230, 160, 80, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 90%;
}

.auto-pause-toast.stuck {
  border-color: rgba(224, 64, 64, 0.5);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.toast-icon {
  font-size: 1.2rem;
}

.toast-text {
  color: var(--warning);
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 520px;
}

.auto-pause-toast.stuck .toast-text {
  color: var(--danger);
}

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

.toast-actions button {
  padding: 6px 14px;
  font-size: 0.85rem;
  min-height: 32px;
}

.resume-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.uplink-toast-btn {
  background: rgba(40, 100, 120, 0.8);
  border-color: #40a0c0;
  color: #80d0f0;
}

.end-toast-btn {
  background: rgba(120, 40, 40, 0.8);
  border-color: var(--danger);
  color: #f08080;
}

/* Uplink Dialog */
.uplink-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.uplink-dialog {
  padding: 24px;
  max-width: 420px;
  width: 100%;
}

.uplink-dialog h3 {
  margin-bottom: 8px;
  color: #60c0e0;
}

.uplink-dialog p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.uplink-slot-select {
  margin-bottom: 16px;
}

.uplink-slot-select label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.uplink-slot-select select,
.uplink-rule-edit select,
.uplink-rule-edit input {
  width: 100%;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid var(--glass-border);
  background: rgba(15, 12, 10, 0.9);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.uplink-rule-edit {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.uplink-rule-edit label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.uplink-rule-edit .hidden {
  display: none;
}

.uplink-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* === END SCREEN === */
.end-screen {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.end-header {
  text-align: center;
  margin-bottom: 0;
  padding: 12px 16px;
  flex-shrink: 0;
}

.end-header h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.end-screen.success .end-header h2 {
  color: var(--success);
  text-shadow: 0 0 20px var(--success-glow);
}

.end-screen.failure .end-header h2 {
  color: var(--danger);
  text-shadow: 0 0 20px var(--danger-glow);
}

.end-reason {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.stat-item {
  padding: 10px 6px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

/* Trace display - single-line rows so 5 ticks fit at 1280x800 */
.end-trace {
  padding: 10px 12px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.end-trace h3 {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.85rem;
}

.trace-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}

.trace-item {
  background: rgba(30, 25, 20, 0.6);
  padding: 6px 10px;
  border-radius: 5px;
  display: grid;
  grid-template-columns: 64px 150px 90px 1fr;
  gap: 8px;
  font-size: 0.78rem;
  border-left: 3px solid var(--glass-border);
  align-items: center;
}

.trace-tick {
  font-weight: 700;
  color: var(--accent);
}

.trace-battery {
  color: var(--text-secondary);
}

.trace-reason {
  color: var(--text-muted);
  font-family: 'Monaco', 'Consolas', monospace;
  font-size: 0.72rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

#show-more-trace {
  margin-top: 8px;
  font-size: 0.8rem;
  padding: 6px 12px;
}

.end-why {
  margin-bottom: 0;
  padding: 10px 12px;
  flex-shrink: 0;
}

.end-why label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.end-why input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  background: rgba(15, 12, 10, 0.55);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.end-why input:focus {
  border-color: var(--accent);
  outline: none;
}

.end-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding-top: 4px;
  flex-shrink: 0;
}

#rerun-btn {
  font-size: 1rem;
  padding: 12px 40px;
}

/* === LOG SCREEN === */
.log-screen {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  height: 100%;
  overflow-y: auto;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
}

.log-header h2 {
  color: var(--accent);
  font-size: 1.2rem;
}

.session-id {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stale-sessions {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.log-summary {
  padding: 16px;
  margin-bottom: 14px;
}

.log-summary h3 {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 0.9rem;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(30, 25, 20, 0.5);
  border-radius: 5px;
  font-size: 0.85rem;
}

.summary-item.highlight {
  border: 1px solid var(--accent);
}

.log-table-container {
  padding: 16px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.log-table th, .log-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.log-table th {
  background: rgba(30, 25, 20, 0.5);
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.75rem;
}

.log-table tr:hover {
  background: rgba(40, 35, 30, 0.5);
}

.log-table .success { color: var(--success); }
.log-table .failure { color: var(--danger); }

.prompted-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.log-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.log-footer {
  display: flex;
  justify-content: center;
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
  .operate-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }
  
  .rules-panel {
    display: none;
  }

  .orbital-left {
    top: 58px;
    left: 6px;
    width: min(210px, 54vw);
    max-height: 46vh;
  }

  .orbital-ops .hud-bar {
    padding: 6px 10px 10px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .hud-title-row {
    flex-wrap: nowrap;
  }

  .orbital-ops .hud-brand {
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .hud-ops {
    font-size: 0.58rem;
    white-space: nowrap;
  }

  .orbital-ops .tick-indicator {
    font-size: 1.05rem;
  }

  .hud-sat, .run-indicator, .telemetry-block {
    display: none;
  }

  .tracking-strip {
    font-size: 0.58rem;
    padding: 5px 8px;
    bottom: 8px;
    max-width: calc(100% - 24px);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .credits-line {
    display: none;
  }

  .tel-row.tel-game {
    display: none;
  }
  
  .info-panel {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 200px;
    max-height: 300px;
    z-index: 40;
  }

  .orbital-ops .info-panel {
    top: auto;
    bottom: 8px;
    right: 6px;
    width: min(160px, 44vw);
    max-height: 38vh;
  }

  .orbital-ops .sensors-panel {
    display: none;
  }
  
  .minimap {
    bottom: 10px;
    left: 10px;
  }

  .orbital-ops .minimap {
    display: none;
  }
  
  .map-container {
    grid-column: 1;
    grid-row: 3;
  }
  
  .hud-bar {
    flex-wrap: wrap;
    padding: 6px 10px;
  }
  
  .hud-section {
    padding: 0 10px;
    font-size: 0.85rem;
  }
}

@media (max-width: 600px) {
  .title-screen h1 {
    font-size: 2.5rem;
  }
  
  .build-content {
    grid-template-columns: 1fr;
  }
  
  .reference-content {
    grid-template-columns: 1fr;
  }
  
  .end-stats {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .trace-item {
    grid-template-columns: 60px 1fr;
  }
  
  .trace-battery {
    grid-column: 1 / -1;
    text-align: left;
  }
  
  .info-panel {
    width: 180px;
  }

  .rover-cam {
    width: 156px;
    right: auto;
    left: 8px;
    bottom: 48px;
  }

  #rover-cam-canvas {
    height: 92px;
  }

  .cam-mode-btn {
    min-height: 32px;
    font-size: 0.58rem;
  }

  .orbital-ops .instrument-toggle {
    min-height: 44px;
    padding: 6px 8px;
  }
  
  .auto-pause-toast {
    flex-direction: column;
    text-align: center;
  }
  
  .toast-actions {
    width: 100%;
    justify-content: center;
  }
}

@media (max-height: 700px) {
  .end-stats {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  
  .stat-item {
    padding: 8px 4px;
  }
  
  .stat-label {
    font-size: 0.65rem;
  }
  
  .stat-value {
    font-size: 1rem;
  }
  
  .trace-item {
    padding: 6px 10px;
    font-size: 0.78rem;
  }
  
  .end-trace {
    padding: 10px;
    margin-bottom: 10px;
  }
}
