* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #12161f;
  color: #e2e8f0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

canvas#game {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

.hud-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(15, 20, 30, 0.9);
  border-bottom: 1px solid rgba(34, 211, 238, 0.28);
  backdrop-filter: blur(8px);
  z-index: 20;
  pointer-events: auto;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  padding-right: 10px;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #22d3ee;
}

.brand-sub {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: #94a3b8;
  text-transform: uppercase;
}

.level-select {
  background: #1a2232;
  color: #f1f5f9;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.level-select:hover {
  border-color: #22d3ee;
}

.score-pill {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.budget-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 148px;
}

.budget-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
}

.budget-bar {
  width: 100%;
  height: 7px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.budget-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22d3ee, #38bdf8);
  transition: width 0.12s ease, background 0.15s ease;
}

.budget-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.mat-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.mat-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #1a2232;
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
}

.mat-btn:hover {
  border-color: rgba(34, 211, 238, 0.65);
  color: #fff;
}

.mat-btn.active {
  background: rgba(34, 211, 238, 0.18);
  border-color: #22d3ee;
  color: #ffffff;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.28);
}

.mat-btn.delete-btn.active {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  color: #fecaca;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.28);
}

.mat-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  display: inline-block;
}

.mat-key {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.7);
  color: #94a3b8;
}

.tool-btn {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.tool-btn:hover {
  background: #273449;
  color: #fff;
}

.launch-btn {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #0b0f17;
  border: none;
  border-radius: 7px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.42);
  transition: transform 0.1s ease, filter 0.12s ease;
}

.launch-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.launch-btn.running {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.42);
}

.hud-bottom {
  position: fixed;
  bottom: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 15;
}

.info-card {
  background: rgba(15, 20, 30, 0.84);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-left: 3px solid #22d3ee;
  border-radius: 7px;
  padding: 8px 12px;
  max-width: 440px;
  backdrop-filter: blur(6px);
}

.info-title {
  font-size: 12px;
  font-weight: 700;
  color: #22d3ee;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hazard-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: repeating-linear-gradient(
    -45deg,
    rgba(245, 158, 11, 0.26),
    rgba(245, 158, 11, 0.26) 6px,
    rgba(15, 23, 42, 0.6) 6px,
    rgba(15, 23, 42, 0.6) 12px
  );
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: #fde68a;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-desc {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.35;
}

.controls-hint {
  background: rgba(15, 20, 30, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  color: #94a3b8;
  backdrop-filter: blur(5px);
}

.cursor-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 25;
  background: rgba(12, 17, 27, 0.92);
  border: 1px solid #22d3ee;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.cursor-tooltip.invalid {
  border-color: #ef4444;
  color: #fca5a5;
}

.status-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(14, 19, 30, 0.95);
  border: 2px solid #22d3ee;
  border-radius: 12px;
  padding: 22px 28px;
  text-align: center;
  min-width: 320px;
  max-width: 90vw;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
  z-index: 30;
  display: none;
  backdrop-filter: blur(10px);
}

.status-modal.fail {
  border-color: #ef4444;
}

.status-modal h2 {
  margin: 0 0 8px 0;
  font-size: 22px;
  letter-spacing: 0.08em;
  color: #22d3ee;
}

.status-modal.fail h2 {
  color: #f87171;
}

.status-modal p {
  margin: 0 0 14px 0;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.45;
}

.modal-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #fbbf24;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.modal-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.modal-btn.primary {
  background: linear-gradient(135deg, #22d3ee, #0284c7);
  border: none;
  color: #082f49;
}

.modal-btn:hover {
  filter: brightness(1.12);
}

.mode-banner {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 16;
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.45);
  color: #67e8f9;
}

.mode-banner.sim {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.65);
  color: #fde68a;
}
