/* FortiHack Simulator — obsidian / hacker-green / crimson theme */
:root {
  --obsidian: #0A0E17;
  --panel: #0D1424;
  --line: #1B2540;
  --green: #00FF66;
  --green-dim: #00c04d;
  --crimson: #FF0033;
  --amber: #FFCC00;
  --text: #C8D3F2;
  --muted: #6B7899;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--obsidian);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* CRT overlay (toggleable) */
.crt-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: repeating-linear-gradient(0deg, rgba(0,255,102,.035) 0 1px, transparent 1px 3px);
  mix-blend-mode: screen;
  animation: crt-flicker 4.5s infinite steps(60);
}
.crt-off .crt-overlay { display: none; }
@keyframes crt-flicker { 0%,100% { opacity: .55; } 50% { opacity: .7; } 52% { opacity: .5; } }

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0B1120 0%, var(--obsidian) 100%);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  font-size: 15px;
  text-decoration: none;
  color: var(--green);
}
.brand .tag { color: var(--muted); font-weight: 500; letter-spacing: .04em; font-size: 12px; }
.glitch { position: relative; text-shadow: 0 0 8px rgba(0,255,102,.45); }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  overflow: hidden;
}
.glitch::before {
  color: var(--crimson);
  animation: glitch-a 2.7s infinite linear alternate-reverse;
  clip-path: inset(0 0 55% 0);
  opacity: .65;
}
.glitch::after {
  color: #00E5FF;
  animation: glitch-b 3.3s infinite linear alternate-reverse;
  clip-path: inset(55% 0 0 0);
  opacity: .65;
}
@keyframes glitch-a { 0%,90%,100% { transform: none; } 92% { transform: translate(-2px,1px); } 96% { transform: translate(2px,-1px); } }
@keyframes glitch-b { 0%,88%,100% { transform: none; } 91% { transform: translate(2px,1px); } 95% { transform: translate(-2px,-1px); } }

.hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-chip {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0B1222;
  color: var(--muted);
  white-space: nowrap;
}
.hud-chip b { color: var(--green); font-weight: 700; }
.hud-chip.timer b { color: var(--amber); }
.hud-btn {
  font-size: 13px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0B1222;
  color: var(--text);
  cursor: pointer;
  transition: .15s;
}
.hud-btn:hover { border-color: var(--green); color: var(--green); }
.hud-btn.is-off { opacity: .45; }
.hud-btn.primary {
  background: rgba(0,255,102,.08);
  border-color: rgba(0,255,102,.45);
  color: var(--green);
  font-weight: 600;
}
.hud-btn.primary:hover { background: rgba(0,255,102,.16); }

.levels { display: flex; gap: 6px; }
.level-badge {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font: 700 12px ui-monospace, monospace;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: #0B1222;
}
.level-badge.is-active { border-color: var(--green); color: var(--green); box-shadow: 0 0 10px rgba(0,255,102,.25); }
.level-badge.is-done { border-color: var(--green-dim); color: var(--obsidian); background: var(--green); }

/* terminal */
.stage { max-width: 1180px; margin: 26px auto 40px; padding: 0 18px; }
.term-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--obsidian);
  box-shadow: 0 0 0 1px rgba(0,255,102,.06), 0 18px 60px rgba(0,0,0,.55), inset 0 0 80px rgba(0,255,102,.03);
}
.term-title {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: #0B1222;
  border-bottom: 1px solid var(--line);
  font: 600 12px ui-monospace, monospace;
  color: var(--muted);
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.r { background: #FF5F56; } .dot.y { background: #FFBD2E; } .dot.g { background: #27C93F; }
#term { height: 62vh; min-height: 420px; padding: 10px 6px 6px; cursor: text; }
#term .xterm { height: 100%; }

/* Terminal control bar */
.term-controls { margin-left: auto; display: inline-flex; gap: 8px; }
.term-btn {
  font: 600 11px ui-monospace, monospace; color: var(--muted);
  background: #10192B; border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 10px; cursor: pointer; transition: color .15s, border-color .15s;
}
.term-btn:hover { color: #d9ffe9; border-color: var(--green); }

/* Custom dark terminal scrollbar */
.xterm-viewport::-webkit-scrollbar { width: 12px; }
.xterm-viewport::-webkit-scrollbar-track { background: #0B1222; }
.xterm-viewport::-webkit-scrollbar-thumb {
  background: #1E2A42; border-radius: 8px; border: 2px solid #0B1222;
}
.xterm-viewport::-webkit-scrollbar-thumb:hover { background: #2C3D63; }
.xterm-viewport { scrollbar-width: thin; scrollbar-color: #1E2A42 #0B1222; }

/* Fullscreen state */
.term-shell:fullscreen { border-radius: 0; height: 100vh; display: flex; flex-direction: column; }
.term-shell:fullscreen #term { height: calc(100vh - 42px); min-height: 0; flex: 1; }
.term-shell:-webkit-full-screen { border-radius: 0; height: 100vh; display: flex; flex-direction: column; }
.term-shell:-webkit-full-screen #term { height: calc(100vh - 42px); min-height: 0; flex: 1; }

/* content sections */
.content { max-width: 1180px; margin: 0 auto 60px; padding: 0 18px; }
.content h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.15;
  margin: 44px 0 14px;
  color: #fff;
  letter-spacing: -.01em;
}
.content h1 span { color: var(--green); }
.content h2 { margin: 38px 0 14px; font-size: 24px; color: #fff; }
.lead { color: var(--muted); font-size: 17px; max-width: 760px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-top: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.card h3 { font-size: 15px; color: var(--green); margin-bottom: 8px; font-family: ui-monospace, monospace; }
.card p { font-size: 14px; color: var(--muted); line-height: 1.6; }
.card .tier { font-size: 11px; letter-spacing: .12em; color: var(--amber); text-transform: uppercase; }
.content ul.plain { list-style: none; }
.content ul.plain li { padding: 7px 0 7px 26px; position: relative; color: var(--text); font-size: 15px; }
.content ul.plain li::before { content: '▸'; position: absolute; left: 4px; color: var(--green); }
code, .cmd {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: #0B1222;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .92em;
  color: var(--amber);
}
.faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.faq summary { cursor: pointer; font-weight: 600; color: #fff; }
.faq details p { margin-top: 10px; color: var(--muted); font-size: 14.5px; line-height: 1.65; }
.footer {
  border-top: 1px solid var(--line);
  padding: 22px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.footer a { color: var(--green); text-decoration: none; }

/* leaderboard drawer */
.lb-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 7, 13, .6);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: .2s;
  z-index: 90;
}
.lb-backdrop.is-open { opacity: 1; pointer-events: auto; }
.lb-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 94vw);
  background: var(--panel);
  border-left: 1px solid rgba(0,255,102,.25);
  box-shadow: -24px 0 60px rgba(0,0,0,.6);
  transform: translateX(105%);
  transition: transform .25s ease;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.lb-drawer.is-open { transform: translateX(0); }
.lb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.lb-head h2 { font-size: 16px; color: #fff; font-family: ui-monospace, monospace; letter-spacing: .04em; }
.lb-head h2 b { color: var(--green); }
.lb-tabs { display: flex; gap: 8px; padding: 12px 18px 0; }
.lb-tab {
  flex: 1;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0B1222;
  color: var(--muted);
  cursor: pointer;
}
.lb-tab.is-active { border-color: var(--green); color: var(--green); background: rgba(0,255,102,.08); }
.lb-meta { padding: 10px 18px 4px; font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; }
.lb-meta b { color: var(--amber); }
.lb-table { flex: 1; overflow-y: auto; padding: 8px 12px 18px; }
.lb-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lb-table th {
  text-align: left; color: var(--muted); font-size: 11px;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 8px; border-bottom: 1px solid var(--line);
}
.lb-table td { padding: 9px 8px; border-bottom: 1px solid rgba(27,37,64,.6); font-family: ui-monospace, monospace; }
.lb-rank { color: var(--muted); width: 42px; }
.lb-rank-1 .lb-rank { color: var(--amber); font-weight: 800; }
.lb-rank-2 .lb-rank { color: #C0C7D5; font-weight: 800; }
.lb-rank-3 .lb-rank { color: #D2996B; font-weight: 800; }
.lb-user { color: var(--text); }
.lb-flag {
  /* SVG country flags — render identically on every device (no emoji font). */
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  margin-right: 8px;
  display: inline-block;
  vertical-align: -1px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.lb-score { color: var(--green); font-weight: 700; }
.lb-levels, .lb-time { color: var(--muted); }
.lb-close {
  background: none; border: 1px solid var(--line); color: var(--muted);
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
}
.lb-close:hover { color: var(--crimson); border-color: var(--crimson); }

/* identity modal */
.id-modal {
  position: fixed; inset: 0;
  background: rgba(4,7,13,.72);
  display: none;
  place-items: center;
  z-index: 120;
}
.id-modal.is-open { display: grid; }
.id-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(0,255,102,.3);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.id-card h3 { color: #fff; font-size: 17px; margin-bottom: 6px; }
.id-card p { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.id-card input, .id-card select {
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 10px;
  background: #0B1222;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
}
.id-card input:focus, .id-card select:focus { outline: none; border-color: var(--green); }
.id-error { color: var(--crimson); font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }
.id-actions { display: flex; gap: 10px; }
.id-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0B1222;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.id-actions .go { background: rgba(0,255,102,.12); border-color: var(--green); color: var(--green); }

@media (max-width: 760px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .hud { justify-content: center; }
  #term { height: 56vh; min-height: 320px; }
  .brand .tag { display: none; }
}