@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg:          #0f0d13;
  --surface:     #17141f;
  --surface2:    #1e1a2e;
  --border:      #2a2535;
  --border2:     #3b2d5e;
  --purple:      #7c3aed;
  --purple-lt:   #a78bfa;
  --purple-dim:  #3b2d5e;
  --purple-glow: rgba(124,58,237,0.3);
  --emerald:     #059669;
  --emerald-lt:  #34d399;
  --text:        #e2dff0;
  --muted:       #7b7491;
  --pixel:       'Press Start 2P', monospace;
  --sans:        'Inter', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124,58,237,0.2) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 5% 90%, rgba(124,58,237,0.07) 0%, transparent 60%);
}

/* ── NAVBAR ── */
.navbar { background: rgba(15,13,19,0.95) !important; border-bottom: 1px solid var(--border) !important; backdrop-filter: blur(12px); position: fixed; top: 0; left: 0; right: 0; z-index: 100; padding: 0 16px; }
.navbar .container { display: flex; align-items: center; justify-content: space-between; height: 56px; max-width: 100%; }
.navbar-brand {
  font-family: var(--pixel); font-size: 0.7rem; letter-spacing: 0.06em;
  background: linear-gradient(135deg, #c4b5fd 0%, #7c3aed 55%, #a78bfa 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  text-decoration: none !important; padding: 0 !important; line-height: 1;
}
.navbar-brand::before { display: none; }
.pc-icon { background-image: none !important; padding-left: 0 !important; }
.navbar-nav { display: flex; list-style: none; margin: 0; padding: 0; gap: 4px; align-items: center; }
.navbar-nav a {
  color: var(--muted) !important; font-size: 0.7rem; text-decoration: none;
  padding: 6px 10px; border-radius: 6px; transition: color 0.2s, background 0.2s;
  font-family: var(--sans); letter-spacing: 0.03em;
}
.navbar-nav a:hover { color: var(--purple-lt) !important; background: rgba(124,58,237,0.12); }
.navbar-collapse { display: flex !important; }
.navbar-toggle { display: none; }
.back-link { color: var(--muted) !important; font-size: 0.7rem; }
.back-link:hover { color: var(--purple-lt) !important; }

/* ── LAYOUT ── */
body > div[ng-cloak], .container-fluid { position: relative; z-index: 1; }
.container-fluid { padding-top: 72px; padding-bottom: 40px; padding-left: 12px; padding-right: 12px; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }

/* ── COLUMNS ── */
#column-lab { padding: 8px; }
#column-tabs { padding: 8px; }

/* ── MESSAGES / ACHIEVEMENTS ── */
#messages-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#achievements-container { position: fixed; top: 70px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.message-item, .achievement-item {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 10px 16px;
  font-size: 0.72rem; color: var(--text); max-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── DETECTOR ── */
#detector-holder { padding: 8px; }
#detector {
  position: relative; cursor: pointer;
  border-radius: 50%; overflow: hidden;
  background: #0f0d13;
  border: 2px solid var(--border2);
  box-shadow: 0 0 40px var(--purple-glow);
  transition: box-shadow 0.2s, border-color 0.2s;
  display: block; margin: 0 auto;
}
#detector:hover { box-shadow: 0 0 60px rgba(124,58,237,0.5); border-color: var(--purple); }
#detector:active { box-shadow: 0 0 80px rgba(124,58,237,0.7); }
#detector-core, #detector-events {
  position: absolute; top: 0; left: 0;
  width: 100% !important; height: 100% !important;
}
#detector-events { z-index: 2; }
#detector-info { position: absolute; top: 8px; right: 8px; z-index: 3; display: none; }

/* ── STAT PANEL ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.panel-heading {
  background: var(--surface2) !important; border-bottom: 1px solid var(--border) !important;
  padding: 12px 16px !important;
}
.panel-body { padding: 14px 16px !important; }
#labname {
  background: transparent; border: none; outline: none;
  color: var(--purple-lt); font-family: var(--pixel); font-size: 0.6rem;
  letter-spacing: 0.05em; width: 100%;
}
#labname::placeholder { color: var(--muted); }

.status {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.status:last-child { border-bottom: none; }
.status .col-xs-4, .status .col-md-6 { color: var(--muted); font-size: 0.72rem; }
.status .col-xs-8, .status .col-md-6:last-child { color: var(--purple-lt); font-weight: 600; font-family: var(--pixel); font-size: 0.6rem; text-align: right; }

/* ── TABS ── */
.nav-tabs { border-bottom: 1px solid var(--border); display: flex; list-style: none; padding: 0; margin: 0 0 0 0; gap: 4px; }
.nav-tabs li a {
  display: block; padding: 8px 14px; border-radius: 8px 8px 0 0;
  color: var(--muted); text-decoration: none; font-size: 0.7rem; font-family: var(--pixel);
  letter-spacing: 0.04em; border: 1px solid transparent; border-bottom: none;
  transition: color 0.2s, background 0.2s;
}
.nav-tabs li.active a, .nav-tabs li a:hover { color: var(--purple-lt); background: var(--surface); border-color: var(--border); }
.tab-content { position: relative; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── SCROLLABLE PANELS ── */
.scrollable { max-height: calc(100vh - 280px); overflow-y: auto; padding: 4px 2px; }
.scrollable::-webkit-scrollbar { width: 4px; }
.scrollable::-webkit-scrollbar-track { background: transparent; }
.scrollable::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ── MEDIA ITEMS (Research / HR) ── */
.media { padding: 14px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; transition: border-color 0.2s; }
.media:hover { border-color: var(--border2); }
.media.blink { border-color: var(--purple); box-shadow: 0 0 12px rgba(124,58,237,0.2); }
.media-heading { font-family: var(--pixel); font-size: 0.6rem; color: var(--text); letter-spacing: 0.04em; margin: 0 0 8px; line-height: 1.6; }
.media-heading small { color: var(--purple-lt); font-size: 0.55rem; margin-left: 8px; }
.media p { font-size: 0.78rem; color: var(--muted); margin: 4px 0; line-height: 1.6; }
.media p strong { color: var(--purple-lt); }

/* ── UPGRADE PANELS ── */
.panel-title { font-family: var(--pixel); font-size: 0.6rem; color: var(--purple-lt); letter-spacing: 0.04em; margin: 0; }

/* ── PROGRESS BAR ── */
.progress { background: var(--border); border-radius: 4px; height: 6px; margin: 8px 0; overflow: hidden; }
.progress-bar { background: linear-gradient(90deg, var(--purple), var(--purple-lt)); height: 100%; font-size: 0; border-radius: 4px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 14px; border-radius: 6px; border: none; cursor: pointer;
  font-family: var(--pixel); font-size: 0.55rem; letter-spacing: 0.04em;
  text-decoration: none; transition: opacity 0.2s, background 0.2s;
  line-height: 1.4;
}
.btn-default, .btn-sm { background: rgba(124,58,237,0.15); border: 1px solid var(--border2); color: var(--purple-lt) !important; }
.btn-default:hover, .btn-sm:hover { background: rgba(124,58,237,0.3); color: #fff !important; text-decoration: none; }
.btn-danger { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #f87171 !important; }

/* ── MODALS ── */
.modal { display: none; position: fixed; inset: 0; z-index: 300; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px); }
.modal.in { display: flex; }
.modal-dialog { width: 100%; max-width: 680px; }
.modal-content { background: var(--surface); border: 1px solid var(--border2); border-radius: 16px; overflow: hidden; box-shadow: 0 24px 80px rgba(0,0,0,0.6); }
.modal-header { background: var(--surface2); border-bottom: 1px solid var(--border); padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--pixel); font-size: 0.65rem; color: var(--purple-lt); letter-spacing: 0.06em; margin: 0; }
.modal-body { padding: 20px; font-size: 0.82rem; line-height: 1.8; color: var(--muted); max-height: 70vh; overflow-y: auto; }
.modal-body p { margin-bottom: 12px; }
.close { background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; padding: 0; line-height: 1; }
.close:hover { color: var(--text); }

/* ── ACHIEVEMENTS MODAL ── */
.panel-success { border-color: var(--emerald) !important; }
.panel-success .panel-body { background: rgba(5,150,105,0.08) !important; }

/* ── DESKTOP SIDE PANELS ── */
#researchLarge, #column-tabs > .tab-pane[id="hr"].hidden-sm, #column-tabs > .tab-pane[id="upgrades"].hidden-sm {
  padding: 8px;
}
.panel-stick { position: sticky; top: 72px; }
.media-list-no-margin .media { margin: 0 0 6px 0; }

/* ── LARGE SCREEN LAYOUT ── */
@media (min-width: 992px) {
  .col-md-6 { width: 50%; float: left; padding: 0 8px; }
  .col-md-3s { display: block !important; }
  .col-md-5s { display: block !important; }
  .hidden-md { display: none !important; }
  .hidden-lg { display: none !important; }
  #column-lab { width: 45%; }
  #column-tabs { width: 55%; }
}
@media (max-width: 991px) {
  .hidden-sm { display: none !important; }
  .hidden-xs { display: none !important; }
}

/* ── BLINK ANIMATION ── */
@keyframes blink-glow { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.blink { animation: blink-glow 1.4s ease-in-out infinite; }

/* ── LEADERBOARD PANEL ── */
#lazy-leaderboard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  margin-top: 12px; overflow: hidden;
}
#lazy-leaderboard .lb-header {
  background: var(--surface2); border-bottom: 1px solid var(--border);
  padding: 10px 16px; font-family: var(--pixel); font-size: 0.55rem; color: var(--purple-lt); letter-spacing: 0.08em;
}
#lazy-leaderboard .lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 0.75rem; }
#lazy-leaderboard .lb-row:last-child { border-bottom: none; }
#lazy-leaderboard .lb-rank { font-family: var(--pixel); font-size: 0.5rem; color: var(--muted); min-width: 22px; }
#lazy-leaderboard .lb-rank.gold { color: #fbbf24; }
#lazy-leaderboard .lb-rank.silver { color: #94a3b8; }
#lazy-leaderboard .lb-rank.bronze { color: #cd7c3a; }
#lazy-leaderboard .lb-name { flex: 1; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lazy-leaderboard .lb-score { font-family: var(--pixel); font-size: 0.5rem; color: var(--purple-lt); }
#lazy-leaderboard .lb-empty { padding: 16px; color: var(--muted); font-size: 0.78rem; text-align: center; }

/* ── SCORE SUBMIT MODAL ── */
#score-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
  z-index: 400; display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#score-modal-overlay.open { opacity: 1; pointer-events: all; }
#score-modal {
  background: var(--surface); border: 1px solid var(--border2); border-radius: 16px;
  padding: 32px 28px; max-width: 380px; width: 100%;
  display: flex; flex-direction: column; gap: 16px;
  transform: translateY(10px); transition: transform 0.25s;
}
#score-modal-overlay.open #score-modal { transform: translateY(0); }
#score-modal h3 { font-family: var(--pixel); font-size: 0.7rem; color: var(--purple-lt); margin: 0; line-height: 1.6; }
#score-modal p { font-size: 0.8rem; color: var(--muted); margin: 0; }
#score-modal .final { font-family: var(--pixel); font-size: 1rem; color: var(--text); text-align: center; }
#score-modal input { background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; color: var(--text); outline: none; width: 100%; font-family: var(--sans); transition: border-color 0.2s; }
#score-modal input:focus { border-color: var(--purple); }
#score-modal input::placeholder { color: var(--muted); }
#score-modal button { font-family: var(--pixel); font-size: 0.55rem; letter-spacing: 0.06em; background: var(--purple); border: none; border-radius: 8px; padding: 11px 18px; color: #fff; cursor: pointer; transition: opacity 0.2s; }
#score-modal button:hover { opacity: 0.85; }
#score-modal .rank-msg { font-size: 0.75rem; color: var(--purple-lt); text-align: center; min-height: 18px; }

/* ── FOOTER ── */
.game-footer { margin-top: 20px; padding: 16px; text-align: center; color: var(--muted); font-size: 0.6rem; font-family: var(--pixel); letter-spacing: 0.06em; border-top: 1px solid var(--border); }
.game-footer a { color: var(--muted); text-decoration: none; }
.game-footer a:hover { color: var(--purple-lt); }

/* ── MISC ── */
a { color: var(--purple-lt); }
strong { color: var(--text); }
p { margin: 0 0 8px; }
.col-xs-4, .col-xs-6, .col-xs-8, .col-xs-12, .col-sm-6, .col-sm-12, .col-md-3, .col-md-6, .col-md-12, .col-lg-5, .col-lg-7 { position: relative; min-height: 1px; }
.col-xs-4 { width: 33.33%; float: left; padding: 0 8px; }
.col-xs-6 { width: 50%; float: left; padding: 0 8px; }
.col-xs-8 { width: 66.66%; float: left; padding: 0 8px; }
.col-xs-12, .col-sm-12, .col-md-12 { width: 100%; float: left; padding: 0 8px; }
.col-sm-6 { width: 50%; float: left; padding: 0 8px; }
.clearfix::after { content: ''; display: table; clear: both; }
