:root {
  --ink: #2b1458;          /* deep purple used for every thick outline */
  --cream: #fff6e0;
  --white: #ffffff;
  --yellow: #ffd93b;
  --pink: #ff5fa8;
  --purple: #8b5cff;
  --blue: #3fb8ff;
  --green: #4fdc6b;
  --orange: #ff9230;
  --red: #ff4d4d;
  --o2: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0px -2px 0 var(--ink), 0px 2px 0 var(--ink), -2px 0px 0 var(--ink), 2px 0px 0 var(--ink), 0 3px 0 var(--ink);
  --o3: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0px -3px 0 var(--ink), 0px 3px 0 var(--ink), -3px 0px 0 var(--ink), 3px 0px 0 var(--ink), 0 5px 0 var(--ink);
  --o4: -4px -4px 0 var(--ink), 4px -4px 0 var(--ink), -4px 4px 0 var(--ink), 4px 4px 0 var(--ink), 0px -4px 0 var(--ink), 0px 4px 0 var(--ink), -4px 0px 0 var(--ink), 4px 0px 0 var(--ink), 0 7px 0 var(--ink);
  --font: "Fredoka", "Arial Rounded MT Bold", "Nunito", "Comic Sans MS", "Trebuchet MS", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #c1440e; color: var(--ink); overflow: hidden;
  font-family: var(--font); font-weight: 600; }
[hidden] { display: none !important; }
html, body { overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#game { position: fixed; inset: 0; touch-action: none; }   /* no page scrolling or zooming while you play */
#game canvas { display: block; }

/* ----- bubble text: fat colored letters with a thick OUTER outline (made with shadows so the letters stay crisp) ----- */
.pill span, .val, .lbl, #modal h2, #modal h3, .btn, #objective, .chip.alert, .chip.info, .chip.ok, #toast, #loading {
  letter-spacing: .03em;
}
.pill span, .val, .lbl, .chip.alert, .chip.info, .chip.ok { text-shadow: var(--o2); }
#objective, #toast, .btn, #modal h3, #loading { text-shadow: var(--o3); }
#modal h2 { text-shadow: var(--o4); }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; padding: 10px 12px; pointer-events: none; z-index: 10; }
.hud-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.pill { border: 5px solid var(--ink); border-radius: 24px; padding: 4px 16px 6px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; min-width: 96px; box-shadow: 0 5px 0 var(--ink); }
.pill span { font-size: 32px; font-weight: 700; line-height: 1.05; color: var(--white); }
.pill small { color: var(--ink); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pill.sol { background: var(--purple); }
.pill.sol small { color: var(--white); }
.pill.clock { background: var(--yellow); }
.pill.clock span { color: var(--white); font-variant-numeric: tabular-nums; }
.pill.clock.paused { background: #c9c3d6; }

.bars { display: grid; gap: 6px; flex: 1 1 280px; max-width: 440px; }
.bar { display: grid; grid-template-columns: 44px 1fr; gap: 6px; align-items: center; }
.bar .ico { width: 44px; height: 44px; border: 5px solid var(--ink); border-radius: 50%; background: var(--white);
  display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 4px 0 var(--ink); }
.track { position: relative; height: 34px; background: var(--white); border: 5px solid var(--ink); border-radius: 20px;
  overflow: hidden; box-shadow: 0 4px 0 var(--ink); }
.fill { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 14px; transition: width .35s; }
.lbl, .val { position: absolute; top: 50%; transform: translateY(-52%); font-size: 20px; color: var(--white); }
.lbl { left: 12px; }
.val { right: 12px; font-variant-numeric: tabular-nums; }
.bar[data-res="power"]  .fill { background: var(--yellow); }
.bar[data-res="oxygen"] .fill { background: var(--blue); }
.bar[data-res="food"]   .fill { background: var(--green); }
.bar.low .fill { background: var(--red); animation: wobble .4s infinite alternate; }
.bar.low .ico { animation: wobble .4s infinite alternate; background: #ffd2d2; }

#objective { margin-top: 12px; display: inline-block; background: var(--pink); color: var(--white);
  border: 5px solid var(--ink); box-shadow: 0 5px 0 var(--ink); border-radius: 22px; padding: 4px 18px 8px;
  font-size: 22px; font-weight: 700; max-width: 100%; }
#status { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip.alert, .chip.info, .chip.ok { display: inline-block; border: 4px solid var(--ink); border-radius: 18px; padding: 2px 14px 5px;
  font-size: 18px; font-weight: 700; color: var(--white); box-shadow: 0 4px 0 var(--ink); }
.chip.alert { background: var(--red); animation: wobble .4s infinite alternate; }
.chip.info { background: var(--blue); }
.chip.ok { background: var(--green); }

#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0;
  box-shadow: inset 0 0 120px 36px rgba(255, 60, 60, .8); transition: opacity .3s; }
body.warning #vignette { opacity: 1; animation: pulse .5s infinite alternate; }
@keyframes pulse { from { opacity: .45; } to { opacity: 1; } }
@keyframes wobble { from { transform: rotate(-2deg) scale(1); } to { transform: rotate(2deg) scale(1.06); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 30; background: var(--orange);
  color: var(--white); border: 5px solid var(--ink); box-shadow: 0 6px 0 var(--ink); border-radius: 26px; padding: 4px 22px 9px;
  font-size: 24px; font-weight: 700; max-width: 92vw; text-align: center; pointer-events: none; animation: pop .25s; }
#toast.bad { background: var(--red); }
#toast.good { background: var(--green); }

/* ---------- Modal ---------- */
#modal-backdrop { position: fixed; inset: 0; background: rgba(43, 20, 88, .6); z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal { background: var(--cream); border: 7px solid var(--ink); border-radius: 36px; width: min(680px, 100%);
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; padding: 18px 26px 24px; box-shadow: 0 10px 0 var(--ink);
  animation: pop .2s; font-size: 19px; line-height: 1.4; color: var(--ink); }
#modal h2 { margin: 0 0 10px; font-size: 44px; line-height: 1.05; display: flex; gap: 12px; align-items: center;
  color: var(--pink); }
#modal h2 .big { font-size: 54px; text-shadow: none; }
#modal h3 { margin: 18px 0 6px; font-size: 28px; color: var(--blue); }
#modal p { margin: 8px 0; }
#modal .tag { display: inline-block; font-size: 14px; font-weight: 700; padding: 2px 12px; border-radius: 14px; border: 3px solid var(--ink);
  background: var(--purple); color: var(--white); text-transform: uppercase; letter-spacing: .04em; }
#modal .card { background: var(--white); border: 4px solid var(--ink); border-radius: 22px; padding: 12px 16px; margin: 12px 0; box-shadow: 0 4px 0 var(--ink); }
#modal .card.alert { background: #ffe1e1; border-color: var(--red); box-shadow: 0 4px 0 var(--red); }
#modal .card.science { background: #dff3ff; }
#modal .msg { background: #d9ffe0; border: 4px solid var(--green); border-radius: 20px; padding: 8px 14px; font-weight: 700; }
#modal .msg.bad { background: #ffe1e1; border-color: var(--red); }
#modal .hint { opacity: .75; font-size: 16px; }
#modal ul { margin: 8px 0; padding-left: 24px; }
#modal li { margin: 4px 0; }
#modal a { color: var(--purple); word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip.cost, .chip.gain { border: 4px solid var(--ink); padding: 2px 14px; border-radius: 16px; font-weight: 700; font-size: 18px; color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.chip.cost { background: #ffb3b3; }
.chip.gain { background: #aaf5b8; }
.buttons { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.btn { font: inherit; font-weight: 700; font-size: 24px; padding: 6px 24px 12px; border-radius: 26px; border: 5px solid var(--ink);
  background: var(--orange); color: var(--white); cursor: pointer; box-shadow: 0 7px 0 var(--ink);
  transition: transform .08s; }
.btn:hover:not(:disabled) { transform: translateY(-2px) rotate(-1deg); }
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.btn.secondary { background: var(--purple); }
.btn.good { background: var(--green); }
.btn:disabled { background: #cfc8dc; cursor: not-allowed; text-shadow: -3px -3px 0 #7d7396, 3px -3px 0 #7d7396, -3px 3px 0 #7d7396, 3px 3px 0 #7d7396, 0px -3px 0 #7d7396, 0px 3px 0 #7d7396, -3px 0px 0 #7d7396, 3px 0px 0 #7d7396; border-color: #7d7396; box-shadow: 0 7px 0 #7d7396; }
.progress { height: 28px; background: var(--white); border: 5px solid var(--ink); border-radius: 18px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; background: var(--blue); }
table.sum { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 22px; }
table.sum td { padding: 6px 8px; border-bottom: 3px dashed rgba(43, 20, 88, .25); }
table.sum td:last-child { text-align: right; font-weight: 700; }
.dn { color: #d6204a; } .up { color: #12a33a; }
.keys kbd { background: var(--white); border: 3px solid var(--ink); border-radius: 10px; padding: 0 9px; font: inherit; font-weight: 700; box-shadow: 0 3px 0 var(--ink); }

#loading, #fatal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50;
  background: var(--purple); color: var(--white); font-size: 44px; font-weight: 700; text-align: center; padding: 24px; line-height: 1.4; }
#fatal { font-size: 22px; text-shadow: none; paint-order: normal; }
#fatal code { background: var(--ink); padding: 2px 8px; border-radius: 8px; }

@media (max-width: 560px) {
  .pill span { font-size: 26px; }
  #modal { padding: 14px 16px 20px; font-size: 17px; }
  #modal h2 { font-size: 34px; }
  .btn { font-size: 20px; }
}

/* real-data cards */
#modal .card.real { background: #e8f7ff; border-color: var(--blue); box-shadow: 0 4px 0 var(--blue); }
#modal .tag.live { background: var(--green); color: var(--ink); }

/* ---------- training, difficulty, badges ---------- */
#skipTut { position: fixed; right: 14px; bottom: 18px; z-index: 15; font: inherit; font-weight: 700; font-size: 20px; cursor: pointer;
  background: var(--purple); color: var(--white); border: 5px solid var(--ink); border-radius: 22px; padding: 2px 18px 7px;
  box-shadow: 0 5px 0 var(--ink); text-shadow: var(--o2); letter-spacing: .03em; }
#skipTut:hover { transform: translateY(-2px) rotate(-1deg); }
/* "Start Night Cycle": shows up once today's jobs are done, so nobody has to stand around waiting for the clock */
#nightBtn { display: block; margin-top: 12px; pointer-events: auto; font: inherit; font-weight: 700; font-size: 22px; cursor: pointer;
  background: #3b4bb8; color: var(--white); border: 5px solid var(--ink); border-radius: 22px; padding: 2px 18px 7px;
  box-shadow: 0 5px 0 var(--ink); text-shadow: var(--o2); letter-spacing: .03em; animation: pop .25s; }
#nightBtn:hover { transform: translateY(-2px) rotate(-1deg); }
#nightBtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
#nightBtn .ic { width: 1.1em; height: 1.1em; vertical-align: -.2em; }
#nightBtn kbd { background: var(--white); color: var(--ink); text-shadow: none; border: 3px solid var(--ink); border-radius: 9px;
  padding: 0 7px; margin-left: 4px; font: inherit; font-size: 17px; box-shadow: 0 2px 0 var(--ink); }
#modal details.more { margin: 12px 0; }
#modal details.more summary { cursor: pointer; font-weight: 700; color: var(--purple); padding: 6px 4px; }
#modal .diffs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0; }
.diff { font: inherit; color: var(--ink); cursor: pointer; background: var(--white); border: 5px solid var(--ink); border-radius: 22px;
  padding: 6px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; box-shadow: 0 5px 0 var(--ink); }
.diff .di { font-size: 30px; line-height: 1; }
.diff b { font-size: 21px; }
.diff small { font-size: 13px; line-height: 1.2; opacity: .8; }
.diff em { font-style: normal; font-size: 13px; font-weight: 700; background: var(--yellow); border: 3px solid var(--ink); border-radius: 12px; padding: 0 8px; margin-top: 3px; }
.diff:hover { transform: translateY(-2px) rotate(-1deg); }
.diff.on { background: var(--yellow); transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
#modal .badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 8px 0; }
.badge { display: flex; gap: 10px; align-items: center; border: 4px solid var(--ink); border-radius: 18px; padding: 4px 10px; background: #aaf5b8; }
.badge .bi { font-size: 26px; }
.badge small { display: block; font-size: 13px; line-height: 1.2; opacity: .8; }
.badge.locked { background: #e6e1ee; border-color: #8d84a3; color: #5b5273; }
#modal .card.score { text-align: center; background: #fff7c9; }
.bigscore { font-size: 34px; font-weight: 700; color: var(--orange); text-shadow: var(--o3); letter-spacing: .03em; }
@media (max-width: 560px) {
  #modal .diffs, #modal .badges { grid-template-columns: 1fr; }
  #skipTut { font-size: 16px; }
}

/* the action buttons stay visible even when a window is taller than the screen */
#modal .buttons { position: sticky; bottom: -24px; z-index: 2; background: linear-gradient(to bottom, rgba(255,246,224,0), var(--cream) 22%);
  padding: 18px 0 14px; margin-top: 4px; }

/* ---------- icons (pictures that replace emoji; see icons.js) ---------- */
.ic { width: 1.12em; height: 1.12em; vertical-align: -.24em; flex: none; overflow: visible; margin: 0 .04em; }
.bar .ico .ic { width: 28px; height: 28px; vertical-align: middle; margin: 0; }
#modal h2 .big { display: inline-flex; }
#modal h2 .big .ic { width: 56px; height: 56px; margin: 0; vertical-align: middle; filter: drop-shadow(0 3px 0 rgba(43, 20, 88, .25)); }
.diff .di { display: flex; justify-content: center; }
.diff .di .ic { width: 38px; height: 38px; margin: 0; }
.badge .bi { display: flex; align-items: center; }
.badge .bi .ic { width: 32px; height: 32px; margin: 0; }
.badge.locked .bi .ic { filter: grayscale(1) opacity(.55); }
.btn .ic { margin-right: .12em; }
#skipTut .ic { width: 1.1em; height: 1.1em; vertical-align: -.2em; }

/* ---------- mood tint over the world (night, dust storm) ---------- */
#haze { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; transition: opacity 1.6s ease; }
body[data-mood="night"] #haze { background: #18276e; opacity: .5; mix-blend-mode: multiply; }
body[data-mood="storm"] #haze { background: radial-gradient(ellipse at center, rgba(222, 130, 70, .30), rgba(190, 90, 40, .55)); opacity: 1; animation: gust 2.4s ease-in-out infinite alternate; }
@keyframes gust { from { filter: brightness(1); } to { filter: brightness(.82); } }

/* ---------- surprise banner ---------- */
#banner { position: fixed; left: 0; right: 0; margin: 0 auto; width: fit-content; top: 46%; z-index: 28; max-width: min(92vw, 720px); text-align: center;
  background: var(--orange); color: var(--white); border: 6px solid var(--ink); border-radius: 30px; box-shadow: 0 8px 0 var(--ink);
  padding: 8px 28px 14px; font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: .03em; text-shadow: var(--o3);
  pointer-events: none; animation: bannerIn .45s cubic-bezier(.2, 1.6, .4, 1) both, wobble .5s .45s 6 alternate; }
#banner.bad { background: var(--red); }
#banner.good { background: var(--green); }
#banner .ic { width: 1.25em; height: 1.25em; }
@keyframes bannerIn { from { transform: scale(.3) rotate(-6deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (max-width: 560px) { #banner { font-size: 22px; padding: 6px 16px 10px; } }

/* ---------- sound button ---------- */
#mute { position: fixed; top: 12px; right: 12px; z-index: 26; width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
  background: var(--purple); border: 5px solid var(--ink); box-shadow: 0 5px 0 var(--ink); display: flex; align-items: center; justify-content: center; padding: 0; }
#mute .ic { width: 26px; height: 26px; margin: 0; }
#mute:hover { transform: translateY(-2px) rotate(-3deg); }

/* ---------- touch controls (only shown on touch screens) ---------- */
#touch { position: fixed; inset: auto 0 0 0; height: 0; z-index: 12; }
#stick { position: fixed; left: 22px; bottom: 22px; width: 150px; height: 150px; border-radius: 50%; touch-action: none;
  background: rgba(255, 255, 255, .22); border: 5px solid rgba(43, 20, 88, .75); box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .25); }
#knob { position: absolute; left: 50%; top: 50%; width: 66px; height: 66px; margin: -33px 0 0 -33px; border-radius: 50%;
  background: var(--pink); border: 5px solid var(--ink); box-shadow: 0 5px 0 var(--ink); pointer-events: none; }
#act { position: fixed; right: 22px; bottom: 26px; width: 128px; height: 128px; border-radius: 50%; touch-action: none; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 26px; color: var(--white); text-shadow: var(--o3); letter-spacing: .04em;
  background: var(--green); border: 6px solid var(--ink); box-shadow: 0 8px 0 var(--ink); -webkit-user-select: none; user-select: none; }
#act.on { transform: translateY(6px); box-shadow: 0 2px 0 var(--ink); background: #3fc35c; }
body.touch #skipTut { bottom: auto; top: 76px; }
body.touch #toast { bottom: 190px; }
body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* ---------- calmer animations for players who ask their device for less motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
  body.warning #vignette { opacity: .8; }
}

/* ---------- small creator credit on the title and end screens ---------- */
#modal .credit { margin: -4px 0 6px; font-size: 13px; font-weight: 600; letter-spacing: .03em; color: var(--purple); opacity: .85; }
#modal .credit:last-child, #modal p.credit:not(:first-child) { margin: 10px 0 0; text-align: center; }

/* ---------- end-of-mission log: what the base lived through, plus the real NASA fix ---------- */
#modal .card.log ul { list-style: none; padding-left: 0; }
#modal .card.log li { margin: 10px 0; padding-bottom: 8px; border-bottom: 3px dashed rgba(43, 20, 88, .18); }
#modal .card.log li:last-child { border-bottom: 0; padding-bottom: 0; }
#modal .card.log .lh { display: block; font-size: 20px; font-weight: 700; }
#modal .card.log small { display: block; margin-top: 3px; font-size: 15px; line-height: 1.35; opacity: .85; }

/* ---------- phones and tablets ---------- */
/* touch screens: the on-screen SPACE button sits under an open window, so "press ESC / SPACE" hints would only confuse */
body.touch #modal p.hint.keys { display: none; }
/* on touch screens a tapped button would otherwise stay tilted, as if the finger were still hovering over it */
@media (hover: none) {
  .btn:hover:not(:disabled), #nightBtn:hover, #skipTut:hover, #mute:hover { transform: none; }
}

/* a compact HUD for phones (narrow screens, and short screens such as a phone held sideways) so you can see the base */
@media (max-width: 560px), (max-height: 500px) {
  #hud { padding: 8px; }
  .hud-top { gap: 6px; padding-right: 50px; }
  .pill { border-width: 4px; border-radius: 18px; padding: 2px 10px 4px; min-width: 66px; box-shadow: 0 3px 0 var(--ink); }
  .pill span { font-size: 22px; }
  .pill small { font-size: 10px; }
  .bars { gap: 4px; }
  .bar { grid-template-columns: 30px 1fr; gap: 4px; }
  .bar .ico { width: 30px; height: 30px; border-width: 4px; box-shadow: 0 2px 0 var(--ink); }
  .bar .ico .ic { width: 18px; height: 18px; }
  .track { height: 26px; border-width: 4px; border-radius: 16px; box-shadow: 0 2px 0 var(--ink); }
  .lbl, .val { font-size: 15px; }
  .lbl { left: 9px; } .val { right: 9px; }
  #objective { margin-top: 8px; font-size: 16px; padding: 3px 12px 5px; border-width: 4px; border-radius: 18px; box-shadow: 0 3px 0 var(--ink); }
  #status { margin-top: 6px; gap: 5px; }
  .chip.alert, .chip.info, .chip.ok { font-size: 13px; padding: 1px 9px 3px; border-width: 3px; border-radius: 14px; box-shadow: 0 2px 0 var(--ink); }
  .chip.meta { display: none; }               /* difficulty and landing site are on the briefing; no room for them here */
  #nightBtn { margin-top: 8px; font-size: 17px; border-width: 4px; padding: 1px 14px 5px; box-shadow: 0 3px 0 var(--ink); }
  #mute { top: 8px; right: 8px; width: 44px; height: 44px; border-width: 4px; }
  #mute .ic { width: 22px; height: 22px; }
  #toast { font-size: 18px; padding: 3px 16px 7px; border-width: 4px; }
  #modal h2 { padding-right: 34px; }          /* keep window titles clear of the round mute button */
}
/* bar labels shrink (and finally hide, leaving the icon) when the bars get very narrow */
.track { container-type: inline-size; }
@container (max-width: 135px) { .lbl, .val { font-size: 12px; } .lbl { left: 7px; } .val { right: 7px; } }
@container (max-width: 76px) { .lbl { display: none; } }
/* phones held upright: the bars get their own full-width row under Sol and the clock */
@media (max-width: 560px) {
  .bars { flex-basis: 100%; max-width: none; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hud-top { padding-right: 0; }              /* the bars have their own row below the mute button, so use the full width */
  /* difficulty cards become short rows: icon, name and blurb, best score */
  .diff { display: grid; grid-template-columns: 34px 1fr auto; column-gap: 10px; align-items: center; text-align: left; padding: 5px 12px 7px; }
  .diff .di { grid-row: 1 / span 2; }
  .diff b { grid-column: 2; font-size: 19px; line-height: 1.1; }
  .diff small { grid-column: 2; }
  .diff em { grid-column: 3; grid-row: 1 / span 2; margin: 0; }
  .diff .di .ic { width: 30px; height: 30px; }
  .btn { font-size: 18px; padding: 4px 14px 9px; }
  .buttons { gap: 10px; }
}
/* short screens (a phone held sideways): bars side by side, smaller windows and touch controls */
@media (max-height: 500px) {
  .bars { flex: 1 1 0; max-width: none; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: center; }
  #modal-backdrop { padding: 8px; }
  #modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 10px 18px 12px; font-size: 16px; border-width: 5px; border-radius: 26px; }
  #modal h2 { font-size: 30px; margin-bottom: 6px; }
  #modal h2 .big .ic { width: 38px; height: 38px; }
  #modal h3 { font-size: 22px; margin: 10px 0 4px; }
  #modal .card { padding: 8px 12px; margin: 8px 0; }
  #modal .buttons { padding: 10px 0 6px; gap: 10px; bottom: -12px; }
  .btn { font-size: 19px; padding: 3px 18px 8px; border-width: 4px; box-shadow: 0 5px 0 var(--ink); }
  #banner { font-size: 20px; padding: 5px 16px 9px; top: 40%; }
  #stick { width: 116px; height: 116px; left: 14px; bottom: 12px; }
  #knob { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
  #act { width: 100px; height: 100px; right: 14px; bottom: 14px; font-size: 20px; }
  body.touch #toast { bottom: 12px; max-width: calc(100vw - 280px); font-size: 16px; }
  body.touch #skipTut { top: auto; bottom: 126px; right: 14px; font-size: 16px; }
}

/* The HUD shrinks on short phone screens (in-app browsers such as the Google app have taller toolbars, and some apps
   enlarge everything), so it never covers too much of the base. game.js sets --hud-s from the visible screen height. */
#hud { right: auto; width: calc(100% / var(--hud-s, 1)); transform: scale(var(--hud-s, 1)); transform-origin: 0 0; }
/* upright phones with a short visible screen: smaller joystick and SPACE button too */
@media (max-width: 560px) and (max-height: 720px) {
  #stick { width: 124px; height: 124px; left: 16px; bottom: 16px; }
  #knob { width: 56px; height: 56px; margin: -28px 0 0 -28px; }
  #act { width: 108px; height: 108px; right: 16px; bottom: 18px; font-size: 22px; }
  body.touch #toast { bottom: 156px; }
}

/* ---------- Field Journal (hidden discoveries found off the paths) ---------- */
#modal details.journal ul { padding-left: 4px; list-style: none; }
#modal details.journal li { margin: 8px 0; font-size: 16px; line-height: 1.35; }
#modal details.journal li.locked { opacity: .6; }
