/* Layout idea: the yard fills the screen; controls sit in the four corners like decals on a cab pillar. */
:root {
  color-scheme: dark;
  --ink: #f4f1e8;            /* text on glass */
  --ink-dim: #c3c6c2;
  --glass: rgba(22, 26, 28, 0.64);
  --line: rgba(244, 241, 232, 0.16);
  --barn: #c2212b;           /* barn-red accent, sampled from the sheds */
  --steel: #cfd6da;          /* galvanized bin steel */
  --sky: #7fa9d6;
  --font-hud: "Barlow Semi Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--sky); color: var(--ink); font-family: var(--font-hud); font-weight: 500;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; touch-action: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#c:active { cursor: grabbing; }
.hud { position: fixed; display: flex; gap: 8px; z-index: 2; pointer-events: none; }
.hud > * { pointer-events: auto; }
.glass { background: var(--glass); border: 1px solid var(--line); border-radius: 12px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
button { font: inherit; color: var(--ink); background: none; border: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
.btn { min-height: 44px; padding: 0 14px; font-size: 16px; letter-spacing: 0.02em; border-radius: 12px; }
.btn.on { background: var(--barn); border-color: transparent; }

#tl { top: calc(12px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); align-items: center; flex-wrap: wrap; max-width: 60vw; }
#brand { padding: 0 14px; height: 44px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: 0.14em; text-transform: uppercase; }
#brand i { width: 10px; height: 18px; background: var(--barn); border-radius: 2px; display: block; }
.seg { display: flex; padding: 3px; gap: 3px; }
.seg button { min-width: 44px; min-height: 38px; padding: 0 14px; border-radius: 9px; font-size: 16px; color: var(--ink-dim); }
.seg button.on { background: var(--barn); color: var(--ink); }

#tr { top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; max-width: 62vw; z-index: 5; }
#viewWrap { position: relative; }
#viewMenu { position: absolute; right: 0; top: 52px; padding: 6px; width: min(340px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))); max-height: calc(100dvh - 86px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; background: rgba(22, 26, 28, 0.94); }
#viewMenu[hidden] { display: none; }
#viewMenu .viewGroup + .viewGroup { border-top: 1px solid var(--line); }
#viewMenu summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 12px; border-radius: 8px; font-size: 18px; font-weight: 600; list-style: none; cursor: pointer; touch-action: manipulation; }
#viewMenu summary::-webkit-details-marker { display: none; }
#viewMenu summary::after { content: '+'; color: var(--ink-dim); }
#viewMenu details[open] > summary { color: var(--steel); background: rgba(244, 241, 232, 0.08); }
#viewMenu details[open] > summary::after { content: '−'; }
#viewMenu .viewGroup > div { display: grid; gap: 2px; padding: 4px 0 8px 8px; }
#viewMenu button { text-align: left; min-height: 44px; padding: 8px 12px; border-radius: 8px; font-size: 16px; line-height: 1.25; }
#viewMenu #trexBtn, #viewMenu #trexSaddleBtn { min-height: 44px; }
#trexBtn[hidden], #trexSaddleBtn[hidden] { display: none; }
#viewMenu button:hover, #viewMenu button:active, #viewMenu summary:hover { background: rgba(244, 241, 232, 0.12); }
#viewMenu button:disabled { color: var(--ink-dim); opacity: 0.6; cursor: default; }
#daddyLunchBtn { font-size: 15px; max-width: 170px; }
#daddyLunchBtn[hidden] { display: none; }
#daddyLunchBtn:disabled { color: var(--ink-dim); cursor: default; }
#quickControls { top: calc(64px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); width: min(560px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))); gap: 6px; }
#quickControls button { flex: 1 1 0; min-width: 0; min-height: 44px; max-width: 150px; padding: 4px 6px; font-size: 14px; line-height: 1.1; }
#quickControls button[hidden] { display: none; }
#workerPanel { color: var(--ink); width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 20px; overflow-y: auto; touch-action: pan-y; background: rgba(22, 26, 28, .97); }
#workerPanel::backdrop { background: rgba(0, 0, 0, .5); }
#workerPanel h1 { margin: 0 0 10px; font-size: 26px; }
#workerPanel p { margin: 10px 0; line-height: 1.4; }
#farmResetBtn[hidden] { display: none; }
#farmResetConfirm { color: var(--ink); width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 20px; overflow-y: auto; touch-action: pan-y; background: rgba(22, 26, 28, .97); }
#farmResetConfirm::backdrop { background: rgba(0, 0, 0, .6); }
#farmResetConfirm h1 { margin: 0 0 12px; font-size: 26px; }
#farmResetConfirm p { line-height: 1.4; }
#farmResetNote { color: #f2d3a0; }
#farmResetConfirm .foot { display: flex; justify-content: flex-end; gap: 8px; }
#farmResetDo { background: var(--barn); }
#farmResetConfirm button:disabled { opacity: .5; cursor: default; }
.workerRow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.workerRow > span { min-width: 0; display: grid; gap: 3px; }
.workerRow > span > span { color: var(--ink-dim); font-size: 14px; line-height: 1.3; }
.workerRow button { flex: 0 0 auto; }
.workerChoices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.workerChoices label { display: grid; gap: 6px; min-width: 0; }
.workerChoices label[hidden] { display: none; }
.workerChoices select { width: 100%; min-height: 44px; padding: 8px; color: var(--ink); background: #242b2d; border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 16px; }
#workerNote { min-height: 24px; color: #f2d3a0; }
#workerPanel .workerSmall { color: var(--ink-dim); font-size: 13px; }
.workerActions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
#workerAssign { background: var(--barn); }
@media (max-width: 360px) { #brand { display: none; } .seg button { padding: 0 6px; font-size: 14px; } }
#sun { height: 44px; padding: 0 12px; display: flex; align-items: center; gap: 10px; font-size: 15px; }
#sun input { width: 128px; accent-color: var(--barn); touch-action: pan-x; }
#timeOut { min-width: 62px; text-align: right; font-variant-numeric: tabular-nums; }

#bl { left: calc(22px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); }
#stick { width: 132px; height: 132px; border-radius: 50%; position: relative; touch-action: none; }
#stick::after { content: attr(data-label); position: absolute; left: 0; right: 0; top: -22px; text-align: center; font-size: 11px; letter-spacing: 0.16em; color: var(--ink-dim); text-shadow: 0 1px 3px rgba(0,0,0,.6); }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: var(--steel); box-shadow: 0 2px 8px rgba(0,0,0,.45), inset 0 -3px 0 rgba(0,0,0,.18); pointer-events: none; }

#br { right: calc(22px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); align-items: flex-end; }
#alt { display: grid; gap: 8px; }
#alt button, #speed { width: 64px; height: 60px; font-size: 22px; font-weight: 600; border-radius: 14px; }
#alt button.on { background: var(--barn); }
#speed { height: 44px; font-size: 17px; }
/* Fixed slots keep familiar actions in place when contextual buttons disappear. Alerts grow upwards. */
#drv { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto repeat(4, 46px) 66px repeat(2, 46px);
  grid-template-areas: "alerts alerts" "field tractor" "crop fold" "hitch unload" "autosteer autosteer" "tool tool" "off off" "machine camera";
  gap: 8px; width: min(330px, 48vw); pointer-events: none; }
#drv button { min-width: 0; min-height: 46px; padding: 0 8px; font-size: 15px; border-radius: 12px; pointer-events: auto; touch-action: none; }
#driveAlerts { grid-area: alerts; display: grid; gap: 8px; }
#driveAlerts:not(:has(button:not([hidden]))) { display: none; }
#drv #fieldBtn { grid-area: field; }
#drv #swapBtn, #drv #truckYardBtn { grid-area: tractor; }
#drv #cropBtn { grid-area: crop; }
#drv #foldBtn { grid-area: fold; }
#drv #hitchBtn, #drv #callCartBtn { grid-area: hitch; }
#drv #unloadBtn { grid-area: unload; }
#drv #offBtn { grid-area: off; }
#drv #machBtn { grid-area: machine; }
#drv #camBtn { grid-area: camera; }
#drv #toolBtn { grid-area: tool; min-height: 66px; font-size: 21px; font-weight: 600; }
#drv #toolBtn.on, #drv #unloadBtn.on, #drv #foldBtn.on { background: var(--barn); border-color: transparent; }
#drv #autosteerBtn { display: none; grid-area: autosteer; min-height: 46px; font-weight: 600; }
body.has-drill #drv #autosteerBtn, body.m-sprayer #drv #autosteerBtn, body.m-combine #drv #autosteerBtn { display: block; }
#drv #autosteerBtn.on { background: #2e7d3a; border-color: transparent; }
#drv #autosteerBtn:disabled { opacity: 0.6; cursor: default; }
#swapBtn, #cropBtn, #foldBtn, #unloadBtn, #hitchBtn, #callCartBtn, #truckYardBtn { display: none; }
body.is-tractor #swapBtn, body.is-tractor #hitchBtn, body.has-drill #cropBtn, body.has-drill #foldBtn,
body.m-combine #unloadBtn, body.has-cart #unloadBtn, body.m-truck #unloadBtn,
body.m-combine #callCartBtn, body.m-truck #truckYardBtn { display: block; }
body.is-tractor:not(.has-drill) #toolBtn, body.m-truck #toolBtn, body.m-pickup #toolBtn { display: none; }
body.has-disc #drv #toolBtn { display: block; }
#drv #discFireDriveBtn { grid-column: 1 / -1; background: #a53226; min-height: 44px; }
#foot #discFireFootBtn { grid-column: 1 / -1; background: #a53226; min-height: 48px; padding: 6px; font-size: 16px; }
#drv #discFireDriveBtn[hidden], #foot #discFireFootBtn[hidden] { display: none; }
body.firefighting #discFireFootBtn { display: none !important; }
body.m-rescue #toolBtn { display: none; }
body.m-rzr #toolBtn, body.m-rzr #autosteerBtn { display: none; }
body.m-dirtbike #toolBtn, body.m-dirtbike2 #toolBtn, body.m-dirtbike #autosteerBtn, body.m-dirtbike2 #autosteerBtn { display: none; }
body.m-seadoo #toolBtn, body.m-seadoo #fieldBtn, body.m-seadoo #roadBar, body.m-seadoo #wetBar, body.m-seadoo #speed { display: none; }
#drv #ropeBtn { grid-column: 1 / -1; min-height: 54px; background: #80542d; font-weight: 600; }
#drv #ropeBtn[hidden] { display: none; }
body.m-boat #toolBtn, body.m-boat #fieldBtn, body.m-boat #roadBar, body.m-boat #wetBar, body.m-boat #speed { display: none; }
#offBtn:disabled { opacity: 0.6; cursor: default; }
body.driving #drv { display: grid; }
body.loader-playing #drv { grid-template-rows: auto repeat(2, 46px); grid-template-areas: "alerts alerts" "off off" "machine camera"; }
/* road mode: shown when the machine is on a road or beside one */
#roadBar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 4; display: none; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
body.driving #roadBar.on, body.driving #roadBar.can { display: flex; }
#roadBar > div { display: flex; gap: 8px; pointer-events: auto; }
#roadBar button { min-width: 52px; min-height: 48px; padding: 0 14px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
#roadBar button.on { background: var(--barn); border-color: transparent; }
#roadBar #turnL, #roadBar #turnR { display: none; font-size: 20px; }
#roadBar.on #turnL, #roadBar.on #turnR { display: block; }
#roadMsg { padding: 8px 14px; font-weight: 600; white-space: nowrap; }
#roadMsg[hidden] { display: none; }
/* on a narrow screen the bottom belongs to the stick and the work buttons: the road buttons go under the field tag */
@media (max-width: 1023px) { #roadBar { bottom: auto; top: calc(164px + env(safe-area-inset-top)); flex-direction: column-reverse; } #roadMsg { font-size: 14px; padding: 6px 12px; } }
body.driving #alt { display: none; }
body.m-plane #fieldBtn, body.m-plane #speed, body.m-plane #roadBar, body.m-plane #wetBar { display: none; }
body.m-plane #drv #toolBtn:disabled { opacity: 0.75; cursor: default; }
@media (max-width: 1400px) { body.driving #bl, body.driving #br { bottom: calc(78px + env(safe-area-inset-bottom)); } body.driving #fieldTag { bottom: auto; top: calc(118px + env(safe-area-inset-top)); } }
#fieldTag { position: fixed; z-index: 2; left: 50%; max-width: calc(100vw - 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; bottom: calc(66px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: none; align-items: center; gap: 8px; padding: 5px 12px; font-size: 15px; font-weight: 600; letter-spacing: 0.03em; }
#fieldTag i { flex: none; width: 8px; height: 14px; background: var(--barn); border-radius: 2px; }
body.driving #fieldTag { display: flex; }
#toast { position: fixed; z-index: 4; left: 50%; top: calc(160px + env(safe-area-inset-top)); transform: translate(-50%, -12px); padding: 12px 18px; font-size: 18px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; border-left: 5px solid var(--barn); max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#updateNotice { position: fixed; z-index: 9; left: 50%; top: calc(112px + env(safe-area-inset-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)); padding: 8px 12px; background: rgba(22, 26, 28, 0.96); border-color: var(--steel); font-size: 16px; }
#updateNotice[hidden] { display: none; }
#updateMessage { min-width: 0; max-width: 480px; }
#updateComment { display: block; margin-top: 6px; max-height: 30vh; overflow-y: auto; overflow-wrap: anywhere; white-space: pre-wrap; touch-action: pan-y; overscroll-behavior: contain; -webkit-user-select: text; user-select: text; }
#updateComment[hidden] { display: none; }
#reloadGameBtn { flex: none; background: var(--barn); font-weight: 600; }
/* Wet-ground warning and recovery stay within reach above the driving controls. */
#wetBar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 4; display: none; align-items: center; gap: 12px; max-width: calc(100vw - 24px); padding: 8px 12px; border-color: #be945c; }
#fireControls { display: grid; grid-column: 1 / -1; gap: 6px; }
#fireControls[hidden], #fireAim[hidden] { display: none; }
#foot #fireControls button { min-height: 48px; padding: 6px 10px; font-size: 15px; line-height: 1.15; white-space: normal; border: 1px solid #f3bf6a; }
#foot #fireSpray { background: #a52c29; touch-action: none; }
#foot #fireSpray.on { background: #216f8b; }
#fireStatus { max-width: 220px; padding: 6px; border-radius: 8px; background: rgba(22, 26, 28, .85); font-size: 14px; }
#fireAim { position: fixed; left: 50%; top: 50%; width: 24px; height: 24px; margin: -12px; border: 2px solid #fff3cc; border-radius: 50%; box-shadow: 0 0 0 1px #a52c29; pointer-events: none; z-index: 15; }
body.firefighting #actBtn, body.firefighting #runBtn, body.firefighting #jumpBtn, body.firefighting #dogFetchBtn { display: none !important; }
@media (max-height: 500px) { #foot #fireControls button { min-height: 44px; font-size: 14px; } #fireStatus { font-size: 12px; padding: 3px; } }
body.driving #wetBar:not([hidden]) { display: flex; }
#wetMsg { font-size: 16px; font-weight: 600; }
#towBtn { min-width: 100px; min-height: 44px; padding: 0 12px; border-radius: 8px; background: #80542d; font-weight: 600; }
#towBtn[hidden] { display: none; }
@media (max-width: 1023px) { #wetBar { bottom: auto; top: calc(164px + env(safe-area-inset-top)); width: max-content; } #wetMsg { font-size: 14px; } }
body.m-rescue #wetBar { max-width: min(540px, calc(100vw - 24px)); }
body.driving:has(#wetBar:not([hidden])) #roadBar { display: none; }
@media (max-width: 1023px) { body.driving:has(#wetBar:not([hidden])) #toast { top: var(--wet-toast-top, 240px); width: calc(100vw - 32px); } }
#bc b { min-width: 0; }

#bc { left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 8px 6px; gap: 0; font-size: 15px; white-space: nowrap; }
#bc div { padding: 0 12px; display: flex; gap: 7px; align-items: baseline; }
#bc div + div { border-left: 1px solid var(--line); }
#bc span { font-size: 11px; letter-spacing: 0.14em; color: var(--ink-dim); }
#bc b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 54px; }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
#labels[hidden] { display: none; }
.tag { position: absolute; left: 0; top: 0; padding: 3px 9px 4px; font-size: 14px; font-weight: 600; letter-spacing: 0.03em; white-space: nowrap; background: var(--glass); border: 1px solid var(--line); border-left: 4px solid var(--barn); border-radius: 4px; will-change: transform; }

#help { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; padding: 18px 20px 16px; width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 24px); overflow-y: auto; touch-action: pan-y; transition: opacity .35s; }
#help.gone { opacity: 0; pointer-events: none; }
#help h1 { margin: 0 0 10px; font-size: 22px; font-weight: 700; letter-spacing: 0.04em; text-wrap: balance; }
#help ul { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 7px; font-size: 16px; line-height: 1.3; color: var(--ink); }
#help li { display: grid; grid-template-columns: 92px 1fr; gap: 6px; }
#help li b { color: var(--steel); font-weight: 600; }
#help .btn { background: var(--barn); width: 100%; }

#loading { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; background: var(--sky); font-size: 18px; letter-spacing: 0.14em; text-transform: uppercase; transition: opacity .5s; }
#loading.gone { opacity: 0; pointer-events: none; }
@media (max-width: 720px) { #brand span, #bc div:first-child { display: none; } #bc div + div { border-left: 0; } #bc div + div + div { border-left: 1px solid var(--line); } #sun input { width: 84px; } .btn, .seg button { padding: 0 10px; } }
@media (prefers-reduced-motion: reduce) { #help, #loading { transition: none; } }

/* ---- the game: money, players, start screen and farm panel ---- */
#money { font-weight: 700; font-variant-numeric: tabular-nums; }
#net { height: 44px; padding: 0 12px; display: flex; align-items: center; font-size: 15px; border-left: 5px solid var(--barn); }
#money[hidden], #net[hidden], #start[hidden], #farm[hidden], #help[hidden], #signIn[hidden], #startForm[hidden], #horseName[hidden] { display: none; }
#horseShade { position: fixed; inset: 0; z-index: 7; background: rgba(12, 18, 16, 0.6); }
#horseShade[hidden] { display: none; }
#horseName { z-index: 8; display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
#horseFields { overflow-y: auto; min-height: 0; padding: 0 3px 3px; touch-action: pan-y; }
#horsePreview { display: block; width: 100%; height: clamp(100px, 17vh, 144px); border-radius: 12px; background: linear-gradient(#b4d1dc, #dae2d3 70%, #85a26c); }
#horseOptions fieldset { margin: 10px 0 0; padding: 0; border: 0; min-width: 0; }
#horseOptions legend { margin-bottom: 6px; font-size: 16px; font-weight: 600; }
#horseOptions .chip { min-width: 44px; height: 44px; }
#horseOptions .chip.color { width: 44px; }
#horseOptions .hint { font-size: 14px; margin-top: 5px; }
#horseName .foot { flex-shrink: 0; margin-top: 8px; }
#horseTitle:focus { outline: none; }
#horseNote { min-height: 22px; margin: 8px 0 0; color: var(--ink); }
#horseNote.bad { color: #ffc9b8; }
#players { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }
.tag.who { border-left-color: var(--steel); font-size: 15px; }
.sheet { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; padding: 18px 20px 16px; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; touch-action: pan-y; -webkit-user-select: text; user-select: text; }
.sheet h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; letter-spacing: 0.04em; }
.sheet h2 { margin: 16px 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim); }
.sheet p { margin: 0 0 8px; font-size: 16px; line-height: 1.35; color: var(--ink-dim); }
.sheet label { display: block; margin: 12px 0 5px; font-size: 15px; color: var(--ink-dim); }
.sheet input[type=text] { width: 100%; min-height: 46px; padding: 0 12px; font: inherit; font-size: 18px; color: var(--ink); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 10px; }
.sheet .btn { background: var(--barn); }
.sheet .btn:disabled { background: rgba(244, 241, 232, 0.1); color: var(--ink-dim); cursor: default; }
.sheet .btn.quiet { background: rgba(244, 241, 232, 0.12); }
.sheet .pair { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.sheet .foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
#start { z-index: 7; }
#shade { position: fixed; inset: 0; z-index: 6; background: rgba(12, 18, 16, 0.35); }
#start[hidden] + #shade { display: none; }
#farmList { display: grid; gap: 6px; }
.farmPick { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 54px; text-align: left; background: rgba(244, 241, 232, 0.12) !important; }
.farmPick.last { background: var(--barn) !important; }
.farmPick b { font-size: 19px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.farmPick span { font-size: 14px; color: var(--ink); opacity: 0.85; white-space: nowrap; }
#startNote { min-height: 22px; margin: 10px 0 0; color: var(--ink); }
#startNote.bad { color: #ffc9b8; }
#farm .row { display: grid; grid-template-columns: 1fr; gap: 3px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 16px; }
#farm .row b { font-weight: 600; }
#farm .row span { color: var(--ink-dim); font-size: 15px; }
#farm .row.sell { grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
#farm .row.sell b, #farm .row.sell span { grid-column: 1; }
#farm .row.sell .btn { grid-column: 2; grid-row: 1 / span 2; min-width: 96px; }
#farm .bar { height: 8px; border-radius: 4px; background: rgba(244, 241, 232, 0.14); overflow: hidden; }
#farm .bar i { display: block; height: 100%; background: var(--steel); border-radius: 4px; }
@media (max-width: 720px) { #tl { max-width: 72vw; } #net { font-size: 13px; } }
@media (max-width: 560px) { #labelsBtn, #doorsBtn, #sun { display: none; } #drv button { font-size: 14px; padding: 0 4px; } #drv #toolBtn { font-size: 19px; } }
/* A third column keeps the extra hitch controls reachable on a landscape phone. */
@media (max-height: 500px) and (min-width: 560px) {
  body.driving #br, body.driving #bl { bottom: calc(12px + env(safe-area-inset-bottom)); }
  #drv { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto repeat(4, 46px);
    grid-template-areas: "alerts alerts alerts" "field crop fold" "tractor hitch unload" "autosteer tool tool" "off machine camera";
    width: min(420px, 62vw); gap: 6px; }
  #drv #toolBtn { min-height: 46px; font-size: 18px; }
  body.loader-playing #drv { grid-template-rows: auto 46px; grid-template-areas: "alerts alerts alerts" "off machine camera"; }
  body.driving #bc { top: 70px; bottom: auto; left: 12px; transform: none; max-width: 230px; }
  body.driving #fieldTag { top: 130px; left: 12px; transform: none; max-width: 200px; white-space: normal; font-size: 14px; }
  body.driving #roadBar { top: 180px; left: 12px; transform: none; }
}
.sheet .btn.link { display: grid; place-items: center; text-decoration: none; margin-top: 10px; }
.sheet .btn.link[hidden] { display: none; }
/* The kid on foot or on a horse: nearby actions, Run / pace, and Jump. */
#foot { display: none; flex-direction: column; gap: 8px; width: min(230px, 48vw); pointer-events: none; }
#footActions { display: grid; grid-template-rows: repeat(3, 60px); grid-template-areas: "act" "run" "jump"; gap: 8px; order: 1; }
#foot #actBtn { grid-area: act; }
#foot #runBtn { grid-area: run; }
#foot #jumpBtn { grid-area: jump; }
#foot button { min-height: 60px; padding: 0 10px; font-size: 19px; font-weight: 600; border-radius: 14px; pointer-events: auto; touch-action: none; }
#foot #actBtn { background: #2e7d3a; border-color: transparent; }
#foot #actBtn.on, #drv #offBtn { background: #a8552a; border-color: transparent; }
#foot button[hidden] { display: none; }
#foot #jumpBtn { background: #406a96; border-color: transparent; }
#foot #jumpBtn:disabled { opacity: 0.65; cursor: default; }
@media (max-width: 360px) { #bl { left: calc(12px + env(safe-area-inset-left)); } #br { right: calc(12px + env(safe-area-inset-right)); } }
body.walking #foot { display: flex; }
body.firefighting #footActions { display: none; }
body.walking #fieldTag { display: flex; top: calc(120px + env(safe-area-inset-top)); bottom: auto; }
body.walking #alt, body.walking #speed { display: none; }
@media (max-width: 900px) { body.walking #bl, body.walking #br { bottom: calc(78px + env(safe-area-inset-bottom)); } }
@media (max-height: 500px) and (min-width: 560px) {
  #foot { width: min(330px, 48vw); }
  #footActions { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(2, 60px); grid-template-areas: "act act" "run jump"; }
}
/* the clothes sheet sits low on a phone and to one side on a wide screen, so the kid can be seen while choosing */
body:has(#look:not([hidden])) #fieldTag { display: none; }
#look { top: auto; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-height: 64vh; padding: 12px 16px; }
#look h1 { font-size: 20px; }
#look .foot { margin-top: 8px; }
@media (min-width: 900px) { #look { left: auto; right: calc(22px + env(safe-area-inset-right)); bottom: auto; top: 50%; transform: translateY(-50%); max-height: calc(100vh - 24px); } }
@media (max-height: 500px) and (min-width: 560px) and (max-width: 899px) {
  #look { left: auto; right: calc(12px + env(safe-area-inset-right)); bottom: auto; top: 50%; transform: translateY(-50%); width: min(360px, 54vw); max-height: calc(100vh - 24px); }
}
#look .row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; margin: 6px 0; }
#look .row b { font-size: 14px; font-weight: 600; color: var(--ink-dim); }
#look .chip[data-part=hairStyle], #look .chip[data-part=facialHair] { min-height: 44px; height: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-width: 36px; height: 36px; padding: 0 11px; border-radius: 18px; border: 2px solid var(--line); background: rgba(244, 241, 232, 0.12); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; }
.chip.color { width: 36px; padding: 0; }
.chip.on { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.55) inset; }
.chip:disabled { opacity: 0.35; }
/* Shared weather uses a native modal so walking and driving cannot take input behind it. */
#weatherPanel { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 20px; color: var(--ink); overflow-y: auto; touch-action: pan-y; }
#weatherPanel::backdrop { background: rgba(12, 18, 16, 0.65); }
#weatherPanel h2 { margin: 0 0 8px; font-size: 25px; }
#weatherPanel p { margin: 10px 0; }
#weatherControls[hidden], #weatherReadOnly[hidden], #weatherNotice[hidden] { display: none; }
#weatherMode { display: block; width: 100%; min-height: 46px; margin-top: 6px; padding: 4px 8px; color: var(--ink); background: #26352e; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
#weatherPanel fieldset { margin: 14px 0; padding: 8px 0 0; border: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
#weatherPanel fieldset label { display: flex; align-items: center; gap: 7px; min-height: 44px; }
#weatherPanel input { width: 22px; height: 22px; accent-color: var(--barn); }
#weatherTriggers, #weatherStops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#weatherStops { grid-template-columns: 1fr 1fr; margin-top: 8px; }
#weatherPanel .btn { min-height: 44px; padding: 8px; height: auto; font-size: 16px; white-space: normal; background: rgba(244, 241, 232, 0.12); }
#weatherPanel .btn:disabled { opacity: 0.42; cursor: default; }
#weatherPanel #weatherOff { background: #744137; }
#weatherPanel #weatherDone { width: 100%; background: var(--barn); }
#weatherNote { min-height: 20px; font-size: 15px; }
#weatherPanel .weatherHint { color: var(--ink-dim); font-size: 14px; }
#weatherNotice { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(74px + env(safe-area-inset-bottom)); padding: 6px 12px; max-width: calc(100vw - 32px); text-align: center; z-index: 2; pointer-events: none; font-size: 15px; }
#weatherNotice.warning { border-color: #d2a759; }
@media (max-height: 500px) { #weatherPanel { padding: 12px 16px; } #weatherPanel fieldset { margin: 8px 0; } #weatherPanel p { margin: 7px 0; } }

/* Equipment paint: the picker and preview scroll together on short phone screens. */
#paint[hidden], #paintShade[hidden] { display: none; }
#paintShade { position: fixed; inset: 0; z-index: 7; background: rgba(12, 18, 16, 0.6); }
#paint { z-index: 8; display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
#paintFields { overflow-y: auto; min-height: 0; padding: 0 3px 3px; touch-action: pan-y; }
#paintFields label { margin-top: 4px; }
#paintMachine { width: 100%; min-height: 46px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 17px; color: var(--ink); background: #26352e; }
#paintPreview { display: block; width: 100%; height: clamp(100px, 20vh, 170px); margin-top: 10px; border-radius: 12px; background: linear-gradient(#b4d1dc, #dae2d3 70%, #85a26c); }
#paintFields fieldset { margin: 10px 0 0; padding: 0; border: 0; min-width: 0; }
#paintFields legend { margin-bottom: 6px; font-size: 16px; font-weight: 600; }
#paintColors .chip { min-width: 44px; height: 44px; }
#paintColors .chip.color { width: 44px; }
#paintColors .chip.on::after { content: '✓'; font-size: 23px; }
#paintColors .chip[data-value=original].on::after { content: ''; }
#paintChoice { margin: 8px 0 0; color: var(--ink); }
#paint .foot { flex-shrink: 0; margin-top: 8px; }
#paintNote { margin: 8px 0 0; font-size: 14px; }
#paintTitle:focus { outline: none; }
@media (max-height: 500px) and (min-width: 560px) {
  #paint { width: min(620px, calc(100vw - 24px)); padding: 12px 16px; }
  #paintFields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
  #paintPreview { height: 110px; }
  #paintFields fieldset { margin-top: 4px; }
}

/* Claiming and visiting homes uses the same large buttons as the rest of the game. */
#mapCredit { position: fixed; right: max(8px, env(safe-area-inset-right)); bottom: max(3px, env(safe-area-inset-bottom)); z-index: 3; max-width: calc(100vw - 16px); font: 10px/1.3 sans-serif; color: #eee; text-shadow: 0 1px 3px #000; text-align: right; }
#houses[hidden], #houseShade[hidden] { display: none; }
#houseShade { position: fixed; inset: 0; z-index: 7; background: rgba(12, 18, 16, 0.6); }
#houses { z-index: 8; }
#houseTitle:focus { outline: none; }
#houseList { display: grid; gap: 12px; margin: 16px 0; }
.homeRow { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 12px; background: rgba(244, 241, 232, 0.08); border-radius: 12px; }
.homeRow b, .homeRow span { grid-column: 1 / -1; }
.homeRow b { font-size: 19px; }
.homeRow span { color: var(--ink-dim); font-size: 15px; }
.homeRow button { min-height: 44px; }
#houses #houseNote { min-height: 22px; color: var(--ink); }
#viewMenu button:disabled { opacity: 0.45; cursor: default; }
/* Riding routes share a map; a compact strip leaves the stick and jump controls clear. */
#arenaPanel { width: min(940px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; padding: 20px; overflow-y: auto; touch-action: pan-y; background: #233b36; color: var(--ink); }
#arenaPanel::backdrop { background: rgba(10, 20, 17, 0.72); }
.arenaHeading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.arenaEyebrow { color: #e5c476; font-size: 12px; letter-spacing: 0.18em; }
#arenaTitle { margin: 4px 0 12px; font-size: 27px; line-height: 1.1; }
#arenaChoices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 8px 0 14px; }
#arenaChoices button { min-height: 64px; padding: 10px; border: 1px solid #698379; border-radius: 10px; text-align: left; }
#arenaChoices b, #arenaChoices span { display: block; }
#arenaChoices b { font-size: 18px; }
#arenaChoices span { margin-top: 4px; color: #d3ddd2; font-size: 13px; }
#arenaChoices button[aria-pressed="true"] { border-color: #e7c77b; background: #405b49; box-shadow: inset 0 0 0 1px #e7c77b; }
#arenaContent { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
#arenaMap { display: block; width: 100%; height: auto; border-radius: 10px; }
#arenaLegend { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: #ced8cb; }
#arenaBrief p { margin: 0 0 14px; font-size: 17px; line-height: 1.4; }
#arenaBrief #arenaSequence { font-size: 14px; color: #e9d6a5; }
#arenaBrief #arenaBest { font-size: 15px; color: #e9d6a5; }
#arenaBrief #arenaRideNote { color: #ffdbab; font-size: 14px; }
#arenaBrief .arenaHint { font-size: 14px; color: #ced8cb; }
#arenaRide { width: 100%; min-height: 48px; margin: 4px 0 12px; padding: 10px; background: #d9b966; color: #233b36; font-weight: 700; }
#arenaDone { min-width: 60px; border: 1px solid #698379; }
#arenaHud { position: fixed; top: calc(116px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 8px; width: min(620px, calc(100vw - 24px)); padding: 8px 10px; background: rgba(25, 47, 39, 0.94); }
#arenaHud[hidden] { display: none; }
#arenaHud > div { flex: 1; min-width: 0; }
#arenaHudTitle, #arenaHudNext { display: block; }
#arenaHudTitle { font-size: 16px; font-variant-numeric: tabular-nums; }
#arenaHudNext { margin-top: 3px; font-size: 14px; color: #e9d6a5; }
#arenaHud button { min-width: 44px; min-height: 44px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
#arenaHud.complete { border-color: #e7c77b; }
body:has(#arenaHud:not([hidden])) #fieldTag { display: none; }
body:has(#arenaHud:not([hidden])) #toast { top: calc(202px + env(safe-area-inset-top)); }
@media (max-width: 600px) {
  #arenaPanel { padding: 14px; }
  #arenaTitle { font-size: 23px; }
  #arenaChoices { gap: 5px; }
  #arenaChoices button { padding: 7px; }
  #arenaChoices b { font-size: 15px; }
  #arenaChoices span { font-size: 11px; }
  #arenaContent { grid-template-columns: 1fr; gap: 14px; }
  #arenaHud { gap: 5px; padding: 6px 8px; }
  #arenaHudTitle { font-size: 14px; }
  #arenaHudNext { font-size: 12px; }
}
@media (max-height: 500px) and (min-width: 560px) {
  #arenaPanel { padding: 12px 16px; }
  #arenaHud { top: calc(112px + env(safe-area-inset-top)); width: min(440px, calc(100vw - 24px)); }
}
@media (max-height: 500px) and (min-width: 560px) {
  #houses { width: min(630px, calc(100vw - 24px)); padding: 12px 16px; }
  #houseList { grid-template-columns: repeat(3, 1fr); margin: 10px 0; gap: 8px; }
  .homeRow { padding: 8px; }
}
