@import url('https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&display=swap');

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

:root {
  --green: #00ff41;
  --green-dim: #00aa2a;
  --green-dark: #003b00;
  --red: #ff3333;
  --amber: #ffaa00;
  --cyan: #00e5ff;
  --bg: #0a0a0a;
  --panel: #0f0f0f;
  --border: #1a3a1a;
}

body {
  background: var(--bg);
  color: var(--green);
  font-family: 'Fira Mono', 'Courier New', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: 1fr;
  gap: 8px;
  height: 100vh;
}

/* Mission strip — compact top row */
.mission-strip {
  display: flex;
  flex-direction: column;
  height: auto;
  flex-shrink: 0;
}

.mission-text {
  overflow: visible;
  flex: 0 0 auto;
  min-height: auto;
  font-size: 0.85rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* Flag submission row — always pinned at bottom of mission strip */
.flag-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.flag-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: .08em;
  white-space: nowrap;
}
.flag-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 8px;
  outline: none;
  transition: border-color .15s;
}
.flag-input:focus {
  border-color: var(--amber);
}
.flag-input::placeholder {
  color: var(--green-dim);
}
.flag-btn {
  background: transparent;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.flag-btn:hover {
  background: var(--amber);
  color: var(--bg-dark);
}
.flag-row.correct .flag-input {
  border-color: var(--green);
  color: var(--green);
}
.flag-row.incorrect .flag-input {
  border-color: #ff4444;
  color: #ff4444;
}

.main-split {
  display: flex;
  min-height: 0;
  gap: 0;
}

.left-col {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 0;
  flex: 0 0 50%;
  gap: 0;
}

.right-col {
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 0;
  flex: 0 0 50%;
}

/* Terminal container in left col */
.terminal-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Browser container in right col */
.browser-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Drag handles */
.resize-handle-h {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.resize-handle-h::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: var(--border);
  border-radius: 1px;
  transition: background 0.2s, height 0.2s;
}

.resize-handle-h:hover::after,
.resize-handle-h.active::after {
  background: var(--green-dim);
  height: 60px;
}

.resize-handle-v {
  height: 6px;
  cursor: row-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.resize-handle-v::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  transition: background 0.2s, width 0.2s;
}

.resize-handle-v:hover::after,
.resize-handle-v.active::after {
  background: var(--green-dim);
  width: 60px;
}

/* Header */
.header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.logo {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.logo span { color: var(--red); }

.stage-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stage-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--green-dim);
  transition: all 0.3s;
  cursor: pointer;
  position: relative;
}

.stage-dot:hover {
  border-color: var(--green);
  transform: scale(1.2);
}

.stage-dot .stage-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--green);
  font-size: 0.65rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin-bottom: 6px;
  pointer-events: none;
}

.stage-dot:hover .stage-tooltip { display: block; }

.stage-dot.completed { background: var(--green); border-color: var(--green); }
.stage-dot.active { border-color: var(--amber); box-shadow: 0 0 8px var(--amber); }

/* Panels */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--green-dim);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.mission-text .highlight { color: var(--amber); font-weight: 700; }
.mission-text .cmd { color: var(--cyan); }

/* SQL Query visualizer */
.query-panel {
  flex: 0 0 auto;
  min-height: 100px;
  overflow-y: auto;
}

.query-display {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.7;
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
  position: relative;
}

.query-display .editor-topbar {
  display: flex;
  align-items: center;
  background: #2d2d2d;
  border-bottom: 1px solid #333;
  padding: 5px 12px;
  font-size: 0.7rem;
  color: #888;
  gap: 10px;
}

.query-display .editor-topbar .tab {
  background: #1e1e1e;
  border: 1px solid #333;
  border-bottom: 1px solid #1e1e1e;
  border-radius: 4px 4px 0 0;
  padding: 3px 12px;
  color: #ccc;
  font-size: 0.72rem;
  margin-bottom: -6px;
}

.query-display .editor-body {
  display: flex;
  min-height: 60px;
}

.query-display .line-numbers {
  padding: 12px 0;
  text-align: right;
  color: #555;
  font-size: 0.78rem;
  user-select: none;
  min-width: 36px;
  border-right: 1px solid #333;
  background: #1e1e1e;
}

.query-display .line-numbers div {
  padding: 0 8px;
  line-height: 1.7;
}

.query-display .code-area {
  padding: 12px 14px;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-all;
}

/* VS Code Dark+ token colors */
.query-display .sql-keyword { color: #569cd6; }
.query-display .sql-function { color: #dcdcaa; }
.query-display .sql-string { color: #ce9178; }
.query-display .sql-number { color: #b5cea8; }
.query-display .sql-operator { color: #d4d4d4; }
.query-display .sql-comment { color: #6a9955; font-style: italic; }
.query-display .sql-identifier { color: #9cdcfe; }
.query-display .sql-star { color: #d4d4d4; }
.query-display .sql-paren { color: #ffd700; }
.query-display .sql-comma { color: #d4d4d4; }
.query-display .sql-injection { color: #f44747; background: rgba(244, 71, 71, 0.1); border-radius: 2px; }
.query-display .sql-default { color: #d4d4d4; }

.query-label { display: none; }

.query-result {
  background: #050505;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  font-size: 0.8rem;
  max-height: 140px;
  overflow-y: auto;
}

.query-result.error { border-color: var(--red); color: var(--red); }
.query-result.success { border-color: var(--green); }

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.result-table th {
  text-align: left;
  color: var(--cyan);
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
}

.result-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #111;
}

/* Terminal */
.terminal-panel {
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
}

.terminal-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.terminal-output {
  font-size: 0.85rem;
  line-height: 1.6;
}

.terminal-output .sys { color: var(--green-dim); }
.terminal-output .err { color: var(--red); }
.terminal-output .warn { color: var(--amber); }
.terminal-output .info { color: var(--cyan); }
.terminal-output .success { color: var(--green); font-weight: 700; }

.terminal-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  min-height: 1.6em;
}

.prompt-symbol {
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--green);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.6;
  caret-color: var(--green);
  white-space: pre;
  overflow: hidden;
  min-height: 1.4em;
}

.terminal-input:empty::before {
  content: 'Type a command...';
  color: var(--green-dark);
}

/* Hint button */
.hint-btn {
  background: transparent;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: inherit;
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.2s;
}

.hint-btn:hover { background: rgba(255, 170, 0, 0.15); }

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* URL Bar UI */
.urlbar-container { display: flex; align-items: center; gap: 0; background: #111; border: 1px solid #333; border-radius: 6px; overflow: hidden; margin-bottom: 8px; flex-shrink: 0; }
.urlbar-prefix { padding: 10px 2px 10px 12px; color: #888; font-size: 0.82rem; white-space: nowrap; user-select: none; }
.urlbar-input { flex: 1; background: transparent; border: none; outline: none; color: #ddd; font-family: inherit; font-size: 0.82rem; padding: 10px 12px 10px 0; }
.urlbar-input::placeholder { color: #444; }

.urlbar-go { background: #2a5a8a; border: none; color: #fff; font-family: inherit; font-size: 0.78rem; font-weight: 700; padding: 10px 18px; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; transition: background 0.2s; }
.urlbar-go:hover { background: #3a6a9a; }

.urlbar-source { background: transparent; border: none; border-left: 1px solid #333; color: #888; font-family: inherit; font-size: 0.68rem; padding: 10px 14px; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; transition: all 0.2s; white-space: nowrap; }
.urlbar-source:hover { color: var(--cyan); }
.urlbar-source.active { color: var(--cyan); background: rgba(0, 229, 255, 0.08); }

.browser-viewport { flex: 1; overflow-y: auto; background: #fff; border: 1px solid #333; border-radius: 6px; position: relative; min-height: 0; }
.browser-frame { width: 100%; height: 100%; border: none; background: #fff; }
.browser-source { display: none; width: 100%; height: 100%; margin: 0; padding: 16px; font-size: 0.82rem; line-height: 1.6; color: var(--green-dim); background: #0a0a0a; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.browser-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; background: #0a0a0a; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--green-dark); border-radius: 3px; }

/* Success modal overlay */
.success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9000;
  overflow-y: auto;
  padding: 80px 0 40px;
  animation: fadeIn 0.3s ease;
}

.success-overlay.visible { display: flex; justify-content: center; align-items: flex-start; }

@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

.success-modal {
  background: #0f0f0f;
  border: 2px solid var(--green);
  border-radius: 12px;
  padding: 40px 48px;
  max-width: 560px;
  width: 90%;
  margin: auto;
  box-shadow: 0 0 60px rgba(0, 255, 65, 0.15), 0 0 120px rgba(0, 255, 65, 0.05);
  animation: slideUp 0.4s ease;
}

.success-badge {
  display: inline-block;
  background: var(--green);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 4px 14px;
  border-radius: 3px;
  margin-bottom: 16px;
}

.success-title {
  color: var(--green);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.success-subtitle {
  color: var(--cyan);
  font-size: 0.9rem;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.success-divider {
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.success-explanation {
  color: var(--green-dim);
  font-size: 0.85rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.success-defense {
  color: var(--amber);
  font-size: 0.82rem;
  line-height: 1.6;
  font-weight: 500;
}

.success-btn-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.success-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 2px solid var(--green);
  border-radius: 6px;
  color: var(--green);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.success-btn:hover {
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.15);
}

.success-btn.secondary {
  border-color: var(--text-dim);
  color: var(--text-dim);
}

.success-btn.secondary:hover {
  border-color: var(--text);
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

/* Typing animation */
@keyframes blink { 50% { opacity: 0; } }
.cursor-blink::after { content: '_'; animation: blink 1s step-end infinite; }

/* ========== COMPLETION SCREEN ========== */
.completion-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9001;
  overflow-y: auto;
  padding: 40px 0;
  animation: fadeIn 0.3s ease;
}

.completion-overlay.visible { display: flex; justify-content: center; align-items: flex-start; }

.completion-modal {
  background: #0f0f0f;
  border: 2px solid var(--green);
  border-radius: 12px;
  padding: 48px;
  max-width: 640px;
  width: 90%;
  margin: auto;
  box-shadow: 0 0 80px rgba(0, 255, 65, 0.2), 0 0 160px rgba(0, 255, 65, 0.08);
  animation: slideUp 0.5s ease;
}

.completion-badge {
  display: inline-block;
  background: var(--green);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 4px;
  padding: 6px 18px;
  border-radius: 3px;
  margin-bottom: 20px;
}

.completion-title {
  color: var(--green);
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.completion-subtitle {
  color: var(--green-dim);
  font-size: 0.85rem;
  margin-bottom: 28px;
}

.completion-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.completion-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(0, 255, 65, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}

.completion-card-num {
  color: var(--green);
  font-size: 1.1rem;
  font-weight: 700;
  min-width: 28px;
}

.completion-card-title {
  color: var(--green);
  font-size: 0.82rem;
  flex: 1;
}

.completion-card-owasp {
  color: var(--green-dim);
  font-size: 0.7rem;
  text-align: right;
  white-space: nowrap;
}

.completion-footer {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.completion-footer p {
  color: var(--green-dim);
  font-size: 0.78rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.completion-btn-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
