:root {
  --bg-color: #0d0f0d;
  --text-color: #33ff33;
  --text-dim: #1b8a1b;
  --text-alert: #ff3333;
  --text-warn: #ffaa00;
  --font-family: 'Courier New', Courier, monospace;
}

* { box-sizing: border-box; }

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

.terminal-container {
  width: 100%;
  max-width: 900px;
  height: 600px;
  border: 2px solid var(--text-dim);
  box-shadow: 0 0 15px rgba(51, 255, 51, 0.2);
  padding: 15px;
  display: flex;
  flex-direction: column;
  position: relative;
  background: rgba(0, 15, 0, 0.95);
}

.hud-bar {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--text-dim);
  padding-bottom: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: bold;
}

.trace-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trace-meter {
  width: 120px;
  height: 12px;
  border: 1px solid var(--text-color);
  background: #000;
  position: relative;
}

#trace-fill {
  width: 0%;
  height: 100%;
  background: var(--text-color);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.mission-panel {
  border: 1px solid var(--text-dim);
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(0, 25, 0, 0.65);
  flex: 0 0 auto;
}

.mission-panel-heading,
.mission-location {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.mission-panel-heading {
  justify-content: space-between;
  color: var(--text-warn);
  font-size: 11px;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--text-dim);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.mission-location {
  flex-wrap: wrap;
  line-height: 1.3;
}

#mission-level,
#mission-stage {
  color: var(--text-dim);
  font-size: 12px;
}

#mission-level-title {
  color: var(--text-color);
  font-size: 14px;
}

.mission-target {
  color: var(--text-warn);
  font-size: 12px;
  margin-top: 7px;
}

.mission-target-line {
  overflow-wrap: anywhere;
}

.mission-objectives {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 4px 16px;
  margin-top: 9px;
}

.mission-objective {
  min-width: 0;
  color: var(--text-color);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mission-objective.complete {
  color: var(--text-dim);
  text-decoration: line-through;
}

.mission-objective::before {
  content: '[ ] ';
  color: var(--text-warn);
}

.mission-objective.complete::before {
  content: '[x] ';
  color: var(--text-dim);
}

.terminal-container::before {
  content: ' ';
  display: block;
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  z-index: 10;
  pointer-events: none;
}

#output-log {
  flex: 1;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 620px) {
  body { padding: 8px; }

  .terminal-container {
    height: 100vh;
    padding: 10px;
  }

  .hud-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .mission-objectives {
    grid-template-columns: 1fr;
  }
}

.input-line {
  display: flex;
  align-items: center;
  font-size: 14px;
}

.recovery-controls {
  display: none;
  gap: 8px;
  margin-top: 10px;
}

.recovery-controls.visible { display: flex; }

.recovery-controls button {
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-color);
  cursor: pointer;
  font-family: var(--font-family);
  padding: 6px 10px;
}

.recovery-controls button:hover,
.recovery-controls button:focus {
  background: var(--text-color);
  color: var(--bg-color);
  outline: none;
}

.prompt {
  margin-right: 8px;
  color: var(--text-color);
  font-weight: bold;
}

#cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-color);
  font-family: var(--font-family);
  font-size: 14px;
}

.dim { color: var(--text-dim); }
.warn { color: var(--text-warn); }
.alert { color: var(--text-alert); font-weight: bold; }
