/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === Variables === */
:root {
  --neon: #00ff41;
  --neon-dim: #00ff4144;
  --neon-glow: #00ff4188;
  --bg: #000;
  --panel-bg: rgba(0, 0, 0, 0.5);
  --border: #1a3a1a;
  --text: #c0c0c0;
  --text-dim: #888;
  --cyan: #00e5ff;
  --purple: #bf5fff;
  --amber: #ffaa00;
  --pink: #ff6688;
  --gold: #ffdd44;
}

/* === Base === */
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', monospace;
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

/* === CRT Scanlines Overlay === */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.03) 0px,
    rgba(0,0,0,0.03) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 999;
}

/* === Game Canvas === */
#game {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  cursor: crosshair;
}

/* === HUD === */
.game-hud {
  position: fixed;
  top: 12px; left: 16px;
  z-index: 3;
  font-size: 14px;
  color: var(--neon);
  text-shadow: 0 0 8px var(--neon-dim);
  pointer-events: none;
}
.game-hud .score { font-size: 22px; font-weight: bold; }
.game-hud .game-selector { height: 18px; } /* spacer for canvas-drawn game names */
.game-hud .controls { font-size: 10px; color: #666; margin-top: 2px; }

/* === Toggle UI Button === */
.toggle-ui {
  position: fixed;
  top: 12px; right: 16px;
  z-index: 4;
  background: rgba(0,0,0,0.6);
  border: 1px solid #333;
  color: var(--neon);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  letter-spacing: 1px;
  border-radius: 2px;
  transition: all 0.3s;
  text-shadow: 0 0 6px var(--neon-dim);
}
.toggle-ui:hover {
  border-color: var(--neon);
  box-shadow: 0 0 12px var(--neon-dim);
}

/* === Terminal Wrap === */
.terminal-wrap {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.terminal-wrap.hidden {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none !important;
}
.tabs, .tab-panel, .header a, .link-row a, .ops-card, .ops-logout { pointer-events: auto; }
.terminal-wrap.hidden .tabs,
.terminal-wrap.hidden .tab-panel,
.terminal-wrap.hidden .header a { pointer-events: none; }

/* === Header === */
.header {
  text-align: center;
  margin-bottom: 24px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 32px;
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon-glow), 0 0 30px var(--neon-dim), 0 0 60px rgba(0,255,65,0.15);
  letter-spacing: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  animation: glitch 5s infinite;
}
.header .tagline {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 3px;
}
.cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--neon);
  box-shadow: 0 0 6px var(--neon-glow);
  animation: blink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}

/* === Glitch Animation === */
@keyframes glitch {
  0%, 95%, 100% { clip-path: none; transform: translateX(0); text-shadow: 0 0 10px var(--neon-glow), 0 0 30px var(--neon-dim); }
  96% { clip-path: inset(20% 0 60% 0); transform: translateX(-3px); text-shadow: -2px 0 var(--pink), 2px 0 var(--cyan); }
  97% { clip-path: inset(50% 0 10% 0); transform: translateX(3px); text-shadow: 2px 0 var(--pink), -2px 0 var(--cyan); }
  98% { clip-path: inset(10% 0 80% 0); transform: translateX(-1px); }
  99% { clip-path: none; transform: translateX(0); }
}

@keyframes blink { 50% { opacity: 0; } }

/* === Tabs === */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}
.tab {
  padding: 10px 20px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.3s;
}
.tab:hover {
  color: #aaa;
  text-shadow: 0 0 8px rgba(255,255,255,0.1);
}
.tab.active {
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon-dim);
  border-color: var(--border);
  border-bottom: 1px solid var(--bg);
  margin-bottom: -1px;
  background: rgba(0,255,65,0.02);
}

/* === Tab Panels (Glassy) === */
.tab-panel {
  border: 1px solid var(--border);
  border-top: none;
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 30px rgba(0,255,65,0.03), inset 0 0 30px rgba(0,0,0,0.3);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.tab-panel.active {
  opacity: 1;
  transform: translateY(0);
}

/* === Project Rows === */
.project {
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,255,65,0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s, border-left 0.2s;
  border-left: 2px solid transparent;
  padding-left: 8px;
  opacity: 0;
  animation: fadeSlideIn 0.3s ease forwards;
}
.project:hover {
  background: rgba(0,255,65,0.03);
  border-left-color: var(--neon);
}
.project:last-child { border-bottom: none; }
.project-name {
  color: var(--neon);
  font-size: 14px;
  text-shadow: 0 0 6px var(--neon-dim);
}
.project-name .arrow { color: #333; margin-right: 8px; }
.project-desc { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.project-tag {
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  color: #3a7a3a;
  border-radius: 3px;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(0,255,65,0.1);
}
.project-tag.tag-cyan { color: var(--cyan); border-color: #0a3a3a; text-shadow: 0 0 4px rgba(0,229,255,0.2); }
.project-tag.tag-purple { color: var(--purple); border-color: #2a1a3a; text-shadow: 0 0 4px rgba(191,95,255,0.2); }
.project-tag.tag-amber { color: var(--amber); border-color: #3a2a0a; text-shadow: 0 0 4px rgba(255,170,0,0.2); }
.project-tag.tag-pink { color: var(--pink); border-color: #3a1a1a; text-shadow: 0 0 4px rgba(255,102,136,0.2); }
.project-tag.tag-gold { color: var(--gold); border-color: #3a3a0a; text-shadow: 0 0 4px rgba(255,221,68,0.2); }

/* Project names alternate colors */
.project:nth-child(1) .project-name { color: var(--neon); text-shadow: 0 0 6px var(--neon-dim); }
.project:nth-child(2) .project-name { color: var(--cyan); text-shadow: 0 0 6px rgba(0,229,255,0.3); }
.project:nth-child(3) .project-name { color: var(--amber); text-shadow: 0 0 6px rgba(255,170,0,0.3); }
.project:nth-child(4) .project-name { color: var(--purple); text-shadow: 0 0 6px rgba(191,95,255,0.3); }
.project:nth-child(5) .project-name { color: var(--pink); text-shadow: 0 0 6px rgba(255,102,136,0.3); }
.project:nth-child(1):hover { border-left-color: var(--neon); }
.project:nth-child(2):hover { border-left-color: var(--cyan); }
.project:nth-child(3):hover { border-left-color: var(--amber); }
.project:nth-child(4):hover { border-left-color: var(--purple); }
.project:nth-child(5):hover { border-left-color: var(--pink); }

/* Staggered row animation */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.tab-panel.active .project:nth-child(1) { animation-delay: 0.05s; }
.tab-panel.active .project:nth-child(2) { animation-delay: 0.1s; }
.tab-panel.active .project:nth-child(3) { animation-delay: 0.15s; }
.tab-panel.active .project:nth-child(4) { animation-delay: 0.2s; }
.tab-panel.active .project:nth-child(5) { animation-delay: 0.25s; }

/* === Status Rows === */
.status-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,255,65,0.06);
  font-size: 13px;
}
.status-row:last-child { border-bottom: none; }
.status-label { color: var(--text-dim); }
.status-val {
  color: var(--neon);
  text-shadow: 0 0 8px var(--neon-dim);
}
.status-val.online { animation: pulse 2s ease-in-out infinite; }
.status-val.cyan { color: var(--cyan); text-shadow: 0 0 8px rgba(0,229,255,0.3); }
.status-val.purple { color: var(--purple); text-shadow: 0 0 8px rgba(191,95,255,0.3); }
.status-val.amber { color: var(--amber); text-shadow: 0 0 8px rgba(255,170,0,0.3); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* === About Text === */
.about-text {
  color: #999;
  font-size: 13px;
  line-height: 1.8;
}
.about-text p { margin-bottom: 4px; }
.about-text .highlight {
  color: var(--neon);
  text-shadow: 0 0 6px var(--neon-dim);
}

/* === Link Rows === */
.link-row {
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,255,65,0.06);
  font-size: 13px;
}
.link-row:last-child { border-bottom: none; }
.link-row a {
  color: var(--neon);
  text-decoration: none;
  text-shadow: 0 0 6px var(--neon-dim);
  transition: text-shadow 0.2s;
}
.link-row a:hover {
  text-shadow: 0 0 12px var(--neon-glow);
}
.link-row a.link-cyan { color: var(--cyan); text-shadow: 0 0 6px rgba(0,229,255,0.3); }
.link-row a.link-cyan:hover { text-shadow: 0 0 14px rgba(0,229,255,0.6); }
.link-row a.link-amber { color: var(--amber); text-shadow: 0 0 6px rgba(255,170,0,0.3); }
.link-row a.link-amber:hover { text-shadow: 0 0 14px rgba(255,170,0,0.6); }
.link-row a.link-gold { color: var(--gold); text-shadow: 0 0 6px rgba(255,221,68,0.3); }
.link-row a.link-gold:hover { text-shadow: 0 0 14px rgba(255,221,68,0.6); }
.link-row .link-desc { color: #777; margin-left: 12px; }

/* === Ops Tab (Auth Only) === */
.ops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ops-card {
  display: block;
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 4px;
  background: rgba(0,0,0,0.3);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.ops-card:hover {
  border-color: var(--neon);
  box-shadow: 0 0 15px var(--neon-dim);
  text-decoration: none;
}
.ops-card-name {
  color: var(--neon);
  font-size: 14px;
  font-weight: bold;
  text-shadow: 0 0 6px var(--neon-dim);
}
.ops-card-desc { color: var(--text-dim); font-size: 11px; margin-top: 4px; }
.ops-card-badge {
  font-size: 9px;
  margin-top: 8px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: inline-block;
}
.ops-card-badge.cyan { color: var(--cyan); border-color: #0a3a3a; }
.ops-card-badge.purple { color: var(--purple); border-color: #2a1a3a; }
.ops-card-badge.amber { color: var(--amber); border-color: #3a2a0a; }
.ops-card-badge.green { color: var(--neon); border-color: var(--border); }
.ops-card-badge.pink { color: var(--pink); border-color: #3a1a1a; }
.ops-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,255,65,0.06);
  text-align: right;
}
.ops-logout {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px;
}
.ops-logout:hover { color: var(--neon); }

/* === Footer === */
.footer {
  flex-shrink: 0;
  text-align: center;
  padding: 12px;
  font-size: 10px;
  color: #444;
  letter-spacing: 2px;
}

/* === Toast === */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--neon);
  font-size: 24px;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 20px var(--neon-glow);
  pointer-events: none;
  z-index: 100;
  animation: toastFade 2s forwards;
}
@keyframes toastFade {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* === Screen Shake === */
@keyframes shake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -2px); }
  60% { transform: translate(-2px, 3px); }
  80% { transform: translate(2px, -3px); }
}
body.shaking { animation: shake 0.3s ease; }

/* === Login Page === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-box {
  background: rgba(10,10,10,0.9);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 40px;
  width: 320px;
  text-align: center;
}
.login-title {
  color: var(--neon);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 3px;
  margin-bottom: 24px;
  text-shadow: 0 0 10px var(--neon-dim);
}
.login-error {
  color: var(--pink);
  font-size: 12px;
  margin-bottom: 12px;
}
.login-box input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  margin-bottom: 14px;
}
.login-box input:focus { border-color: var(--neon); box-shadow: 0 0 8px var(--neon-dim); }
.login-box button {
  width: 100%;
  background: transparent;
  color: var(--neon);
  border: 1px solid var(--neon);
  border-radius: 4px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  text-shadow: 0 0 6px var(--neon-dim);
}
.login-box button:hover {
  background: var(--neon);
  color: var(--bg);
  box-shadow: 0 0 15px var(--neon-dim);
  text-shadow: none;
}

/* === 404 Page === */
.page-404 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  font-family: 'Courier New', monospace;
}
.dead-ship {
  animation: drift 8s ease-in-out infinite;
  margin-bottom: 32px;
  opacity: 0.4;
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(15px, -10px) rotate(5deg); }
  50% { transform: translate(-10px, 8px) rotate(-3deg); }
  75% { transform: translate(8px, 12px) rotate(2deg); }
}
.four04-code {
  font-size: 80px;
  color: var(--neon);
  font-weight: bold;
  text-shadow: 0 0 30px var(--neon-dim);
  margin-bottom: 8px;
}
.four04-text {
  font-size: 18px;
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon-dim);
  letter-spacing: 6px;
  margin-bottom: 16px;
}
.four04-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 32px; }
.four04-link {
  color: var(--neon);
  font-size: 14px;
  text-decoration: none;
  text-shadow: 0 0 6px var(--neon-dim);
}
.four04-link:hover { text-shadow: 0 0 12px var(--neon-glow); }

/* === Secret Overlays === */
.secret-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.secret-terminal {
  font-family: 'Courier New', monospace;
  color: var(--neon);
  font-size: 14px;
  line-height: 2;
  text-shadow: 0 0 6px var(--neon-dim);
}
.bsod-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: #0078d7;
  display: flex; align-items: center; justify-content: center;
}
.bsod-content {
  color: white;
  font-family: 'Segoe UI', sans-serif;
  font-size: 18px;
  max-width: 600px;
  text-align: left;
}
.bsod-content h2 { font-size: 64px; font-weight: 200; margin-bottom: 24px; }
.matrix-canvas {
  position: fixed; inset: 0; z-index: 500; pointer-events: none;
}
.hack-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.95);
  padding: 20px;
  overflow-y: auto;
}

/* === Scrollbar === */
.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* === Scores Tab === */
.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}
.scores-col {
  min-width: 0;
}
.scores-header {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  text-shadow: 0 0 8px currentColor;
  margin-bottom: 4px;
}
.scores-separator {
  color: #333;
  font-size: 12px;
  margin-bottom: 8px;
}
.scores-list {
  font-size: 13px;
  line-height: 1.8;
}
.scores-entry {
  display: flex;
  gap: 8px;
  color: var(--text);
}
.scores-entry .rank { color: var(--text-dim); min-width: 24px; }
.scores-entry .initials { color: var(--neon); min-width: 40px; }
.scores-entry .score-val { color: var(--text); margin-left: auto; }
.scores-empty {
  color: #444;
  font-style: italic;
  font-size: 12px;
}

@media (max-width: 600px) {
  .scores-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* === Mobile === */
@media (max-width: 768px) {
  .terminal-wrap { padding: 20px 12px; }
  .header h1 { font-size: 22px; letter-spacing: 4px; }
  .tabs { overflow-x: auto; }
  .tab { padding: 8px 14px; font-size: 12px; }
  .ops-grid { grid-template-columns: 1fr; }
  .game-hud .controls { display: none; }
}
