/* ── BioBuilder Academy — Global Styles ─────────────────────────────────── */

:root {
  --bg: #f8f7f3;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.1);
  --border-subtle: rgba(0,0,0,0.06);
  --text-primary: #1a1a18;
  --text-secondary: #5c5b57;
  --text-tertiary: #9c9a92;
  --teal: #1D9E75;
  --teal-light: #E1F5EE;
  --amber: #BA7517;
  --amber-light: #FAEEDA;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 20px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a18;
    --surface: #242422;
    --border: rgba(255,255,255,0.1);
    --border-subtle: rgba(255,255,255,0.06);
    --text-primary: #e8e6de;
    --text-secondary: #b0ae a6;
    --text-tertiary: #6e6c66;
    --teal-light: #04342C;
    --amber-light: #412402;
  }
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */

#app { max-width: 720px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

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

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.hero { text-align: center; padding: 2rem 0 2.5rem; }
.hero-badge {
  display: inline-block; font-size: 12px; font-weight: 500;
  background: var(--teal-light); color: var(--teal);
  padding: 4px 12px; border-radius: var(--radius-pill); margin-bottom: 10px;
}
.hero h1 { font-size: 32px; font-weight: 500; margin-bottom: 8px; }
.hero-sub { font-size: 15px; color: var(--text-secondary); max-width: 400px; margin: 0 auto; }

/* ── World grid ───────────────────────────────────────────────────────────── */

.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 2rem;
}

.world-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  text-align: center;
}
.world-card:hover { border-color: var(--world-color, var(--teal)); transform: translateY(-2px); }
.world-icon { font-size: 28px; margin-bottom: 8px; }
.world-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.world-grade { font-size: 12px; color: var(--text-tertiary); margin-bottom: 8px; }
.world-prog { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }

/* ── Progress bars ────────────────────────────────────────────────────────── */

.prog-track {
  height: 6px; border-radius: 3px;
  background: var(--border-subtle); overflow: hidden;
}
.prog-track.sm { height: 4px; }
.prog-fill { height: 100%; background: var(--teal); border-radius: 3px; transition: width 0.5s ease; }

.progress-bar-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-top: 0.5px solid var(--border-subtle);
}
.progress-bar-row .prog-track { flex: 1; height: 6px; }

/* ── Level list ───────────────────────────────────────────────────────────── */

.back-btn {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--text-tertiary);
  padding: 4px 0; margin-bottom: 1rem;
  transition: color 0.15s;
}
.back-btn:hover { color: var(--text-primary); }

#screen-levels h2 { font-size: 20px; font-weight: 500; margin-bottom: 1.25rem; }

.level-list { display: flex; flex-direction: column; gap: 8px; }

.level-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  cursor: pointer; transition: border-color 0.15s;
}
.level-item:hover:not(.locked) { border-color: var(--border); filter: brightness(0.97); }
.level-item.done { border-left: 3px solid var(--teal); border-radius: 0 var(--radius) var(--radius) 0; }
.level-item.locked { opacity: 0.5; cursor: not-allowed; }

.level-num {
  font-size: 11px; font-weight: 500; color: var(--text-tertiary);
  padding-top: 2px; min-width: 24px;
}
.level-info { flex: 1; min-width: 0; }
.level-title { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.level-tagline { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.level-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.level-status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.status-done { color: var(--teal); font-size: 14px; }
.status-lock { font-size: 12px; }
.status-play { color: var(--teal); font-size: 14px; }

/* ── Tags & pills ─────────────────────────────────────────────────────────── */

.tag {
  font-size: 11px; background: var(--bg); color: var(--text-tertiary);
  border: 0.5px solid var(--border); border-radius: 5px; padding: 2px 7px;
}
.grade-pill {
  font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: var(--radius-pill);
}
.label-sm { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }

/* ── Game layout ──────────────────────────────────────────────────────────── */

#game-container { padding-top: 0.5rem; }

.jon-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: #EAF3DE; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 1.25rem; line-height: 1.6;
}
.jon-avatar {
  width: 28px; height: 28px; min-width: 28px; border-radius: 50%;
  background: #C0DD97; display: flex; align-items: center; justify-content: center;
  font-size: 14px; margin-top: 1px;
}
.jon-name { font-size: 12px; font-weight: 500; color: #3B6D11; margin-bottom: 2px; }
.jon-text { font-size: 13px; color: #27500A; }

.gene-library { display: flex; flex-direction: column; gap: 8px; }

.gene-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1.5px solid transparent; user-select: none;
  transition: opacity 0.15s, transform 0.1s;
}
.gene-chip:active { transform: scale(0.97); }
.gene-chip.used { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

.slot {
  border: 2px dashed var(--border);
  border-radius: var(--radius-pill); padding: 8px 14px;
  font-size: 13px; color: var(--text-tertiary);
  text-align: center; cursor: pointer;
  transition: all 0.15s; min-width: 150px;
}
.slot.filled { border-style: solid; border-color: transparent; }
.slot.highlight { border-color: #378ADD; background: #E6F1FB; }

.sim-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.stat-card { background: var(--bg); border-radius: var(--radius-sm); padding: 10px; }
.stat-label { font-size: 12px; color: var(--text-tertiary); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 500; }
.bar-wrap { height: 10px; border-radius: 5px; background: var(--border-subtle); overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; border-radius: 5px; transition: width 0.7s ease; }

.feedback { border-radius: 10px; padding: 12px 16px; font-size: 13px; line-height: 1.6; margin-bottom: 12px; }
.feedback.win  { background: #E1F5EE; color: #085041; }
.feedback.warn { background: #FAEEDA; color: #412402; }
.feedback.fail { background: #FCEBEB; color: #501313; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--text-primary); transition: background 0.15s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 0.75rem; }

.btn-primary { background: var(--teal); color: #E1F5EE; border-color: var(--teal); }
.btn-primary:hover { background: #0F6E56; }

.btn-green  { background: #3B6D11; color: #EAF3DE; border-color: #3B6D11; }
.btn-green:hover { background: #27500A; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */

.loading, .error {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-secondary); font-size: 14px;
}
.section-label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 8px;
}
.two-col { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.two-col > * { flex: 1; min-width: 190px; }
.card {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}

/* ── Field / ocean grids ──────────────────────────────────────────────────── */

.field-grid {
  display: grid; gap: 3px; margin-bottom: 8px;
}
.field-cell { border-radius: 3px; transition: background 0.5s; }

.grid-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-tertiary);
}
.grid-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
