
/* ══════════════════════════════════════════════
   VARIABLES & RESET
══════════════════════════════════════════════ */
:root {
  --bg:        #0a0a0f;
  --bg2:       #11111a;
  --bg3:       #1a1a2e;
  --surface:   #16213e;
  --border:    #0f3460;
  --accent:    #e94560;
  --accent2:   #f5a623;
  --green:     #0cda4a;
  --blue:      #4cc9f0;
  --purple:    #7b2fff;
  --text:      #e8e8f0;
  --muted:     #6b6b85;
  --pixel:     2px;
  --font-px:   'Press Start 2P', monospace;
  --font-mono: 'Share Tech Mono', monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ══════════════════════════════════════════════
   STARFIELD BG
══════════════════════════════════════════════ */
#stars {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(123,47,255,.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(76,201,240,.10) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(233,69,96,.08) 0%, transparent 50%),
    var(--bg);
}

/* ══════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════ */
.page { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 0 1.5rem 4rem; }

/* ══════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════ */
header {
  padding: 2.5rem 0 2rem;
  text-align: center;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2.5rem;
}
.logo {
  font-family: var(--font-px);
  font-size: clamp(14px, 3vw, 26px);
  color: var(--accent2);
  text-shadow:
    4px 4px 0 var(--accent),
    8px 8px 0 rgba(233,69,96,.3);
  letter-spacing: 2px;
  animation: flicker 5s infinite;
}
@keyframes flicker {
  0%,95%,100% { opacity: 1; }
  96% { opacity: .85; }
  97% { opacity: 1; }
  98% { opacity: .7; }
  99% { opacity: 1; }
}
.subtitle {
  margin-top: .75rem;
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 3px;
}
.header-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-top: 1rem;
  padding: .3rem .9rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 11px;
  color: var(--muted);
}
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ══════════════════════════════════════════════
   GRID
══════════════════════════════════════════════ */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ══════════════════════════════════════════════
   CARD / PANEL
══════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color .2s;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--purple), var(--blue), var(--green));
}
.card:hover { border-color: var(--blue); }

.card-title {
  font-family: var(--font-px);
  font-size: 9px;
  color: var(--blue);
  letter-spacing: 2px;
  margin-bottom: 1.25rem;
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════
   FORM CONTROLS
══════════════════════════════════════════════ */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.field input, .field select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: .55rem .75rem;
  border-radius: 1px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}
.field input:focus, .field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(76,201,240,.15);
}
.field select { cursor: pointer; }

.row { display: flex; gap: 1rem; }
.row .field { flex: 1; }

/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  font-family: var(--font-px);
  font-size: 8px;
  letter-spacing: 1px;
  padding: .75rem 1.5rem;
  border: none; border-radius: 1px;
  cursor: pointer;
  transition: transform .1s, box-shadow .2s, opacity .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 #7a1c28, 0 0 20px rgba(233,69,96,.3);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 0 #7a1c28, 0 0 30px rgba(233,69,96,.5);
}

.btn-success {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 4px 0 #047a25;
}
.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 0 #047a25, 0 0 20px rgba(12,218,74,.4);
}

.btn-danger {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: none;
}
.btn-danger:hover:not(:disabled) { background: rgba(233,69,96,.1); }

.btn-ghost {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--blue); background: rgba(76,201,240,.05); }

.btn-full { width: 100%; }

/* ══════════════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════════════ */
.progress-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  height: 18px;
  border-radius: 1px;
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--accent), var(--accent2));
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
  transition: width .5s ease;
  width: 0%;
}
@keyframes shimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}
.progress-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-px); font-size: 7px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
  mix-blend-mode: difference;
}

/* ══════════════════════════════════════════════
   STAT TILES
══════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: .75rem; }
.stat-tile {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: .75rem 1rem;
  border-radius: 1px;
}
.stat-tile .label {
  font-size: 9px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: .25rem;
}
.stat-tile .value {
  font-family: var(--font-px);
  font-size: 13px;
  color: var(--accent2);
}
.stat-tile .value.green { color: var(--green); }
.stat-tile .value.blue  { color: var(--blue);  }

/* ══════════════════════════════════════════════
   STATUS BADGE
══════════════════════════════════════════════ */
.status-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .75rem;
  border-radius: 1px;
  font-family: var(--font-px);
  font-size: 7px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.status-badge.queued    { background: rgba(107,107,133,.2); color: var(--muted); border: 1px solid var(--muted); }
.status-badge.building  { background: rgba(76,201,240,.15); color: var(--blue);  border: 1px solid var(--blue); }
.status-badge.training  { background: rgba(12,218,74,.15);  color: var(--green); border: 1px solid var(--green); }
.status-badge.completed { background: rgba(245,166,35,.15); color: var(--accent2); border: 1px solid var(--accent2); }
.status-badge.error     { background: rgba(233,69,96,.15);  color: var(--accent); border: 1px solid var(--accent); }
.status-badge.stopped   { background: rgba(107,107,133,.2); color: var(--muted);  border: 1px solid var(--muted); }

/* ══════════════════════════════════════════════
   LOG / TERMINAL
══════════════════════════════════════════════ */
.terminal {
  background: #050508;
  border: 1px solid var(--border);
  border-radius: 1px;
  padding: 1rem;
  height: 200px;
  overflow-y: auto;
  font-size: 11px;
  color: var(--green);
  font-family: var(--font-mono);
  line-height: 1.5;
}
.terminal::-webkit-scrollbar { width: 4px; }
.terminal::-webkit-scrollbar-track { background: var(--bg2); }
.terminal::-webkit-scrollbar-thumb { background: var(--border); }
.log-line { animation: fadeIn .3s ease; }
.log-line.error { color: var(--accent); }
.log-line.info  { color: var(--blue); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ══════════════════════════════════════════════
   MARIO GRID VISUALIZER
══════════════════════════════════════════════ */
#mario-grid {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  background: #050508;
  border: 1px solid var(--border);
  padding: 8px;
  aspect-ratio: 16/13;
  border-radius: 1px;
}
.cell {
  border-radius: 1px;
  transition: background .1s;
}
.cell.empty  { background: #0a0a14; }
.cell.tile   { background: var(--accent2); box-shadow: inset 0 -2px rgba(0,0,0,.4); }
.cell.enemy  { background: var(--accent);  animation: blink .5s infinite; }
.cell.mario  { background: var(--green);   box-shadow: 0 0 8px var(--green); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ══════════════════════════════════════════════
   JOB LIST
══════════════════════════════════════════════ */
.job-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 1px;
  padding: 1rem;
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.job-item:hover { border-color: var(--blue); background: rgba(76,201,240,.03); }
.job-item.active { border-color: var(--accent2); }
.job-meta { flex: 1; min-width: 120px; }
.job-id   { font-size: 10px; color: var(--muted); font-family: var(--font-mono); }
.job-name { font-family: var(--font-px); font-size: 8px; color: var(--text); margin-bottom: .3rem; }
.job-mini-bar { width: 100%; height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-top: .5rem; }
.job-mini-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width .4s; }

/* ══════════════════════════════════════════════
   WORLD/LEVEL PICKER
══════════════════════════════════════════════ */
.level-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
}
.level-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-px); font-size: 7px;
  padding: .6rem .3rem;
  cursor: pointer; border-radius: 1px;
  transition: all .15s;
  text-align: center;
}
.level-btn:hover { border-color: var(--blue); color: var(--blue); }
.level-btn.selected {
  border-color: var(--accent2);
  color: var(--accent2);
  background: rgba(245,166,35,.1);
  box-shadow: 0 0 8px rgba(245,166,35,.2);
}

.world-tabs {
  display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.world-tab {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-px); font-size: 7px;
  padding: .4rem .7rem; cursor: pointer; border-radius: 1px;
  transition: all .15s;
}
.world-tab:hover { border-color: var(--blue); color: var(--blue); }
.world-tab.active {
  border-color: var(--accent); color: var(--accent);
  background: rgba(233,69,96,.1);
}

/* ══════════════════════════════════════════════
   MODEL LIST
══════════════════════════════════════════════ */
.model-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: .85rem 1rem;
  border-radius: 1px;
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap;
  transition: border-color .2s;
}
.model-item:hover { border-color: var(--green); }
.model-icon { font-size: 20px; }
.model-info { flex: 1; }
.model-name { font-family: var(--font-px); font-size: 7px; color: var(--accent2); }
.model-sub  { font-size: 11px; color: var(--muted); margin-top: .2rem; }
.model-actions { display: flex; gap: .5rem; }

/* ══════════════════════════════════════════════
   SECTIONS / NAV
══════════════════════════════════════════════ */
.nav-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.nav-tab {
  font-family: var(--font-px); font-size: 7px;
  padding: .75rem 1.25rem;
  border: none; border-bottom: 2px solid transparent;
  background: none; color: var(--muted);
  cursor: pointer; letter-spacing: 1px;
  transition: all .2s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: var(--accent2);
  border-bottom-color: var(--accent2);
}

.section { display: none; }
.section.active { display: block; }

/* ══════════════════════════════════════════════
   TOOLTIP / INFO
══════════════════════════════════════════════ */
.info-box {
  background: rgba(76,201,240,.07);
  border: 1px solid rgba(76,201,240,.2);
  padding: .75rem 1rem;
  border-radius: 1px;
  font-size: 11px;
  color: var(--blue);
  margin-bottom: 1rem;
  line-height: 1.6;
}
.info-box strong { color: var(--accent2); }

/* ══════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--muted);
  font-family: var(--font-px); font-size: 8px;
  line-height: 2;
}

/* ══════════════════════════════════════════════
   DIVIDER
══════════════════════════════════════════════ */
.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 700px) {
  .btn { font-size: 7px; padding: .6rem 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
