/* The Adventures of Felipe. --u = one logical game pixel in CSS px (set by engine.js), so the UI scales with the game. */
:root {
  --ink: #3b2a20; --wood: #6b4226; --wood-l: #a86b3c; --paper: #f6ecd6; --paper-d: #eadcbd; --sun: #ffd84d; --blue: #3859ff;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --u: 2px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #14102a; overflow: hidden; overscroll-behavior: none; }
#stage, #stage * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#stage { touch-action: none; }
.case__scroll, .dlg__text { -webkit-user-select: text; user-select: text; }
/* on phones the dialogue text isn't selectable: a double-tap or long-press on selectable text makes Safari zoom in */
@media (pointer: coarse) { .case__scroll, .dlg__text { -webkit-user-select: none; user-select: none; } }
body { display: grid; place-items: center; font-family: var(--font); color: var(--ink); -webkit-font-smoothing: antialiased; }
#stage { position: relative; overflow: hidden; background: #14102a; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; font-size: clamp(11px, calc(var(--u) * 5.6), 18px); }
@media (pointer: coarse) { #ui { font-size: clamp(12px, calc(var(--u) * 6.4), 19px); } }
#ui > * { pointer-events: auto; }
#ui .hint, #ui .lhud { pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: calc(var(--u) * 1.2) solid #5a3418; outline-offset: calc(var(--u) * 0.8); border-radius: calc(var(--u) * 2); }
kbd { font: 700 0.78em var(--font); background: rgba(59, 42, 32, 0.12); border-radius: 4px; padding: 0.05em 0.4em; margin: 0 0.1em; }

/* loading */
.boot { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; color: #f6ecd6; text-align: center; font: 600 16px var(--font); }
.boot__bar { width: 200px; height: 8px; border-radius: 99px; background: #2c2550; overflow: hidden; }
.boot__bar i { display: block; height: 100%; width: 0; background: var(--sun); transition: width .2s; }

/* wooden buttons */
.wbtn {
  border: solid transparent; border-width: calc(var(--u) * 3.2) calc(var(--u) * 7);
  border-image: url(../art/ui-button.webp) 22 44 fill / calc(var(--u) * 3.2) calc(var(--u) * 7) stretch;
  background: none; color: #fff8e8; font-weight: 800; letter-spacing: .01em; padding: calc(var(--u) * 0.6) calc(var(--u) * 2);
  text-shadow: 0 2px 0 rgba(59, 42, 32, .55); line-height: 1.15; white-space: nowrap; transition: transform .12s;
}
.wbtn:hover, .wbtn:focus-visible { border-image-source: url(../art/ui-button-hover.webp); transform: translateY(-1px); }
.wbtn:active { border-image-source: url(../art/ui-button-press.webp); transform: translateY(1px); }
.wbtn--main { filter: saturate(1.15) brightness(1.06); }
.wbtn--alt { filter: brightness(.88); }
.wbtn--sm { font-size: .9em; } .wbtn--xs { font-size: .78em; border-width: calc(var(--u) * 2.4) calc(var(--u) * 5); }
.wbtn kbd { background: rgba(0, 0, 0, .18); color: #fff8e8; text-shadow: none; font-size: .7em; }

/* icon buttons */
.ibtn { width: calc(var(--u) * 19); height: calc(var(--u) * 19); padding: calc(var(--u) * 2.5); border: 0; border-radius: calc(var(--u) * 5);
  background: rgba(246, 236, 214, .88); box-shadow: 0 calc(var(--u) * 1.2) 0 rgba(59, 42, 32, .35); display: grid; place-items: center; }
.ibtn img { width: 100%; height: 100%; object-fit: contain; }
.ibtn:hover { background: #fff8e8; }
.hud { position: absolute; top: calc(var(--u) * 6); right: max(calc(var(--u) * 6), env(safe-area-inset-right)); display: flex; gap: calc(var(--u) * 4); z-index: 5; }

/* paper panel with a wooden frame. Corners stay fixed; beams and paper repeat ("round") instead of stretching.
   The frame art is wider than the border, so it overlaps the padding a little (leaves sit behind the content). */
.panel {
  border: calc(var(--u) * 13) solid transparent;
  border-image: url(../art/ui-frame.webp) 280 fill / calc(var(--u) * 30) round;
  color: var(--ink);
}

/* press start */
.press { position: absolute; inset: 0; border: 0; color: #fff8e8; /* the starry sky shows through, softly blurred */
  background: rgba(16, 18, 52, 0.25); -webkit-backdrop-filter: blur(calc(var(--u) * 2.5)); backdrop-filter: blur(calc(var(--u) * 2.5));
  display: grid; place-content: center; gap: calc(var(--u) * 4); text-align: center; }
.press__t { font-weight: 800; font-size: 1.6em; text-shadow: 0 2px 0 rgba(20, 14, 40, .6), 0 0 18px rgba(255, 216, 77, .35); animation: pulse 1.6s ease-in-out infinite; }
.press__s { opacity: .85; font-size: .8em; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
@keyframes pulse { 50% { opacity: .45; } }

/* title menu */
.tmenu { position: absolute; left: 50%; top: calc(var(--u) * 112); transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * 4); width: 90%; animation: rise .6s cubic-bezier(.2, .9, .3, 1.2) both; }
.tmenu .wbtn { font-size: 1.05em; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 20px); } }

/* map */
.dcard {
  position: absolute; left: calc(var(--u) * 8); bottom: calc(var(--u) * 8); width: calc(var(--u) * 190);
  background: var(--paper); border-radius: calc(var(--u) * 3); padding: calc(var(--u) * 6) calc(var(--u) * 8) calc(var(--u) * 6);
  box-shadow: 0 calc(var(--u) * 2) 0 rgba(59, 42, 32, .35), inset 0 0 0 calc(var(--u) * 1) rgba(168, 107, 60, .35);
  transform: rotate(-0.6deg); animation: pin .35s cubic-bezier(.2, .9, .3, 1.3) both;
}
.dcard::before { content: ''; position: absolute; top: calc(var(--u) * -3); left: 50%; width: calc(var(--u) * 7); height: calc(var(--u) * 7); border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8a8a, #c62f2f 60%); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
@keyframes pin { from { opacity: 0; transform: translateY(12px) rotate(-3deg); } }
.dcard__meta { margin: 0; font-size: .72em; font-weight: 700; color: var(--wood-l); text-transform: uppercase; letter-spacing: .06em; }
.dcard__done { color: #c28a00; }
.dcard__t { margin: calc(var(--u) * 1) 0 calc(var(--u) * 1.5); font-size: 1em; line-height: 1.15; }
.dcard__l { margin: 0 0 calc(var(--u) * 4); font-size: .78em; line-height: 1.4; }
.dcard__a { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 3); align-items: center; }
.pill { font-size: .7em; font-weight: 700; background: var(--paper-d); border-radius: 99px; padding: .25em .7em; color: var(--wood); }
.hint { position: absolute; right: calc(var(--u) * 8); bottom: calc(var(--u) * 6); margin: 0; font-size: .68em; font-weight: 600; color: #fff8e8; background: rgba(40, 26, 18, .55); padding: .35em .8em; border-radius: 99px; }
.hint kbd { background: rgba(255, 255, 255, .18); }

/* dialogue */
.dlg { position: absolute; left: 0; right: 0; bottom: calc(var(--u) * 6); display: flex; justify-content: center; }
.dlg__box { width: calc(var(--u) * 380); display: flex; gap: calc(var(--u) * 7); align-items: flex-start;
  border: calc(var(--u) * 11) solid transparent; border-image: url(../art/ui-frame.webp) 280 fill / calc(var(--u) * 26) round;
  padding: calc(var(--u) * 7) calc(var(--u) * 9) calc(var(--u) * 6) calc(var(--u) * 6); animation: pin .3s ease-out both; }
.dlg__face { width: calc(var(--u) * 50); height: calc(var(--u) * 50); object-fit: cover; object-position: top; background: #f1dfb8; border-radius: calc(var(--u) * 3); box-shadow: inset 0 0 0 calc(var(--u) * 1) rgba(168, 107, 60, .4); flex: none; }
.dlg__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: calc(var(--u) * 1.5); }
/* header: small "where am I" line, then the title, then (for recommendations) the person's role */
.dlg__head { display: flex; flex-direction: column; gap: calc(var(--u) * .6); }
.dlg__step { margin: 0; font-weight: 800; color: var(--wood); opacity: .7; text-transform: uppercase; letter-spacing: .06em; font-size: .72em; }
.dlg__label { margin: 0; font-weight: 800; color: #2b1d14; font-size: 1.2em; line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }
.dlg__role { margin: 0; color: var(--wood); font-size: .82em; font-weight: 600; }
.dlg__text { margin: 0; line-height: 1.45; font-size: 1.04em; display: grid; }
/* the full text sits invisibly underneath, so the box is sized for the finished text and never jumps while typing */
.dlg__ghost, .dlg__typed { grid-area: 1 / 1; }
.dlg__ghost { visibility: hidden; }

/* sheets (case page, quick view, level clear) */
.sheet { position: absolute; inset: 0; background: rgba(20, 14, 30, .55); display: grid; place-items: center; animation: fadein .2s ease-out; z-index: 10; }
@keyframes fadein { from { opacity: 0; } }
.case, .quick { position: relative; width: calc(var(--u) * 420); height: calc(var(--u) * 252); display: flex; flex-direction: column; animation: pin .3s ease-out both; }
.case__x { position: absolute; top: calc(var(--u) * -6); right: calc(var(--u) * -6); width: calc(var(--u) * 16); height: calc(var(--u) * 16); z-index: 2; }
.case__scroll { flex: 1; overflow-y: auto; padding: calc(var(--u) * 2) calc(var(--u) * 8) calc(var(--u) * 4); scrollbar-width: thin; scrollbar-color: var(--wood-l) transparent; }
.case__meta { margin: 0; font-size: .7em; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--wood-l); }
.case__t { margin: calc(var(--u) * 1.5) 0 0; font-size: 1.35em; line-height: 1.08; letter-spacing: -.01em; }
.case__name { margin: calc(var(--u) * 1) 0 0; font-weight: 700; color: var(--wood); font-size: .85em; }
.case__k { margin: calc(var(--u) * 4) 0; font-size: .92em; line-height: 1.45; }
.case__cover { margin: 0 0 calc(var(--u) * 5); border-radius: calc(var(--u) * 3); overflow: hidden; aspect-ratio: 16 / 7; display: grid; place-items: center; }
.case__cover img { width: 100%; height: 100%; object-fit: contain; display: block; }
.case__facts { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 3) calc(var(--u) * 8); margin: 0 0 calc(var(--u) * 5); font-size: .82em; }
.case__facts .wide { grid-column: 1 / -1; }
.case__facts dt { font-weight: 800; font-size: .8em; text-transform: uppercase; letter-spacing: .06em; color: var(--wood-l); }
.case__facts dd { margin: 0; line-height: 1.35; }
.case__nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(var(--u) * 110), 1fr)); gap: calc(var(--u) * 4); margin: 0 0 calc(var(--u) * 5); }
.num { background: var(--sun); border-radius: calc(var(--u) * 3); padding: calc(var(--u) * 4) calc(var(--u) * 5); box-shadow: 0 calc(var(--u) * 1.2) 0 rgba(59, 42, 32, .25); transform: rotate(-.6deg); }
.num:nth-child(2n) { transform: rotate(.6deg); background: #ffc6d3; }
.num b { display: block; font-size: 1.45em; line-height: 1; }
.num span { display: block; margin-top: calc(var(--u) * 1.5); font-size: .78em; line-height: 1.3; }
.case__p { line-height: 1.55; margin: 0 0 calc(var(--u) * 4); font-size: .88em; }
.case__soon { font-style: italic; opacity: .7; }
.case__tags { list-style: none; padding: 0; margin: calc(var(--u) * 2) 0 0; display: flex; flex-wrap: wrap; gap: calc(var(--u) * 2.5); }
.case__tags li { font-size: .72em; font-weight: 700; padding: .3em .8em; border-radius: 99px; background: var(--paper-d); }
.case__foot { display: flex; justify-content: flex-end; gap: calc(var(--u) * 4); padding: calc(var(--u) * 3) calc(var(--u) * 4) 0; }
.qgrid { list-style: none; margin: calc(var(--u) * 6) 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: calc(var(--u) * 6); }
.qgrid li { position: relative; }
.qcard { display: flex; flex-direction: column; width: 100%; height: 100%; text-align: left; border: 0; padding: calc(var(--u) * 3) calc(var(--u) * 3) calc(var(--u) * 6);
  background: #fff; border-radius: calc(var(--u) * 6); box-shadow: 0 calc(var(--u) * 1) 0 rgba(59, 42, 32, .12), 0 calc(var(--u) * 4) calc(var(--u) * 10) rgba(59, 42, 32, .08);
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), box-shadow .35s; }
.qcard__cover { position: relative; display: block; border-radius: calc(var(--u) * 4); background: var(--bg); aspect-ratio: 16 / 9; overflow: hidden; }
.qcard__cover img { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .5s cubic-bezier(.2, .9, .3, 1); }
.qcard__go { position: absolute; top: calc(var(--u) * 3); right: calc(var(--u) * 3); width: calc(var(--u) * 14); height: calc(var(--u) * 14); border-radius: 50%; display: grid; place-items: center;
  background: rgba(30, 20, 40, .55); color: #fff; font-size: .8em; transform: scale(.6); opacity: 0; transition: transform .3s cubic-bezier(.2, .9, .3, 1.4), opacity .2s; }
.qcard__meta { margin: calc(var(--u) * 4) calc(var(--u) * 3) 0; font: 600 .62em ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--wood-l); }
.qcard__t { margin: calc(var(--u) * 1.5) calc(var(--u) * 3) 0; font-weight: 800; font-size: .98em; line-height: 1.15; letter-spacing: -.01em; }
.qcard__k { margin: calc(var(--u) * 2) calc(var(--u) * 3) 0; font-size: .74em; line-height: 1.45; color: #6b5444; }
.qcard:hover, .qcard:focus-visible { transform: translateY(calc(var(--u) * -2)) rotate(-.4deg); box-shadow: 0 calc(var(--u) * 2) 0 rgba(59, 42, 32, .14), 0 calc(var(--u) * 10) calc(var(--u) * 18) rgba(59, 42, 32, .16); }
.qcard:hover .qcard__cover img, .qcard:focus-visible .qcard__cover img { transform: scale(1.05); }
.qcard:hover .qcard__go, .qcard:focus-visible .qcard__go { transform: scale(1); opacity: 1; }
.qcard__play { position: absolute; left: calc(var(--u) * 6); top: calc(var(--u) * 6); }
.qsub { margin: calc(var(--u) * 10) 0 calc(var(--u) * 3); font-size: .9em; }
.qmini { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: calc(var(--u) * 4); }
.qmini li { background: rgba(255, 255, 255, .55); border-radius: calc(var(--u) * 4); padding: calc(var(--u) * 4) calc(var(--u) * 5); }
.qmini b { font-size: .85em; } .qmini span { display: block; font-size: .65em; color: var(--wood-l); font-weight: 700; margin-top: 2px; } .qmini p { margin: calc(var(--u) * 1.5) 0 0; font-size: .72em; line-height: 1.4; }
.clear { width: calc(var(--u) * 260); text-align: center; padding-bottom: calc(var(--u) * 8); animation: pin .35s cubic-bezier(.2, .9, .3, 1.3) both; }
.clear__t { margin: calc(var(--u) * 2) 0; font-size: 1.3em; }
.clear__s { margin: 0 0 calc(var(--u) * 6); font-weight: 600; font-size: .85em; }
.clear__a { display: flex; gap: calc(var(--u) * 4); justify-content: center; flex-wrap: wrap; }
.clear__a--col { flex-direction: column; align-items: center; margin-top: calc(var(--u) * 4); }
.clear__a--col .wbtn { width: calc(var(--u) * 110); }
.clear--pause { width: calc(var(--u) * 170); }

/* level HUD */
.lhud { position: absolute; top: calc(var(--u) * 6); left: max(calc(var(--u) * 6), env(safe-area-inset-left)); display: flex; align-items: center; gap: calc(var(--u) * 5); background: rgba(246, 236, 214, .9); border-radius: calc(var(--u) * 5); padding: calc(var(--u) * 3) calc(var(--u) * 6); box-shadow: 0 calc(var(--u) * 1.2) 0 rgba(59, 42, 32, .35); font-size: .85em; }
.lhud__beats { display: flex; gap: calc(var(--u) * 1.6); }
.lhud__beats i { width: calc(var(--u) * 7); height: calc(var(--u) * 7); border-radius: 2px; background: rgba(59, 42, 32, .15); }
.lhud__beats i.on { background: var(--sun); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.lhud__beats--bonus i.on { background: #ff9fb2; }
.lhud__bulbs { font-weight: 700; }

.nojs { color: #fff; text-align: center; font: 16px system-ui; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* 7.5 + the body's 1.5 gap = 9 game px between the text and the buttons (~24px on a desktop screen) */
.dlg__foot { display: flex; align-items: center; justify-content: flex-end; gap: calc(var(--u) * 3); margin-top: calc(var(--u) * 7.5); }
.dlg__next { margin-left: calc(var(--u) * 1); }
/* bigger buttons in the dialogue box (Continue, Skip intro, LinkedIn…) */
.dlg__foot .wbtn { font-size: .98em; border-width: calc(var(--u) * 3.6) calc(var(--u) * 7.5); padding: calc(var(--u) * 1) calc(var(--u) * 3); }
.dcard__a a, .dlg__foot a, .qmini__a a { text-decoration: none; }
.qmini__a { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 2); margin-top: calc(var(--u) * 3); }

.lhud__n { font-weight: 800; color: var(--wood); }
.clear__face { width: calc(var(--u) * 44); height: calc(var(--u) * 44); object-fit: cover; object-position: top; border-radius: 50%; background: #f1dfb8; display: block; margin: 0 auto calc(var(--u) * 3); }
/* end screen stats: two cards with icon, count-up number and a filling bar, then a 3-star rating */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--u) * 4); margin: calc(var(--u) * 3) calc(var(--u) * 4) calc(var(--u) * 3); }
.stat { display: grid; grid-template-columns: auto 1fr; column-gap: calc(var(--u) * 3); align-items: center; text-align: left;
  background: #fffaf0; border-radius: calc(var(--u) * 4); padding: calc(var(--u) * 3) calc(var(--u) * 4) calc(var(--u) * 3.5);
  box-shadow: 0 calc(var(--u) * 1) 0 rgba(59, 42, 32, .15), inset 0 0 0 1px rgba(168, 107, 60, .18); }
.stat img { grid-row: 1 / 3; height: calc(var(--u) * 13); }
.stat b { font-size: 1.6em; font-weight: 900; line-height: 1; color: #2b1d14; font-variant-numeric: tabular-nums; }
.stat b small { font-size: .55em; font-weight: 800; color: var(--wood-l); margin-left: .1em; }
.stat__l { font-size: .68em; font-weight: 800; color: var(--wood); text-transform: uppercase; letter-spacing: .05em; }
.bar { grid-column: 1 / -1; display: block; height: calc(var(--u) * 2.6); margin-top: calc(var(--u) * 2.5); border-radius: 99px; overflow: hidden;
  background: rgba(59, 42, 32, .12); box-shadow: inset 0 1px 0 rgba(59, 42, 32, .15); }
.bar i { display: block; height: 100%; width: calc(var(--p) * 100%); border-radius: inherit; background: linear-gradient(#ffe27a, #f2b600); animation: fill 1s .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes fill { from { width: 0; } }
.stars { display: flex; justify-content: center; gap: calc(var(--u) * 2); }
.stars img { width: calc(var(--u) * 15); height: calc(var(--u) * 15); filter: grayscale(1) opacity(.3); }
.stars img.on { filter: none; animation: star .45s calc(1.15s + var(--d) * .25s) cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes star { from { transform: scale(0) rotate(-30deg); opacity: 0; } }
.rank { margin: calc(var(--u) * 1) 0 calc(var(--u) * 4); font-weight: 800; color: var(--wood); text-transform: uppercase; letter-spacing: .08em; font-size: .75em; }
.clear__hint { margin: calc(var(--u) * -2) 0 calc(var(--u) * 5); font-size: .78em; opacity: .8; }

.dlg__stat { margin: 0; display: flex; align-items: baseline; gap: .6em; color: #2b1d14; }
.dlg__stat b { font-weight: 900; font-size: 2.3em; line-height: .95; letter-spacing: -.03em; flex: none; }
.dlg__stat i { font-style: normal; color: #e0a400; }
.dlg__stat span { font-weight: 700; font-size: 1.04em; line-height: 1.2; }
/* small screens: the text stops shrinking at 11px but the box keeps going, so the number drops to text size and reads as one line with its caption */
@media (max-width: 900px), (max-height: 500px) {
  .dlg__stat { display: block; line-height: 1.2; }
  .dlg__stat b { font-size: 1.04em; line-height: inherit; letter-spacing: 0; margin-right: .3em; }
}
.dlg__face--photo { border-radius: 50%; object-position: center; }
.dlg__text--quote { font-style: italic; }

/* controls row inside the welcome chat */
.dlg__keys { list-style: none; margin: calc(var(--u) * 1) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: calc(var(--u) * 2) calc(var(--u) * 6); font-weight: 700; font-size: .85em; }
.dlg__keys li { display: flex; align-items: center; gap: calc(var(--u) * 1.2); }
.dlg__keys kbd { min-width: 1.9em; height: 1.9em; display: inline-grid; place-items: center; background: #fff; border: 1px solid rgba(59, 42, 32, .35);
  border-radius: 6px; box-shadow: 0 3px 0 rgba(59, 42, 32, .35); font-size: .95em; padding: 0 .45em; margin: 0 0 3px; }
.clear__cta { margin: 0 0 calc(var(--u) * 4); font-weight: 700; font-size: 1em; }
.clear__a a { text-decoration: none; }

/* ---------- touch controls ---------- */
.tpad { position: fixed; left: 0; width: 100vw; bottom: var(--band, 0px); height: 0; z-index: 4; --u: min(100vw / 480, 100vh / 270); --u: min(100vw / 480, 100dvh / 270); }
/* the pad lives outside #stage, so it needs its own no-select rules (otherwise a long press selects the arrows) */
.tpad, .tpad * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.has-band .tpad { bottom: calc(var(--band) / 2 - 40px); }
.has-band .tpad button { bottom: 0; }
.tpad button { position: absolute; bottom: calc(var(--u) * 8); border: 0; border-radius: 50%; color: #fff8e8; font-size: calc(var(--u) * 14); line-height: 1;
  width: max(56px, calc(var(--u) * 40)); height: max(56px, calc(var(--u) * 40)); display: grid; place-items: center;
  background: rgba(59, 42, 32, .45); box-shadow: inset 0 0 0 2px rgba(255, 248, 232, .35), 0 3px 0 rgba(20, 12, 8, .35); touch-action: none; }
.tpad button.on { background: rgba(255, 216, 77, .75); color: #3b2a20; transform: translateY(2px); }
.tpad__move { position: absolute; bottom: 0; left: max(calc(var(--u) * 8), calc(env(safe-area-inset-left) + 8px)); }
.tpad__move button:first-child { left: 0; } .tpad__move button:last-child { left: calc(max(56px, calc(var(--u) * 40)) + 12px); }
.tpad__jump { right: max(calc(var(--u) * 8), calc(env(safe-area-inset-right) + 8px)); width: max(66px, calc(var(--u) * 46)) !important; height: max(66px, calc(var(--u) * 46)) !important; }
.tpad__jump small { display: block; font-size: 11px; font-weight: 800; letter-spacing: .04em; margin-top: -6px; }
body:has(.sheet, .dlg) .tpad { display: none; }
/* while a dialogue is open the pad would cover it: the box sits above the controls */
@media (pointer: coarse) { .dlg { bottom: calc(var(--u) * 4); } .dlg__box { width: min(calc(var(--u) * 400), 94%); } .case__x, .ibtn { min-width: 40px; min-height: 40px; } }

/* ---------- rotate prompt: phones held upright ---------- */
.rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  .rotate { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 18px; background: #14102a; color: #fff8e8; font: 700 18px var(--font); text-align: center; padding: 24px; }
  .rotate__phone { width: 46px; height: 80px; border: 4px solid #ffd84d; border-radius: 10px; animation: turn 2.2s ease-in-out infinite; }
  @keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}

/* tablets held upright: sky above the game, earth below, and a tip */
@media (orientation: portrait) { html, body { background: linear-gradient(#9fd8ff 0 50%, #4a3020 50% 100%); } }
.band-tip { display: none; }
@media (pointer: coarse) { .has-band .band-tip { display: block; position: fixed; left: 0; right: 0; top: calc(var(--band) / 2 - 12px); margin: 0; text-align: center; font: 700 15px var(--font); color: #2b4a66; } }

/* ---------- case study trailers ---------- */
.dlg__trailer { position: relative; padding: 0; border: 0; overflow: hidden; background: #1c1630; cursor: pointer; width: calc(var(--u) * 80); height: calc(var(--u) * 50); }
.dlg__trailer video, .dlg__trailer img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dlg__play { position: absolute; inset: 0; margin: auto; width: calc(var(--u) * 15); height: calc(var(--u) * 15); border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 216, 77, .92); color: #3b2a20; font-style: normal; font-size: calc(var(--u) * 6); padding-left: calc(var(--u) * 1);
  box-shadow: 0 calc(var(--u) * 1) 0 rgba(59, 42, 32, .4); transition: transform .15s; }
.dlg__trailer:hover .dlg__play, .dlg__trailer:focus-visible .dlg__play { transform: scale(1.12); }
.cine { background: rgba(14, 10, 24, .82); z-index: 20; }
.cine__box { width: min(94vw, calc((100vh - calc(var(--u) * 26) - 24px) * 1.6 + calc(var(--u) * 26)), calc((100dvh - calc(var(--u) * 26) - 24px) * 1.6 + calc(var(--u) * 26)), 1100px); padding: 0; animation: pin .3s ease-out both; } /* as big as the screen allows, video at 16:10 */
/* close sits at the top-right of the screen, clear of the frame and the iPhone notch */
.cine__x { position: absolute; top: max(calc(var(--u) * 5), env(safe-area-inset-top)); right: max(calc(var(--u) * 5), env(safe-area-inset-right)); z-index: 1;
  width: max(40px, calc(var(--u) * 15)); height: max(40px, calc(var(--u) * 15)); border: 0; border-radius: 50%; background: var(--wood); color: #fff8e8; font-size: 1.1em;
  display: grid; place-items: center; box-shadow: 0 calc(var(--u) * 1) 0 rgba(20, 12, 8, .45), inset 0 0 0 2px rgba(255, 248, 232, .3); }
.cine__x:hover, .cine__x:focus-visible { background: #8a5530; }
.cine__v { display: block; width: 100%; aspect-ratio: 16 / 10; background: #1c1630; border-radius: calc(var(--u) * 2); }

/* ---------- photo galleries (hobbies, side projects) ---------- */
.dlg__gal img { transition: opacity .25s; } .dlg__gal img.out { opacity: 0; }
.dlg__count { position: absolute; left: 50%; bottom: calc(var(--u) * 2.5); transform: translateX(-50%); white-space: nowrap; font-style: normal; font-weight: 800; font-size: .62em;
  background: rgba(255, 216, 77, .95); color: #3b2a20; border-radius: 99px; padding: .2em .7em; box-shadow: 0 calc(var(--u) * .8) 0 rgba(59, 42, 32, .35); }
.gal__box { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: calc(var(--u) * 7); align-items: center; padding: 0 calc(var(--u) * 12) 0 0; width: min(94vw, 1000px); } /* right padding clears the wooden frame art */
.gal__fig { margin: 0; }
/* the photo is as tall as the screen allows; portrait for hobbies, landscape for app screens */
.gal__img { display: block; height: min(calc(100dvh - calc(var(--u) * 26) - 40px), 640px); aspect-ratio: 3 / 4; max-width: 46vw; object-fit: cover; border-radius: calc(var(--u) * 2); background: #e6d4ae; touch-action: pan-y; }
.gal__img.wide { aspect-ratio: 4 / 3; max-width: 52vw; height: auto; width: min(52vw, calc((100dvh - calc(var(--u) * 26) - 40px) * 4 / 3), 620px); object-fit: contain; }
.gal__side { min-width: 0; display: flex; flex-direction: column; gap: calc(var(--u) * 3); }
.gal__tabs { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 1.5); }
.gal__tabs button { border: 0; border-radius: 99px; padding: .3em .8em; font-size: .7em; font-weight: 800; background: rgba(59, 42, 32, .1); color: var(--wood); }
.gal__tabs button[aria-selected="true"] { background: var(--wood); color: #fff8e8; }
.gal__meta { margin: 0; font-weight: 800; color: var(--wood); text-transform: uppercase; letter-spacing: .06em; font-size: .7em; }
.gal__intro { margin: 0; font-weight: 700; font-size: .9em; line-height: 1.4; }
.gal__intro, .gal__cap { display: grid; } .gal__intro span, .gal__cap span { grid-area: 1 / 1; visibility: hidden; } .gal__intro span.on, .gal__cap span.on { visibility: visible; }
.gal__cap { margin: 0; font-size: .85em; line-height: 1.4; opacity: .85; }
.gal__nav { display: flex; align-items: center; gap: calc(var(--u) * 3); margin-top: calc(var(--u) * 1); }
.gal__n { flex: none; white-space: nowrap; min-width: 3.6em; text-align: center; font-weight: 800; font-size: .8em; color: var(--wood-l); font-variant-numeric: tabular-nums; }
.gal__nav .wbtn { flex: none; }

/* end screen on phones: a little more room so the buttons don't sit on the bottom beam */
@media (pointer: coarse) { .clear { padding-bottom: calc(var(--u) * 6); } }
