/* Cut & Line — FULL REBUILD schematic UI (readable layers > polish) */
:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --panel2: #232d3a;
  --ink: #e8eef4;
  --muted: #8b9aab;
  --line: #3a4a5c;
  --hold: #3dce7a;
  --buckle: #e85d5d;
  --warn: #e6b84d;
  --tbm: #4db0e6;
  --natm: #c9a0ff;
  --road: #5a6570;
  --sky: #1c2836;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--ink); }
button { font: inherit; cursor: pointer; }
a { color: var(--tbm); }

.screen { display: none; min-height: 100%; padding: 20px 24px 40px; }
.screen.active { display: block; }

/* —— Hub —— */
.hub-header { max-width: 920px; margin: 0 auto 28px; }
.hub-header h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
.hub-header .tag { display: inline-block; margin-top: 6px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); padding: 3px 8px; border-radius: 4px; }
.hub-header p { margin-top: 12px; color: var(--muted); max-width: 56ch; line-height: 1.45; font-size: 0.95rem; }

.level-grid { max-width: 920px; margin: 0 auto; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.level-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; text-align: left; color: var(--ink); transition: border-color .15s, transform .1s;
}
.level-card:hover:not(:disabled) { border-color: var(--tbm); transform: translateY(-1px); }
.level-card:disabled { opacity: 0.45; cursor: not-allowed; }
.level-card .num { font-size: 0.7rem; font-weight: 800; color: var(--muted); letter-spacing: 0.08em; }
.level-card h2 { font-size: 1.1rem; margin: 4px 0 8px; font-weight: 800; }
.level-card .grounds { font-size: 0.82rem; color: var(--tbm); margin-bottom: 8px; }
.level-card .blurb { font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.level-card .status { margin-top: 12px; font-size: 0.75rem; font-weight: 700; }
.level-card .status.cleared { color: var(--hold); }
.level-card .status.locked { color: var(--muted); }
.level-card .status.open { color: var(--warn); }

.hub-footer { max-width: 920px; margin: 28px auto 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hub-footer .sandbox-link {
  display: inline-block; background: var(--panel2); border: 1px dashed var(--line);
  color: var(--ink); padding: 10px 16px; border-radius: 8px; text-decoration: none; font-weight: 700;
}
.hub-footer .sandbox-link:hover { border-color: var(--natm); color: var(--natm); }
.hub-footer .hint { color: var(--muted); font-size: 0.82rem; }

/* —— Method pick —— */
.method-wrap { max-width: 720px; margin: 0 auto; }
.method-wrap h1 { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.method-wrap .meta { color: var(--muted); margin-bottom: 20px; line-height: 1.4; font-size: 0.92rem; }
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .method-grid { grid-template-columns: 1fr; } }
.method-card {
  background: var(--panel); border: 2px solid var(--line); border-radius: 12px;
  padding: 18px; text-align: left; color: var(--ink);
}
.method-card.tbm:hover { border-color: var(--tbm); }
.method-card.natm:hover { border-color: var(--natm); }
.method-card.favoured { box-shadow: 0 0 0 1px var(--hold); }
.method-card h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 6px; }
.method-card.tbm h3 { color: var(--tbm); }
.method-card.natm h3 { color: var(--natm); }
.method-card p { font-size: 0.84rem; color: var(--muted); line-height: 1.4; margin-bottom: 10px; }
.method-card ul { font-size: 0.8rem; padding-left: 1.1em; line-height: 1.45; color: var(--ink); }
.method-card .badge {
  display: inline-block; margin-top: 10px; font-size: 0.7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--hold);
}
.back-btn {
  background: transparent; border: none; color: var(--muted); margin-bottom: 14px; padding: 4px 0;
}
.back-btn:hover { color: var(--ink); }

/* —— Drive / play —— */
#screen-drive { padding: 12px 16px 24px; }
.drive-top {
  max-width: 1100px; margin: 0 auto 10px; display: flex; flex-wrap: wrap;
  gap: 10px; align-items: center; justify-content: space-between;
}
.drive-top .left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip {
  font-size: 0.72rem; font-weight: 800; padding: 4px 9px; border-radius: 5px;
  background: var(--panel2); border: 1px solid var(--line); letter-spacing: 0.04em;
}
.chip.tbm { color: var(--tbm); border-color: #2a5a78; }
.chip.natm { color: var(--natm); border-color: #5a4578; }
.chip.ground { color: var(--warn); }

.canvas-wrap {
  max-width: 1100px; margin: 0 auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative;
}
#game-canvas { display: block; width: 100%; height: auto; background: var(--sky); }

.meters {
  max-width: 1100px; margin: 12px auto 0; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px;
}
.meter {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.meter label { display: block; font-size: 0.7rem; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.meter .bar {
  height: 10px; background: #0a0e12; border-radius: 5px; overflow: hidden; position: relative;
}
.meter .bar > i {
  display: block; height: 100%; width: 0%; background: var(--hold); border-radius: 5px;
  transition: width 0.08s linear, background 0.15s;
}
.meter .bar .band {
  position: absolute; top: 0; bottom: 0; background: rgba(61,206,122,0.18); pointer-events: none;
}
.meter .val { margin-top: 4px; font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.meter.warn .bar > i { background: var(--warn); }
.meter.bad .bar > i { background: var(--buckle); }

.controls {
  max-width: 1100px; margin: 14px auto 0; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.ctrl-group { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 160px; }
.ctrl-group label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.ctrl-group input[type="range"] { width: 100%; accent-color: var(--tbm); }
.ctrl-group .hint { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }

.btn {
  border: none; border-radius: 8px; padding: 10px 16px; font-weight: 800; font-size: 0.9rem;
}
.btn-primary { background: var(--tbm); color: #0a1218; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-natm { background: var(--natm); color: #1a1028; }
.btn-danger { background: var(--buckle); color: #fff; }
.btn-ghost { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--muted); }

.banner {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(8,12,16,0.72); z-index: 5; flex-direction: column; gap: 12px; text-align: center; padding: 20px;
}
.banner.show { display: flex; }
.banner h2 { font-size: 2.4rem; font-weight: 900; letter-spacing: 0.04em; }
.banner.hold h2 { color: var(--hold); }
.banner.buckle h2 { color: var(--buckle); }
.banner p { color: var(--ink); max-width: 42ch; line-height: 1.4; font-size: 0.95rem; }
.banner .actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Mid-drive modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 20;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-back.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  max-width: 520px; width: 100%; padding: 22px;
}
.modal h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 0.9rem; line-height: 1.45; margin-bottom: 16px; }
.modal .row { display: flex; flex-wrap: wrap; gap: 10px; }

.teach {
  max-width: 1100px; margin: 10px auto 0; font-size: 0.82rem; color: var(--muted);
  background: var(--panel2); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: 0 6px 6px 0;
  line-height: 1.4;
}

/* —— Sandbox —— */
.sandbox-header { max-width: 1100px; margin: 0 auto 14px; display: flex; flex-wrap: wrap;
  gap: 12px; align-items: center; justify-content: space-between; }
.sandbox-header h1 { font-size: 1.35rem; font-weight: 800; }
.sandbox-picks { max-width: 1100px; margin: 0 auto 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sandbox-picks select, .sandbox-picks button {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; font: inherit;
}
.legend {
  max-width: 1100px; margin: 10px auto 0; display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 0.75rem; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid #0006; }
