:root{
  --bg:#fff;
  --ui-bg: rgba(0,0,0,0.6);
  --ui-fg: #fff;
  font-family: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}
html,body{height:100%;margin:0;background:var(--bg);}
canvas{display:block;width:100%;height:100%}
#ui{
  position:fixed;left:12px;top:12px;z-index:10;
  display:flex;flex-direction:column;gap:8px;
}
#startBtn{
  position:fixed; left:50%; top:50%; transform:translate(-50%,-50%);
  background:var(--ui-bg);color:var(--ui-fg);border:0;padding:12px 18px;border-radius:8px;
  cursor:pointer; z-index:60;
}
#stamina{display:flex;align-items:center;gap:8px;color:var(--ui-fg);font-size:12px}
#staminaBar{width:140px;height:10px;background:rgba(255,255,255,0.12);border-radius:6px;overflow:hidden}
#staminaFill{height:100%;width:100%;background:#ddd;border-radius:6px;transform-origin:left;transform:scaleX(1)}
#staminaLabel{opacity:0.85}
#startRow{ display:flex;align-items:center;gap:8px; }

/* NEW: Stamina UI bottom left positioning */
#staminaUI {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px; 
}

/* NEW: Welcome Overlay */
#welcomeOverlay, #tutorialOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f8fafc;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#welcomeOverlay[aria-hidden="false"], #tutorialOverlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.welcomeInner, .tutorialInner {
  background: rgba(16, 20, 32, 0.95);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-width: 400px;
  text-align: center;
}

.welcomeInner p {
  font-size: 18px;
  margin-top: 0;
  margin-bottom: 20px;
}

.welcomeActions button {
  padding: 10px 18px;
  margin: 0 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  min-width: 100px;
}
#tutorialYes {
  background: #34d399; /* Green for Yes */
  color: #064e3b;
  border: none;
}
#tutorialNo {
  background: #ef4444; /* Red for No */
  color: #7f1d1d;
  border: none;
}

/* Tutorial Content Styling (reusing map header styles for consistency) */
.tutorialInner {
  max-width: 600px;
  text-align: left;
}
.tutorialHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tutorialTitle {
  font-weight: 600;
  font-size: 18px;
  color: #f1f5f9;
  margin: 0;
}
#tutorialText {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 15px;
  color: #cbd5e1;
}
#tutorialText li {
  margin-bottom: 8px;
  line-height: 1.5;
}


#deathOverlay{
  position:fixed;
  inset:0;
  background:rgba(125,0,0,0.0);
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
  opacity:0;
  transition:background 0.4s ease, opacity 0.4s ease;
  z-index:200;
}
#deathOverlay.visible{
  /* make background fully opaque red with no transparency */
  background: #7d0000;
  opacity:1;
}
#deathOverlay .deathText{
  color:#fee2e2;
  font-size:32px;
  font-weight:800;
  text-shadow:0 0 18px rgba(0,0,0,0.9);
}

/* NEW: Wind Fade Overlay */
#windFadeOverlay {
  position: fixed;
  inset: 0;
  z-index: 100; /* Above 3D scene, below death/menus */
  pointer-events: none;
  background: transparent;
  transition: background 0.1s linear; /* Smooth visual transition */
}


/* NEW: Compass styles */
#compass {
  position: fixed;
  left: 50%;
  top: 12px; 
  transform: translateX(-50%);
  z-index: 45; /* was 100, set lower than thermoMenu (z-index 50) */
  width: 140px; /* fixed width viewport */
  height: 30px;
  background: rgba(16, 20, 32, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden; 
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: none;
  display: flex;
  align-items: center;
}

#compassTape {
  display: flex;
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  transition: none;
}

.compassMarker {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  font-family: monospace;
  position: relative;
  /* Default width for minor marker if not overridden by .major */
  min-width: 90px;
}

.compassMarker.major {
    font-size: 14px;
    min-width: 90px; /* N, E, S, W only */
}

.compassMarker.active {
  color: #f9d85b; /* Highlight current direction (Yellow) */
}
.compassMarker.minor {
  opacity: 0.6;
}

/* Centerline indicator (visual aid to show center of view) */
#compassCenterLine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.5);
  z-index: 10;
  transform: translateX(-50%);
}

#thermoMenu{
  position:fixed;left:50%;transform:translateX(-50%) translateY(-12px);top:0;z-index:50;
  pointer-events:none;opacity:0;transition:opacity .18s ease, transform .18s ease;
}
#thermoMenu[aria-hidden="false"]{ pointer-events:auto; opacity:1; transform:translateX(-50%) translateY(8px); }
#thermoMenu .menuInner{
  background:rgba(16,20,32,0.95);color:#f8fafc;backdrop-filter:blur(12px);
  padding:20px 24px;border-radius:12px;margin:8px;min-width:480px;
  box-shadow:0 8px 32px rgba(0,0,0,0.4);
  border:1px solid rgba(255,255,255,0.06);
}
#thermoMenu .menuHeader{
  display:flex;justify-content:space-between;align-items:center;
  margin-bottom:16px;padding-bottom:12px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
#thermoMenu .menuTitle{ 
  font-weight:600;font-size:18px;color:#f1f5f9;margin:0;
}
#thermoMenu .stpBadge{
  /* slightly darker than the menu background for subtle contrast */
  background: #0b0f14;
  color: #f8fafc;
  padding:4px 8px;
  border-radius:6px;
  font-size:11px;
  font-weight:600;
  letter-spacing:0.5px;
}

#thermoMenu .stpWrap{
  display:flex;
  align-items:center;
  gap:8px;
}

#thermoMenu .stpLabel{
  color:#94a3b8;
  font-size:12px;
  font-weight:700;
  letter-spacing:0.6px;
  background:transparent;
  padding:2px 4px;
}

#thermoMenu .thermoGrid{
  display:grid; grid-template-columns: 1fr; gap:16px;
}
#thermoMenu .thermoSection h3{
  margin:0 0 12px 0;font-size:14px;font-weight:600;
  color:#cbd5e1;letter-spacing:0.3px;text-transform:uppercase;
}
#thermoMenu .thermoGrid.single { text-align: center; min-width:360px; }
#thermoMenu .thermoSection.centerForecast { display:inline-block; min-width:320px; }
#thermoMenu .thermoList{ 
  list-style:none;margin:0;padding:0;font-size:14px;
}
#thermoMenu .thermoList li{ 
  padding:8px 0;display:flex;justify-content:space-between;align-items:center;
  border-bottom:1px solid rgba(255,255,255,0.03);
}
#thermoMenu .thermoList li:last-child{
  border-bottom:none;
}
#thermoMenu .param{
  color:#94a3b8;font-weight:500;
}
#thermoMenu .value{
  color:#e2e8f0;font-weight:600;font-family:monospace;
}
#thermoMenu ul{ list-style:none;margin:0;padding:0; font-size:13px; }
#thermoMenu li{ padding:6px 0;border-top:1px solid rgba(255,255,255,0.03); display:flex;justify-content:space-between; }
#thermoMenu .stpTitle{ margin-top:8px;font-weight:600;font-size:13px;opacity:0.9 }
#thermoMenu span{ opacity:0.95; color:#e6eef8 }

#mapOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mapOverlay[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
}

.mapContainer {
  background: rgba(16, 20, 32, 0.95);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}

.mapHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mapTitle {
  font-weight: 600;
  font-size: 18px;
  color: #f1f5f9;
  margin: 0;
}

.mapClose {
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s ease;
}

.mapClose:hover {
  color: #f1f5f9;
}

#mapCanvas {
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #0f172a;
}

#probeHUD{
  background: rgba(16,20,32,0.95);
  color:#e6eef8;
  font-size:14px;               /* slightly smaller text for a flatter look */
  padding:10px 12px;            /* reduced padding */
  border-radius:10px;
  line-height:1.25;
  min-width:220px;              /* narrower width */
  box-shadow:0 6px 20px rgba(0,0,0,0.38);
  border:1px solid rgba(255,255,255,0.06);
  position:fixed;
  left:50%;
  bottom:12px;
  transform:translateX(-50%);
  z-index:60;
  display:none; /* hidden until at least one probe is placed */
  text-align:center;
  max-width:64vw;               /* ensure it doesn't overflow on small viewports */
}
/* compact stat rows in the probe HUD */
#probeHUD .ph-title { font-weight:700; font-size:15px; margin-bottom:6px; color:#f1f5f9; }
#probeHUD .ph-row { display:flex; justify-content:space-between; gap:8px; align-items:center; margin:6px 0; }
#probeHUD .ph-label { color:#94a3b8; font-size:13px; }
#probeHUD .ph-value { font-family:monospace; font-weight:700; color:#e6eef8; font-size:13px; }
#probeHUD .ph-hint { font-size:13px; color:#8b94a6; margin-top:6px; }

/* NEW: money counter styles (top-right) */
#moneyCounter{
  position: fixed;
  right: 12px;
  top: 12px;
  z-index: 120;
  background: rgba(8,10,18,0.92);
  color: #e6eef8;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  font-family: monospace;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
#moneyCounter #moneyLabel{
  color: #facc15; /* warm gold */
  font-variant-numeric: tabular-nums;
}

/* Shop toggle button (left of money) */
#shopToggle{
  position: fixed;
  right: 90px; /* sits left of moneyCounter (12px + width ~64) */
  top: 12px;
  z-index: 125;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(8,10,18,0.92);
  color: #e6eef8;
  border: 1px solid rgba(255,255,255,0.06);
  font-weight:700;
  cursor:pointer;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

/* Shop panel */
#shopPanel {
  position: fixed;
  right: 12px;
  top: 60px;
  z-index: 130;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  transform-origin: top right;
}
#shopPanel[aria-hidden="false"]{ pointer-events:auto; opacity:1; transform: translateY(6px); }
#shopPanel .shopInner{
  background: rgba(16,20,32,0.95);
  color:#e6eef8;
  padding:12px 14px;
  border-radius:10px;
  min-width:240px;
  box-shadow:0 8px 32px rgba(0,0,0,0.4);
  border:1px solid rgba(255,255,255,0.06);
}
#shopPanel .shopHeader{ display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;padding-bottom:8px;border-bottom:1px solid rgba(255,255,255,0.04); }
#shopPanel .shopTitle{ font-weight:700 }
#shopPanel .shopItem{ display:flex;justify-content:space-between;align-items:center;padding:8px 0;border-top:1px solid rgba(255,255,255,0.02); }
#shopPanel .shopItem:first-child{ border-top:0; }
#shopPanel .shopItem .desc{ font-size:13px;color:#cbd5e1 }
#shopPanel .shopItem button{ padding:6px 8px;border-radius:8px;background:rgba(255,255,255,0.04);color:#fff;border:1px solid rgba(255,255,255,0.06);cursor:pointer;font-size:13px; }
#shopPanel .owned{ opacity:0.6; color:#94a3b8; }
#mesonetHUD {
  position: fixed;
  right: 12px;
  top: 64px;
  margin-top: 120px;
  z-index: 122;
  background: rgba(8,10,18,0.92);
  color: #e6eef8;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  font-family: monospace;
  font-weight:700;
  font-size:13px;
  display:none;
}

/* Updates toggle button (left of screen) */
#updatesToggle{
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 130;
  height: 40px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:10px;
  background: rgba(8,10,18,0.92);
  color: #e6eef8;
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  font-weight:700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
#updatesToggle #updatesBadge{
  display:inline-block;
  min-width:18px;
  height:18px;
  line-height:18px;
  border-radius:9px;
  background:#ef4444;
  color:#fff;
  text-align:center;
  font-weight:800;
  font-size:12px;
  margin-left:6px;
}

/* Updates panel */
#updatesPanel{
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%) translateY(-12px);
  z-index: 260;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#updatesPanel[aria-hidden="false"]{ pointer-events:auto; opacity:1; transform: translateX(-50%) translateY(8px); }
#updatesPanel .updatesInner{
  background: rgba(16,20,32,0.98);
  color:#f8fafc;
  padding:14px 18px;
  border-radius:10px;
  min-width:320px;
  box-shadow:0 8px 32px rgba(0,0,0,0.4);
  border:1px solid rgba(255,255,255,0.06);
}
.updatesHeader{ display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;border-bottom:1px solid rgba(255,255,255,0.04);padding-bottom:8px }
.updatesTitle{ font-weight:700;font-size:16px }
#updatesContent{ font-size:14px; color:#cbd5e1; line-height:1.5 }
#updatesClose{ cursor:pointer; color:#94a3b8; font-size:20px; padding:4px }
#updatesToggle #updatesBadge.hidden{ display:none }

/* NEW: Personal records toggle (right side, under money) */
#recordsToggle{
  position: fixed;
  right: 12px;
  top: 60px;
  z-index: 130;
  height: 36px;
  display:flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:10px;
  background: rgba(8,10,18,0.92);
  color: #e6eef8;
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  font-weight:700;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  font-size: 13px;
}

/* NEW: Personal records panel */
#recordsPanel{
  position: fixed;
  right: 12px;
  top: 100px;
  z-index: 260;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  transform: translateY(-10px);
}
#recordsPanel[aria-hidden="false"]{
  pointer-events:auto;
  opacity:1;
  transform: translateY(6px);
}
#recordsPanel .recordsInner{
  background: rgba(16,20,32,0.98);
  color:#f8fafc;
  padding:14px 16px;
  border-radius:10px;
  min-width:260px;
  max-width:320px;
  box-shadow:0 8px 32px rgba(0,0,0,0.4);
  border:1px solid rgba(255,255,255,0.06);
  font-size:14px;
}
.recordsHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
  border-bottom:1px solid rgba(255,255,255,0.06);
  padding-bottom:6px;
}
.recordsTitle{
  font-weight:700;
  font-size:15px;
}
#recordsClose{
  cursor:pointer;
  color:#94a3b8;
  font-size:20px;
  padding:4px;
}
.recordsTabs{
  display:flex;
  gap:6px;
  margin-top:6px;
  margin-bottom:8px;
}
.recordsTab{
  flex:1;
  padding:6px 8px;
  border-radius:6px;
  border:1px solid rgba(255,255,255,0.06);
  background:rgba(15,23,42,0.9);
  color:#cbd5e1;
  font-size:13px;
  cursor:pointer;
}
.recordsTab.active{
  background:#0f172a;
  color:#f9fafb;
  border-color:rgba(148,163,184,0.8);
}
#recordsContent{
  font-size:13px;
  color:#cbd5e1;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.recordsRow{
  display:flex;
  justify-content:space-between;
  gap:8px;
}
.recordsLabel{
  opacity:0.85;
}
.recordsValue{
  font-family:monospace;
  font-weight:700;
}

/* Spawn immunity banner fallback style (if inserted dynamically elsewhere) */
#spawnImmunity {
  font-family: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  letter-spacing: 0.6px;
  box-sizing: border-box;
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600; /* ensures it sits above the compass */
  pointer-events: none;
}