:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(13, 29, 48, .88);
  --line: rgba(143, 201, 255, .18);
  --text: #f3f8ff;
  --muted: #9eb1c7;
  --cyan: #4cd9ff;
  --lime: #c6ff73;
  --coral: #ff826e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(54, 140, 207, .22), transparent 40%),
    linear-gradient(135deg, #07111f, #071825 60%, #06101d);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 15, 27, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 36px); letter-spacing: -.04em; }
h2 { margin-bottom: 14px; font-size: 22px; }
.eyebrow { margin-bottom: 3px; color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.topbar nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ghost, .action, .info-action {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.055);
  color: var(--text);
  padding: 9px 12px;
}
.ghost:hover, .ghost:focus-visible, .info-action:hover { border-color: var(--cyan); }
.danger { color: #ffad9f; }
.game-shell { display: grid; grid-template-columns: minmax(370px, 42vw) 1fr; min-height: calc(100vh - 91px); }
.lab-panel {
  padding: clamp(24px, 4vw, 52px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lab-name-label { align-self: stretch; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .1em; }
#lab-name {
  align-self: stretch;
  margin: 8px 0 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: clamp(21px, 2.2vw, 27px);
  font-weight: 750;
  outline: none;
}
#lab-name:focus { border-color: var(--cyan); }
.detector-hint { align-self: stretch; color: var(--muted); }
.detector { position: relative; width: min(100%, 520px); aspect-ratio: 1; margin: 10px auto 18px; border-radius: 50%; outline: none; }
.detector:focus-visible { box-shadow: 0 0 0 4px rgba(76, 217, 255, .3); }
.detector canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.resources { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.resources div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.resources span { display: block; color: var(--muted); font-size: 12px; }
.resources strong { display: block; margin-top: 3px; font-size: clamp(18px, 2.4vw, 26px); }
.save-status { align-self: stretch; color: var(--muted); margin: 12px 0 0; }
.progress-panel { display: grid; grid-template-columns: repeat(3, minmax(210px, 1fr)); min-width: 0; }
.column { min-width: 0; padding: 26px 16px; border-right: 1px solid var(--line); }
.column:last-child { border-right: 0; }
.section-heading { padding: 0 6px; }
.card-list { display: grid; gap: 10px; }
.game-card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 14px 35px rgba(0,0,0,.12); }
.game-card h3 { margin: 0 0 6px; font-size: 16px; }
.game-card p { margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; color: var(--lime); font-size: 12px; }
.card-actions { display: flex; gap: 7px; }
.action { flex: 1; border-color: transparent; background: linear-gradient(135deg, #117d9c, #1a5f99); font-weight: 750; }
.action:disabled { cursor: not-allowed; opacity: .4; filter: grayscale(.6); }
.info-action { flex: 0 0 auto; }
.empty { padding: 18px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
.toast-region { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 30; }
.toast { max-width: 320px; padding: 12px 15px; border: 1px solid rgba(198,255,115,.4); border-radius: 12px; background: #14261e; box-shadow: 0 12px 35px rgba(0,0,0,.35); }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.68); backdrop-filter: blur(8px); }
.modal-card { position: relative; z-index: 1; width: min(680px, 100%); max-height: min(780px, 90vh); overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: 20px; background: #0d1d30; box-shadow: 0 28px 80px rgba(0,0,0,.5); }
.modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; color: var(--muted); font-size: 30px; }
.modal-body { color: #d3deeb; }
.modal-body a { color: inherit; pointer-events: none; text-decoration: none; }
.modal-body img { max-width: 100%; height: auto; }
.modal-body li { margin-bottom: 7px; }
@media (max-width: 1120px) {
  .game-shell { grid-template-columns: 1fr; }
  .lab-panel { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar nav { justify-content: flex-start; }
  .progress-panel { grid-template-columns: 1fr; }
  .column { border-right: 0; border-bottom: 1px solid var(--line); }
  .resources { grid-template-columns: 1fr; }
  .game-shell { min-height: 0; }
}
