/* Layout: one-column field manifest. A cold-chain thermometer and a road map are the two instruments; everything else is a paper logbook. */
:root {
  --bg: #efe9dc;        /* sun-faded manifest paper */
  --panel: #f8f4ea;
  --ink: #1f2a2b;
  --muted: #5d6764;
  --line: #cfc5b0;
  --cold: #1f6f8b;      /* cold-chain blue */
  --cold-soft: #d6e8ee;
  --sun: #c8742a;       /* sertão earth */
  --sun-soft: #f3dfc6;
  --ok: #2f7a4a;
  --bad: #b23a2c;
  --road: #8b7b5e;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151b1c; --panel: #1d2526; --ink: #ece6d8; --muted: #a3aba7; --line: #34403f;
    --cold: #6cbcd6; --cold-soft: #1c3640; --sun: #e3955a; --sun-soft: #3a2a1c;
    --ok: #6cc28c; --bad: #ec7a6a; --road: #a8987a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151b1c; --panel: #1d2526; --ink: #ece6d8; --muted: #a3aba7; --line: #34403f;
  --cold: #6cbcd6; --cold-soft: #1c3640; --sun: #e3955a; --sun-soft: #3a2a1c;
  --ok: #6cc28c; --bad: #ec7a6a; --road: #a8987a; color-scheme: dark;
}
* { box-sizing: border-box; }
/* The phone's grey/blue tap box hides the arrows; every control already shows its own pressed state. */
* { -webkit-tap-highlight-color: transparent; }
/* .panel sets display:flex, which would beat the hidden attribute and show the empty HUD on the first screen. */
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; }
.wrap { max-width: 560px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 40px; display: flex; flex-direction: column; gap: 16px; }
header.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 900; font-size: 2.6rem; line-height: .9; letter-spacing: .01em; text-transform: uppercase; margin: 0; }
.brand span { color: var(--sun); }
.tag { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
h2 { font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1.05; margin: 0; text-wrap: balance; text-transform: uppercase; letter-spacing: .01em; }
/* Headings get focus from the script so screen readers announce each new screen; no ring needed. */
h2:focus { outline: none; }
p { margin: 0; }
.muted { color: var(--muted); }
.label { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* HUD */
.hud { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: stretch; }
.thermo { width: 54px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tube { position: relative; width: 22px; height: 150px; border: 2px solid var(--ink); border-radius: 11px; overflow: hidden; background: var(--panel); }
.band { position: absolute; left: 0; right: 0; background: var(--cold-soft); }
.fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--cold); transition: height .6s ease, background .3s; }
.tval { font-family: var(--mono); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-content: start; }
.stat { border-top: 2px solid var(--ink); padding-top: 6px; min-width: 0; }
.stat b { display: block; font-family: var(--mono); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.map { grid-column: 2; }
.map svg { width: 100%; height: auto; display: block; }

/* Choices */
.choices { display: flex; flex-direction: column; gap: 10px; }
button { font: inherit; color: inherit; }
.choice { text-align: left; background: var(--bg); border: 1.5px solid var(--line); border-radius: 6px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; transition: border-color .15s, transform .15s; }
/* Hover only where there is a real mouse: on a touch screen it sticks to whatever option ends up under
   the finger, and a new option looks chosen before the player taps it. */
@media (hover: hover) and (pointer: fine) { .choice:hover:not(.picked):not(.right):not(.wrong) { border-color: var(--muted); } }
.choice:active { transform: translateY(1px); }
.choice:focus-visible, .btn:focus-visible { outline: 3px dashed var(--ink); outline-offset: 2px; }
.choice strong { font-weight: 700; }
.choice .num { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; margin-right: 10px; border: 1.5px solid var(--line); border-radius: 50%; font-family: var(--mono); font-size: .85rem; font-weight: 700; color: var(--muted); vertical-align: middle; }
.choice small { color: var(--muted); font-size: .85rem; }
.choice.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--bg)); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg)); }
.choice.picked { border-color: var(--cold); border-width: 2.5px; background: var(--cold-soft); }
.choice.picked.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--bg)); }
.choice.picked.mid { border-color: var(--sun); background: var(--sun-soft); }
.choice.picked.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg)); }
.choice[disabled] { cursor: default; }

/* Guide: the assistant's speech bubble */
.guide { display: flex; gap: 12px; align-items: flex-start; background: var(--cold-soft); border: 1.5px solid var(--cold); border-radius: 4px 14px 14px 14px; padding: 12px; }
.guide .face { width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--panel); border: 2px solid var(--ink); }
.guide > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; }
.guide.ok { background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border-color: var(--ok); }
.guide.mid { background: var(--sun-soft); border-color: var(--sun); }
.guide.bad { background: color-mix(in srgb, var(--bad) 10%, var(--panel)); border-color: var(--bad); }
.tagv { font-family: var(--mono); font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; color: var(--panel); background: var(--ok); }
.guide.mid .tagv { background: var(--sun); }
.guide.bad .tagv { background: var(--bad); }
.btn { align-self: flex-start; background: var(--ink); color: var(--bg); border: 0; border-radius: 4px; padding: 12px 20px; font-family: var(--display); font-weight: 700; font-size: 1.2rem; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.btn.alt { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.feedback { border-left: 4px solid var(--cold); background: var(--cold-soft); padding: 10px 12px; border-radius: 0 4px 4px 0; font-size: .95rem; }
.feedback.warn { border-color: var(--sun); background: var(--sun-soft); }
.log { font-family: var(--mono); font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; max-height: 110px; overflow-y: auto; }
.progress { display: flex; gap: 4px; }
.progress i { flex: 1; height: 4px; background: var(--line); border-radius: 2px; }
.progress i.on { background: var(--sun); }

/* Language choice on the first screen */
.langs { display: flex; gap: 6px; align-self: flex-end; }
.langs button { min-width: 48px; min-height: 40px; background: transparent; border: 1.5px solid var(--line); border-radius: 4px; font-family: var(--mono); font-size: .85rem; font-weight: 700; letter-spacing: .06em; cursor: pointer; }
.langs button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.langs button:focus-visible { outline: 3px solid var(--cold); outline-offset: 2px; }

/* Result */
.big { font-family: var(--display); font-weight: 900; font-size: 4rem; line-height: .9; font-variant-numeric: tabular-nums; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare div { border: 1px solid var(--line); border-radius: 4px; padding: 10px; }
.compare b { font-family: var(--mono); font-size: 1.6rem; font-variant-numeric: tabular-nums; display: block; }
.card { background: var(--ink); color: var(--bg); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.card .brand { font-size: 1.8rem; }
.card .label { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.story { font-size: .98rem; border-top: 1px dashed var(--line); padding-top: 12px; }
footer { font-size: .78rem; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .fill, .choice { transition: none; } #truck { transition: none !important; } }

/* Load: Central de Frio */
.room { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; }
#worker { transition: transform .5s ease; }
.btn[disabled] { opacity: .4; cursor: default; }

/* Drive */
#stage.driving { padding: 8px; gap: 8px; }
.drive { position: relative; border-radius: 6px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.drive canvas { display: block; width: 100%; height: clamp(380px, calc(100vh - 190px), 640px); height: clamp(380px, calc(100dvh - 190px), 640px); }
.dhud { position: absolute; top: 8px; left: 8px; right: 8px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; pointer-events: none; }
.dhud div { background: color-mix(in srgb, var(--panel) 90%, transparent); border-radius: 4px; padding: 4px 8px; min-width: 0; }
.dhud b { display: block; font-family: var(--mono); font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dbar { position: absolute; top: 62px; left: 8px; right: 8px; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--panel) 80%, transparent); overflow: hidden; pointer-events: none; }
.dbar i { display: block; height: 100%; width: 0; background: var(--sun); }
.toast { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 380px; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 4px; font-size: 1.1rem; font-weight: 700; line-height: 1.35; text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.on { opacity: 1; }
.hitcard { position: absolute; top: 76px; left: 50%; transform: translate(-50%, -6px); width: calc(100% - 32px); max-width: 340px; display: flex; gap: 10px; align-items: center; background: var(--panel); border: 2px solid var(--bad); border-radius: 6px; padding: 8px 10px; opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; }
.hitcard.on { opacity: 1; transform: translate(-50%, 0); }
.hitcard svg { display: block; width: 60px; height: 60px; flex: none; }
.hitcard strong { font-size: 1.15rem; }
.hitcard div { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.hitcard b { font-family: var(--mono); font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--bad); }
.hitcard small { color: var(--muted); font-size: 1rem; }
.cbox { position: absolute; right: 8px; top: 164px; width: 76px; display: flex; flex-direction: column; align-items: center; background: color-mix(in srgb, var(--panel) 90%, transparent); border: 2px solid var(--line); border-radius: 6px; padding: 4px 4px 2px; pointer-events: none; }
.cbox svg { display: block; width: 100%; height: auto; }
.cbox .icep { fill: var(--cold); }
.cbox.hot .icep { fill: var(--bad); }
.cbox.ice-bottom .icep .side, .cbox.ice-none .icep { display: none; }
.cbox b { font-family: var(--mono); font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--bad); min-height: 1.3em; }
.cbox.shake { border-color: var(--bad); }
.cbox.shake svg { animation: boxshake .9s ease-in-out; }
.cbox.shake .vials { animation: vialshake .9s ease-in-out; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes boxshake { 0%, 100% { transform: none; } 10% { transform: translate(-5px, -3px) rotate(-10deg); } 25% { transform: translate(5px, 2px) rotate(9deg); } 40% { transform: translate(-4px, -2px) rotate(-7deg); } 55% { transform: translate(4px, 1px) rotate(5deg); } 70% { transform: translate(-2px, 0) rotate(-3deg); } 85% { transform: translate(2px, 0) rotate(2deg); } }
@keyframes vialshake { 0%, 100% { transform: none; } 15% { transform: rotate(16deg); } 35% { transform: rotate(-14deg); } 55% { transform: rotate(10deg); } 75% { transform: rotate(-6deg); } }
.flat { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; touch-action: manipulation; }
.flatdone { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; border: 2px solid var(--ok); border-radius: 6px; padding: 10px 12px; background: color-mix(in srgb, var(--ok) 12%, var(--panel)); }
.flatdone strong { grid-column: 1 / -1; }
.flatdone div { display: flex; flex-direction: column; }
.flatdone b { font-family: var(--mono); font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--bad); }
#flatWheel { cursor: pointer; }
#flatWheel.done { cursor: default; }
#flatWheel:focus { outline: none; }
#flatWheel:focus-visible #flatRing { stroke: var(--cold); }
#wrench { transform-origin: 160px 108px; transition: transform .25s ease; }
#flatRing { animation: ring 1s ease-in-out infinite alternate; }
@keyframes ring { to { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .hitcard, #wrench { transition: none; } .cbox.shake svg, .cbox.shake .vials, #flatRing { animation: none; } }
.pad { position: absolute; left: 10px; bottom: 10px; width: 156px; height: 156px; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); gap: 3px; touch-action: none; cursor: pointer; }
.pad i { display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--ink) 80%, transparent); border: 2px solid var(--panel); border-radius: 10px; pointer-events: none; }
.pad i svg { width: 26px; height: 26px; fill: var(--panel); }
.pad i.on { background: var(--sun); }
.pad [data-d="u"] { grid-area: 1 / 2; }
.pad [data-d="l"] { grid-area: 2 / 1; } .pad [data-d="l"] svg { transform: rotate(-90deg); }
.pad [data-d="r"] { grid-area: 2 / 3; } .pad [data-d="r"] svg { transform: rotate(90deg); }
.pad [data-d="d"] { grid-area: 3 / 2; } .pad [data-d="d"] svg { transform: rotate(180deg); }
.ice { position: absolute; right: 14px; bottom: 22px; width: 100px; height: 100px; border-radius: 50%; background: var(--cold); color: var(--panel); border: 3px solid var(--panel); font-family: var(--display); font-weight: 700; font-size: 1.05rem; line-height: 1.05; letter-spacing: .03em; text-transform: uppercase; cursor: pointer; touch-action: manipulation; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; }
.ice small { font-family: var(--mono); font-size: .75rem; font-weight: 700; letter-spacing: 0; text-transform: none; }
.ice.empty { background: var(--muted); }
.ice.call { animation: call .7s ease-in-out infinite alternate; }
@keyframes call { to { transform: scale(1.08); } }
.ice:focus-visible { outline: 3px solid var(--panel); outline-offset: 2px; }
.pop { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 84%, transparent); display: flex; align-items: center; justify-content: center; padding: 10px; touch-action: auto; }
.pop .panel { width: 100%; max-height: 100%; overflow-y: auto; }
.hint { font-size: .85rem; padding: 0 6px 4px; }
@media (prefers-reduced-motion: reduce) { #worker, .toast { transition: none; } .ice.call { animation: none; } }

/* Ranking on the result screen */
.rankForm { display: flex; gap: 10px; flex-wrap: wrap; }
.rankForm input { flex: 1 1 180px; min-width: 0; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 4px; }
.rankList { margin: 0; padding-left: 28px; display: flex; flex-direction: column; gap: 4px; }
.rankList li span { margin-right: 8px; }
.rankList li b { font-family: var(--mono); font-size: .85rem; }
.rankList li.me { color: var(--ok); font-weight: 700; }

/* Intro: the two promises shown before the game starts */
.notes p { margin: 0; }
.notes p + p { margin-top: 8px; }

/* Rating on the result screen */
.rate h3 { margin: 0; font-size: 1.1rem; }
.stars { display: flex; gap: 6px; }
.stars button { width: 48px; height: 48px; font-size: 1.9rem; line-height: 1; background: transparent; border: 1.5px solid var(--line); border-radius: 6px; color: var(--line); cursor: pointer; touch-action: manipulation; }
.stars button[aria-pressed="true"] { color: var(--sun); border-color: var(--sun); }
.rate textarea { width: 100%; min-height: 76px; padding: 8px 12px; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 4px; resize: vertical; }

/* Sound on/off in the header */
.snd { min-width: 44px; min-height: 40px; font-size: 1.2rem; line-height: 1; background: transparent; border: 1.5px solid var(--line); border-radius: 4px; cursor: pointer; touch-action: manipulation; }
.snd[aria-pressed="false"] { opacity: .6; }
.sndbox { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sndbox input[type=range] { width: 110px; height: 40px; accent-color: var(--sun); cursor: pointer; touch-action: manipulation; }
.sndbox input.off { opacity: .45; }

/* Important messages on the road: the truck stops until the player taps the button */
.pop .note { max-width: 380px; }
.note .noteText { margin: 0; font-size: 1.3rem; line-height: 1.4; font-weight: 700; }
.note p.muted { font-size: 1.05rem; }
.note .btn { font-size: 1.35rem; padding: 14px 26px; }
.noteHit { display: flex; gap: 12px; align-items: center; }
.noteHit svg { width: 76px; height: 76px; flex: none; }
.noteHit strong { font-size: 1.3rem; }
.noteHit div { display: flex; flex-direction: column; line-height: 1.25; }
.noteHit b { font-family: var(--mono); font-size: 1.7rem; color: var(--bad); }
