/* SimBee — warm golden-hour HUD */
:root {
  --honey:      #E8A33D;
  --honey-deep: #C8801E;
  --amber:      #B5613C;
  --wax:        #F4D08A;
  --cream:      #FFF6E6;
  --bark:       #4A3522;
  --bark-soft:  #6E5436;
  --pollen:     #F2B705;
  --nectar:     #E8843C;
  --water:      #5FB6C9;
  --leaf:       #6E8C3A;
  --ink:        #2C2014;
  --card-bg:    rgba(40, 27, 14, 0.62);
  --card-line:  rgba(255, 230, 180, 0.18);
  --shadow:     0 8px 28px rgba(40, 24, 6, 0.35);
  --font-ui:    "Nunito", system-ui, sans-serif;
  --font-disp:  "Outfit", system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #1c1209;
  font-family: var(--font-ui);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#stage { position: fixed; inset: 0; }
#scene-canvas { display: block; width: 100%; height: 100%; }

/* ===== HUD root ===== */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud .panel { pointer-events: auto; }

/* glassy honeycomb card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: 16px;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  box-shadow: var(--shadow);
}

/* ===== Top-left: title + season ===== */
#topleft {
  position: absolute;
  top: 20px; left: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 12px;
}
.brand .hexmark {
  width: 34px; height: 34px; flex: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}
.brand .wordmark {
  font-family: var(--font-disp);
  font-weight: 700; font-size: 24px; letter-spacing: .5px;
  line-height: 1;
  color: var(--cream);
}
.brand .wordmark b { color: var(--honey); font-weight: 800; }
.brand .tag {
  font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase;
  color: rgba(255,246,230,.55); margin-top: 3px; font-weight: 700;
}

.season-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px 12px 14px;
}
.season-orb {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  transition: background .8s ease, box-shadow .8s ease;
}
.season-orb svg { width: 26px; height: 26px; }
.season-meta { display: flex; flex-direction: column; gap: 2px; }
.season-name {
  font-family: var(--font-disp);
  font-weight: 700; font-size: 19px; line-height: 1;
  transition: color .8s ease;
}
.season-day {
  font-size: 12.5px; color: rgba(255,246,230,.6); font-weight: 600;
}
.season-progress {
  margin-top: 6px; width: 132px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.12); overflow: hidden;
}
.season-progress > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--honey), var(--pollen));
  border-radius: 3px;
}

/* ===== Top-right: resources ===== */
#topright {
  position: absolute;
  top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  align-items: flex-end;
}
.resource-rail {
  display: flex; gap: 8px; padding: 10px 12px;
}
.res {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 8px;
  border-radius: 11px;
  background: rgba(255,246,230,.06);
  min-width: 96px;
}
.res .ico {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(0,0,0,.18);
}
.res .ico svg { width: 19px; height: 19px; }
.res .txt { display: flex; flex-direction: column; line-height: 1.05; }
.res .val {
  font-family: var(--font-disp);
  font-weight: 700; font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.res .lbl {
  font-size: 10px; letter-spacing: .8px; text-transform: uppercase;
  color: rgba(255,246,230,.55); font-weight: 700; margin-top: 1px;
}
.res .val.flash { animation: pop .5s ease; }
@keyframes pop {
  0% { transform: scale(1); color: var(--cream); }
  35% { transform: scale(1.22); color: var(--pollen); }
  100% { transform: scale(1); }
}

.pop-card {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px 11px 12px;
}
.pop-card .ico { width: 34px; height: 34px; }
.pop-card .ico svg { width: 22px; height: 22px; }
.pop-card .big {
  font-family: var(--font-disp); font-weight: 800; font-size: 22px;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.pop-card .sub {
  font-size: 11px; color: rgba(255,246,230,.6); font-weight: 700;
  letter-spacing: .4px; margin-top: 3px;
}
.pop-breakdown { display: flex; gap: 10px; margin-top: 4px; }
.pop-breakdown span { font-size: 11px; font-weight: 700; }
.pop-breakdown .w { color: var(--honey); }
.pop-breakdown .d { color: var(--amber); }
.pop-breakdown .q { color: #FFD75E; }

/* ===== Bottom-center: controls ===== */
#controls {
  position: absolute;
  bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 8px;
}
.ctl {
  pointer-events: auto;
  border: none; cursor: pointer;
  font-family: var(--font-ui); font-weight: 800;
  color: var(--cream);
  background: rgba(255,246,230,.08);
  border-radius: 11px;
  height: 42px; padding: 0 14px;
  display: flex; align-items: center; gap: 7px;
  font-size: 14px;
  transition: background .15s ease, transform .1s ease, color .15s ease;
}
.ctl:hover { background: rgba(255,246,230,.18); }
.ctl:active { transform: translateY(1px); }
.ctl svg { width: 17px; height: 17px; }
.ctl.icon { width: 42px; padding: 0; justify-content: center; }
.ctl.active { background: var(--honey); color: var(--ink); }
.ctl.primary {
  background: linear-gradient(180deg, var(--honey), var(--honey-deep));
  color: var(--ink); box-shadow: 0 4px 14px rgba(200,128,30,.4);
}
.ctl.primary:hover { filter: brightness(1.07); background: linear-gradient(180deg, var(--honey), var(--honey-deep)); }
.speed-group {
  display: flex; gap: 3px; padding: 3px;
  background: rgba(0,0,0,.2); border-radius: 12px;
}
.speed-group .ctl { height: 36px; border-radius: 9px; padding: 0 12px; background: transparent; }
.speed-group .ctl.active { background: var(--honey); }
.ctl-divider { width: 1px; height: 26px; background: rgba(255,246,230,.15); margin: 0 4px; }

/* ===== Educational callouts (bottom-left) ===== */
#callouts {
  position: absolute;
  bottom: 24px; left: 22px;
  display: flex; flex-direction: column-reverse; gap: 10px;
  max-width: 360px;
}
.callout {
  pointer-events: auto;
  display: flex; gap: 12px;
  padding: 13px 16px 13px 13px;
  border-left: 3px solid var(--honey);
  border-radius: 13px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  transform: translateX(-120%);
  opacity: 0;
  transition: transform .45s cubic-bezier(.2,.9,.3,1.2), opacity .4s ease;
}
.callout.show { transform: translateX(0); opacity: 1; }
.callout .c-ico {
  width: 30px; height: 30px; flex: none; margin-top: 1px;
  display: grid; place-items: center;
  border-radius: 9px; background: rgba(232,163,61,.18);
}
.callout .c-ico svg { width: 19px; height: 19px; }
.callout .c-body { display: flex; flex-direction: column; gap: 3px; }
.callout .c-title {
  font-family: var(--font-disp); font-weight: 700; font-size: 14px;
  color: var(--pollen); letter-spacing: .2px;
}
.callout .c-text {
  font-size: 13px; line-height: 1.42; color: rgba(255,246,230,.9);
  text-wrap: pretty;
}
.callout .c-text b { color: var(--cream); font-weight: 800; }

/* ===== First-person mode ===== */
#fpv-layer {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0; transition: opacity .5s ease;
}
#fpv-layer * { pointer-events: none !important; }
#fpv-layer.on { opacity: 1; }
.fpv-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 62% 62% at 50% 50%,
    transparent 52%, rgba(60,34,8,.55) 100%);
}
.fpv-crosshair {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 26px; height: 26px;
  opacity: .65;
}
.fpv-crosshair::before, .fpv-crosshair::after {
  content: ""; position: absolute; background: rgba(255,246,230,.85);
}
.fpv-crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
.fpv-crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }
.fpv-hint {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 18px; align-items: center;
  padding: 11px 22px;
  font-size: 13px; font-weight: 700; color: rgba(255,246,230,.9);
}
.fpv-hint .key {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  margin-right: 6px;
  border-radius: 6px; background: rgba(255,246,230,.16);
  font-family: var(--font-disp); font-weight: 800; font-size: 12px;
}
.fpv-hint .exit { color: var(--pollen); }
.fpv-top {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  padding: 9px 20px; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; gap: 9px;
}
.fpv-top svg { width: 18px; height: 18px; }

body.fpv #topleft,
body.fpv #topright,
body.fpv #controls { opacity: 0; pointer-events: none; transition: opacity .35s ease; }
body.fpv #scene-canvas { cursor: none; }

/* ===== Loading ===== */
#loader {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(circle at 50% 38%, #4a2f12, #1c1209 75%);
  display: grid; place-items: center;
  transition: opacity .7s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.loader-hex {
  width: 92px; height: 92px;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-12px)} }
.loader-title {
  font-family: var(--font-disp); font-weight: 800; font-size: 30px;
  letter-spacing: 1px;
}
.loader-title b { color: var(--honey); }
.loader-bar { width: 200px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; }
.loader-bar > i { display:block; height:100%; width:0%; background: var(--honey); transition: width .3s ease; }
.loader-sub { font-size: 13px; color: rgba(255,246,230,.55); font-weight: 600; }

/* small helper */
.hint-pill {
  position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 700; color: rgba(255,246,230,.55);
  background: rgba(40,27,14,.5); padding: 6px 14px; border-radius: 20px;
  pointer-events: none; backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .5s ease;
}
.hint-pill.show { opacity: 1; }

@media (max-width: 720px) {
  .resource-rail { flex-wrap: wrap; max-width: 220px; }
  .res { min-width: 92px; }
}

/* ===== Hive interior chrome ===== */
#interior-bar {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  display: flex; align-items: center; gap: 16px;
  padding: 8px 16px 8px 8px;
  opacity: 0; pointer-events: none;
  transition: opacity .4s ease, transform .4s ease;
}
.interior-title {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-disp); font-weight: 700; font-size: 16px;
  color: var(--cream); padding-right: 6px;
}
.interior-title svg { width: 19px; height: 19px; }

#comb-legend {
  position: absolute; right: 20px; bottom: 22px;
  padding: 14px 18px;
  opacity: 0; pointer-events: none;
  transform: translateY(12px);
  transition: opacity .4s ease, transform .4s ease;
}
.legend-head {
  font-family: var(--font-disp); font-weight: 700; font-size: 12px;
  letter-spacing: 1px; text-transform: uppercase; color: rgba(255,246,230,.55);
  margin-bottom: 10px;
}
.legend-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 700; color: rgba(255,246,230,.92);
  padding: 3px 0;
}
.legend-row i {
  width: 16px; height: 18px; flex: none;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

body.inside #interior-bar { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
body.inside #comb-legend { opacity: 1; pointer-events: auto; transform: translateY(0); }
body.inside #btn-inside,
body.inside #btn-bee,
body.inside #btn-waggle,
body.inside #btn-colony,
body.inside #btn-research,
body.inside #btn-season { display: none; }

/* honey fade transition */
#hive-fade {
  position: fixed; inset: 0; z-index: 40;
  background: radial-gradient(circle at 50% 45%, #E8A33D, #6E4516 80%);
  opacity: 0; pointer-events: none;
  transition: opacity .36s ease;
}
#hive-fade.show { opacity: 1; }

/* interactive comb labels */
#cell-labels, #cell-tip { display: none; }
body.inside #cell-labels { display: block; }
.dev-label {
  position: fixed; z-index: 12;
  transform: translateX(-50%);
  pointer-events: none;
  background: rgba(28, 18, 8, 0.86);
  border: 1px solid rgba(255, 220, 150, 0.35);
  color: var(--cream);
  font-family: var(--font-disp); font-weight: 700; font-size: 12.5px;
  padding: 4px 10px; border-radius: 9px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.dev-label::after {
  content: ""; position: absolute; left: 50%; bottom: -5px;
  transform: translateX(-50%) rotate(45deg);
  width: 9px; height: 9px;
  background: rgba(28, 18, 8, 0.86);
  border-right: 1px solid rgba(255, 220, 150, 0.35);
  border-bottom: 1px solid rgba(255, 220, 150, 0.35);
}
#cell-tip.tip {
  display: none;
  max-width: 240px; white-space: normal;
  font-family: var(--font-ui); font-weight: 600; font-size: 12.5px;
  line-height: 1.4; text-align: left;
  padding: 10px 13px;
}
#cell-tip.tip::after { display: none; }
#cell-tip.tip b {
  display: block; font-family: var(--font-disp); font-weight: 700;
  font-size: 13.5px; color: var(--pollen); margin-bottom: 3px;
}
body.inside #cell-tip.tip.show { display: block; }

/* ===== Bee inspector ===== */
#inspector {
  position: absolute; top: 162px; right: 20px;
  width: 296px; padding: 16px 18px 16px;
  pointer-events: auto;
  transform: translateX(118%); opacity: 0;
  transition: transform .42s cubic-bezier(.2,.9,.3,1.15), opacity .35s ease;
}
#inspector.show { transform: translateX(0); opacity: 1; }
body.fpv #inspector, body.inside #inspector { transform: translateX(118%); opacity: 0; pointer-events: none; }

.insp-head { display: flex; align-items: center; gap: 11px; }
.insp-avatar {
  width: 40px; height: 40px; flex: none; border-radius: 11px;
  background: rgba(0,0,0,.22);
  display: grid; place-items: center;
}
.insp-avatar svg { width: 26px; height: 26px; }
.insp-id { flex: 1; min-width: 0; }
#insp-name { font-family: var(--font-disp); font-weight: 800; font-size: 17px; line-height: 1.1; }
.insp-caste { font-size: 11px; font-weight: 700; color: rgba(255,246,230,.55); letter-spacing: .3px; margin-top: 2px; }
.insp-close {
  width: 26px; height: 26px; flex: none; border: none; cursor: pointer;
  border-radius: 8px; background: rgba(255,246,230,.08); color: var(--cream);
  font-size: 18px; line-height: 1; display: grid; place-items: center;
  transition: background .15s ease;
}
.insp-close:hover { background: rgba(255,246,230,.2); }

.insp-role-row { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 12px; }
.insp-role { font-family: var(--font-disp); font-weight: 700; font-size: 21px; color: var(--pollen); }
.insp-age { font-size: 12.5px; font-weight: 700; color: rgba(255,246,230,.6); }

.insp-activity {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 11px;
  background: rgba(255,246,230,.06); margin-bottom: 12px;
}
.act-dot {
  width: 9px; height: 9px; flex: none; border-radius: 50%;
  background: #6FCF6F; box-shadow: 0 0 0 0 rgba(111,207,111,.6);
  animation: actpulse 1.8s ease-out infinite;
}
@keyframes actpulse { 0%{box-shadow:0 0 0 0 rgba(111,207,111,.55)} 70%{box-shadow:0 0 0 8px rgba(111,207,111,0)} 100%{box-shadow:0 0 0 0 rgba(111,207,111,0)} }
#insp-activity { font-weight: 800; font-size: 14px; }
.insp-actsub { font-size: 11.5px; color: rgba(255,246,230,.55); font-weight: 600; margin-top: 1px; }

.insp-stat { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.insp-stat-label { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: rgba(255,246,230,.5); width: 64px; flex: none; }
.insp-bar { flex: 1; height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.insp-bar > i { display: block; height: 100%; width: 70%; border-radius: 4px; background: linear-gradient(90deg,#E8A33D,#F2B705); transition: width .3s ease, background .3s ease; }
.insp-carry { font-size: 13px; font-weight: 700; color: var(--cream); }

.insp-edu {
  margin: 12px 0 14px; padding-top: 12px;
  border-top: 1px solid var(--card-line);
  font-size: 12.5px; line-height: 1.45; color: rgba(255,246,230,.82);
  text-wrap: pretty;
}
.insp-actions { display: flex; gap: 8px; }
.insp-actions .ctl { flex: 1; height: 38px; justify-content: center; }

/* ===== Waggle dance mini-game ===== */
.wg-backdrop {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(20, 12, 4, 0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.wg-backdrop.show { opacity: 1; pointer-events: auto; }
.wg-card {
  width: min(720px, 94vw); padding: 22px 24px 24px;
  transform: translateY(14px) scale(.98); transition: transform .32s cubic-bezier(.2,.9,.3,1.1);
}
.wg-backdrop.show .wg-card { transform: none; }
.wg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.wg-title { display: flex; align-items: center; gap: 11px; font-family: var(--font-disp); font-weight: 800; font-size: 21px; }
.wg-title svg { width: 24px; height: 24px; }
.wg-body { display: flex; gap: 26px; }
@media (max-width: 640px) { .wg-body { flex-direction: column; align-items: center; } }

.wg-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: none; }
#wg-canvas {
  width: 300px; height: 300px; border-radius: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,230,180,0.15), 0 10px 30px rgba(0,0,0,.4);
}
.wg-waggling {
  font-size: 12px; font-weight: 800; letter-spacing: .5px;
  color: rgba(255,246,230,.3); transition: color .15s ease;
}
.wg-waggling.on { color: var(--pollen); }
#wg-replay { height: 36px; }

.wg-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wg-instr { font-size: 13px; line-height: 1.5; color: rgba(255,246,230,.82); margin-bottom: 18px; text-wrap: pretty; }
.wg-instr b { color: var(--cream); font-weight: 800; }
.wg-control { margin-bottom: 18px; }
.wg-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-disp); font-weight: 700; font-size: 14px; margin-bottom: 8px;
}
.wg-val { color: var(--pollen); font-size: 16px; font-variant-numeric: tabular-nums; }
.wg-dial { width: 150px; height: 150px; display: block; margin: 0 auto; cursor: grab; touch-action: none; }
.wg-dial:active { cursor: grabbing; }
.wg-hint { font-size: 11.5px; color: rgba(255,246,230,.5); font-weight: 600; text-align: center; margin-top: 7px; }

.wg-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, rgba(242,183,5,.5), rgba(255,255,255,.12)); outline: none; }
.wg-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--honey); border: 3px solid #2a1a0a; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.wg-slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--honey); border: 3px solid #2a1a0a; cursor: pointer; }
.wg-submit { width: 100%; height: 44px; justify-content: center; margin-top: 4px; }

.wg-result { opacity: 0; max-height: 0; overflow: hidden; transition: opacity .3s ease; }
.wg-result.show { opacity: 1; max-height: 600px; }
.wg-verdict { font-family: var(--font-disp); font-weight: 800; font-size: 22px; margin-bottom: 14px; }
.wg-verdict.good { color: #7BD86B; }
.wg-verdict.ok { color: var(--pollen); }
.wg-verdict.bad { color: #E0653C; }
.wg-scores { display: flex; gap: 12px; margin-bottom: 14px; }
.wg-score { flex: 1; background: rgba(255,246,230,.06); border-radius: 11px; padding: 11px 13px; display: flex; flex-direction: column; gap: 2px; }
.wg-score span { font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: rgba(255,246,230,.5); }
.wg-score b { font-family: var(--font-disp); font-size: 17px; }
.wg-score b.g { color: #7BD86B; } .wg-score b.b { color: #E0653C; }
.wg-score small { font-size: 11px; color: rgba(255,246,230,.55); font-weight: 600; }
.wg-note { font-size: 12.5px; line-height: 1.5; color: rgba(255,246,230,.78); margin-bottom: 16px; text-wrap: pretty; }
.wg-note b { color: var(--cream); font-weight: 800; }
.wg-actions { display: flex; gap: 8px; }
.wg-actions .ctl { flex: 1; height: 40px; justify-content: center; }

/* ===== Colony dashboard ===== */
#dashboard {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 22;
  width: 344px; max-width: 88vw;
  display: flex; flex-direction: column;
  background: rgba(32, 21, 10, 0.82);
  backdrop-filter: blur(14px) saturate(1.1); -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-left: 1px solid var(--card-line);
  box-shadow: -14px 0 40px rgba(20,12,2,.45);
  transform: translateX(100%); opacity: 0;
  transition: transform .4s cubic-bezier(.2,.9,.3,1.05), opacity .35s ease;
  pointer-events: auto;
}
#dashboard.show { transform: translateX(0); opacity: 1; }
body.fpv #dashboard { transform: translateX(100%); opacity: 0; }
/* when open, fade the small top-right summary so it isn't duplicated */
body.dash-open #topright { opacity: 0; pointer-events: none; transition: opacity .3s ease; }

.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px; flex: none;
  border-bottom: 1px solid var(--card-line);
}
.dash-title { font-family: var(--font-disp); font-weight: 800; font-size: 23px; line-height: 1; }
.dash-sub { font-size: 12.5px; font-weight: 700; color: rgba(255,246,230,.55); margin-top: 4px; }
.dash-scroll { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.dash-scroll::-webkit-scrollbar { width: 8px; }
.dash-scroll::-webkit-scrollbar-thumb { background: rgba(255,230,180,.18); border-radius: 4px; }

.dash-health {
  padding: 15px 16px; border-radius: 14px;
  border-left: 4px solid var(--honey);
  background: rgba(255,246,230,.06);
}
.dash-health.good { border-left-color: #7BD86B; }
.dash-health.ok { border-left-color: var(--pollen); }
.dash-health.bad { border-left-color: #E0653C; }
.dh-status { font-family: var(--font-disp); font-weight: 800; font-size: 19px; }
.dash-health.good .dh-status { color: #7BD86B; }
.dash-health.ok .dh-status { color: var(--pollen); }
.dash-health.bad .dh-status { color: #E0653C; }
.dh-reason { font-size: 12.5px; line-height: 1.45; color: rgba(255,246,230,.78); margin-top: 5px; text-wrap: pretty; }

.dash-card { padding: 15px 16px; border-radius: 14px; background: rgba(255,246,230,.05); border: 1px solid var(--card-line); }
.dc-title {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-disp); font-weight: 700; font-size: 13px;
  letter-spacing: .5px; text-transform: uppercase; color: rgba(255,246,230,.6);
  margin-bottom: 13px;
}
.dc-title span { font-size: 18px; color: var(--cream); text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.dc-foot { font-size: 11.5px; line-height: 1.4; color: rgba(255,246,230,.5); margin-top: 12px; text-wrap: pretty; }

.role-row, .store-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.role-row:last-child, .store-row:last-child { margin-bottom: 0; }
.role-label, .store-label { font-size: 12.5px; font-weight: 700; color: rgba(255,246,230,.85); width: 96px; flex: none; }
.role-bar, .store-bar { flex: 1; height: 8px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
.role-bar > i, .store-bar > i { display: block; height: 100%; border-radius: 4px; transition: width .4s ease; }
.role-count, .store-val { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cream); width: 58px; text-align: right; flex: none; }

.temp-gauge { position: relative; height: 16px; border-radius: 8px; background: linear-gradient(90deg,#5FB6C9,#7BD86B 50%,#E0653C); margin: 6px 0 24px; }
.temp-band { position: absolute; left: 45%; width: 10%; top: -3px; bottom: -3px; border: 2px solid rgba(255,255,255,.85); border-radius: 6px; box-shadow: 0 0 8px rgba(255,255,255,.3); }
.temp-marker { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid #2a1a0a; transform: translate(-50%,-50%); transition: left .5s ease; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.temp-tick { position: absolute; top: 20px; font-size: 10px; font-weight: 700; color: rgba(255,246,230,.45); }
.temp-tick.l { left: 0; } .temp-tick.m { left: 50%; transform: translateX(-50%); } .temp-tick.r { right: 0; }
.temp-meta { display: flex; justify-content: space-between; }
.temp-meta span:first-child { font-family: var(--font-disp); font-weight: 800; font-size: 17px; }
.temp-meta span:last-child { font-weight: 800; font-size: 13px; }

.dash-activity { display: flex; gap: 9px; }
.act-tile { flex: 1; text-align: center; padding: 12px 6px; border-radius: 11px; background: rgba(0,0,0,.18); }
.act-tile b { display: block; font-family: var(--font-disp); font-weight: 800; font-size: 22px; color: var(--pollen); }
.act-tile span { font-size: 10.5px; font-weight: 700; color: rgba(255,246,230,.55); }

/* dashboard defense rows */
.def-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 12.5px; }
.def-row .def-k { font-weight: 700; color: rgba(255,246,230,.6); }
.def-row span:last-child { font-family: var(--font-disp); font-weight: 800; }
.def-attack { width: 100%; height: 40px; justify-content: center; margin-top: 8px; }
.def-attack:disabled { opacity: .5; cursor: default; }

/* dashboard save card */
.save-when { font-size: 11px !important; font-weight: 700; color: rgba(255,246,230,.45); text-transform: none; letter-spacing: 0; }
.save-when.pulse { animation: savepulse .6s ease; }
@keyframes savepulse { 0%{color:var(--pollen)} 100%{color:rgba(255,246,230,.45)} }
.save-actions { display: flex; gap: 8px; }
.save-actions .ctl { flex: 1; height: 38px; justify-content: center; }
#btn-reset { background: rgba(224,101,60,.14); color: #F0937A; }
#btn-reset:hover { background: rgba(224,101,60,.28); }

/* ===== Threat banner (top-center) ===== */
.threat-banner {
  position: fixed; top: 20px; left: 50%; z-index: 30;
  transform: translateX(-50%) translateY(-24px);
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px 12px 14px; border-radius: 16px;
  background: rgba(46, 22, 10, 0.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(224, 101, 60, 0.45);
  box-shadow: 0 10px 30px rgba(40,12,2,.5);
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease, transform .4s cubic-bezier(.2,.9,.3,1.1);
}
.threat-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.tb-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; }
.tb-icon svg { width: 26px; height: 26px; }
.threat-banner.alert .tb-icon { color: #E0653C; background: rgba(224,101,60,.18); }
.threat-banner.hot .tb-icon, .threat-banner.win .tb-icon { color: #F2B705; background: rgba(242,183,5,.18); }
.threat-banner.alert { border-color: rgba(224,101,60,.5); }
.threat-banner.hot { border-color: rgba(242,135,30,.6); animation: tbpulse 1s ease-in-out infinite; }
.threat-banner.win { border-color: rgba(123,216,107,.6); }
@keyframes tbpulse { 0%,100%{box-shadow:0 10px 30px rgba(40,12,2,.5)} 50%{box-shadow:0 10px 40px rgba(242,135,30,.55)} }
.tb-title { font-family: var(--font-disp); font-weight: 800; font-size: 16px; line-height: 1.1; }
.threat-banner.alert .tb-title { color: #F0937A; }
.threat-banner.hot .tb-title, .threat-banner.win .tb-title { color: var(--pollen); }
.threat-banner.win .tb-title { color: #8FE07C; }
.tb-sub { font-size: 12px; font-weight: 600; color: rgba(255,246,230,.75); margin-top: 2px; max-width: 360px; text-wrap: pretty; }
.tb-temp { display: none; flex-direction: column; align-items: center; padding-left: 14px; margin-left: 4px; border-left: 1px solid rgba(255,230,180,.2); }
.tb-temp-val { font-family: var(--font-disp); font-weight: 800; font-size: 19px; color: #FF7A2E; font-variant-numeric: tabular-nums; }
.tb-temp-lbl { font-size: 9.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: rgba(255,246,230,.5); margin-top: 1px; }
body.fpv .threat-banner, body.inside .threat-banner { opacity: 0; pointer-events: none; }

/* ===== Research tree ===== */
.rp-badge {
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px;
  display: none; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--pollen); color: #2a1a0a;
  font-family: var(--font-disp); font-weight: 800; font-size: 11px;
}
.rp-badge.has { display: inline-flex; }
#btn-research { position: relative; }

.rp-card { width: min(860px, 95vw); max-height: 90vh; padding: 22px 24px 18px; display: flex; flex-direction: column; }
.rp-points-wrap { margin-left: auto; margin-right: 14px; font-size: 13px; font-weight: 700; color: rgba(255,246,230,.6); }
.rp-points-wrap b { font-family: var(--font-disp); font-size: 20px; color: var(--pollen); margin-left: 4px; font-variant-numeric: tabular-nums; }
.rp-tree { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 6px 4px 4px; }
.rp-tree::-webkit-scrollbar { width: 8px; }
.rp-tree::-webkit-scrollbar-thumb { background: rgba(255,230,180,.18); border-radius: 4px; }

.rp-branch { display: flex; align-items: center; gap: 14px; }
.rp-branch-head {
  width: 130px; flex: none; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-disp); font-weight: 700; font-size: 14px;
}
.rp-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.rp-nodes { display: flex; align-items: center; flex: 1; min-width: 0; }
.rp-link { width: 18px; height: 3px; background: rgba(255,255,255,.12); flex: none; }
.rp-link.on { background: rgba(242,183,5,.6); }

.rp-node {
  position: relative; flex: 1; min-width: 0; cursor: default;
  text-align: left; border: none; border-radius: 11px;
  padding: 11px 13px; color: var(--cream);
  background: rgba(255,246,230,.05); border: 1px solid var(--card-line);
  display: flex; flex-direction: column; gap: 3px;
  transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.rp-node-name { font-family: var(--font-disp); font-weight: 700; font-size: 13.5px; }
.rp-node-cost { font-size: 11px; font-weight: 800; color: rgba(255,246,230,.5); }
.rp-node.got { background: rgba(123,216,107,.14); border-color: rgba(123,216,107,.5); }
.rp-node.got .rp-node-cost { color: #7BD86B; }
.rp-node.avail { cursor: pointer; border-color: var(--pollen); background: rgba(242,183,5,.12); }
.rp-node.avail:hover { background: rgba(242,183,5,.22); transform: translateY(-1px); }
.rp-node.avail .rp-node-cost { color: var(--pollen); }
.rp-node.poor { opacity: .82; }
.rp-node.poor .rp-node-cost { color: #E8A33D; }
.rp-node.locked { opacity: .42; }

.rp-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  width: 210px; padding: 9px 12px; border-radius: 10px;
  background: rgba(20,12,4,.96); border: 1px solid var(--card-line);
  font-family: var(--font-ui); font-weight: 600; font-size: 11.5px; line-height: 1.4;
  color: rgba(255,246,230,.9);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  z-index: 5; box-shadow: var(--shadow); text-wrap: pretty;
}
.rp-node:hover .rp-tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.rp-foot { font-size: 12px; font-weight: 600; color: rgba(255,246,230,.5); margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--card-line); text-align: center; }

@media (max-width: 680px) {
  .rp-branch { flex-direction: column; align-items: stretch; gap: 8px; }
  .rp-branch-head { width: auto; }
  .rp-link { display: none; }
  .rp-nodes { flex-wrap: wrap; gap: 8px; }
}
