/* OWNER: UI-Dev. Pixel-perfect UI theme for RAUL JOURNEY.
   Fonts: 'Pixelify Sans' display / 'VT323' body.
   Palette mirror (palette.js): uiBg #20223a · cream #f2ead8 · gold #f0c040 ·
   goldDark #c08a20 · ink #1a1c2c · navy #26406e · tramGreen #1d9d49 ·
   waterDeep #2e7c99 · water #3f9bb8 · waterLight #62b8cf · foam #cdeef5 ·
   grass1 #6cb84e · grass3 #74c055 · grassDark #4e9138 · leafDark #357a2a ·
   roofRed #c0503c · redCross #d63a30. Hard shadows, no blur, radius ≤ 4px. */

:root {
  --ink: #1a1c2c;
  --bg: #20223a;
  --cream: #f2ead8;
  --gold: #f0c040;
  --gold-d: #c08a20;
  --navy: #26406e;
  --green: #1d9d49;
  --red: #d63a30;
  --cream-75: rgba(242, 234, 216, .75);
  --cream-55: rgba(242, 234, 216, .55);
  --cream-30: rgba(242, 234, 216, .3);
  --cream-15: rgba(242, 234, 216, .15);
  --ink-85: rgba(26, 28, 44, .85);
  --ink-55: rgba(26, 28, 44, .55);
  --frame: 0 0 0 3px var(--ink), 6px 6px 0 rgba(26, 28, 44, .55);
  --fontD: 'Pixelify Sans', 'VT323', monospace;
  --fontB: 'VT323', 'Pixelify Sans', monospace;
}

/* ================================================================ base button */
.pix {
  font-family: var(--fontB);
  font-size: 20px;
  line-height: 1;
  color: var(--cream);
  background: var(--bg);
  border: 2px solid var(--cream);
  border-radius: 0;
  box-shadow: 2px 2px 0 var(--ink);
  padding: 7px 12px;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-user-select: none;
  user-select: none;
}
.pix:hover { background: var(--navy); }
.pix:active { transform: translate(2px, 2px); box-shadow: none; }
.pix:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.pix.gold { background: var(--gold); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink-55), 0 0 0 2px var(--gold-d) inset; }
.pix.gold:hover { background: var(--cream); }

/* ================================================================ HUD */
#hud {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  right: calc(8px + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 30;
}
#hud button, #hud #badgeBar { pointer-events: auto; }

#hudLeft {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
}

#badgeBar {
  display: flex;
  align-items: center;
  gap: 4px;
  /* may shrink + clip on tiny viewports — never push #hudBtns off-screen */
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  background: var(--ink-85);
  border: 2px solid var(--cream);
  box-shadow: 3px 3px 0 var(--ink-55);
  padding: 5px 7px;
}
#badgeBar .badge {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-family: var(--fontB);
  font-size: 15px;
  line-height: 1;
  color: var(--cream-30);
  background: var(--bg);
  border: 2px solid var(--cream-15);
  box-shadow: inset 1px 1px 0 var(--ink);
}
#badgeBar .badge.on {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--cream);
  box-shadow: inset -2px -2px 0 var(--gold-d);
}
#badgeBar .badge.pop { animation: badgePop .6s steps(12) both; }
@keyframes badgePop {
  0% { transform: scale(.4); background: var(--cream); }
  35% { transform: scale(1.75); background: var(--cream); }
  60% { transform: scale(.85); }
  80% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
#badgeBar .eggChip {
  margin-left: 4px;
  padding: 2px 6px 2px 5px;
  font-family: var(--fontB);
  font-size: 17px;
  line-height: 1;
  color: var(--gold);
  border-left: 2px solid var(--cream-30);
  white-space: nowrap;
}

/* objective chip — the "roter Faden": names where the gold arrow points */
#objChip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  font-family: var(--fontB);
  font-size: 17px;
  line-height: 1.1;
  color: var(--cream);
  background: var(--ink-85);
  border: 2px solid var(--cream-30);
  border-left: 4px solid var(--gold);
  box-shadow: 2px 2px 0 var(--ink-55);
  padding: 4px 9px 4px 6px;
  pointer-events: none;
}
#objChip .objIco { font-size: 13px; line-height: 1; flex: 0 0 auto; }
#objChip .objTxt {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#objChip .objTxt b { color: var(--gold); font-weight: 400; }
#objChip.chest { border-color: var(--gold); }
#objChip.chest .objTxt { color: var(--gold); }
#objChip.bump { animation: objBump .35s steps(5) both; }
@keyframes objBump {
  0% { transform: translateY(-6px); }
  60% { transform: translateY(2px); }
  100% { transform: translateY(0); }
}

#hudBtns {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  flex-wrap: wrap;          /* 7–8 buttons: allow a second row before overflow */
  justify-content: flex-end;
  max-width: 50vw;
}
#btnBike.on {
  background: var(--gold);
  border-color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink-55), 0 0 0 2px var(--gold-d) inset;
}
#btnBike.on:hover { background: var(--cream); }
.hudBtn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 20px;
  background: var(--ink-85);
  position: relative;
}
.zoomBtn { font-family: var(--fontD); font-weight: 700; font-size: 24px; line-height: 1; }
.hudBtn:disabled { opacity: .35; cursor: default; }
.hudBtn:disabled:hover { background: var(--ink-85); }
.hudBtn:disabled:active { transform: none; box-shadow: 2px 2px 0 var(--ink); }
/* backpack "new skill cards" bubble */
#packNew {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  font-family: var(--fontB);
  font-size: 13px;
  line-height: 1;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  animation: packPulse 1s steps(4) infinite;
}
@keyframes packPulse { 50% { transform: scale(1.2); background: var(--cream); } }
#btnLang { width: auto; min-width: 42px; padding: 0 8px; font-size: 16px; letter-spacing: 1px; }
#btnLang span { color: var(--cream-55); }
#btnLang span.on { color: var(--gold); }
#btnLang i { font-style: normal; color: var(--cream-30); margin: 0 3px; }

/* ================================================================ toasts */
#toasts {
  position: fixed;
  top: calc(62px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  font-family: var(--fontB);
  font-size: 20px;
  line-height: 1.2;
  color: var(--gold);
  background: var(--bg);
  border: 2px solid var(--cream);
  border-left: 6px solid var(--gold);
  box-shadow: 3px 3px 0 var(--ink-55);
  padding: 8px 16px;
  max-width: 92vw;
  text-align: center;
  opacity: 0;
  transform: translateY(-14px);
  transition: transform .22s cubic-bezier(.2, .9, .3, 1.3), opacity .22s steps(4);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.out { opacity: 0; transform: translateY(-10px); }

/* ================================================================ dialog */
#dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 12px 12px calc(14px + env(safe-area-inset-bottom));
  z-index: 50;
}
.panel.dlg {
  position: relative;
  width: min(640px, 96vw);
  color: var(--cream);
  background: var(--bg);
  border: 3px solid var(--cream);
  box-shadow: var(--frame), inset 0 3px 0 var(--cream-15);
  padding: 14px 18px 12px;
  cursor: pointer;
  animation: dlgIn .28s cubic-bezier(.2, .9, .3, 1.25) both;
}
@keyframes dlgIn {
  from { transform: translateY(36px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.dBadge {
  position: absolute;
  top: -22px;
  left: 14px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  background: var(--gold);
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 2px var(--cream), 3px 3px 0 var(--ink-55);
  animation: dlgIn .34s cubic-bezier(.2, .9, .3, 1.4) both;
}
.dBadge + .dTitle { padding-left: 56px; min-height: 26px; }
.dTitle {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 25px;
  line-height: 1.05;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
  letter-spacing: .5px;
}
.dSub { font-family: var(--fontB); font-size: 18px; color: #b3dcea; margin: 3px 0 0; }
.dBody {
  font-family: var(--fontB);
  font-size: 21px;
  line-height: 1.3;
  margin-top: 8px;
  min-height: calc(3 * 1.3em);
}
.dBody .line { min-height: 1.3em; }
#dialog.typing .dBody .line.vis:not(:has(~ .line.vis))::after {
  content: '▮';
  color: var(--gold);
  animation: caretBlink .5s steps(2, jump-none) infinite;
}
@keyframes caretBlink { from { opacity: 1; } to { opacity: 0; } }

.dLinks { display: none; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.dLinks.show { display: flex; animation: linksIn .25s cubic-bezier(.2, .9, .3, 1.3) both; }
@keyframes linksIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* gained skill chips (badge dialogs) */
.dSkills { display: none; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.dSkills.show { display: flex; animation: linksIn .3s cubic-bezier(.2, .9, .3, 1.3) both; }
.dSkillLbl { font-family: var(--fontB); font-size: 17px; color: var(--cream-75); margin-right: 2px; }
.dSkill {
  font-family: var(--fontB);
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink-55), 0 0 0 1px var(--gold-d) inset;
  padding: 4px 8px;
  white-space: nowrap;
}
.dLink { font-size: 18px; min-height: 40px; padding: 5px 10px; }
.dLink:hover { background: var(--gold); color: var(--ink); border-color: var(--ink); }

.dRow { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.dPage { font-family: var(--fontB); font-size: 18px; color: var(--cream-55); letter-spacing: 2px; }
.dNext { margin-left: auto; font-size: 20px; padding: 7px 16px; opacity: .45; transition: opacity .15s steps(3); }
.dNext.ready { opacity: 1; animation: nextPulse .75s steps(6) infinite; }
@keyframes nextPulse {
  0%, 100% { transform: translateY(0); box-shadow: 2px 2px 0 var(--ink-55), 0 0 0 2px var(--gold-d) inset; }
  50% { transform: translateY(-3px); box-shadow: 2px 5px 0 var(--ink-55), 0 0 0 2px var(--gold-d) inset; }
}

/* ================================================================ overlays (map + cv + backpack) */
#mapOverlay, #cvOverlay, #packOverlay {
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(26, 28, 44, .35) 0 2px, transparent 2px 4px),
    var(--ink-85);
  display: grid;
  place-items: center;
  padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  z-index: 60;
}

/* -------- map: the showpiece -------- */
.mapWrap {
  position: relative;
  display: flex;
  flex-direction: column;
  width: fit-content;
  max-width: min(1100px, 96vw);
  max-height: 96dvh;
  min-height: 0;
  background: var(--bg);
  border: 3px solid var(--cream);
  box-shadow: var(--frame);
  padding: 12px 16px 12px;
  animation: overlayIn .25s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes overlayIn { from { transform: scale(.94) translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
/* gold pixel corner brackets */
.mapWrap::before, .mapWrap::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.mapWrap::before { top: -8px; left: -8px; border-top: 4px solid var(--gold); border-left: 4px solid var(--gold); }
.mapWrap::after { bottom: -8px; right: -8px; border-bottom: 4px solid var(--gold); border-right: 4px solid var(--gold); }

.mapHead { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 2px; }
.mTitle {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 25px;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
  letter-spacing: 1px;
}
.mClose, .cClose { width: 42px; height: 42px; min-width: 42px; padding: 0; font-size: 20px; flex: 0 0 auto; }
.mClose:hover, .cClose:hover { background: var(--red); border-color: var(--cream); color: var(--cream); }
.mapHint {
  font-family: var(--fontB);
  font-size: 18px;
  line-height: 1.25;
  color: var(--cream-75);
  margin-bottom: 8px;
  white-space: pre-line; /* hint may carry a 2nd line (tram stops open this map too) */
}
.mapHint::before { content: '▸ '; color: var(--gold); }

.mapScrollBox {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 0 1 auto;
}
.mapScroll {
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  border: 3px solid var(--ink);
  background: var(--ink);
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
  cursor: grab;
}
.mapScroll:active { cursor: grabbing; }
.mZoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-family: var(--fontB);
  font-size: 16px;
  line-height: 1;
  color: var(--gold);
  background: var(--ink-85);
  border: 2px solid var(--cream-30);
  padding: 4px 7px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s steps(3);
}
.mZoom.on { opacity: 1; }
.mapCanvasWrap { position: relative; width: fit-content; }
#mapCanvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#mapPins { position: absolute; inset: 0; pointer-events: none; }

.poiPin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  background: var(--ink-85);
  border: 2px solid var(--cream-55);
  pointer-events: auto;
  cursor: help;
  z-index: 2;
}
.poiPin:hover { border-color: var(--gold); background: var(--ink); z-index: 6; }
.poiPin.done { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-d) inset; }
.poiPin.done::before {
  content: '✓';
  position: absolute;
  top: -8px;
  right: -8px;
  width: 13px;
  height: 13px;
  display: grid;
  place-items: center;
  font-family: var(--fontB);
  font-size: 11px;
  color: var(--ink);
  background: var(--gold);
  border: 1px solid var(--ink);
}
.poiPin:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--fontB);
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  color: var(--cream);
  background: var(--ink);
  border: 2px solid var(--gold);
  box-shadow: 2px 2px 0 var(--ink-55);
  padding: 4px 7px;
}

.stop {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  background: var(--green);
  border: 2px solid var(--cream);
  box-shadow: 2px 2px 0 var(--ink-55);
  border-radius: 0;
  cursor: pointer;
  pointer-events: auto;
  z-index: 4;
  font-family: var(--fontB);
}
.stop:hover, .stop:focus-visible { border-color: var(--gold); outline: none; z-index: 7; transform: translate(-50%, -50%) scale(1.18); }
/* invisible hit-area extension: 26px visual stays, tap target becomes 42px */
.stop::after { content: ''; position: absolute; inset: -8px; }
.stopLbl {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  color: var(--cream);
  background: var(--ink-85);
  border: 1px solid var(--cream-30);
  padding: 2px 5px;
  pointer-events: none;
}
.stop:hover .stopLbl, .stop:focus-visible .stopLbl { color: var(--ink); background: var(--gold); border-color: var(--ink); font-size: 15px; }

.you {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--gold);
  border: 2px solid var(--ink);
  z-index: 5;
  pointer-events: none;
  animation: youBlink .8s steps(2, jump-none) infinite;
}
.you::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--gold);
  animation: youPing 1.4s steps(7) infinite;
}
@keyframes youBlink { from { background: var(--gold); } to { background: var(--cream); } }
@keyframes youPing {
  0% { inset: -3px; opacity: 1; }
  100% { inset: -15px; opacity: 0; }
}

.mapLegend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 2px solid var(--cream-15);
  font-family: var(--fontB);
  font-size: 18px;
  color: var(--cream-75);
}
.mapLegend .leg { display: inline-flex; align-items: center; gap: 6px; }
.mapLegend b { color: var(--gold); font-weight: 400; }
.legYou { margin-left: auto; color: var(--cream-55); }
.youKey {
  width: 10px;
  height: 10px;
  background: var(--gold);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--gold);
  display: inline-block;
}

/* ================================================================ backpack 🎒 skill cards */
.packWrap {
  display: flex;
  flex-direction: column;
  width: min(820px, 96vw);
  max-height: 96dvh;
  min-height: 0;
  background: var(--bg);
  border: 3px solid var(--cream);
  box-shadow: var(--frame);
  padding: 12px 16px;
  animation: overlayIn .25s cubic-bezier(.2, .9, .3, 1.2) both;
}
.packCount {
  margin-left: auto;
  font-family: var(--fontB);
  font-size: 20px;
  color: var(--cream-75);
  white-space: nowrap;
}
.packCount b { color: var(--gold); font-weight: 400; }
.pClose { width: 42px; height: 42px; min-width: 42px; padding: 0; font-size: 20px; flex: 0 0 auto; }
.pClose:hover { background: var(--red); }
.packScroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  margin-top: 10px;
  padding: 8px 6px;
  border: 3px solid var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(26, 28, 44, .5) 0 8px, transparent 8px 16px),
    var(--navy);
}
.packGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 10px;
}
.sCard { perspective: 480px; }
.sInner {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  transform-style: preserve-3d;
  transition: transform .4s steps(8);
}
.sCard.up .sInner { transform: rotateY(180deg); }
.sCard.fresh .sInner { animation: cardFlip .8s steps(10) both; }
@keyframes cardFlip {
  0% { transform: rotateY(0deg) scale(1); }
  45% { transform: rotateY(90deg) scale(1.12); }
  100% { transform: rotateY(180deg) scale(1); }
}
.sFace {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 3px solid var(--ink);
}
.sBack {
  background:
    repeating-linear-gradient(45deg, rgba(242, 234, 216, .07) 0 6px, transparent 6px 12px),
    var(--bg);
  box-shadow: 0 0 0 2px var(--cream-30) inset, 3px 3px 0 var(--ink-55);
}
.sBack span {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 34px;
  color: var(--cream-30);
  text-shadow: 2px 2px 0 var(--ink);
}
.sFront {
  transform: rotateY(180deg);
  gap: 5px;
  padding: 8px 6px;
  background: linear-gradient(var(--gold) 0 30%, var(--cream) 30% 100%);
  box-shadow: 0 0 0 2px var(--gold-d) inset, 3px 3px 0 var(--ink-55);
}
.sIco {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  background: var(--cream);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(26, 28, 44, .25);
}
.sName {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.1;
  color: var(--ink);
  overflow-wrap: break-word;
  hyphens: auto;
}
.sFrom {
  font-family: var(--fontB);
  font-size: 12px;
  line-height: 1.1;
  color: var(--ink-55);
}

/* ================================================================ classic CV */
.cvCard {
  display: flex;
  flex-direction: column;
  width: min(760px, 96vw);
  max-height: 96dvh;
  min-height: 0;
  color: var(--cream);
  background: var(--bg);
  border: 3px solid var(--cream);
  box-shadow: var(--frame);
  padding: 14px 18px;
  animation: overlayIn .25s cubic-bezier(.2, .9, .3, 1.2) both;
}
.cvTop { display: flex; align-items: center; gap: 14px; padding-bottom: 12px; border-bottom: 2px solid var(--cream-15); }
.cvAvatar {
  flex: 0 0 auto;
  width: 60px;
  height: 84px;
  display: grid;
  place-items: center;
  background: var(--navy);
  border: 2px solid var(--cream);
  box-shadow: 2px 2px 0 var(--ink-55), inset 0 -10px 0 #4e9138;
}
.cvAvatar canvas { width: 48px; height: 72px; image-rendering: pixelated; }
.cvName { min-width: 0; }
.cvName h1 {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 30px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
}
.cvSubtitle { font-family: var(--fontB); font-size: 18px; color: var(--cream-75); margin-top: 4px; }
.cClose { margin-left: auto; }

.cvContact { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0; }
.cvCBtn { font-size: 18px; padding: 6px 10px; }
.cvCBtn:hover { background: var(--navy); }
.cvCBtn.gold:hover { background: var(--cream); }

.cvScroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 2px 10px 2px 2px;
  border-top: 2px solid var(--cream-15);
}
.cvSec { margin: 14px 0 18px; }
.cvSec h2 {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 20px;
  color: var(--gold);
  text-shadow: 1px 1px 0 var(--ink);
  letter-spacing: .5px;
  margin-bottom: 8px;
  padding-bottom: 3px;
  border-bottom: 2px solid var(--gold-d);
  width: fit-content;
  padding-right: 28px;
}
.cvAbout { font-family: var(--fontB); font-size: 19px; line-height: 1.35; color: var(--cream); }

.cvItem { display: flex; gap: 10px; margin-bottom: 14px; }
.cvIco {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  background: var(--ink);
  border: 2px solid var(--cream-30);
  box-shadow: 2px 2px 0 var(--ink-55);
}
.cvIT { min-width: 0; font-family: var(--fontB); }
.cvRole { font-size: 21px; line-height: 1.15; color: var(--cream); }
.cvOrg { font-size: 18px; color: var(--cream-75); margin-top: 1px; }
.cvPer { color: var(--gold); white-space: nowrap; margin-left: 6px; }
.cvIT ul { margin: 5px 0 0 20px; }
.cvIT li, .cvProj li { font-size: 18px; line-height: 1.3; color: var(--cream-75); }
.cvIT li::marker, .cvProj li::marker { color: var(--gold); }

.skillGrid { display: flex; flex-wrap: wrap; gap: 6px; }
.skill {
  font-family: var(--fontB);
  font-size: 18px;
  line-height: 1;
  color: var(--cream);
  background: var(--ink);
  border: 2px solid var(--cream-30);
  box-shadow: 2px 2px 0 var(--ink-55);
  padding: 5px 9px;
}
.cvProj { margin: 0 0 8px 20px; }
.cvProjLinks { display: flex; flex-wrap: wrap; gap: 8px; }
.cvLink { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.cvFoot { text-align: center; font-family: var(--fontB); font-size: 15px; color: var(--cream-55); margin: 18px 0 6px; }

/* ================================================================ intro */
#intro {
  position: fixed;
  inset: 0;
  /* iOS Safari: fixed inset:0 spans the LARGE viewport (behind the toolbar),
     which pushes centered content down. Pin to the dynamic viewport instead. */
  bottom: auto;
  height: 100vh;
  height: 100dvh;
  z-index: 70;
  display: grid;
  place-items: center;
  overflow: hidden;
  /* banded pixel sky */
  background: linear-gradient(
    #2e7c99 0 16%, #3f9bb8 16% 36%, #62b8cf 36% 56%,
    #b3dcea 56% 68%, #cdeef5 68% 78%, #74c055 78% 100%);
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom));
}
.introSky { position: absolute; inset: 0; pointer-events: none; }
/* boot veil: same color as the static #loader → the page loader appears to
   "open up" onto the intro sky instead of hard-cutting */
.iVeil {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--bg);
  pointer-events: none;
  animation: veilOut .8s steps(10) .15s both;
}
@keyframes veilOut { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }
.iSun {
  position: absolute;
  top: 7%;
  right: 9%;
  width: 64px;
  height: 64px;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(240, 192, 64, .35);
  clip-path: polygon(25% 0, 75% 0, 75% 12.5%, 87.5% 12.5%, 87.5% 25%, 100% 25%, 100% 75%, 87.5% 75%, 87.5% 87.5%, 75% 87.5%, 75% 100%, 25% 100%, 25% 87.5%, 12.5% 87.5%, 12.5% 75%, 0 75%, 0 25%, 12.5% 25%, 12.5% 12.5%, 25% 12.5%);
  animation: sunBob 4s steps(8) infinite;
}
@keyframes sunBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
.iCloud {
  position: absolute;
  width: 68px;
  height: 16px;
  background: var(--cream);
  box-shadow: 14px -12px 0 var(--cream), 34px -8px 0 var(--cream), -10px -4px 0 var(--cream);
  opacity: .92;
  animation: cloudDrift linear infinite;
}
.iCloud.c1 { top: 12%; animation-duration: 64s; animation-delay: -12s; }
.iCloud.c2 { top: 26%; transform: scale(1.5); animation-duration: 88s; animation-delay: -47s; opacity: .75; }
.iCloud.c3 { top: 42%; transform: scale(.8); animation-duration: 52s; animation-delay: -30s; opacity: .6; }
@keyframes cloudDrift { from { left: -140px; } to { left: 110vw; } }
.iGrass {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 23%;
  background:
    repeating-linear-gradient(90deg, rgba(78, 145, 56, .5) 0 3px, transparent 3px 17px),
    linear-gradient(#74c055 0 12%, #6cb84e 12% 55%, #4e9138 55% 100%);
  border-top: 4px solid #357a2a;
}

.introCard {
  position: relative;
  z-index: 1;
  text-align: center;
  color: var(--cream);
  background: rgba(32, 34, 58, .92);
  border: 3px solid var(--cream);
  box-shadow: var(--frame);
  padding: 24px 28px 18px;
  width: min(560px, 96vw);
  max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.introCard > * { animation: fadeUp .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.introCard > *:nth-child(2) { animation-delay: .55s; }
.introCard > *:nth-child(3) { animation-delay: .65s; }
.introCard > *:nth-child(4) { animation-delay: .75s; }
.introCard > *:nth-child(5) { animation-delay: .85s; }
.introCard > *:nth-child(6) { animation-delay: .95s; }
.introCard > *:nth-child(7) { animation-delay: 1.05s; }
.introCard > *:nth-child(8) { animation-delay: 1.15s; }
.introCard > *:nth-child(9) { animation-delay: 1.25s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.iTitle {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: clamp(38px, 9vw, 64px);
  line-height: 1;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink), 6px 6px 0 rgba(26, 28, 44, .35);
  letter-spacing: 2px;
  margin-bottom: 6px;
  white-space: nowrap;
}
/* longer wordmark ("RAUL JOURNEY") — keep it on one line inside the card */
.iTitle.long { font-size: clamp(30px, 7.4vw, 52px); letter-spacing: 1px; }
.iTitle .tl { display: inline-block; animation: tlIn .55s cubic-bezier(.2, .9, .3, 1.4) both; }
.iTitle .tsp { display: inline-block; width: .45em; }
@keyframes tlIn {
  0% { opacity: 0; transform: translateY(-46px); }
  60% { opacity: 1; transform: translateY(5px); }
  100% { opacity: 1; transform: translateY(0); }
}
.tagline { font-family: var(--fontB); font-size: 22px; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); margin-bottom: 14px; }

.prevBox {
  display: inline-grid;
  place-items: center;
  width: 88px;
  height: 112px;
  margin-bottom: 14px;
  background:
    repeating-linear-gradient(90deg, rgba(78, 145, 56, .55) 0 3px, transparent 3px 14px) left bottom / 100% 38% no-repeat,
    linear-gradient(#62b8cf 0 58%, #357a2a 58% 62%, #6cb84e 62% 100%);
  border: 3px solid var(--cream);
  box-shadow: 0 0 0 3px var(--ink), 4px 4px 0 var(--ink-55);
}
.prevBox canvas { width: 64px; height: 96px; image-rendering: pixelated; margin-top: 10px; }

.langRow { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.lang { min-width: 56px; font-size: 19px; letter-spacing: 1px; }
.lang.on { background: var(--gold); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink-55), 0 0 0 2px var(--gold-d) inset; }

.start {
  font-family: var(--fontD);
  font-weight: 700;
  font-size: 25px;
  padding: 12px 34px;
  margin: 0 auto 10px;
  display: flex;
  box-shadow: 3px 3px 0 var(--ink), 0 0 0 2px var(--gold-d) inset;
  animation: fadeUp .5s cubic-bezier(.2, .9, .3, 1.2) both, startPulse 1.1s steps(6) 1.4s infinite;
}
@keyframes startPulse {
  0%, 100% { transform: translateY(0); box-shadow: 3px 3px 0 var(--ink), 0 0 0 2px var(--gold-d) inset; }
  50% { transform: translateY(-3px); box-shadow: 3px 6px 0 var(--ink), 0 0 0 2px var(--gold-d) inset; }
}
.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 12px; }
.controls div {
  font-family: var(--fontB);
  font-size: 17px;
  line-height: 1;
  color: var(--cream);
  background: var(--ink-55);
  border: 2px solid var(--cream-30);
  padding: 6px 10px;
  white-space: nowrap;
}
.howTo { font-family: var(--fontB); font-size: 18px; line-height: 1.3; color: var(--gold); max-width: 420px; margin: 0 auto 6px; }
.credits { font-family: var(--fontB); font-size: 15px; color: var(--cream-55); margin-top: 10px; }

/* ================================================================ tram-ride fade */
#fade {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s steps(5);
  overflow: hidden;
}
#fade.on { opacity: 1; }
#fadeTram {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: min(17vw, 110px);
  line-height: 1;
  transform: translate(-50%, -100%);
  filter: none;
  text-shadow: 0 6px 0 rgba(26, 28, 44, .8);
}
#fade.on #fadeTram { animation: tramRide .62s steps(24) both; }
@keyframes tramRide {
  0% { left: -18%; }
  100% { left: 118%; }
}
#fadeRail {
  position: absolute;
  top: calc(50% + 10px);
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(90deg, var(--cream-55) 0 26px, rgba(242, 234, 216, .12) 26px 44px);
}
#fade.on #fadeRail { animation: railMove .62s linear both; }
@keyframes railMove { from { background-position-x: 0; } to { background-position-x: -260px; } }

/* ================================================================ badge-fly FX */
#fxLayer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.badgeFly {
  position: fixed;
  font-size: 42px;
  line-height: 1;
  transform: translate(-50%, -50%) scale(1.5);
  text-shadow: 3px 3px 0 rgba(26, 28, 44, .6);
  animation: flySpawn .18s steps(4) both;
  transition:
    left .68s cubic-bezier(.25, .6, .4, 1),
    top .68s cubic-bezier(.6, -.25, .7, .4),
    transform .68s steps(10);
}
.badgeFly.go { transform: translate(-50%, -50%) scale(.45); }
@keyframes flySpawn { from { transform: translate(-50%, -50%) scale(.2); } to { transform: translate(-50%, -50%) scale(1.5); } }

/* ================================================================ touch controls (engine DOM) */
#joy .base {
  border: 4px solid rgba(242, 234, 216, .55);
  background: rgba(32, 34, 58, .35);
  box-shadow: 0 0 0 3px rgba(26, 28, 44, .4);
}
#joy .knob {
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: inset -5px -5px 0 rgba(26, 28, 44, .2);
}
#btnA {
  font-family: var(--fontD);
  color: var(--ink);
  background: var(--gold);
  border: 4px solid var(--ink);
  box-shadow: 0 5px 0 var(--ink), inset -4px -4px 0 var(--gold-d);
}
#btnA.pressed { box-shadow: 0 1px 0 var(--ink), inset -4px -4px 0 var(--gold-d); }

/* ================================================================ pixel scrollbars */
.mapScroll::-webkit-scrollbar, .cvScroll::-webkit-scrollbar, .introCard::-webkit-scrollbar, .packScroll::-webkit-scrollbar { width: 12px; height: 12px; }
.mapScroll::-webkit-scrollbar-track, .cvScroll::-webkit-scrollbar-track, .introCard::-webkit-scrollbar-track, .packScroll::-webkit-scrollbar-track { background: var(--ink); }
.mapScroll::-webkit-scrollbar-thumb, .cvScroll::-webkit-scrollbar-thumb, .introCard::-webkit-scrollbar-thumb, .packScroll::-webkit-scrollbar-thumb {
  background: var(--cream);
  border: 3px solid var(--ink);
}
.mapScroll::-webkit-scrollbar-corner { background: var(--ink); }

/* ================================================================ mobile */
@media (max-width: 720px) {
  #hud { gap: 4px; }
  #badgeBar { gap: 2px; padding: 3px 4px; }
  #badgeBar .badge { width: 20px; height: 20px; font-size: 11px; border-width: 1px; }
  #badgeBar .eggChip { font-size: 14px; margin-left: 2px; padding: 1px 2px 1px 4px; }
  #hudLeft { gap: 4px; }
  #objChip { font-size: 14px; line-height: 1.15; padding: 3px 7px 3px 5px; border-left-width: 3px; gap: 4px; }
  #objChip .objIco { font-size: 11px; }
  #objChip .objTxt { white-space: normal; } /* wrap, never truncate the goal */
  /* up to 8 buttons → cap at 4 per row so the badge bar keeps its space */
  #hudBtns { gap: 4px; max-width: 172px; }
  .hudBtn { width: 40px; height: 40px; min-width: 40px; font-size: 18px; }
  .zoomBtn { font-size: 21px; }
  #btnLang { min-width: 40px; padding: 0 4px; font-size: 13px; }
  #btnLang i { margin: 0 1px; }
  /* clear two HUD button rows (8 buttons wrap into 2×4 on phones) */
  #toasts { top: calc(102px + env(safe-area-inset-top)); }
  .toast { font-size: 18px; padding: 7px 12px; }

  #dialog { padding: 0; }
  .panel.dlg {
    width: 100vw;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 0 -3px 0 var(--ink);
    padding: 12px 14px calc(10px + env(safe-area-inset-bottom));
  }
  .dBody { font-size: 20px; }
  .dTitle { font-size: 22px; }

  #mapOverlay, #cvOverlay, #packOverlay { padding: 0; place-items: stretch; }
  .mapWrap, .cvCard, .packWrap {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    box-shadow: none;
    padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  }
  .mapWrap::before, .mapWrap::after { display: none; }
  .mapScrollBox { flex: 1 1 auto; }
  .mTitle { font-size: 21px; }
  .mapHint { font-size: 16px; margin-bottom: 6px; }
  .mapLegend { font-size: 16px; gap: 6px 12px; margin-top: 8px; }
  .stopLbl { font-size: 15px; }
  .packCount { font-size: 17px; }
  .packGrid { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: 8px; }

  .cvName h1 { font-size: 24px; }
  .cvAvatar { width: 52px; height: 74px; }
  .cvAvatar canvas { width: 40px; height: 60px; }
  .cvContact { gap: 6px; }
  .cvCBtn { font-size: 16px; flex: 1 1 auto; }

  .introCard { padding: 18px 14px calc(14px + env(safe-area-inset-bottom)); }
  .iTitle { letter-spacing: 1px; }
  .tagline { font-size: 19px; }
  .controls div { font-size: 15px; }
}

/* 430px: 8 HUD buttons (2 rows of 4) + 8 badges + egg chip must coexist */
@media (max-width: 430px) {
  #badgeBar .badge { width: 17px; height: 17px; font-size: 9px; }
  #badgeBar .eggChip { font-size: 13px; }
  #objChip { font-size: 13px; }
  #hudBtns { max-width: 156px; }
  .hudBtn { width: 36px; height: 36px; min-width: 36px; }
  .zoomBtn { font-size: 19px; }
  #btnLang { min-width: 36px; padding: 0 3px; }
  #packNew { min-width: 15px; height: 15px; font-size: 11px; top: -6px; right: -6px; }
}

/* landscape phones: same full-screen treatment for map + CV + backpack */
@media (max-height: 480px) {
  #mapOverlay, #cvOverlay, #packOverlay { padding: 0; place-items: stretch; }
  .mapWrap, .cvCard, .packWrap {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    box-shadow: none;
    padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  }
  .mapWrap::before, .mapWrap::after { display: none; }
  .mapScrollBox { flex: 1 1 auto; }
  .mTitle { font-size: 21px; }
  .mapHint { font-size: 16px; margin-bottom: 4px; }
  .mapLegend { font-size: 16px; gap: 6px 12px; margin-top: 6px; padding-top: 5px; }
  .stopLbl { font-size: 15px; }
}

/* ================================================================ reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}

/* ================================================================ iOS dynamic viewport
   Fixed inset:0 overlays span the LARGE viewport on iOS Safari (extends behind
   the collapsed/expanded toolbar), so centered/bottom-anchored content drifts.
   Pin every fullscreen overlay to the dynamic viewport height instead. */
#dialog, #mapOverlay, #cvOverlay, #packOverlay {
  bottom: auto;
  height: 100vh;
  height: 100dvh;
}
