/* ============================================
   运维闯关大挑战 - 终端风格样式
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Courier New', 'Fira Code', 'Consolas', monospace;
  background: #0d0d1a;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(0, 255, 65, 0.05), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(100, 120, 180, 0.06), transparent 45%);
  color: #d4d4d4;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* --- Animations --- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 255, 65, 0.4); }
  50% { box-shadow: 0 0 20px rgba(0, 255, 65, 0.8); }
}

@keyframes scanline {
  0% { top: -100%; }
  100% { top: 100%; }
}

/* --- Common: Terminal Window --- */
.terminal-window {
  background: #1a1a2e;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.4),
    0 0 70px rgba(0, 255, 65, 0.05);
  border: 1px solid rgba(0, 255, 65, 0.08);
  width: 100%;
  max-width: 800px;
  animation: fadeIn 0.5s ease-out;
  position: relative;
}

.terminal-window::after {
  content: '';
  position: absolute;
  top: -100%;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(transparent, rgba(0, 255, 65, 0.02), transparent);
  animation: scanline 8s linear infinite;
  pointer-events: none;
}

.terminal-header {
  background: #16213e;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #0f3460;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dot.red { background: #ff5f56; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #27c93f; }

.terminal-title {
  margin-left: 8px;
  font-size: 0.8rem;
  color: #8892b0;
}

.terminal-body {
  padding: 24px;
  min-height: 200px;
}

/* --- Common: Prompt & Text --- */
.prompt {
  color: #00ff41;
  font-weight: bold;
  margin-right: 6px;
}

.typing-text {
  margin-bottom: 12px;
  color: #ccd6f6;
  font-size: 0.95rem;
}

.blink-cursor {
  color: #00ff41;
  font-weight: bold;
  animation: blink 1s step-end infinite;
  font-size: 1.1rem;
}

.loading-state {
  padding: 20px 0;
  animation: fadeIn 0.3s ease-out;
}

/* --- Page Containers --- */
.landing-container,
.result-container {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 20px 0;
}

.game-page {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 0;
}

.loading-standalone {
  max-width: 800px;
  margin: 0 auto;
}

/* ============================================
   Index Page (Landing)
   ============================================ */
.ascii-art {
  text-align: center;
  margin-bottom: 16px;
}

.ascii-art pre {
  color: #00ff41;
  font-size: 0.55rem;
  line-height: 1.2;
  display: inline-block;
  text-align: left;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}

.game-title {
  text-align: center;
  font-size: 1.6rem;
  color: #e6f1ff;
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
}

.game-subtitle {
  text-align: center;
  color: #00ff41;
  font-size: 0.95rem;
  margin-bottom: 24px;
  opacity: 0.85;
}

.game-intro {
  margin-bottom: 28px;
}

.intro-content {
  background: rgba(0, 255, 65, 0.04);
  border-left: 3px solid #00ff41;
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  margin-top: 8px;
}

.intro-content p {
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #a8b2d1;
}

.intro-content p:last-child {
  margin-bottom: 0;
}

.intro-content strong {
  color: #ffbd2e;
}

.start-section {
  text-align: center;
  padding: 20px 0 8px;
}

.ready-text {
  margin-bottom: 20px;
  font-size: 1rem;
}

.start-btn {
  display: inline-block;
  background: linear-gradient(135deg, #00ff41, #00cc33);
  color: #0d0d1a;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: bold;
  padding: 14px 40px;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 24px rgba(0, 255, 65, 0.6), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.start-btn:active {
  transform: scale(0.97);
}

.landing-footer,
.game-footer,
.result-footer {
  text-align: center;
  padding: 16px 0;
  color: #5a6785;
  font-size: 0.8rem;
}

/* --- Debug cheat-code panel (testing shortcut on landing page) --- */
.debug-cheat-section {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed #2a3f5f;
  text-align: center;
}

.cheat-toggle-btn {
  background: transparent;
  color: #5a6785;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 6px 14px;
  border: 1px solid #2a3f5f;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cheat-toggle-btn:hover {
  color: #8892b0;
  border-color: #3d4f6f;
}

.cheat-panel {
  margin-top: 14px;
  padding: 16px 18px;
  background: rgba(100, 120, 180, 0.06);
  border: 1px solid rgba(100, 120, 180, 0.2);
  border-radius: 8px;
  text-align: left;
  animation: fadeIn 0.3s ease-out;
}

.cheat-hint {
  color: #8892b0;
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.cheat-input-line {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.cheat-code-input {
  flex: 1;
  background: #0d0d1a;
  border: 1px solid #1e2d4a;
  border-radius: 6px;
  color: #e6f1ff;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  min-height: 38px;
  outline: none;
}

.cheat-code-input:focus {
  border-color: #6478b4;
}

.cheat-code-input::placeholder {
  color: #3d4f6f;
}

.cheat-submit-btn {
  background: linear-gradient(135deg, #6478b4, #8892d0);
  color: #e6f1ff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: bold;
  padding: 8px 18px;
  min-height: 38px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cheat-submit-btn:hover:not(:disabled) {
  box-shadow: 0 0 12px rgba(100, 120, 180, 0.5);
}

.cheat-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cheat-error {
  color: #ff5f56;
  font-size: 0.8rem;
  margin-bottom: 10px;
}

.cheat-code-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: #5a6785;
}

.cheat-code-list code {
  color: #e2b714;
  background: rgba(226, 183, 20, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ============================================
   Game Page
   ============================================ */

/* --- Two-pane layout: WebShell terminal (left) + task info panel (right) --- */
.game-layout {
  display: flex;
  align-items: stretch;
  gap: 20px;
}

.terminal-pane {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #0d0d1a;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.4),
    0 0 70px rgba(0, 255, 65, 0.05);
  border: 1px solid rgba(0, 255, 65, 0.08);
  min-height: 620px;
  position: relative;
  animation: fadeIn 0.5s ease-out;
}

.webshell-header {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.webshell-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #27c93f;
}

.webshell-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #27c93f;
  box-shadow: 0 0 6px rgba(39, 201, 63, 0.8);
  animation: blink 1.6s ease-in-out infinite;
}

.webshell-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  background: #0a0a14;
}

.webshell-body .xterm-container {
  flex: 1 1 auto;
  min-height: 0;
}

.webshell-body #legacy-terminal {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
}

.webshell-body #legacy-terminal .terminal-output {
  flex: 1 1 auto;
  max-height: none;
}

.terminal-pane .feedback-area,
.terminal-pane .redirect-banner {
  margin: 0 16px 16px;
  border-radius: 8px;
}

.terminal-pane .feedback-area:empty {
  display: none;
}

/* --- Right-side task/info panel --- */
.info-panel {
  flex: 0 0 380px;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 2px 8px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(226, 183, 20, 0.1);
  animation: fadeIn 0.5s ease-out;
}

.info-panel-header {
  background: #16213e;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #0f3460;
}

.info-panel-icon {
  font-size: 1rem;
}

.info-panel-title {
  font-size: 0.85rem;
  font-weight: bold;
  color: #e2b714;
  letter-spacing: 0.02em;
}

.info-panel-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.info-panel .action-buttons {
  flex-direction: column;
}

.info-panel .action-btn {
  min-width: 0;
  width: 100%;
}


.challenge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.challenge-index {
  color: #ccd6f6;
  font-size: 1rem;
  font-weight: bold;
}

.difficulty-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
}

.difficulty-badge.easy {
  background: rgba(39, 201, 63, 0.15);
  color: #27c93f;
  border: 1px solid rgba(39, 201, 63, 0.3);
}

.difficulty-badge.medium {
  background: rgba(255, 189, 46, 0.15);
  color: #ffbd2e;
  border: 1px solid rgba(255, 189, 46, 0.3);
}

.difficulty-badge.hard {
  background: rgba(255, 95, 86, 0.15);
  color: #ff5f56;
  border: 1px solid rgba(255, 95, 86, 0.3);
}

.scenario-section {
  margin-bottom: 16px;
}

.scenario-text {
  background: rgba(204, 214, 246, 0.05);
  padding: 14px 18px;
  border-radius: 8px;
  color: #a8b2d1;
  font-size: 0.9rem;
  line-height: 1.7;
  margin-top: 8px;
  border-left: 3px solid #e2b714;
}

.environment-section {
  margin-bottom: 20px;
}

.environment-output {
  background: #0d0d1a;
  color: #8892b0;
  padding: 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
  border: 1px solid #1e2d4a;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

.command-section {
  margin-bottom: 20px;
}

.command-input-line {
  display: flex;
  align-items: center;
  background: #0d0d1a;
  padding: 12px 14px;
  border-radius: 8px 8px 0 0;
  border: 1px solid #1e2d4a;
  border-bottom: none;
}

.command-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e6f1ff;
  font-family: inherit;
  font-size: 1rem;
  min-height: 24px;
  caret-color: #00ff41;
}

.command-input::placeholder {
  color: #3d4f6f;
}

.submit-btn {
  display: block;
  width: 100%;
  min-height: 46px;
  background: linear-gradient(135deg, #e2b714, #f0c040);
  color: #0d0d1a;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  padding: 12px;
  border: none;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.submit-btn:hover {
  box-shadow: 0 0 16px rgba(226, 183, 20, 0.5);
  transform: translateY(-1px);
}

.submit-btn:active {
  transform: scale(0.98);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Terminal Scrolling Output Area --- */
.terminal-output {
  background: #0a0a14;
  color: #d4d4d4;
  font-family: 'Courier New', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #1e2d4a;
  margin-bottom: 16px;
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  scroll-behavior: smooth;
}

.terminal-output:empty {
  display: none;
}

.terminal-output .terminal-cmd {
  color: #00ff41;
}

.terminal-output .terminal-response {
  color: #a8b2d1;
  margin-bottom: 8px;
  display: block;
}

.terminal-output .terminal-system {
  color: #e2b714;
  font-style: italic;
}

.terminal-output .terminal-error {
  color: #ff5f56;
}

.terminal-output .terminal-success {
  color: #27c93f;
}

/* --- Action Buttons --- */
.action-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.action-btn {
  flex: 1;
  min-width: 140px;
  min-height: 46px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: bold;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.submit-action-btn {
  background: linear-gradient(135deg, #e2b714, #f0c040);
  color: #0d0d1a;
}

.submit-action-btn:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(226, 183, 20, 0.5);
  transform: translateY(-1px);
}

.next-action-btn {
  background: linear-gradient(135deg, #00ff41, #00cc33);
  color: #0d0d1a;
}

.next-action-btn:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.5);
  transform: translateY(-1px);
}

.result-action-btn {
  background: linear-gradient(135deg, #6478b4, #8892d0);
  color: #e6f1ff;
}

.result-action-btn:hover:not(:disabled) {
  box-shadow: 0 0 16px rgba(100, 120, 180, 0.5);
  transform: translateY(-1px);
}

/* --- Feedback Area --- */
.feedback-area {
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease-out;
}

.feedback-area.correct {
  background: rgba(39, 201, 63, 0.1);
  border: 1px solid rgba(39, 201, 63, 0.3);
  color: #27c93f;
}

.feedback-area.wrong {
  background: rgba(255, 95, 86, 0.1);
  border: 1px solid rgba(255, 95, 86, 0.3);
  color: #ff5f56;
}

/* --- Redirect Banner (auto-jump to result page) --- */
.redirect-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  background: rgba(226, 183, 20, 0.1);
  border: 1px solid rgba(226, 183, 20, 0.35);
  color: #e2b714;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease-out;
}

.redirect-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.redirect-now-btn,
.redirect-cancel-btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: bold;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.redirect-now-btn {
  background: linear-gradient(135deg, #00ff41, #00cc33);
  color: #0d0d1a;
}

.redirect-now-btn:hover {
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.5);
  transform: translateY(-1px);
}

.redirect-cancel-btn {
  background: transparent;
  color: #a8b2d1;
  border-color: #3d4f6f;
}

.redirect-cancel-btn:hover {
  border-color: #8892b0;
  color: #ccd6f6;
}

/* --- Hint Section --- */
.hint-section {
  margin-top: 8px;
}

.hint-btn {
  background: rgba(100, 120, 180, 0.15);
  color: #8892b0;
  font-family: inherit;
  font-size: 0.85rem;
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid rgba(100, 120, 180, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.hint-btn:hover {
  background: rgba(100, 120, 180, 0.25);
  color: #ccd6f6;
  box-shadow: 0 0 10px rgba(100, 120, 180, 0.3);
}

.hints-area {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(100, 120, 180, 0.08);
  border-radius: 8px;
  border-left: 3px solid #6478b4;
  color: #a8b2d1;
  font-size: 0.85rem;
  animation: fadeIn 0.3s ease-out;
}

/* ============================================
   Result Page
   ============================================ */
.result-grade-section {
  margin-bottom: 24px;
}

.grade-display {
  text-align: center;
  padding: 24px 16px;
  background: rgba(0, 255, 65, 0.04);
  border-radius: 8px;
  margin-top: 12px;
  border: 1px solid rgba(0, 255, 65, 0.1);
}

.grade-label {
  font-size: 1rem;
  color: #8892b0;
  margin-bottom: 8px;
}

.grade-name {
  font-size: 1.8rem;
  color: #00ff41;
  text-shadow: 0 0 16px rgba(0, 255, 65, 0.5);
  margin-bottom: 10px;
  animation: glowPulse 3s ease-in-out infinite;
  display: inline-block;
}

.grade-description {
  color: #a8b2d1;
  font-size: 0.95rem;
  line-height: 1.6;
}

.result-score-section {
  margin-bottom: 24px;
}

.score-display {
  text-align: center;
  padding: 16px;
  background: rgba(226, 183, 20, 0.06);
  border-radius: 8px;
  margin-top: 12px;
  border: 1px solid rgba(226, 183, 20, 0.15);
}

.score-text {
  font-size: 1.1rem;
  color: #ccd6f6;
}

.score-highlight {
  color: #e2b714;
  font-weight: bold;
  font-size: 1.4rem;
}

.result-special-section {
  margin-bottom: 24px;
  padding: 14px 18px;
  background: rgba(39, 201, 63, 0.08);
  border: 1px solid rgba(39, 201, 63, 0.3);
  border-radius: 8px;
  text-align: center;
}

.special-message-text {
  color: #27c93f;
  font-size: 1.05rem;
  font-weight: bold;
  line-height: 1.6;
  margin: 0;
}

.result-details-section {
  margin-bottom: 28px;
}

.details-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.details-list li {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  font-size: 0.85rem;
  color: #a8b2d1;
  border-left: 3px solid #3d4f6f;
  transition: background 0.2s ease;
}

.details-list li:hover {
  background: rgba(255, 255, 255, 0.07);
}

.result-actions {
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 0;
}

.back-home-link {
  display: inline-block;
  padding: 12px 28px;
  border: 1px solid #3d4f6f;
  border-radius: 8px;
  color: #8892b0;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.back-home-link:hover {
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 600px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  .landing-container,
  .game-page,
  .result-container {
    padding: 0;
    max-width: 100%;
  }

  .game-layout {
    flex-direction: column;
    gap: 0;
  }

  .info-panel {
    flex: 0 0 auto;
    order: -1;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .terminal-pane {
    min-height: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    flex: 1 1 auto;
  }

  .webshell-body {
    min-height: min(360px, 50vh);
    min-height: min(360px, 50dvh);
  }

  .terminal-window {
    border-radius: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    border-left: none;
    border-right: none;
  }

  .terminal-body {
    padding: 16px;
    flex: 1;
  }

  .terminal-header {
    padding: 12px 14px;
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .ascii-art {
    display: none;
  }

  .game-title {
    font-size: 1.3rem;
    margin-top: 4px;
  }

  .game-subtitle {
    font-size: 0.8rem;
  }

  .start-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 14px 20px;
  }

  .grade-name {
    font-size: 1.3rem;
  }

  .score-highlight {
    font-size: 1.2rem;
  }

  .challenge-header {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .challenge-index {
    font-size: 0.9rem;
  }

  .scenario-text,
  .environment-output {
    font-size: 0.85rem;
    padding: 12px 14px;
  }

  .xterm-container {
    height: min(360px, 50vh);
    height: min(360px, 50dvh);
  }

  .command-input-line {
    padding: 10px 12px;
  }

  .command-input {
    font-size: 1rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-btn {
    min-width: 0;
    width: 100%;
  }

  .redirect-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .redirect-actions {
    justify-content: center;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .start-btn,
  .result-actions .back-home-link {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
  }

  .intro-content {
    padding: 12px 14px;
  }

  .terminal-output {
    max-height: 220px;
    font-size: 0.8rem;
  }
}

@media (max-width: 400px) {
  .terminal-header {
    padding: 10px 12px;
  }

  .terminal-dot {
    width: 9px;
    height: 9px;
  }

  .terminal-title {
    font-size: 0.7rem;
  }

  .difficulty-badge {
    font-size: 0.72rem;
    padding: 2px 10px;
  }
}

/* Landscape phones: keep the terminal usable without excessive height */
@media (max-width: 900px) and (orientation: landscape) {
  .xterm-container {
    height: min(300px, 60vh);
    height: min(300px, 60dvh);
  }
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #0d0d1a;
}

::-webkit-scrollbar-thumb {
  background: #1e2d4a;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #2a3f5f;
}

/* --- Selection --- */
::selection {
  background: rgba(0, 255, 65, 0.25);
  color: #e6f1ff;
}

/* --- xterm.js Terminal Container --- */
.xterm-container {
  width: 100%;
  height: 400px;
}
