/* DINO DEFENSE — UI styling */
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

:root {
  --bg: #10140d;
  --panel: #1b2117;
  --panel2: #242c1e;
  --line: #3a4530;
  --amber: #e8b93a;
  --amber2: #ffd24a;
  --text: #d8dcc8;
  --dim: #8b937c;
  --red: #e05a4a;
  --green: #8fd14f;
  --dna: #7ec8ff;
  --bio: #46e6c4;        /* bioluminescent teal accent */
  --bio2: #7ff4dc;
  --ink: #070a06;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Verdana, Geneva, sans-serif;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

.hidden { display: none !important; }

/* ---------- HUD (top bar) ---------- */
#hud {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  background: linear-gradient(#232b1b, #1a2014);
  border-bottom: 2px solid var(--amber);
  font-size: 14px;
  /* NEVER wrap on desktop/landscape: a second HUD row shrinks the stage and
     the map visibly "zooms" whenever a badge/label appears or grows. When
     space is tight the title and ticker shrink instead (portrait phones
     override this with their own STABLE two-row layout). */
  flex-wrap: nowrap; overflow: hidden;
}
#hud button { white-space: nowrap; }  /* long labels must widen, never grow a 2nd line */
#speedBtns { display: inline-flex; flex: none; }  /* 1×/2×/4×/10× never stack into a 2nd line */
#levelTitle {
  font-weight: bold; color: var(--amber2); letter-spacing: 0.5px;
  min-width: 0; flex: 0 4 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#streakBadge { font-variant-numeric: tabular-nums; }
.stat { background: #00000040; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; white-space: nowrap; }
#hCash { color: var(--amber2); font-weight: bold; }
#hDna  { color: var(--dna); }
#hLives { color: var(--green); font-weight: bold; }
#hLives.low { color: var(--red); animation: blink 0.8s infinite; }
@keyframes blink { 50% { opacity: 0.45; } }
#invBadge {
  color: #ffdf70; border: 1px solid #ffdf70; border-radius: 6px;
  padding: 3px 8px; font-size: 12px; font-weight: bold;
}
#streakBadge {
  color: #ffb84a; border: 1px solid #ffb84a55; border-radius: 6px;
  padding: 3px 8px; font-size: 12px; font-weight: bold; white-space: nowrap;
  background: #ff8a2020;
}
#streakBadge.hot {
  color: #fff2c0; border-color: #ff7a2a; background: #ff6a1533;
  box-shadow: 0 0 10px #ff7a2a66; animation: streakPulse 0.9s ease-in-out infinite;
}
@keyframes streakPulse { 50% { box-shadow: 0 0 16px #ff7a2aaa; } }
@media (prefers-reduced-motion: reduce){ #streakBadge.hot { animation: none; } }
#hud .spacer { flex: 1; }
#hud button, .modal button, #shop button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; font-family: inherit; font-size: 13px; cursor: pointer;
}
#hud button:hover:not(:disabled), .modal button:hover:not(:disabled), #shop button:hover:not(:disabled) { border-color: var(--amber); color: #fff; }
#hud button:disabled, .modal button:disabled, #shop button:disabled { opacity: 0.45; cursor: default; }
#hud button.on { background: var(--amber); color: #1a1a0a; font-weight: bold; border-color: var(--amber2); }
#btnWave { background: #3d5226; font-weight: bold; }
#speedCycle { display: none; min-width: 34px; } /* mobile-only single speed toggle */

/* ---------- main area ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #0a0d08; min-width: 0; }
canvas#game {
  max-width: 100%; max-height: 100%;
  aspect-ratio: 16/9;
  background: #1c2415;
  cursor: crosshair;
  box-shadow: 0 0 40px #000 inset;
}

#pausePrompt {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 16; max-width: calc(100% - 24px); text-align: center; pointer-events: none;
}
#pausePrompt .pause-title {
  margin-bottom: 12px; color: #fff; font-size: clamp(18px, 3vw, 28px);
  font-weight: bold; text-shadow: 0 2px 8px #000;
}
#btnResume {
  min-height: 48px; padding: 12px 24px; border: 2px solid var(--amber2); border-radius: 8px;
  background: var(--amber); color: var(--ink); font: bold 16px Verdana, sans-serif;
  white-space: nowrap; cursor: pointer; pointer-events: auto; touch-action: manipulation;
  box-shadow: 0 4px 20px #0008;
}
#btnResume:hover { background: var(--amber2); }
#btnResume:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

/* ---------- shop (right panel) ---------- */
#shop {
  width: 210px; padding: 10px;
  background: var(--panel);
  border-left: 2px solid var(--line);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px;
}
#shop h3 { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
#shopCards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shopCard {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 4px; text-align: center; cursor: pointer;
  transition: transform 0.06s, border-color 0.06s;
}
.shopCard:hover { border-color: var(--amber); transform: translateY(-1px); }
.shopCard.sel { border-color: var(--amber2); background: #3a4227; box-shadow: 0 0 10px #e8b93a55; }
.shopCard.cant { opacity: 0.45; }
.shopCard.locked { opacity: 0.35; filter: grayscale(0.8); cursor: default; }
.shopCard.locked:hover { border-color: var(--line); transform: none; }
.shopCard.locked .cost { color: var(--dim); }
.shopCard .ico { font-size: 22px; }
.shopCard .ico canvas { display: block; width: 84px; height: 56px; max-width: 100%; object-fit: contain; margin: -5px auto -2px; pointer-events: none; }
.arsenal-open { display: flex; justify-content: space-between; gap: 8px; padding: 8px 7px; color: #e8cd96; background: #172329; border: 1px solid #47544f; border-radius: 5px; font-size: 10px; text-align: left; }
#tpHardware { display: flex; align-items: center; gap: 4px; border-block: 1px solid #80969d25; padding: 2px 0; }
#tpHardware canvas { width: 76px; height: 50px; object-fit: contain; flex: 0 0 76px; }
#tpHardware b { display: block; font-size: 11px; color: #cddde0; }
#tpHardware span { display: block; font-size: 9px; line-height: 1.4; color: #99adae; margin-top: 3px; }
/* Living collection */
.creatures-open { display:flex; align-items:center; justify-content:center; gap:15px; width:100%; padding:14px 20px; margin:0 0 18px; color:#d6e6d8; background:linear-gradient(110deg,#1c332c,#12271f); border:1px solid #567461; border-radius:7px; font:12px Verdana,sans-serif; cursor:pointer; }
.creatures-open span { color:#91bfa7; font:9px monospace; letter-spacing:2px; } .creatures-open b { color:#bdd8b7; font-size:20px; }
#creatureGuide { color:#e4ece4; background:#101f1a; border:1px solid #576e5f; border-radius:12px; padding:0; width:min(1180px,95vw); max-width:95vw; max-height:94dvh; margin:auto; box-shadow:0 28px 120px #000c; overflow:auto; }
#creatureGuide::backdrop { background:#020b08ed; }
.cg-top { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:22px 30px; background:#102019; border-bottom:1px solid #77998530; position:sticky; top:0; z-index:3; }
.cg-eyebrow { color:#93b4a0; font:10px monospace; letter-spacing:2.5px; } .cg-top h2 { font-size:29px; font-weight:500; letter-spacing:-.8px; margin-top:7px; }
#creatureGuide button { font-family:inherit; cursor:pointer; } .cg-close { color:#dae7da; background:transparent; border:1px solid #607b6b; border-radius:50%; width:36px; height:36px; font-size:16px; flex-shrink:0; }
.cg-body { display:grid; grid-template-columns:215px minmax(0,1fr); }
.cg-roster { background:#0c1914; border-right:1px solid #77998530; padding:20px 12px; }
.cg-roster label { display:block; color:#86a393; font:9px monospace; letter-spacing:.6px; margin:0 8px 15px; }
.cg-roster nav { max-height:590px; overflow-y:auto; scrollbar-color:#435b4d #0c1914; }
.cg-roster button { display:flex; align-items:center; gap:10px; width:100%; text-align:left; color:#a7bbae; background:transparent; border:1px solid transparent; border-radius:4px; padding:9px 7px; font-size:11px; }
.cg-roster button span { color:#658976; font:9px monospace; } .cg-roster button i { margin-left:auto; font-size:7px; color:#d0b582; }
.cg-roster button.active { color:#eff4e3; background:#243b2f; border-color:#648774; } .cg-roster button.active span { color:#b7d4b9; }
#cgSpecies { display:none; width:100%; min-height:40px; color:#e0e9dd; background:#20362b; border:1px solid #617d68; padding:7px; font:12px Verdana,sans-serif; border-radius:4px; }
.cg-main { min-width:0; } .cg-stage { position:relative; overflow:hidden; } .cg-stage canvas { width:100%; display:block; height:auto; touch-action:none; cursor:grab; } .cg-stage canvas:active { cursor:grabbing; }
.cg-habitat,.cg-drag { position:absolute; top:23px; left:28px; color:#97b0a4; font:9px monospace; letter-spacing:1.2px; pointer-events:none; } .cg-habitat { border-left:2px solid #adc98d; padding-left:9px; } .cg-drag { left:auto; right:26px; color:#638274; font-size:8px; }
.cg-copy { padding:3px 30px 22px; } .cg-index { color:#b7c897; font:9px monospace; letter-spacing:2px; } .cg-copy h3 { font-size:34px; font-weight:500; letter-spacing:-1px; margin:7px 0 10px; } .cg-copy p { color:#a3b7aa; font-size:12px; line-height:1.7; max-width:650px; min-height:41px; }
.cg-controls { display:flex; gap:10px; align-items:center; padding:0 30px 24px; } .cg-controls button { border:1px solid #6b806b; background:#20372a; color:#e0e7d5; border-radius:4px; padding:11px 15px; font-size:10px; } .cg-controls label { margin-left:auto; display:flex; align-items:center; gap:12px; color:#90ab9a; font:10px monospace; } .cg-angle { width:145px; accent-color:#b7ce9f; }
.cg-footer { display:flex; justify-content:space-between; gap:12px; border-top:1px solid #77998530; padding:15px 30px; color:#7a9887; font:9px monospace; }
#creatureGuide button:focus-visible,#creatureGuide input:focus-visible,#cgSpecies:focus-visible,.creatures-open:focus-visible { outline:2px solid #d1e4a9; outline-offset:2px; }
@media(max-width:700px) {
  .creatures-open { gap:10px; padding:11px; font-size:10px; } .creatures-open span { font-size:7px; letter-spacing:1px; }
  .cg-top { padding:17px; } .cg-top h2 { font-size:25px; } .cg-eyebrow { font-size:8px; letter-spacing:1.7px; }
  .cg-body { display:block; } .cg-roster { padding:12px 17px; border-right:0; border-bottom:1px solid #77998530; } .cg-roster label { display:none; } .cg-roster nav { display:none; } #cgSpecies { display:block; }
  .cg-copy { padding:4px 19px 16px; } .cg-copy h3 { font-size:29px; } .cg-copy p { font-size:11px; min-height:0; } .cg-index { font-size:8px; letter-spacing:1.4px; }
  .cg-habitat { top:12px; left:17px; font-size:7px; letter-spacing:.4px; } .cg-drag { display:none; }
  .cg-controls { padding:0 18px 19px; flex-wrap:wrap; gap:8px; } .cg-controls button { padding:10px 12px; } .cg-controls label { width:100%; margin:4px 0 0; justify-content:space-between; } .cg-angle { flex:1; max-width:210px; }
  .cg-footer { padding:13px 18px; font-size:8px; }
}
@media(max-height:550px) and (orientation:landscape) {
  .cg-top { padding:12px 23px; } .cg-top h2 { font-size:23px; } .cg-roster nav { max-height:425px; }
  .cg-stage canvas { max-height:290px; object-fit:contain; } .cg-copy h3 { font-size:27px; } .cg-copy { padding-bottom:14px; }
}
/* Weapon inspection / firing range */
#armoryGuide { --weapon-color: #ffc266; color: #e3eeec; background: #111c22; border: 1px solid #547079; border-radius: 14px; padding: 0; width: min(1040px, 94vw); max-width: 94vw; max-height: 94dvh; margin: auto; box-shadow: 0 30px 110px #000b; overflow: auto; }
#armoryGuide::backdrop { background: #020c13da; backdrop-filter: blur(7px); }
.ag-top { display: flex; justify-content: space-between; align-items: center; padding: 24px 28px 18px; border-bottom: 1px solid #3f555b66; position: sticky; top: 0; z-index: 2; background: #111c22; }
.ag-eyebrow { font: 10px monospace; letter-spacing: 2.5px; color: #8ba4aa; }
.ag-top h2 { font-size: 30px; letter-spacing: -.8px; margin: 6px 0 0; }
.ag-close { background: transparent; border: 1px solid #52666a; border-radius: 50%; width: 35px; height: 35px; color: #dae7e6; padding: 0; }
.ag-body { display: grid; grid-template-columns: 185px minmax(0, 1fr); }
.ag-weapons { border-right: 1px solid #3f555b66; padding: 10px; display: flex; flex-direction: column; gap: 3px; background: #0d181e; }
.ag-weapons button { display: flex; align-items: center; gap: 3px; min-width: 0; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; text-align: left; font-size: 10px; color: #a4b5b8; }
.ag-weapons button.active { color: #f2f6eb; background: #253239; border-color: #55696a; }
.ag-weapons canvas { width: 65px; height: 43px; object-fit: contain; }
.ag-main { min-width: 0; }
.ag-stage { position: relative; background: #101b22; overflow: hidden; }
.ag-stage canvas { width: 100%; height: auto; display: block; }
.ag-status { position: absolute; left: 24px; top: 20px; color: #9aafb2; font: 9px monospace; letter-spacing: 1.8px; border-left: 2px solid var(--weapon-color); padding-left: 8px; }
.ag-spec { display: flex; align-items: center; justify-content: space-between; padding: 0 25px 19px; gap: 12px; }
.ag-level { font: 9px monospace; letter-spacing: 1.8px; color: var(--weapon-color); }
.ag-name { font-size: 28px; letter-spacing: -.6px; margin: 6px 0; }
.ag-detail { color: #a7babe; font-size: 12px; line-height: 1.4; margin: 0; }
.ag-fire { flex-shrink: 0; color: #e6eeeb; background: #28383f; border: 1px solid #698087; border-radius: 5px; padding: 10px 14px; font-size: 11px; }
.ag-tiers { display: flex; gap: 7px; padding: 0 25px 19px; }
.ag-tiers button { flex: 1; color: #acbdc0; border: 1px solid #3e555b; background: #19272f; padding: 12px 8px; border-radius: 5px; font-size: 10px; line-height: 1.3; text-align: left; }
.ag-tiers button span { display: block; font: 9px monospace; color: #749097; margin-bottom: 6px; }
.ag-tiers button.active { border-color: var(--weapon-color); color: var(--weapon-color); background: #273338; }
.ag-footer { padding: 14px 25px; border-top: 1px solid #3f555b66; display: flex; align-items: center; justify-content: space-between; gap: 20px; font-size: 9px; color: #8ca3a8; }
.ag-footer label { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.ag-angle { width: 110px; accent-color: var(--weapon-color); }
#armoryGuide button:focus-visible, .ag-angle:focus-visible { outline: 2px solid var(--weapon-color); outline-offset: 2px; }
@media (max-width: 700px) {
  .shopCard .ico canvas { height: 39px; width: 66px; margin: -3px auto -1px; }
  #tpHardware canvas { width: 57px; height: 40px; flex-basis: 57px; }
  #tpHardware b { font-size: 10px; } #tpHardware span { font-size: 8px; }
  .ag-top { padding: 17px; } .ag-top h2 { font-size: 25px; } .ag-eyebrow { font-size: 8px; letter-spacing: 1.8px; }
  .ag-body { display: flex; flex-direction: column; }
  .ag-weapons { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 3px; border-right: 0; border-bottom: 1px solid #3f555b66; padding: 7px; }
  .ag-weapons button { font-size: 8px; padding: 2px; gap: 0; } .ag-weapons canvas { width: 42px; height: 30px; flex-shrink: 0; }
  .ag-spec { padding: 0 15px 14px; } .ag-level { font-size: 8px; letter-spacing: 1px; } .ag-name { font-size: 23px; } .ag-detail { font-size: 10px; }
  .ag-fire { font-size: 9px; padding: 8px; }
  .ag-tiers { padding: 0 14px 16px; gap: 4px; } .ag-tiers button { font-size: 9px; padding: 8px 6px; }
  .ag-status { left: 15px; top: 13px; font-size: 7px; }
  .ag-footer { padding: 12px 15px; gap: 10px; font-size: 8px; } .ag-angle { width: 80px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .shopCard .ico canvas { height: 30px; width: 52px; }
  #armoryGuide { width: 92vw; }
  .ag-top { padding: 10px 18px; } .ag-top h2 { font-size: 20px; margin-top: 3px; } .ag-eyebrow { font-size: 8px; }
  .ag-stage canvas { max-height: 155px; object-fit: contain; }
  .ag-weapons { padding: 5px; gap: 0; } .ag-weapons button { font-size: 9px; padding: 0 5px; } .ag-weapons canvas { height: 27px; width: 47px; }
  .ag-spec { padding: 0 16px 8px; } .ag-name { font-size: 20px; margin: 3px 0; } .ag-detail { font-size: 10px; }
  .ag-tiers { padding: 0 16px 8px; } .ag-tiers button { padding: 7px; font-size: 9px; } .ag-tiers button span { display: inline; margin-right: 4px; }
  .ag-footer { padding: 7px 16px; } .ag-status { top: 10px; font-size: 7px; }
}
.shopCard .nm { font-size: 10.5px; margin-top: 3px; line-height: 1.2; }
.shopCard .cost { font-size: 11px; color: var(--amber2); margin-top: 2px; font-weight: bold; }

/* Hold-to-read descriptions: a compact sheet on phones, a card on tablets. */
#weaponHoldHint { display: none; color: var(--dim); font-size: 11px; line-height: 1.4; margin-top: -5px; }
.shopCard { position: relative; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.shopCard:focus-visible { outline: 2px solid var(--amber2); outline-offset: 3px; }
.shopCard.info-holding::after { content: ''; position: absolute; inset: auto 8px 3px; height: 2px; border-radius: 2px; background: var(--amber2); transform-origin: left; animation: weapon-hold .48s linear both; pointer-events: none; }
@keyframes weapon-hold { from { transform: scaleX(0); } to { transform: scaleX(1); } }
#weaponInfo { --weapon-accent: #edbc65; position: fixed; inset: 0; margin: auto; width: min(440px,calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); padding: 24px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #64746b; border-top: 3px solid var(--weapon-accent); border-radius: 16px; color: #f0eee3; background: #172124; box-shadow: 0 24px 90px #0009; font-family: system-ui,sans-serif; text-align: left; }
#weaponInfo::backdrop { background: #061013b8; }
#weaponInfo button { font: inherit; min-height: 44px; cursor: pointer; touch-action: manipulation; }
#weaponInfo button:focus-visible { outline: 3px solid #f4c36b; outline-offset: 3px; }
#wiClose { float: right; position: sticky; top: 0; margin: -12px -12px 0 4px; width: 44px; border: 1px solid #53635b; border-radius: 8px; color: #d6e0d5; background: #253337; z-index: 1; }
.wi-eyebrow { color: var(--weapon-accent); font-size: 10px; font-weight: 700; letter-spacing: 1.6px; line-height: 20px; }
.wi-heading { display: flex; align-items: center; gap: 12px; clear: both; margin: 12px 0 18px; }
#wiModel { width: 108px; height: 72px; flex: 0 0 108px; object-fit: contain; }
#wiName { font-size: 23px; line-height: 1.12; letter-spacing: -.5px; margin: 0 0 8px; overflow-wrap: anywhere; }
#wiStatus { color: #c6cdbb; font-size: 12px; line-height: 1.4; }
.wi-facts { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; padding: 14px 0; border-block: 1px solid #ffffff20; }
.wi-facts small { display: block; font-size: 9px; letter-spacing: 1px; color: #9daf9f; margin-bottom: 5px; }
.wi-facts b { font-size: 13px; font-weight: 600; }
#wiPrice { color: #f4cc83; }
#wiDescription { font-size: 15px; line-height: 1.65; margin: 18px 0 20px; }
#wiSelect { width: 100%; padding: 11px 16px; border: 1px solid #f4cc83; border-radius: 8px; color: #172124; background: #edbc65; font-weight: 700 !important; }
#wiSelect:disabled { background: #273533; border-color: #53635b; color: #b2bdad; cursor: default; }
#wiPause { margin: 12px 0 0; color: #a8baac; font-size: 11px; line-height: 1.5; text-align: center; }
@media (any-pointer: coarse) { #weaponHoldHint { display: block; } }
@media (max-width: 600px) and (min-height: 500px) {
  #weaponInfo { inset: auto 0 0; width: 100%; max-height: calc(100dvh - max(24px,env(safe-area-inset-top))); margin: 0; border-radius: 20px 20px 0 0; padding: 22px 20px max(20px,env(safe-area-inset-bottom)); }
}
@media (max-height: 499px) { #weaponInfo { padding: 18px 22px; } .wi-heading { margin: 4px 0 10px; } #wiDescription { margin-block: 12px; } }
@media (prefers-reduced-motion: reduce) { .shopCard.info-holding::after { animation: none; } }

#airCard {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, #2a3040, #1c2128);
  border: 1px solid #3d4a62; border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
  transition: border-color 0.06s, transform 0.06s;
}
#airCard:hover:not(.locked) { border-color: #7fb2ff; transform: translateY(-1px); }
#airCard.sel { border-color: #ff9a7a; box-shadow: 0 0 10px #ff6b4a55; }
#airCard.cant { opacity: 0.45; }
#airCard.locked { opacity: 0.35; filter: grayscale(0.8); cursor: default; }
#airCard .ico { font-size: 22px; }
#airCard .nm { font-size: 12px; font-weight: bold; }
#airCard .cost { font-size: 11px; color: #7fb2ff; font-weight: bold; }

/* Omega — the robotic T-Rex show-stopper */
#omegaCard {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
  background: linear-gradient(135deg, #22303a, #171f26);
  border: 1px solid #3aa0c8; border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
  transition: border-color 0.06s, transform 0.06s, box-shadow 0.2s;
}
#omegaCard:not(.locked) { box-shadow: 0 0 12px #3fb0ff33; }
#omegaCard:hover:not(.locked) { border-color: #8fe0ff; transform: translateY(-1px); box-shadow: 0 0 16px #3fb0ff66; }
#omegaCard.cant { opacity: 0.45; box-shadow: none; }
#omegaCard.locked { opacity: 0.35; filter: grayscale(0.8); cursor: default; box-shadow: none; }
#omegaCard .ico { font-size: 22px; }
#omegaCard .nm { font-size: 12px; font-weight: bold; color: #bfe6ff; }
#omegaCard .cost { font-size: 11px; color: #8fe0ff; font-weight: bold; }

/* floating weapon menu that pops up over a tapped/clicked tower */
#towerPop {
  position: absolute; z-index: 15; width: 210px;
  background: linear-gradient(#2a3220, #20281a);
  border: 1px solid var(--amber); border-radius: 10px;
  box-shadow: 0 8px 24px #000b, 0 0 0 3px #0006;
  padding: 10px 10px 9px; display: flex; flex-direction: column; gap: 7px;
}
/* only scroll internally when the panel can't fit the stage (short screens) —
   JS adds .scroll in that case, so no vestigial scrollbar shows otherwise */
#towerPop.scroll { max-height: calc(100% - 12px); overflow-y: auto; overscroll-behavior: contain; }
/* little pointer notch aimed at the tower (flips when shown below) */
#towerPop::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: var(--amber); border-bottom: 0;
}
#towerPop.below::after { bottom: auto; top: -7px; border-top: 0; border-bottom: 7px solid var(--amber); }
#tpClose, #tpMute {
  position: absolute; top: 5px; width: 24px; height: 24px;
  padding: 0 !important; line-height: 1; font-size: 13px; border-radius: 6px;
  background: #0006 !important; color: var(--dim) !important; border: 1px solid var(--line) !important;
}
#tpClose { right: 5px; font-size: 14px; }
#tpClose:hover { color: #fff !important; border-color: var(--red) !important; }
#tpMute { right: 33px; }
#tpMute:hover { color: #fff !important; border-color: var(--amber) !important; }
#tpMute.muted { color: var(--red) !important; border-color: var(--red) !important; opacity: 0.95; }
#tpName { font-weight: bold; color: var(--amber2); font-size: 13.5px; padding-right: 52px; }
#tpStats { font-size: 11px; color: var(--text); line-height: 1.5; }
#tpStats .warn { color: var(--red); }
#towerPop button { font-size: 12px; text-align: center; padding: 8px 10px; }
/* upgrade button: obviously-disabled grey when broke, bright green when affordable */
#up_main { font-weight: bold; }
#up_main:disabled { background: #23281d !important; color: #6a7060 !important; border-color: #333a2b !important; opacity: 1; }
#up_main.can {
  background: var(--green); color: #14200a; border-color: #b6ef6e;
  box-shadow: 0 0 12px #8fd14f66;
}
#up_main.can:hover:not(:disabled) { background: #a6e35f; color: #14200a; }
.tpRow { display: flex; gap: 6px; }
.tpRow button { flex: 1; }
#tpSell { color: var(--red); }
/* armed sell button (awaiting confirming second tap) */
#tpSell.confirm {
  background: var(--red); color: #fff; border-color: #ff8a7a;
  box-shadow: 0 0 12px #e05a4a77; font-weight: bold;
}

/* onboarding banner shown over the map before wave 1 */
#startPrompt {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 14; text-align: center; pointer-events: none; max-width: 92%;
  background: linear-gradient(#1c2414ee, #141a0eee);
  border: 1px solid var(--amber); border-radius: 12px;
  padding: 11px 22px; box-shadow: 0 6px 22px #0008;
  animation: spPulse 1.7s ease-in-out infinite;
}
#startPrompt.counting { border-color: var(--green); animation: none; }
#startPrompt .sp-main { color: var(--amber2); font-weight: bold; font-size: 17px; letter-spacing: 0.3px; }
#startPrompt.counting .sp-main { color: var(--green); }
#startPrompt .sp-sub { color: var(--dim); font-size: 12px; margin-top: 3px; }
@keyframes spPulse { 50% { box-shadow: 0 6px 26px #0008, 0 0 16px #e8b93a66; border-color: var(--amber2); } }
@media (prefers-reduced-motion: reduce){ #startPrompt { animation: none; } }
/* Keep the first-build instruction at the near edge of the painted scenes,
   leaving the scenery and tactical space visible on phones. */
#startPrompt:is(.sector7, .sanctuary) {
  top: auto; bottom: 10px; width: max-content; max-width: calc(100% - 24px);
  padding: 9px 20px; border-radius: 3px; border-color: #9b8757;
  background: linear-gradient(100deg, #111d1bea, #1c2822e8);
  box-shadow: 0 3px 16px #0008; animation: none;
}
#startPrompt:is(.sector7, .sanctuary) .sp-main { color: #e2d3a9; font-size: 13px; letter-spacing: 1px; }
#startPrompt:is(.sector7, .sanctuary) .sp-sub { color: #bec8bc; font-size: 11px; }
#startPrompt:is(.sector7, .sanctuary).counting .sp-main { color: #b9d5ae; }
@media (max-width: 600px) {
  #startPrompt:is(.sector7, .sanctuary) { bottom: 5px; padding: 6px 12px; }
  #startPrompt:is(.sector7, .sanctuary) .sp-main { font-size: 11px; }
  #startPrompt:is(.sector7, .sanctuary) .sp-sub { font-size: 9px; }
}
.hint { font-size: 10.5px; color: var(--dim); line-height: 1.5; }

/* ---------- menu ---------- */
/* =====================================================================
   HOME / MENU — layered bioluminescent-jungle brand experience
   ===================================================================== */
#menu {
  position: absolute; inset: 0; z-index: 10;
  background: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(18px, 4vh, 48px) 20px 28px; overflow-y: auto; overflow-x: hidden;
  --accent: var(--amber2); --accent-soft: #e8b93a;
}
#menu[data-scene="day"] { --accent: #ffd88a; --accent-soft: #f0b24a; }

/* ---- ambient background layers ---- */
#menuBg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.mb { position: absolute; inset: 0; }
/* canvas is a REPLACED element: inset alone doesn't stretch it (it renders at
   its intrinsic buffer size, anchored left, clipping the right side on wide
   screens) — force it to fill the background layer */
#menuDinos { width: 100%; height: 100%; }
.mb-sky {
  background:
    radial-gradient(120% 80% at 50% 118%, #14301f 0%, transparent 60%),
    radial-gradient(90% 60% at 50% -20%, #223a1e 0%, transparent 55%),
    linear-gradient(#0c140b 0%, #0a0f08 55%, #070b06 100%);
}
#menu[data-scene="day"] .mb-sky {
  background:
    radial-gradient(120% 80% at 50% 120%, #2c4a26 0%, transparent 60%),
    radial-gradient(100% 70% at 50% -25%, #6f8a3e 0%, transparent 55%),
    linear-gradient(#2a3d1c 0%, #1b2814 60%, #121a0e 100%);
}
/* slow rotating god-rays */
.mb-rays {
  top: -60%; left: -25%; width: 150%; height: 150%;
  background: conic-gradient(from 0deg at 50% 40%,
    transparent 0deg, #e8b93a14 12deg, transparent 30deg,
    #46e6c40f 60deg, transparent 84deg, #e8b93a12 120deg, transparent 150deg,
    transparent 210deg, #46e6c40d 250deg, transparent 285deg, #e8b93a10 320deg, transparent 350deg);
  opacity: 0.72;
}
/* floodlight bloom behind the crest */
.mb-glow {
  background: radial-gradient(46% 42% at 50% 26%, #e8b93a2e 0%, #46e6c412 34%, transparent 62%);
}
#menu[data-scene="day"] .mb-glow { background: radial-gradient(50% 46% at 50% 24%, #ffe6a840 0%, transparent 62%); }
/* drifting fog bands */
.mb-fog { background: radial-gradient(60% 100% at 50% 100%, #35543733 0%, transparent 70%); }
.mb-fog1 { transform: translateX(-4%); opacity: 0.55; }
.mb-fog2 { transform: translateX(4%); opacity: 0.35; }
/* parallax treeline */
.mb-trees { top: auto; bottom: 0; height: 42vh; width: 100%; min-height: 220px; }
.mb-trees .tree { transform-box: view-box; }
.tree-far  { fill: #16281a; opacity: 0.85; }
.tree-mid  { fill: #102015; }
.tree-near { fill: #0a1510; }
/* fireflies / spores (filled by JS) */
.mb-spores .spore {
  position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent-soft); box-shadow: 0 0 8px 1px currentColor; color: #e8b93a;
  opacity: 0; animation: floatup linear infinite;
}
.mb-spores .spore.teal { background: var(--bio); color: var(--bio); }
@keyframes floatup {
  0%   { transform: translateY(20px) scale(0.6); opacity: 0; }
  12%  { opacity: 0.9; }
  85%  { opacity: 0.7; }
  100% { transform: translateY(-64vh) translateX(var(--drift, 20px)) scale(1); opacity: 0; }
}
.mb-vignette { background: radial-gradient(130% 100% at 50% 42%, transparent 55%, #000 128%); }
.mb-scan { background: repeating-linear-gradient(to bottom, #ffffff09 0 1px, transparent 1px 3px); opacity: 0.5; }

/* iOS Add-to-Home-Screen steps */
.iosSteps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px; }
.iosSteps li {
  counter-increment: step; display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; background: #0e150c; border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
}
.iosSteps li::before {
  content: counter(step); flex: 0 0 auto; width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent-soft); color: #12180f; font-weight: bold; font-size: 13px;
}
.iosIco { display: inline-flex; align-items: center; vertical-align: middle; color: var(--accent); }
.iosNote { font-size: 12.5px; color: var(--dim); margin-top: 12px; text-align: center; }

.menuFoot { display: flex; flex-direction: column; align-items: center; margin-top: 22px; }

@media (prefers-reduced-motion: reduce) {
  .mb-rays, .mb-glow, .mb-fog, .tree, .crest, .wordmark::after, .mb-spores .spore { animation: none !important; }
}

/* ---------- achievements (own modal page) ---------- */
#achProg { color: var(--amber2); }
#achList { display: flex; flex-direction: column; gap: 8px; }
.achRow {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  background: #171c12; border: 1px solid #2a3122; opacity: 0.72;
}
.achRow.got {
  opacity: 1; border-color: var(--amber);
  background: linear-gradient(#2c2814, #201b0e);
  box-shadow: 0 0 12px #e8b93a24, inset 0 0 8px #e8b93a14;
}
.achIco {
  font-size: 30px; line-height: 1; width: 40px; text-align: center; flex: none;
  filter: grayscale(1) brightness(0.65);
}
.achRow.got .achIco { filter: none; }
.achInfo { flex: 1; font-size: 14px; }
.achInfo b { color: var(--dim); }
.achRow.got .achInfo b { color: var(--amber2); }
.achInfo small { color: var(--dim); font-size: 11.5px; line-height: 1.4; }
.achDna { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: bold; color: var(--dna); }
.achStat {
  flex: none; font-size: 11px; font-weight: bold; letter-spacing: 0.5px;
  padding: 4px 9px; border-radius: 12px; white-space: nowrap;
  background: #00000033; border: 1px solid var(--line); color: var(--dim);
}
.achRow.got .achStat { color: #1a1a0a; background: var(--amber); border-color: var(--amber2); }

/* ---------- achievement toast ---------- */
#achToast {
  position: fixed; top: 60px; left: 50%; z-index: 60;
  transform: translate(-50%, -180%);
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(#2c2814, #1c1810);
  border: 1px solid var(--amber); border-radius: 12px;
  box-shadow: 0 8px 30px #000a, 0 0 20px #e8b93a3a;
  padding: 12px 20px 12px 14px; max-width: 92vw;
  transition: transform 0.42s cubic-bezier(0.2, 1.3, 0.5, 1), opacity 0.42s;
  opacity: 0; pointer-events: none;
}
#achToast.show { transform: translate(-50%, 0); opacity: 1; }
#achToast .atIco { font-size: 34px; line-height: 1; }
#achToast .atH { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--amber); }
#achToast .atN { font-size: 16px; font-weight: bold; color: var(--amber2); margin-top: 2px; }
#achToast .atR {
  margin-left: 6px; padding: 6px 12px; border-radius: 10px; text-align: center;
  background: #12233a; border: 1px solid var(--dna); color: var(--dna);
  font-size: 16px; font-weight: bold; line-height: 1.05;
}
#achToast .atR span { display: block; font-size: 9px; letter-spacing: 1px; opacity: 0.8; }
#achToast .atD { font-size: 11px; color: var(--dim); margin-top: 2px; max-width: 340px; }
#verChip {
  font-size: 11.5px; color: #aab494;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 15px;
  background: #0f160caa; cursor: pointer; transition: color 0.1s, border-color 0.1s, transform 0.1s;
}
#verChip:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

/* tips + changelog */
.tipsH {
  color: var(--dim); font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; margin: 14px 0 4px;
}
.tipRow { font-size: 13px; line-height: 1.6; padding: 5px 2px; border-bottom: 1px solid #2a3122; }
.tipRow:last-child { border-bottom: none; }
.clogVer { color: var(--amber2); margin-top: 12px; font-size: 14px; }
.clogVer small { color: var(--dim); font-weight: normal; }
.clogItems { margin: 6px 0 0 22px; font-size: 12.5px; line-height: 1.65; color: var(--text); }
#menu .foot { padding-top: 16px; color: #a6b096; font-size: 11.5px; text-align: center; line-height: 1.7; max-width: 640px; text-shadow: 0 1px 3px #000c; }

/* ---------- modals ---------- */
.modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(5, 8, 4, 0.75);
  display: flex; align-items: center; justify-content: center;
}
.modalBox {
  position: relative;
  background: var(--panel); border: 2px solid var(--amber); border-radius: 12px;
  padding: 22px 26px; width: min(560px, 92vw); max-height: 86vh;
  overflow-y: auto; box-shadow: 0 20px 60px #000;
}
.modalX {
  position: sticky; top: 0; float: right; margin: -6px -10px 0 10px;
  width: 34px; height: 34px; line-height: 1;
  background: var(--panel2); color: var(--dim);
  border: 1px solid var(--line); border-radius: 50%;
  font-size: 15px; cursor: pointer; z-index: 2;
}
.modalX:hover { color: #fff; border-color: var(--amber); }
.modalBox h2 { color: var(--amber2); margin-bottom: 6px; letter-spacing: 1px; }
.modalBox .sub { color: var(--dim); font-size: 12.5px; margin-bottom: 16px; }
.modalBox p { line-height: 1.65; font-size: 14px; }
.modalBtns { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modalBtns button { padding: 9px 18px; font-size: 14px; }
.primary { background: #3d5226 !important; font-weight: bold; }
.dna { color: var(--dna); }
.dim { color: var(--dim); }

/* A full-screen reward, independent of the small portrait battlefield. */
#victoryShow { padding: 0; overflow: auto; background: #07141b; isolation: isolate; }
#victorySky { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1; }
.victory-ceremony { width: min(900px,100%); min-height: 100%; margin: auto; padding: max(28px,env(safe-area-inset-top)) 24px max(20px,env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #f5efde; box-sizing: border-box; text-shadow: 0 2px 20px #000; }
.victory-kicker { color: #e8c882; letter-spacing: .32em; font-size: 11px; font-weight: 800; margin: 0 0 12px; }
.victory-medal { width: clamp(130px,23vh,210px); flex: 0 0 auto; filter: drop-shadow(0 0 35px #e2b55b35); opacity: var(--medal,0); transform: scale(var(--medal-scale,.8)); }
.victory-medal svg { display: block; width: 100%; }
.medal-laurel { fill: none; stroke: #c79e56; stroke-width: 2; }
#victoryShow h2 { color: #f5edda; font: 900 clamp(46px,8vw,92px)/.91 Arial,sans-serif; letter-spacing: -.06em; margin: 14px 0 18px; opacity: var(--reveal,0); transform: translateY(var(--title-y,20px)); }
#victoryShow h2 span { background: linear-gradient(#fff0b8,#e8ba65 65%,#b27835); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none; }
body:has(#victoryShow:not(.hidden)) #achToast { visibility: hidden; }
.victory-dedication { margin: 0; font-size: clamp(12px,1.7vw,17px); letter-spacing: .025em; opacity: var(--reveal,0); }
.victory-operation { margin: 16px 0 20px; color: #a9ccc4; font-size: 12px; letter-spacing: .08em; opacity: var(--details,0); }
.victory-highlights { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); width: min(570px,100%); padding: 16px 0; border-block: 1px solid #d6bf7440; background: linear-gradient(90deg,transparent,#091718a8,transparent); opacity: var(--details,0); }
.victory-highlights div+div { border-left: 1px solid #d6bf7428; }
.victory-highlights strong { display: block; color: #ffe1a2; font: 700 clamp(23px,3.6vw,36px)/1.2 Arial,sans-serif; }
.victory-highlights span { display: block; margin-top: 7px; font-size: 10px; letter-spacing: .04em; color: #bdcec7; }
#victoryShow #victorySkip { position: static; float: none; margin: 24px 0 0; width: auto; height: auto; min-height: 46px; padding: 12px 25px; border: 1px solid #e2bd75; border-radius: 4px; background: #17292de8; color: #f4dcaa; font: 700 13px system-ui,sans-serif; cursor: pointer; }
#victoryShow #victorySkip:hover { background: #29413e; border-color: #ffe3a4; }
.victory-results span { margin-left: 20px; }
.victory-signoff { color: #8aa79c; font-size: 8px; letter-spacing: .22em; margin: 22px 0 0; }
@media(max-width:500px) {
  .victory-ceremony { padding-inline: 18px; }
  .victory-kicker { font-size: 9px; }
  .victory-medal { width: clamp(120px,21vh,180px); }
  .victory-highlights span { font-size: 8px; }
}
@media(max-height:600px) {
  .victory-ceremony { padding-block: 14px; }
  .victory-medal { width: 96px; }
  #victoryShow h2 { font-size: 42px; margin-block: 8px 10px; }
  .victory-kicker { margin-bottom: 3px; }
  .victory-operation { margin: 10px 0; }
  .victory-highlights { padding-block: 10px; }
  #victoryShow #victorySkip { margin-top: 14px; }
  .victory-signoff { margin-top: 12px; }
}
@media(max-height:450px) and (min-width:600px) {
  .victory-ceremony { display: grid; grid-template-columns: 145px minmax(0,500px); column-gap: 24px; justify-content: center; align-content: center; min-height: 100%; padding: 18px 30px; }
  .victory-medal { grid-column: 1; grid-row: 1 / 8; width: 145px; }
  .victory-ceremony > :not(.victory-medal) { grid-column: 2; }
  .victory-kicker { margin-bottom: 6px; }
  #victoryShow h2 { font-size: 44px; }
  .victory-dedication { font-size: 12px; }
  .victory-highlights strong { font-size: 24px; }
  #victoryShow #victorySkip { justify-self: center; }
}

/* victory recap breakdown */
.recapSub { color: var(--text); font-size: 13.5px; line-height: 1.5; margin-bottom: 14px; }
.recapGrid {
  display: grid; grid-template-columns: 1fr auto; gap: 7px 16px; align-items: baseline;
  background: #00000033; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  max-width: 420px; margin: 0 auto;
}
.recapGrid .rl { text-align: left; font-size: 13px; color: var(--text); }
.recapGrid .rv { text-align: right; font-weight: bold; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.recapGrid .rv.dna { color: var(--dna); }
.recapGrid .rv.cash { color: var(--amber2); }
.recapGrid .rv.streak { color: #ffb84a; }
.recapGrid .rl.total, .recapGrid .rv.total { font-size: 15px; color: var(--amber2); padding-top: 3px; }
.recapGrid .rv.total { color: var(--dna); }
.recapGrid .rsep { grid-column: 1 / -1; height: 1px; background: var(--line); margin: 3px 0; }
.recapUnlock { margin-top: 14px; color: var(--green); font-size: 13.5px; }

/* lab */
#labDna { color: var(--dna); font-weight: bold; }
.labRow {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; margin-top: 8px;
}
.labIco { font-size: 22px; }
.labInfo { flex: 1; font-size: 12.5px; line-height: 1.45; }
.labInfo small { color: var(--dim); }
.labInfo .tier { color: var(--amber2); font-size: 10px; letter-spacing: 1px; }
.labBuy { min-width: 86px; }
/* a one-time unlock that's already been purchased */
.labRow.owned { border-color: #3f6b34; background: #1c2717; }
.labBuy.owned { color: var(--green) !important; border-color: #3f6b34 !important; opacity: 1; }

/* settings rows */
.optRow { display: flex; align-items: center; gap: 10px; padding: 9px 2px; font-size: 14px; }
.optRow input { width: 17px; height: 17px; accent-color: var(--amber); cursor: pointer; }
.optRow small { color: var(--dim); display: block; font-size: 11px; }
.optHead {
  margin: 16px 0 2px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--red);
}
.optHead small { display: block; margin-top: 4px; color: var(--dim); font-size: 11px; letter-spacing: 0; text-transform: none; line-height: 1.5; }
/* revealed dev cheats, grouped/indented under the password-gated toggle */
#devOptions { margin: 2px 0 2px 8px; padding-left: 12px; border-left: 2px solid var(--line); }
#btnSkip { background: #3a2a4a; border-color: #6b4f8a; }

/* lab & achievements open above end-of-run modals */
#lab, #achievements { z-index: 30; }

/* ---------- mobile / narrow screens ---------- */
* { -webkit-tap-highlight-color: transparent; }
#hud button, .modal button { touch-action: manipulation; }
canvas#game { touch-action: none; }   /* we handle pan/pinch/tap ourselves */

/* mobile map-zoom pill (top-centre of the stage) */
#zoomBar {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 12; display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 8px; border-radius: 20px;
  background: rgba(12,16,10,0.74); border: 1px solid var(--line); box-shadow: 0 2px 8px #0007;
}
#zoomBar .zIcon { font-size: 12px; opacity: 0.8; }
#stage[data-map-art] #zoomBar { left: auto; right: 8px; transform: none; gap: 6px; padding: 4px 6px; }
#stage[data-map-art] #zoomSlider { width: 72px; }
#zoomBar .zBtn {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: #1a2113; color: var(--text);
  font-size: 17px; line-height: 1; display: grid; place-items: center; cursor: pointer;
  touch-action: manipulation;
}
#zoomBar .zBtn:active { background: #2a3520; border-color: var(--accent-soft); }
#zoomSlider {
  -webkit-appearance: none; appearance: none; width: 120px; height: 5px; margin: 0;
  border-radius: 3px; background: #3a4630; outline: none;
}
#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent-soft); border: 2px solid #12180f; cursor: pointer;
}
#zoomSlider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-soft); border: 2px solid #12180f; cursor: pointer;
}
#zoomSlider::-moz-range-track { height: 5px; border-radius: 3px; background: #3a4630; }
/* a vertical drag on a card scrolls the shop; a sideways drag places the weapon */
.shopCard { touch-action: pan-y; }
/* shared small-screen tweaks (both orientations) */
@media (max-width: 920px) {
  #app { height: 100dvh; }
  .shopCard { padding: 6px 3px; min-width: 0; }
  .shopCard .ico { font-size: 18px; }
  .shopCard .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 9.5px; }
  #hud { font-size: 11px; gap: 5px; padding: 5px 6px; }
  #levelTitle { font-size: 12px; min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #hud button { padding: 6px 8px; font-size: 12px; }
  #hud .stat { padding: 5px 7px; }
  #speedBtns { display: none; }         /* four speed buttons → one cycle button on mobile */
  #speedCycle { display: inline-block; }
  #towerPop { width: 190px; }
  #towerPop button { padding: 9px 10px; }
  .statBar { gap: 8px; }
  .stat { padding: 7px 12px; font-size: 12px; }
  .hint { display: none; }
}

/* PORTRAIT phones: keep the HUD to a STABLE two rows (stats up top, controls
   below) so it never bounces between one and two lines as numbers change */
@media (max-width: 920px) and (orientation: portrait) {
  #hud { flex-wrap: wrap; }
  #hud .spacer { flex-basis: 100%; height: 0; margin: 0; }
}
/* very narrow: the map name would crowd the stats — drop it */
@media (max-width: 470px) { #levelTitle { display: none; } }

/* PORTRAIT phones/tablets: stack the shop UNDER the map */
@media (max-width: 920px) and (orientation: portrait) {
  #main { flex-direction: column; overflow: hidden; }
  #stage { flex: none; }
  canvas#game { width: 100%; max-height: 52vh; }
  #shop {
    width: 100%; flex: 1; min-height: 0;
    border-left: none; border-top: 2px solid var(--line); padding: 8px;
  }
  #shopCards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
}

/* LANDSCAPE phones (short screens): keep map + shop SIDE BY SIDE so the
   weapons are always visible without scrolling the page */
@media (orientation: landscape) and (max-height: 560px) {
  #main { flex-direction: row; overflow: hidden; }
  #stage { flex: 1; min-width: 0; }
  canvas#game { max-width: 100%; max-height: 100%; width: auto; }
  #shop {
    width: 150px; flex: none; height: 100%;
    border-left: 2px solid var(--line); border-top: none;
    padding: 6px; gap: 6px;
  }
  #shop h3 { font-size: 10px; margin: 0; }
  #shopCards { grid-template-columns: 1fr 1fr; gap: 5px; }
  .shopCard { padding: 5px 2px; }
  .shopCard .ico { font-size: 15px; }
  .shopCard .nm { font-size: 8.5px; }
  .shopCard .cost { font-size: 9.5px; }
  #airCard { padding: 6px 8px; }
  #hud { font-size: 10px; gap: 4px; padding: 3px 6px; flex-wrap: nowrap; }
  #hud button { padding: 5px 7px; font-size: 10.5px; }
  #hud .stat { padding: 3px 6px; white-space: nowrap; }
  #levelTitle { font-size: 11px; }
  /* compact weapon-upgrade popup so it fits on short screens without clipping */
  #towerPop { width: 178px; padding: 7px 8px; gap: 5px; }
  #towerPop #tpName { font-size: 12px; padding-right: 44px; }
  #towerPop #tpStats { font-size: 10px; line-height: 1.35; }
  #towerPop button { padding: 6px 8px !important; font-size: 11px; }
  #tpClose, #tpMute { width: 20px; height: 20px; font-size: 12px; top: 4px; }
  #tpClose { right: 4px; }
  #tpMute { right: 28px; }
}

/* error overlay */
#errbox {
  position: absolute; left: 10px; bottom: 10px; z-index: 99;
  background: #4a1010; color: #ffb0a0; border: 1px solid #a04030;
  padding: 8px 12px; border-radius: 8px; font-size: 12px; max-width: 70vw;
}

/* ---- incoming-wave ticker (HUD) ---- */
#waveTicker {
  color: var(--dim); font-size: 12px;
  min-width: 0; flex: 0 2 auto; overflow: hidden; text-overflow: ellipsis;
}
#waveTicker.alert { border-color: var(--amber); color: var(--text); }
#waveTicker .tickWarn { color: var(--red); animation: blink 0.9s infinite; }
@media (max-width: 700px) { #waveTicker { display: none; } } /* too tight on phones */

/* ---- weapon mastery (popup) ---- */
#tpStats .mast { color: var(--amber2); white-space: nowrap; }

/* ---- sticker book ---- */
/* one clean internal scroll region: the modal itself never scrolls, the grid
   pans invisibly (no scrollbars), and a bottom fade hints at more rows */
#stickers .modalBox {
  width: min(780px, 94vw); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
#stickers h2, #stickers .sub, #stickers .modalBtns { flex: none; }
#stickWrap {
  flex: 1; min-height: 0; overflow: auto;
  border: 1px solid var(--line); border-radius: 10px;
  scrollbar-width: none;                       /* Firefox */
  -webkit-mask-image: linear-gradient(#000 calc(100% - 26px), transparent);
          mask-image: linear-gradient(#000 calc(100% - 26px), transparent);
}
#stickWrap::-webkit-scrollbar { display: none; }  /* Chromium/Safari */
#stickTable { border-collapse: collapse; width: 100%; font-size: 13px; }
#stickTable th { position: sticky; top: 0; background: var(--panel2); padding: 6px 4px; font-size: 15px; z-index: 1; }
#stickTable td { border-top: 1px solid #262e1e; text-align: center; padding: 3px 4px; }
#stickTable .spName { text-align: left; white-space: nowrap; padding-left: 8px; color: var(--text); }
#stickTable .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; border: 1px solid #0008; vertical-align: -1px; }
#stickTable .cell { min-width: 26px; opacity: 0.25; }
#stickTable .cell.got { opacity: 1; background: #2a331d; box-shadow: inset 0 0 0 1px var(--amber); border-radius: 4px; }
#stickTable .cell.na { color: #3a4530; opacity: 0.5; }

/* ---- dino studio ---- */
.studioRow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px; margin-bottom: 8px; border-radius: 10px;
  background: #171c12; border: 1px solid #2a3122;
}
.studioRow .stName {
  flex: 1 1 130px; min-width: 110px; padding: 8px 10px; font-family: inherit; font-size: 14px;
  background: #0f140b; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
}
.studioRow .stName:focus { outline: none; border-color: var(--amber); }
.studioRow .stSp {
  flex: 0 1 170px; padding: 8px 6px; font-family: inherit; font-size: 13px;
  background: #0f140b; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
}
.studioRow .stCol { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--dim); }
.studioRow .stCol input { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.studioRow .stDel { padding: 7px 10px; }

/* ---- sticker trading card ---- */
#stickCard { z-index: 60; }
#stickTable .cell.got { cursor: pointer; }
#stickTable .cell.got:hover { box-shadow: inset 0 0 0 1px var(--amber2), 0 0 10px #ffd24a66; }
#cardBox {
  position: relative; width: min(380px, 92vw);
  border-radius: 18px; padding: 10px 10px 12px;
  background: linear-gradient(160deg, #232c1a, #10140d 60%);
  animation: cardGlow 2.6s ease-in-out infinite;
}
@keyframes cardGlow {
  0%, 100% { box-shadow: 0 0 0 2px var(--amber), 0 0 26px #e8b93a44, 0 18px 60px #000c; }
  50%      { box-shadow: 0 0 0 2px var(--amber2), 0 0 46px #ffd24a77, 0 18px 60px #000c; }
}
#cardBox .modalX { position: absolute; top: 8px; right: 8px; float: none; margin: 0; z-index: 2; }
#cardCv { display: block; width: 100%; height: auto; border-radius: 12px; }
#cardInfo { padding: 10px 6px 2px; text-align: center; }
#cardInfo h3 { margin: 2px 0; font-size: 21px; color: var(--amber2); letter-spacing: 0.5px; }
#cardInfo .cEpithet { color: var(--dim); font-style: italic; font-size: 12px; }
#cardInfo .cLine { margin-top: 7px; font-size: 13.5px; color: var(--text); }
#cardInfo .cDate { margin-top: 5px; font-size: 12px; color: var(--dna); }
#stickTable .cell.dev { box-shadow: inset 0 0 0 1px var(--dim); background: #1d2417; opacity: 0.8; }

/* ---- sticker chips: earned stickers read as tappable, like real stickers ---- */
#stickTable .cell.got .stk {
  display: inline-block; padding: 2px 5px; border-radius: 7px;
  background: linear-gradient(160deg, #37451f, #1e2812);
  box-shadow: 0 2px 5px #000b, inset 0 0 0 1px #e8b93a66, inset 0 1px 0 #ffffff22;
  transform: rotate(-3deg);
  transition: transform 0.13s, box-shadow 0.13s;
  cursor: pointer;
}
#stickTable tr:nth-child(even) .cell.got .stk { transform: rotate(2.5deg); } /* scrapbook scatter */
#stickTable .cell.got:hover .stk {
  transform: scale(1.28) rotate(0deg);
  box-shadow: 0 4px 12px #000c, inset 0 0 0 1px var(--amber2), 0 0 14px #ffd24a88;
}
#stickTable .cell.got:active .stk { transform: scale(0.88) rotate(0deg); }
#stickTable .cell.dev .stk { opacity: 0.75; box-shadow: 0 1px 3px #0009, inset 0 0 0 1px #8b937c66; }
/* first-time coach: earned stickers bounce for attention until a card is opened */
#stickTable.hintPulse .cell.got .stk { animation: stkBounce 1.7s ease-in-out infinite; }
#stickTable.hintPulse tr:nth-child(even) .cell.got .stk { animation-delay: 0.85s; }
@keyframes stkBounce {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50%      { transform: rotate(3deg) scale(1.22); }
}
@media (prefers-reduced-motion: reduce) { #stickTable.hintPulse .cell.got .stk { animation: none; } }
