:root {
  --paper: #f8f1e0;
  --paper-2: #eee3c8;
  --paper-3: #e2d4b2;
  --ink: #2a2017;
  --ink-2: #6d5c49;
  --green: #2f6b3c;
  --green-2: #3f8a4c;
  --rust: #b6502a;
  --gold: #f4b82e;
  --gold-2: #ffd767;
  --sky: #2f86d6;
  --good: #2e9d57;
  --bad: #d1492e;
  --font-d: Rockwell, "Rockwell Nova", "Roboto Slab", "DejaVu Serif", Georgia, serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
/* No element may hand Safari a pinch or a double-tap to zoom the page with: lists and menus scroll, nothing else moves. */
html, body, canvas, #toasts, #countdown, #rotate, .screen, .screen.crush *,
#hud, #hud *, #touch, #touch *, #homeHud, #homeHud *, #villageHud, #villageHud *, #rodeoHud, #rodeoHud *, #houseHud, #houseHud *, #placeHud, #placeHud *, #partyHud, #partyHud * { touch-action: none; }
.panel, .panel *, .app-body, .app-body * { touch-action: pan-y; }
#hud .hud-menu, #hud .hud-menu * { touch-action: pan-y; }   /* a long menu on a short screen scrolls */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* If Safari has zoomed the page anyway, let a pinch through everywhere so it can be zoomed back out. */
html.page-zoomed, html.page-zoomed * { touch-action: pinch-zoom pan-x pan-y !important; }
#zoomHint { position: fixed; z-index: 200; left: 0; right: 0; top: 0; padding: 10px 14px; background: var(--bad); color: #fff; font: 700 15px var(--font); text-align: center; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #cfe6f3; color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

h1, h2, h3 { font-family: var(--font-d); margin: 0; line-height: 1.05; text-wrap: balance; }
h1 { font-size: clamp(38px, 5vw, 58px); letter-spacing: -0.02em; color: var(--green); white-space: nowrap; }
h2 { font-size: 30px; }
h3 { font-size: 17px; margin: 18px 0 8px; display: flex; align-items: baseline; gap: 10px; }
p { margin: 8px 0; }
a { color: var(--rust); }
b, .chip b, td.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rust); margin: 0 0 6px; }
.lede { font-size: 16px; color: var(--ink-2); max-width: 36ch; }
.fine { font-size: 12.5px; color: var(--ink-2); margin: 6px 0 0; }
kbd { display: inline-block; min-width: 24px; padding: 1px 6px; margin: 0 2px; border: 1.5px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; background: #fff; font: 600 12px var(--font); text-align: center; }

/* ---------- panels and buttons */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; }
.screen.side { align-items: center; padding: 3vh 3vw; padding: 3dvh 3vw; pointer-events: none; background: linear-gradient(90deg, rgba(20, 30, 20, 0.28), transparent 55%); }
.screen.side > * { pointer-events: auto; }
.screen.modal { align-items: center; justify-content: center; padding: 2vh 2vw; padding: 2dvh 2vw; background: rgba(24, 18, 10, 0.5); backdrop-filter: blur(3px); }

.panel {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 8px 0 var(--ink), 0 24px 50px rgba(0, 0, 0, 0.35);
  padding: 26px 28px; max-height: 94vh; max-height: 94dvh; overflow: auto; overscroll-behavior: contain;
}
.panel.hero { width: min(430px, 94vw); }
.panel.small { width: min(480px, 94vw); }
.panel.wide { width: min(1180px, 96vw); }
.panel.wide.narrow { width: min(860px, 96vw); }
.phead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.phead h2 { margin-right: auto; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .btn.big { flex: 1; }
label { display: block; font-weight: 700; font-size: 13px; margin: 14px 0 6px; }
input {
  font: 600 17px var(--font); color: var(--ink); background: #fff;
  border: 2.5px solid var(--ink); border-radius: 10px; padding: 10px 12px; min-width: 0; flex: 1;
  -webkit-user-select: text; user-select: text;
}
input:focus-visible, .btn:focus-visible, .tab:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

.btn {
  font: 700 15px var(--font); color: var(--ink); cursor: pointer;
  background: var(--paper-2); border: 2.5px solid var(--ink); border-radius: 11px;
  padding: 8px 14px; box-shadow: 0 3px 0 var(--ink); transition: transform 0.06s, box-shadow 0.06s, background 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #fff; transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.big { font-size: 17px; padding: 12px 16px; text-align: left; }
.btn.primary { background: var(--gold); }
.btn.primary:hover:not(:disabled) { background: var(--gold-2); }
.btn.green { background: var(--green-2); color: #fff; }
.btn.green:hover:not(:disabled) { background: #4c9d5a; }
.btn.danger { background: #f3c9bd; }
.btn.sm { font-size: 13px; padding: 5px 10px; box-shadow: 0 2px 0 var(--ink); border-width: 2px; }
.link { background: none; border: 0; padding: 0; font: 600 12.5px var(--font); color: var(--rust); text-decoration: underline; cursor: pointer; }
.menu { display: grid; gap: 10px; margin: 16px 0; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--rust); color: #fff; font-size: 12px; text-align: center; margin-left: 6px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.stats div { background: var(--paper-2); border-radius: 10px; padding: 8px 12px; }
.stats span { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.stats b { font: 700 21px var(--font-d); }

.mp { border-top: 2px dashed var(--paper-3); padding-top: 12px; margin-top: 4px; }
.mp-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b9ac95; display: inline-block; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(46, 157, 87, 0.25); }
.roster { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.who { display: inline-flex; align-items: center; gap: 6px; background: var(--paper-2); border-radius: 20px; padding: 3px 10px 3px 6px; font-size: 12.5px; }
.who i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); }
.who small { color: var(--ink-2); }

/* ---------- HUD */
/* Every layer of controls keeps clear of the notch and the home bar on phones. */
#hud, #touch, #homeHud, #villageHud, #rodeoHud, #houseHud, #placeHud, #partyHud { inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px) !important; }
.screen { padding-left: max(2vw, env(safe-area-inset-left, 0px)); padding-right: max(2vw, env(safe-area-inset-right, 0px)); }
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud button, #hud .prompt { pointer-events: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 12px;
  background: rgba(26, 20, 13, 0.74); color: #fff; font-size: 17px; backdrop-filter: blur(4px);
}
button.chip { border: 0; font-family: inherit; font-weight: inherit; cursor: pointer; touch-action: manipulation; }
.chip .lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #d9cdb6; }
.chip.dark { background: var(--ink); }
/* A narrower header says the same in fewer letters and shorter bars, so it stays three rows deep. */
@media (max-width: 900px) { .chip .roomy { display: none; } }
@media (min-width: 601px) and (max-width: 900px) and (min-height: 481px) { .hud-tl .chip { padding: 6px 9px; gap: 6px; } .hud-tl .chip .meter { width: 44px; } .hud-tl .chip.fuel .meter { width: 40px; } }
.hud-tl { position: absolute; z-index: 2; top: 12px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 270px); }
.hud-tr { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-bl { position: absolute; left: 12px; bottom: 12px; }
#minimap { width: 220px; height: 216px; border-radius: 14px; border: 2.5px solid rgba(26, 20, 13, 0.85); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: rgba(26, 20, 13, 0.74); color: #fff; font-size: 17px; cursor: pointer; }
.meter { width: 90px; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: var(--good); border-radius: 6px; transition: width 0.2s, background 0.3s; }
.hud-btn { pointer-events: auto; width: 220px; height: 34px; border: 0; border-radius: 10px; background: rgba(26, 20, 13, 0.78); color: #fff; font: 700 13.5px var(--font); cursor: pointer; backdrop-filter: blur(4px); }
.hud-btn:hover { background: #1a140d; }
.menu .btn { white-space: normal; line-height: 1.25; }
/* The homestead menu: two columns so nothing is hidden below the fold. */
#scrHub .panel.hero { width: min(540px, 94vw); padding: 18px 22px; }
#scrHub h2 { margin: 0 0 2px; }
/* Refresh sits beside the heading, always in the same place, however long the menu below it grows. */
.hub-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#btnRefreshTop { flex: none; min-height: 38px; font-size: 14.5px; }
/* A newer version is waiting: the menu button wears a dot, and Refresh says so. */
body.update-due #btnHudMenu, body.update-due #btnRefreshTop { box-shadow: 0 0 0 3px #e5484d; }
body.update-due #btnHudRefresh { background: #ffe08a; }
/* The ☰ Menu indoors: the same button as in the paddock, first along the top, with its list dropping below it. */
.indoor-menu { height: 40px; }
#indoorMenu { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 60px); left: calc(env(safe-area-inset-left, 0px) + 12px); z-index: 45; grid-template-columns: 1fr; }
/* Your host has gone to the village or to school: one tap to go too. And who is in class with you. */
#followNote, #schoolMates { position: fixed; left: 50%; transform: translateX(-50%); z-index: 40; width: max-content; max-width: min(560px, 92vw); padding: 10px 16px; border: 2px solid var(--ink); border-radius: 12px; font: 800 15px/1.3 var(--font); text-align: center; }
#followNote { top: 112px; background: var(--gold); color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 var(--ink); }
#schoolMates { bottom: 10px; z-index: 60; background: #fff7d6; color: var(--ink); pointer-events: none; }
/* At the place of someone whose device still has an old version of the game open: said plainly, for as long as it is so. */
#staleNote { position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 40; width: max-content; max-width: min(600px, 92vw); padding: 8px 14px; border: 2px solid var(--ink); border-radius: 12px; background: #8a2320; color: #fff; font: 700 14px/1.3 var(--font); text-align: center; pointer-events: none; }
#scrHub .stats { grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
#scrHub .stats div { padding: 5px 9px; }
#scrHub .stats span { font-size: 10px; }
#scrHub .stats b { font-size: 17px; }
.hub-menu { grid-template-columns: 1fr 1fr; gap: 7px; margin: 10px 0; }
.hub-menu .primary { grid-column: 1 / -1; }
.hub-menu .primary.half { grid-column: auto; }
.hub-menu .btn.big { padding: 8px 12px; font-size: 15.5px; }
.hub-menu .btn small { display: block; font-size: 11.5px; font-weight: 600; opacity: 0.72; margin-top: 1px; }
#scrHub .fine { margin-top: 4px; }
/* Tablets held upright have the room for the full-size map column and labelled buttons. */
@media (min-width: 700px) and (min-height: 700px) and (max-width: 900px) {
  #minimap, .hud-btn { width: 220px; }
  #minimap { height: 216px; }
}
/* The paddock menu: one button by the chips, opening a list. Nothing sits across the view, or near the thumb buttons. */
.burger { position: relative; display: inline-flex; }
.menu-btn { pointer-events: auto; padding: 0 14px; border: 2px solid var(--ink); border-radius: 12px; background: var(--gold); color: var(--ink); font: 800 15px var(--font); white-space: nowrap; cursor: pointer; }
.menu-btn:active, .menu-btn[aria-expanded="true"] { background: var(--gold-2); }
.hud-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 5; display: grid; gap: 6px; padding: 8px; width: max-content; max-width: calc(100vw - 24px); max-height: calc(100vh - 76px); max-height: calc(100dvh - 76px); overflow-y: auto; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ink), 0 14px 30px rgba(0, 0, 0, 0.35); }
.hud-menu .menu-btn { min-height: 46px; padding: 5px 14px; text-align: left; background: var(--paper-2); font-size: 15.5px; }
.hud-menu .menu-btn:hover { background: var(--gold-2); }
.hud-menu .menu-btn small { display: block; font-size: 11.5px; font-weight: 600; opacity: 0.72; }
body.solo .mp-only { display: none !important; }
.name-picks { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 8px; }
.name-picks button { padding: 6px 11px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); color: var(--ink); font: 700 13.5px var(--font); cursor: pointer; }
.name-picks button:active, .name-picks button.on { background: var(--gold); }
.name-picks .pick-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; width: 100%; }
.name-picks .pick-row b { min-width: 64px; font-size: 13px; }
body.soccer #btnHouseUp, body.soccer #btnHouseUse { display: none !important; }   /* the controller has its own Stop button */
body.in-flight #touch { display: none !important; }
#walkieBtn { position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 178px); z-index: 16; width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(26, 20, 13, 0.55); background: rgba(244, 184, 46, 0.82); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); font-size: 21px; cursor: pointer; touch-action: manipulation; }
#walkieBtn i { position: absolute; right: -5px; bottom: -5px; font-style: normal; font-size: 14px; }
#walkieBtn b { position: absolute; right: -2px; top: -2px; width: 12px; height: 12px; border-radius: 50%; background: #d94a3d; border: 2px solid #fff; }
/* the friends' bubble: small and quiet, beside the walkie button, gone by itself in a few seconds */
#walkieMsg { position: fixed; left: calc(max(16px, env(safe-area-inset-left)) + 54px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 186px); z-index: 16; max-width: min(270px, calc(100vw - 90px)); background: rgba(255, 250, 240, 0.86); border: 1px solid rgba(26, 20, 13, 0.22); border-radius: 12px 12px 12px 3px; padding: 5px 22px 6px 9px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16); animation: wkIn 0.3s ease-out; }
@keyframes wkIn { from { opacity: 0; transform: translateY(6px); } }
#walkieMsg b { font-size: 11px; font-weight: 700; opacity: 0.75; }
#walkieMsg p { margin: 1px 0 2px; font: 600 13px/1.3 var(--font); cursor: pointer; }
#walkieMsg .wk-replies button { padding: 3px 10px; border-width: 1px; font-size: 12px; }
.wk-x { position: absolute; right: 6px; top: 6px; border: 0; background: none; font-size: 18px; cursor: pointer; }
#walkieMsg .wk-x { right: 3px; top: 2px; font-size: 12px; opacity: 0.55; }
.wk-replies { display: flex; flex-wrap: wrap; gap: 6px; }
.wk-replies button { padding: 7px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--gold); font: 800 14px var(--font); color: var(--ink); cursor: pointer; }
.wk-log { display: grid; gap: 6px; max-height: min(46dvh, 380px); overflow: auto; padding: 4px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px; margin-bottom: 8px; }
.wk-log div { padding: 6px 10px; border-radius: 12px; background: #fff; max-width: 85%; font: 600 15px/1.3 var(--font); }
.wk-log div b { display: block; font-size: 12.5px; }
.wk-log div.me { justify-self: end; background: #e3f0ff; }
.wk-form { margin-top: 8px; }
.wk-form input { flex: 1; min-width: 0; }
.fr-switches { display: grid; gap: 8px; margin-bottom: 8px; }
.fr-switches .row { align-items: center; gap: 8px; flex-wrap: wrap; }
.fr-switches button.on { background: var(--gold); }
.fr-list { display: grid; gap: 8px; }
.fr-card { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); }
.fr-card .em { font-size: 34px; }
.fr-card span { flex: 1; display: grid; }
.fr-card small { opacity: 0.8; }
.fr-card .btns { display: grid; gap: 4px; }
.fr-card .btns button { padding: 6px 10px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 800 13px var(--font); cursor: pointer; }
.fr-card .btns button.on { background: var(--gold); }
#bkChart { width: 100%; height: 120px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 12px; margin: 8px 0; }
.bk-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.bk-btns button { padding: 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--gold); font: 800 15px var(--font); color: var(--ink); cursor: pointer; }
.bk-btns button.sell { background: var(--paper-2); }
.bk-btns button:disabled { opacity: 0.45; cursor: default; }
#spaceHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#churchHud { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
#churchHud button { pointer-events: auto; height: 44px; font-size: 16px; }
.church-btns { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.church-cap { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); width: min(760px, calc(100vw - 32px)); background: rgba(20, 18, 30, 0.84); color: #fff; border: 2px solid rgba(155, 109, 214, 0.85); border-radius: 16px; padding: 10px 16px; text-align: center; }
.church-cap b { display: block; font-size: 13px; color: #cdb7f0; letter-spacing: 0.04em; }
.church-cap p { margin: 4px 0 0; font: 700 19px/1.3 var(--font); }
@media (max-height: 480px) { .church-cap p { font-size: 15px; } .church-btns { flex-direction: row; } }
#spaceHud button { pointer-events: auto; touch-action: none; }
.space-where { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); font-weight: 800; }
.space-btns { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.space-jump { position: absolute; right: max(28px, env(safe-area-inset-right)); bottom: max(36px, env(safe-area-inset-bottom)); width: 112px; height: 112px; }
#cityHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.city-panel { pointer-events: auto; position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); bottom: max(12px, env(safe-area-inset-bottom)); width: min(330px, 46vw); overflow: auto; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.city-panel h3 { margin: 0; }
.city-panel .fine { margin: 0; }
#cityList { display: grid; gap: 6px; }
#cityList button { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); font: 700 14px var(--font); color: var(--ink); cursor: pointer; }
#cityList button i { font-style: normal; font-size: 22px; }
#cityList button em { margin-left: auto; font-style: normal; }
.city-panel .city-walk { font-size: 17px; padding: 12px; }
#cityWalkHud button, #cityWalkHud .city-panel { pointer-events: auto; }
#cityWalkHud .hud-tl { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
#cityWalkHud .hud-tr { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
#cityWalkHud .pump-btn { white-space: normal; max-width: min(460px, 56vw); text-align: center; line-height: 1.2; }
.city-taxi { top: 176px; z-index: 3; }   /* under the three buttons, which stay in view */
@media (max-height: 480px) { .city-taxi { top: 56px; right: auto !important; left: max(12px, env(safe-area-inset-left)); } }   /* (a phone on its side: the buttons are in a row) */
#cityTaxiList { display: grid; gap: 6px; }
#cityTaxiList button { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); font: 700 14px var(--font); color: var(--ink); cursor: pointer; }
#cityTaxiList button i { font-style: normal; font-size: 22px; }
#cityTaxiList button em { margin-left: auto; font-style: normal; }
.sport-screen .panel { width: min(1100px, 96vw); }
.sp-field { width: 100%; height: min(48vw, 46dvh); }
.sp-field canvas { width: 100%; height: 100%; border-radius: 10px; touch-action: none; display: block; }
.sp-controls { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.sp-controls .fine { flex: 1; margin: 0; }
.sp-controls .soc-pad, .sp-controls .soc-kick { position: relative; left: auto; right: auto; bottom: auto; flex: none; touch-action: none; }
.sp-pad { width: 120px; height: 120px; background: rgba(0, 0, 0, 0.12); border-color: rgba(0, 0, 0, 0.35); }
.sp-pad i { width: 50px; height: 50px; margin: -25px; background: rgba(0, 0, 0, 0.45); }
.sp-act { width: 104px; height: 104px; font-size: 19px; }
#soccerHud { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#soccerHud button, #soccerHud .soc-pad { pointer-events: auto; touch-action: none; }
.soc-stop { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; height: 44px; }
.soc-pad { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(24px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); border: 3px solid rgba(255, 255, 255, 0.65); }
.soc-pad i { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: rgba(255, 255, 255, 0.9); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35); }
.soc-kick { position: absolute; right: max(28px, env(safe-area-inset-right)); bottom: max(36px, env(safe-area-inset-bottom)); width: 118px; height: 118px; border-radius: 50%; background: var(--gold); border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink); font: 900 22px var(--font); color: var(--ink); line-height: 1.1; }
.soc-kick:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.quiz-q { margin: 4px 0 10px; font: 800 19px var(--font); }
.snooker-screen .panel { width: min(1100px, 96vw); }
.snk-board { margin: 0 0 6px; line-height: 1.35; }
.snk-board small { font-weight: 600; opacity: 0.85; }
.snk-table { width: 100%; height: min(54vw, 52dvh); display: flex; justify-content: center; align-items: center; }
.snk-table canvas { touch-action: none; border-radius: 10px; }
.wd-top { display: flex; gap: 14px; align-items: flex-start; }
#wdLook { flex: none; width: 120px; height: 168px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 14px; }
.wd-side { flex: 1; min-width: 0; display: grid; gap: 8px; }
.wd-side p { margin: 0; font-weight: 700; }
.wd-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.wd-tabs button { padding: 7px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); color: var(--ink); font: 800 14px var(--font); cursor: pointer; }
.wd-tabs button.on { background: var(--gold); }
.wd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.wd-list button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); color: var(--ink); font: 700 14px var(--font); text-align: left; cursor: pointer; }
.wd-list button i { font-style: normal; font-size: 22px; }
.wd-list button span { display: grid; }
.wd-list button small { font-weight: 600; opacity: 0.75; }
.wd-list button.on { background: var(--gold); }
.wd-colours button.mine { outline: 3px dashed var(--ink); outline-offset: -6px; }
.farm-town { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.farm-town input { min-width: 0; }
@media (max-width: 420px) { .farm-town { grid-template-columns: 1fr; } }
.pf-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 8px; }
.ct-form input, .ct-form select, .ct-form textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 600 15px var(--font); color: var(--ink); }
.ct-form textarea { resize: vertical; min-height: 110px; line-height: 1.35; }
.ct-form .row { margin-top: 12px; }
.ct-form .trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
#btnTitleContact { font-size: 14px; }
.pf-who, #pfCodeIn, #codeInput { width: 100%; min-width: 0; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 600 15px var(--font); color: var(--ink); }
#pfCodeIn, #codeInput { flex: 1; width: auto; text-transform: uppercase; letter-spacing: 0.08em; }
#pfCodeIn::placeholder, #codeInput::placeholder { text-transform: none; letter-spacing: 0; }
.pf-code { margin: 8px 0; padding: 10px 12px; border: 2px dashed var(--ink); border-radius: 10px; background: var(--paper-2); }
.pf-code b { font: 800 26px var(--font-d); letter-spacing: 0.18em; }
.code-form { margin-top: 10px; flex-wrap: nowrap; }
.pf-grid input, .pf-grid select, #pfName { min-width: 0; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 600 15px var(--font); color: var(--ink); }
@media (max-width: 520px) { .pf-grid { grid-template-columns: 1fr 1fr; } .pf-grid input:first-child { grid-column: 1 / -1; } }
.colour-picks { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.colour-picks button { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(26, 20, 13, 0.35); cursor: pointer; }
.colour-picks button.on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--gold); }
.radio-type { display: flex; gap: 6px; margin: 8px 0 2px; }
.radio-type input { flex: 1; min-width: 0; padding: 10px 12px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font: 600 15px var(--font); color: var(--ink); }
.radio-type .listening { background: var(--bad); color: #fff; }
.radio-says { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 8px 0; }
.radio-says button { padding: 10px 12px; border: 2px solid var(--ink); border-radius: 12px; background: var(--gold); color: var(--ink); font: 700 14.5px var(--font); cursor: pointer; box-shadow: 0 3px 0 var(--ink); text-align: left; }
.radio-says button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.radio-log { display: grid; gap: 4px; max-height: 26vh; max-height: 26dvh; overflow-y: auto; }
.radio-log div { padding: 6px 10px; border-radius: 9px; background: var(--paper-2); font-size: 14px; }
.radio-log div.me { background: #dcefd8; }
.radio-log i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
/* A long menu: always two columns, and the words may wrap. */
.hud-menu { grid-template-columns: 1fr 1fr; }
.hud-menu .menu-btn { white-space: normal; line-height: 1.15; }
/* Helping with someone else's muster: their menu, their gate and their clock are not yours to work. */
.visit-only { display: none !important; }
body.visiting .visit-only { display: block !important; }
body.visiting .host-only, body.visiting #btnToYards, body.visiting #btnPause { display: none !important; }
.join-list { display: grid; gap: 8px; margin: 10px 0; }
.join-item { display: flex; gap: 8px; align-items: stretch; }
.join-item .join-row { flex: 1; min-width: 0; }
.give-btn { flex: none; width: 54px; border: 2px solid var(--ink); border-radius: 14px; background: #dcefd8; font-size: 22px; cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.give-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.give-box { margin-top: 8px; padding: 10px 14px; border-radius: 12px; background: #dcefd8; border: 2px solid var(--ink); }
.join-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 14px; background: var(--paper-2); color: var(--ink); font: inherit; text-align: left; cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
button.join-row:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.join-row.go { background: var(--gold); }
.join-row.waiting { background: #dcefd8; }
.join-row[disabled] { opacity: 0.6; cursor: default; }
.join-row i { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid var(--ink); }
.join-row span { flex: 1; min-width: 0; }
.join-row b { display: block; font-size: 16px; }
.join-row small { opacity: 0.75; }
.join-row em { font-style: normal; font-weight: 800; font-size: 13.5px; text-align: right; max-width: 46%; }
.chip.fuel .meter { display: block; width: 64px; }
body.farming .menu-btn.farm-only:not([hidden]) { display: inline-block !important; min-height: 36px; }
.sell-how { margin: 0 0 8px; padding: 8px 12px; border-radius: 10px; background: var(--gold); color: var(--ink); font-weight: 700; font-size: 14px; }
.sell-how.closed { background: #f6dcd3; }
.chip.low .meter i { background: #fff !important; }
.money-next { background: var(--ink); color: var(--paper); border-radius: 12px; padding: 12px 16px; margin: 4px 0 12px; }
.money-next h3 { margin: 0 0 6px; font: 700 16px var(--font-d); color: var(--gold-2); }
.money-next ol { margin: 0; padding-left: 22px; }
.money-next li { margin: 3px 0; }
.money-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.money-grid section { background: var(--paper-2); border-radius: 12px; padding: 10px 14px; }
.money-grid h3 { margin: 0 0 4px; font: 700 16px var(--font-d); }
.money-grid p { margin: 0 0 4px; font-size: 14px; }
.money-grid ul { margin: 2px 0 0; padding-left: 18px; font-size: 13.5px; }
.money-grid li { margin: 2px 0; }
.money-grid b.up { color: var(--green); }
.money-grid section.warn-box { background: #f6dcd3; }
@media (max-width: 760px) { .money-grid { grid-template-columns: 1fr; } }
.turbo-btn { pointer-events: auto; display: block; width: 100%; margin-top: 8px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 10px; background: var(--gold); color: var(--ink); font: 800 14px var(--font); cursor: pointer; box-shadow: 0 3px 0 var(--ink); touch-action: none; }
.turbo-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); background: var(--gold-2); }
.turbo-btn.off { background: #cfc6b1; font-size: 12px; box-shadow: 0 2px 0 var(--ink); }
.turbo-btn kbd { font-size: 10.5px; padding: 0 5px; min-width: 0; }
.pump-btn { pointer-events: auto; position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); padding: 16px 34px; border: 3px solid var(--ink); border-radius: 16px; background: var(--gold); color: var(--ink); font: 800 24px var(--font); cursor: pointer; box-shadow: 0 5px 0 var(--ink); touch-action: none; }
.pump-btn:active { transform: translateX(-50%) translateY(3px); box-shadow: 0 2px 0 var(--ink); background: var(--gold-2); }
.pump-btn kbd { font-size: 13px; }
.tyres { display: inline-flex; gap: 5px; }
.tyres i { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #d9cdb6; background: conic-gradient(var(--good) var(--p), transparent 0); }
.tyres i.soft { border-color: var(--gold); background: conic-gradient(var(--gold) var(--p), transparent 0); }
.tyres i.flat { border-color: var(--bad); background: conic-gradient(var(--bad) var(--p), transparent 0); }
.veh-link { pointer-events: auto; display: block; width: 100%; margin-top: 6px; padding: 5px 8px; border: 1px dashed rgba(255, 255, 255, 0.45); border-radius: 8px; background: transparent; color: #f3ead6; font: 600 12px var(--font); text-align: left; cursor: pointer; }
.veh-link:hover { background: rgba(255, 255, 255, 0.12); }
.chip.low { background: var(--bad); }
.touch-only { display: none !important; }
body.touch .touch-only:not([hidden]) { display: inline-flex !important; }
body.touch .hud-bl { display: none; }
.farm-only { display: none !important; }
body.farming .farm-only:not([hidden]) { display: inline-flex !important; }
body.farming .hud-btn.farm-only:not([hidden]) { display: block !important; }
body.farming .muster-only { display: none !important; }
.chip.horn { background: var(--gold); color: var(--ink); font-size: 14px; font-weight: 700; }
.tbtns button.on { background: var(--gold); border-color: var(--ink); }
.mini-board { width: 220px; background: rgba(26, 20, 13, 0.74); color: #fff; border-radius: 12px; padding: 8px 10px; font-size: 12.5px; backdrop-filter: blur(4px); }
.mini-board:empty { display: none; }
.mini-board div { display: flex; gap: 6px; align-items: center; padding: 1.5px 0; }
.mini-board i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.mini-board span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-board small { color: #d9cdb6; }
.mini-board .me { color: var(--gold-2); font-weight: 700; }

.veh { background: rgba(26, 20, 13, 0.74); color: #fff; border-radius: 14px; padding: 10px 14px; min-width: 190px; backdrop-filter: blur(4px); }
.veh-mode { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; color: var(--gold-2); }
.veh-speed b { font: 700 40px/1 var(--font-d); }
.veh-speed span { font-size: 13px; margin-left: 6px; color: #d9cdb6; }
.veh-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #d9cdb6; margin-top: 4px; }
.veh-row > span:first-child { min-width: 44px; }
.meter.batt { width: 70px; }
.prompt {
  position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: var(--gold); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink);
  padding: 10px 18px; font-weight: 700; font-size: 16px; cursor: pointer;
  /* Stays between the vehicle panel on the left and the map column on the right, wrapping if it has to. */
  width: max-content; max-width: max(260px, min(760px, calc(100vw - 530px))); text-align: center;
}
.keys { position: absolute; right: 12px; bottom: 12px; max-width: min(760px, calc(100vw - 250px)); background: rgba(26, 20, 13, 0.6); color: #f3ead6; border-radius: 10px; padding: 6px 12px; font-size: 12.5px; line-height: 1.9; text-align: right; }
.keys kbd { background: rgba(255, 255, 255, 0.92); color: var(--ink); border-color: #000; }

#houseHud, #partyHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#houseHud button, #partyHud button { pointer-events: auto; }
#partyHud .prompt { cursor: default; }
.house-use { font-size: 19px; padding: 13px 26px; bottom: 120px; white-space: nowrap; }
/* Sitting or lying down in the house: the way back onto your feet, top and centre, clear of the thumbs. */
.pump-btn.house-up { top: 64px; bottom: auto; font-size: 17px; padding: 9px 20px; background: var(--paper-2); white-space: nowrap; }
#hseHint { bottom: 34px; cursor: default; white-space: normal; max-width: 92vw; text-align: center; }
body.indoors #touch .tbtns { display: none; }
#placeHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#placeHud button { pointer-events: auto; }
.place-btns { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: 96vw; }
#plcPrompt { bottom: 92px; cursor: default; white-space: normal; max-width: 92vw; text-align: center; }
#plcWhy.bad { background: var(--bad); }
#plcWhy.good { background: var(--green); }
body.placing #touch .tbtns { display: none; }
#rodeoHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#rodeoHud button { pointer-events: auto; }
#btnDash:not(.on) { background: rgba(26, 20, 13, 0.74); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
body.dash-off #hud .hud-tl > .chip:not(.low):not(#chipTyres) { display: none !important; }   /* a clear view: only the warnings stay */
.build-steps { margin: 6px 0 12px; padding: 0; list-style: none; counter-reset: bstep; display: grid; gap: 6px; }
.build-steps li { counter-increment: bstep; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper-2); }
.build-steps li::before { content: counter(bstep); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font: 800 14px var(--font); }
.build-steps li.done { background: #dcefd8; }
.build-steps li.done::before { content: '✓'; background: var(--good); }
.build-steps li span { flex: 1; min-width: 0; font-size: 14.5px; }
.build-steps li .btn { flex: none; white-space: nowrap; }
.build-bar { display: block; height: 9px; margin: 5px 0 3px; border: 1.5px solid var(--ink); border-radius: 6px; background: #fff; overflow: hidden; }
.build-bar i { display: block; height: 100%; width: auto; border: 0; border-radius: 0; background: var(--good); }
.auto-bar { pointer-events: auto; position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: 2.5px solid var(--ink); border-radius: 14px; background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 var(--ink); font-weight: 700; white-space: nowrap; }
.auto-bar, .auto-bar * { touch-action: auto !important; }
.auto-bar input { width: min(34vw, 240px); accent-color: var(--ink); }
.auto-bar button { padding: 8px 12px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper); color: var(--ink); font: 800 14px var(--font); cursor: pointer; }
#btnAutoMuster.on { background: var(--gold); color: var(--ink); }
body.auto-muster #touch { display: none !important; }   /* nothing to steer while the riders have it */
@media (max-width: 640px) { .auto-bar { gap: 6px; padding: 6px 8px; font-size: 13px; } .auto-bar > b:first-child { display: none; } }
#seasonTint { position: fixed; inset: 0; z-index: 5; pointer-events: none; transition: background 5s; }
.hub-menu .btn.winter { background: #cfe4f7; }
body.on-foot #touch .tbtns button:not([data-code="KeyX"]) { visibility: hidden; }   /* on foot there is nothing to brake or boost: only the way back in */
body.on-foot.hero #touch .tbtns button[data-code="KeyH"] { visibility: visible; }   /* (except a hero's power, in the horn's place) */
.pile-box { pointer-events: auto; position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); display: flex; gap: 10px; }
.pile-box button { padding: 12px 18px; border: 3px solid var(--ink); border-radius: 16px; background: var(--gold); color: var(--ink); font: 800 19px var(--font); cursor: pointer; box-shadow: 0 5px 0 var(--ink); white-space: nowrap; }
.pile-box button small { display: block; font-size: 11.5px; font-weight: 600; opacity: 0.75; }
#btnPileFire { background: #ffb26b; }
#villageHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#villageHud button { pointer-events: auto; }
#homeHud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#homeHud button { pointer-events: auto; }
#homeHud .chip .meter { display: block; width: 70px; }
#scrFurnish .join-list { max-height: 58vh; max-height: 58dvh; overflow: auto; }
.village-btns { flex-direction: column; align-items: flex-end; gap: 8px; }
.village-btns .menu-btn { height: 44px; font-size: 16px; }
.village-foot { margin-top: 10px; gap: 8px; }
#scrVillage .join-list { max-height: 56vh; max-height: 56dvh; overflow: auto; }
#vlgHint { white-space: normal; max-width: 92vw; text-align: center; cursor: default; }
body.touch #vlgHint { max-width: calc(100vw - 330px); font-size: 13.5px; }   /* clear of the joystick and the brake */
#scrSchool { z-index: 40; background: var(--paper); overflow: auto; }
#scrSchool:has(.relief) { align-items: center; justify-content: center; padding: 2vh 2vw; }
.relief-board { margin: 12px 0; padding: 22px 18px; border: 8px solid #7b5230; border-radius: 10px; background: #2f5d45; color: #f6f3e7; font: 700 22px var(--font); text-align: center; line-height: 1.35; }
.relief-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.relief-row .btn.big { text-align: center; font-size: 22px; min-height: 56px; }
#rdoPrompt { white-space: normal; max-width: 92vw; text-align: center; cursor: default; }
.rodeo-bar { position: absolute; left: 50%; bottom: 176px; transform: translateX(-50%); width: min(440px, 72vw); height: 34px; border: 3px solid var(--ink); border-radius: 12px; background: rgba(26, 20, 13, 0.8); overflow: hidden; box-shadow: 0 4px 0 var(--ink); }
.rodeo-bar i { position: absolute; top: 0; bottom: 0; display: block; }
.rodeo-bar #rdoFill { left: 0; width: 0; background: linear-gradient(90deg, var(--gold), var(--good)); }
.rodeo-bar #rdoZone { background: var(--good); opacity: 0.85; }
.rodeo-bar #rdoMark { width: 8px; margin-left: -4px; background: #fff; box-shadow: 0 0 0 2px var(--ink); }
.rodeo-bar.mash #rdoZone, .rodeo-bar.mash #rdoMark, .rodeo-bar.tie #rdoFill { display: none; }
.rodeo-menu .btn small { display: block; font-weight: 600; font-size: 12px; opacity: 0.85; margin-top: 2px; white-space: normal; }
.rodeo-menu .btn { text-align: left; white-space: normal; }
body.rodeo-ride #touch .tbtns button:not([data-code="Space"]) { display: none; }
body.rodeo-ride #touch .tbtns [data-code="Space"] { grid-area: 2 / 4; }
#countdown { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; font: 700 min(30vw, 240px) var(--font-d); color: #fff; text-shadow: 0 8px 0 var(--ink), 0 0 60px rgba(0, 0, 0, 0.4); pointer-events: none; }
/* Other players on the same connection: in the paddock they sit under the header, at the homestead in the top corner. */
.peers { position: fixed; z-index: 25; left: max(12px, env(safe-area-inset-left, 0px)); top: calc(var(--hud-clear, 150px) + 2px); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.peers.at-hub { left: auto; right: max(12px, env(safe-area-inset-right, 0px)); top: max(12px, env(safe-area-inset-top, 0px)); align-items: flex-end; }
.peer { pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--gold); color: var(--ink); font: 700 14px var(--font); box-shadow: 0 3px 0 var(--ink); cursor: pointer; text-align: left; touch-action: none; }
.peer i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.peer span { display: grid; line-height: 1.15; }
.peer small { font-weight: 600; font-size: 11px; opacity: 0.8; }
.peer em { font-style: normal; font-weight: 800; white-space: nowrap; }
.peer:disabled { background: var(--paper-2); cursor: default; }
.peer.here { background: #fff; }
.peer:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.peer * { pointer-events: none; }
.title-games { display: grid; gap: 8px; margin: 12px 0 4px; }
.title-games p { margin: 0; font-weight: 700; }
.title-games button { display: grid; gap: 2px; text-align: left; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 14px; background: var(--gold); color: var(--ink); font: 800 17px var(--font); box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.title-games button small { font-weight: 600; font-size: 12.5px; }
.title-games button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#btnRoad.on, #btnPipe.on { background: var(--gold); color: var(--ink); }
body.farming #btnRoad:not([hidden]) { display: block !important; }
#sleepFade { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: #05070f; color: #fff; font-size: min(22vw, 150px); opacity: 0; transition: opacity 0.8s; pointer-events: none; }
#sleepFade.on { opacity: 1; pointer-events: auto; }
.chip.night { background: rgba(20, 28, 66, 0.86); }
#btnSleep { grid-column: 1 / -1; background: #26315f; color: #fff; }
#btnSleep small { color: #cdd5f5; }
#spookFlash { position: fixed; inset: 0; z-index: 9; pointer-events: none; box-shadow: inset 0 0 140px 30px rgba(209, 73, 46, 0.75); opacity: 0; transition: opacity 0.25s; }
#toasts { position: fixed; z-index: 60; left: 50%; top: max(64px, var(--hud-clear, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 8px 16px; font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); animation: toastIn 0.25s ease-out; max-width: 92vw; }
.toast.good { background: var(--green); }
.toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: opacity 0.4s, transform 0.4s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- tables and lists */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { font: 700 14px var(--font); padding: 8px 14px; border-radius: 10px; border: 2.5px solid var(--ink); background: var(--paper-2); cursor: pointer; color: var(--ink); }
.tab.on { background: var(--ink); color: var(--paper); }
.table-wrap { overflow: auto; border: 2px solid var(--paper-3); border-radius: 12px; max-height: 58vh; max-height: 58dvh; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { position: sticky; top: 0; background: var(--paper-2); text-align: left; font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); padding: 8px 10px; white-space: nowrap; }
.tbl td { padding: 7px 10px; border-top: 1px solid var(--paper-3); white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tr.me td { background: #fdeebf; font-weight: 700; }
.tbl .empty td { text-align: center; color: var(--ink-2); padding: 22px; white-space: normal; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--ink); vertical-align: -1px; margin-right: 6px; }
.tag { display: inline-block; background: var(--gold); border: 1.5px solid var(--ink); border-radius: 5px; padding: 0 5px; font: 700 12px var(--font); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 8px; padding: 1px 6px; background: var(--paper-3); color: var(--ink-2); margin-right: 3px; }
.pill.on { background: #cfe9d5; color: var(--green); }
.pill.calf { background: #fbd9e3; color: #b0245a; }
.pill.low { background: #fbdcd4; color: #b3301a; }
.warn { color: #b3301a; font-weight: 700; }
.prompt.calving { background: #ffd9e4; cursor: default; }
.up { color: var(--good); } .down { color: var(--bad); }

/* ---------- market */
.mkt { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; }
.prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.price { background: var(--paper-2); border-radius: 12px; padding: 10px 12px; }
.price span { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.price small { display: block; font-size: 11.5px; color: var(--ink-2); }
.price b { font: 700 24px var(--font-d); }
.price canvas { width: 100%; height: 38px; display: block; margin-top: 4px; }
.pens, .lots { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; }
.card h4 { margin: 0; font: 700 15.5px var(--font-d); }
.card .meta { font-size: 12.5px; color: var(--ink-2); }
.card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.card .foot b { font: 700 19px var(--font-d); }
.card.mine { background: #fdf3d0; }
.shop-item { grid-template-rows: auto auto 1fr auto; }
.shop-icon { font-size: 34px; line-height: 1; }
.shop-note { grid-column: 1 / -1; margin: 0 0 4px; }
.card .foot small { font: 400 12px var(--font); color: var(--ink-2); }
.card.winning { border-color: var(--good); box-shadow: 0 0 0 3px rgba(46, 157, 87, 0.25); }
.card.outbid { border-color: var(--bad); }
.clock { height: 6px; border-radius: 4px; background: var(--paper-3); overflow: hidden; }
.clock i { display: block; height: 100%; background: var(--green-2); }
.clock.hot i { background: var(--bad); }
.herd-list { border: 2px solid var(--paper-3); border-radius: 12px; max-height: 42vh; max-height: 42dvh; overflow: auto; background: #fff; }
.hrow { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-top: 1px solid var(--paper-2); font-size: 13.5px; font-weight: 400; margin: 0; cursor: pointer; }
.hrow .d { flex: 1; min-width: 0; display: grid; gap: 3px; }
.hrow .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.hrow .tag { flex: none; }
.hrow:first-child { border-top: 0; }
.hrow:hover { background: #fdf6e0; }
.hrow input { flex: none; width: 17px; height: 17px; padding: 0; accent-color: var(--green); }
.hrow .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.hrow .empty { flex: 1; text-align: center; color: var(--ink-2); padding: 14px; cursor: default; }
.sell-box { margin-top: 12px; display: grid; gap: 8px; }
.sell-sum { display: flex; justify-content: space-between; font-size: 14px; }
.sell-sum b { font: 700 20px var(--font-d); }
.sell-box input { font-size: 15px; padding: 7px 10px; max-width: 120px; }
.sell-box label { margin: 0; }

/* ---------- results */
.result { display: grid; gap: 4px; margin: 14px 0; }
.result div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 8px; background: var(--paper-2); font-size: 14.5px; }
.result div b { font-variant-numeric: tabular-nums; }
.result div.bonus { background: var(--gold); font-weight: 700; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 16px; padding: 10px 12px; border-radius: 12px; background: var(--ink); color: var(--paper); }
.total b { font: 700 30px var(--font-d); color: var(--gold-2); }
#mdStock { margin: -6px 0 12px; }

/* ---------- help */
.help { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.help h3:first-child { margin-top: 0; }
.keytbl { font-size: 13.5px; border-collapse: collapse; margin-top: 8px; }
.keytbl td { padding: 3px 10px 3px 0; }

/* ---------- crush */
.screen.crush { flex-direction: column; gap: 10px; padding: 12px; background: rgba(24, 18, 10, 0.62); backdrop-filter: blur(4px); }
.crush-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crush-top .btn { margin-left: auto; }
.crush-top .btn + .btn { margin-left: 0; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; }
.steps span { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 9px; background: rgba(255, 255, 255, 0.16); color: #e9dfca; }
.steps span.now { background: var(--gold); color: var(--ink); }
.steps span.done { background: var(--good); color: #fff; }
.steps span.out { background: var(--bad); color: #fff; }
.crew-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; padding: 4px 6px 4px 12px; border-radius: 12px; background: rgba(26, 20, 13, 0.74); color: #fff; font-size: 14px; }
.crew-bar .btn { margin-left: 0; padding: 6px 12px; font-size: 14px; }
.crew-bar.auto { padding: 8px 12px; }
.crew-bar.auto .crew-speed, .crew-bar.auto .btn { display: none; }
.crew-speed { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: #fff; font-size: 16px; }
.crew-speed b { min-width: 3.2em; font-size: 14px; }
.crew-speed input { width: 140px; height: 28px; margin: 0; accent-color: var(--gold); touch-action: none; }
.crush-main { flex: 1; min-height: 0; display: flex; gap: 14px; align-items: stretch; justify-content: center; }
.crush-stage { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; }
#crushCanvas, #calveCanvas { max-width: 100%; max-height: 100%; aspect-ratio: 16 / 9; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 8px 0 var(--ink); background: #bfe0f2; touch-action: none; cursor: crosshair; }
.crush-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--gold); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink); padding: 8px 16px; font-weight: 700; font-size: 16px; white-space: nowrap; pointer-events: none; max-width: 94%; overflow: hidden; text-overflow: ellipsis; }
.phone { flex: none; width: 290px; align-self: center; background: #17181b; border-radius: 36px; padding: 12px; box-shadow: 0 8px 0 #000, 0 20px 40px rgba(0, 0, 0, 0.4); position: relative; }
.phone-notch { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 80px; height: 20px; border-radius: 12px; background: #17181b; z-index: 2; }
.phone-screen { background: #f4f6f3; border-radius: 26px; overflow: hidden; height: min(520px, 68vh); height: min(520px, 68dvh); display: flex; flex-direction: column; }
.app-head { background: var(--green); color: #fff; padding: 34px 14px 10px; display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.app-head b { font: 700 19px var(--font-d); }
.app-body { padding: 12px 14px; font-size: 13.5px; overflow: auto; flex: 1; }
.app-body .eid { font: 700 17px ui-monospace, Menlo, monospace; letter-spacing: 0.02em; }
.app-body .muted { color: #7c8580; }
.app-card { background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.app-card h5 { margin: 0 0 4px; font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: #7c8580; }
.app-card .big { font: 700 26px var(--font-d); }
.check { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-top: 1px solid #edf0ec; }
.check:first-of-type { border-top: 0; }
.check b { color: var(--good); }
.check .todo { color: #b0b7b2; font-weight: 400; }
.app-card .out { color: var(--bad); font-weight: 700; }
.app-card small.left { color: #7c8580; font-weight: 400; margin-left: 3px; white-space: nowrap; }
.app-card small.left.low { color: var(--bad); font-weight: 700; }

/* ---------- phones held upright: the paddock needs a wide screen */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  body.touch.needs-wide #rotate { display: grid; place-items: center; position: fixed; inset: 0; z-index: 80; background: rgba(24, 18, 10, 0.94); color: #fff; font: 700 24px/1.5 var(--font-d); text-align: center; padding: 30px; }
}

/* ---------- touch controls */
#touch { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#stick { position: absolute; left: 22px; bottom: 120px; width: 130px; height: 130px; border-radius: 50%; background: rgba(26, 20, 13, 0.4); border: 2px solid rgba(255, 255, 255, 0.5); pointer-events: auto; }
#stick i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); }
.tbtns { position: absolute; right: 16px; bottom: 60px; display: grid; grid-template-columns: repeat(4, 64px); grid-template-rows: repeat(2, 60px); gap: 10px; pointer-events: none; }
.tbtns button { pointer-events: auto; }
/* Every thumb button has its own place and keeps it: one that is not needed leaves a gap, nothing else moves. */
/* Four across: a column was added on the left for getting out, so every older button is where it always was. */
.tbtns [data-code="KeyR"] { grid-area: 1 / 2; }
.tbtns [data-code="KeyB"] { grid-area: 1 / 3; }
.tbtns [data-code="Space"] { grid-area: 1 / 4; }
.tbtns [data-code="KeyF"] { grid-area: 2 / 2; }
.tbtns [data-code="KeyH"] { grid-area: 2 / 3; }
.tbtns [data-code="ShiftLeft"] { grid-area: 2 / 4; }
.tbtns [data-code="KeyX"] { grid-area: 2 / 1; }
.tbtns button.dim { opacity: 0.55; }
.tbtns button { height: 60px; border-radius: 16px; border: 2px solid rgba(255, 255, 255, 0.5); background: rgba(26, 20, 13, 0.55); color: #fff; font-size: 20px; }
.tbtns button small { display: block; font-size: 9px; }
.tbtns button * { pointer-events: none; }   /* the button itself takes the touch, never the label inside it */
.tbtns .wide { grid-column: 1 / -1; font-size: 16px; }

@media (max-width: 900px) and (orientation: portrait) {
  /* Phones held upright: menu at the bottom, homestead in view above it. */
  .screen.side { align-items: flex-end; justify-content: center; padding: 12px; background: linear-gradient(0deg, rgba(20, 30, 20, 0.3), transparent 60%); }
  .panel.hero { max-height: 62vh; max-height: 62dvh; }
  .lede { display: none; }
}
@media (max-width: 900px) {
  .mkt, .help { grid-template-columns: 1fr; }
  .phone { width: 230px; }
  .panel { padding: 18px; }
  .hud-tl { max-width: calc(100vw - 190px); }
  #minimap, .mini-board, .hud-btn { width: 160px; }
  #minimap { height: 157px; }
  .keys { display: none; }
}
@media (max-height: 560px) {
  .phone-screen { height: 62vh; height: 62dvh; }
  .mini-board { display: none; }
}
/* Phones held sideways: everything a size smaller so the paddock stays visible. */
@media (max-height: 480px) {
  .screen.side { padding: 8px 12px; }
  .panel { padding: 12px 16px; border-radius: 14px; }
  .panel.hero { width: min(350px, 58vw); }
  h1 { font-size: 32px; }
  h2 { font-size: 21px; }
  h3 { margin: 10px 0 6px; }
  .lede, .eyebrow { display: none; }
  label { margin: 8px 0 4px; }
  .btn.big { font-size: 14.5px; padding: 7px 12px; }
  .panel.hero { width: min(430px, 62vw); }
  #scrHub .panel.hero { width: min(480px, 60vw); padding: 9px 14px; }
  .hub-menu .btn small { display: none; }
  .hub-menu .btn.big { padding: 6px 10px; font-size: 14px; }
  #scrHub .stats b { font-size: 15px; }
  .menu { gap: 6px; margin: 8px 0; grid-template-columns: 1fr 1fr; }
  .menu .primary { grid-column: 1 / -1; }
  .menu .btn { white-space: normal; line-height: 1.2; }
  .stats { gap: 5px; margin-top: 6px; }
  .stats div { padding: 3px 10px; }
  .stats b { font-size: 16px; }
  .mp { padding-top: 6px; }
  .hud-tl { top: 8px; left: 8px; gap: 5px; max-width: calc(100vw - 190px); }
  .chip { font-size: 14px; padding: 4px 8px; gap: 6px; }
  .chip .lbl { font-size: 9.5px; letter-spacing: 0.05em; }   /* cash, cattle and net worth ride along on a phone too, so every chip gives up a little */
  .hud-tr { top: 8px; right: 8px; flex-direction: row; align-items: flex-start; }
  #minimap { width: 116px; height: 114px; }
  .hud-btn { width: 116px; height: 28px; font-size: 11.5px; position: absolute; top: 122px; right: 0; }
  #btnRecentre { top: 154px; }
  #btnGateToggle { top: 186px; }
  #btnRoad { top: 218px; }
  #btnPipe, #btnFoot { top: 186px; }
  #btnAutoMuster { top: 250px; }
  #btnBuild { top: 250px; }
  #btnPipeBack { top: 250px; }
  .menu-btn { padding: 0 10px; font-size: 13px; border-radius: 9px; }
  .hud-menu { grid-template-columns: 1fr 1fr; gap: 5px; padding: 6px; }
  .hud-menu .menu-btn { min-height: 40px; padding: 4px 10px; font-size: 13.5px; }
  .hud-menu .menu-btn small { font-size: 10.5px; }
  .chip .meter { display: none; }
  .chip.fuel .meter { width: 20px; }
  #btnFarmHome { top: 122px; }
  #btnSpread { top: 186px; }
  .icon-btn { width: 34px; height: 34px; }
  .veh { min-width: 0; padding: 5px 10px; }
  .veh-speed b { font-size: 24px; }
  .prompt { bottom: 12px; font-size: 14px; padding: 7px 12px; }
  .pump-btn { bottom: 62px; padding: 10px 26px; font-size: 19px; }
  .pump-btn kbd { display: none; }
  #toasts { top: max(44px, var(--hud-clear, 0px)); }
  .toast { font-size: 12.5px; padding: 5px 12px; }
  .screen.crush { padding: 6px; gap: 5px; }
  .crush-top { gap: 5px; }
  .crush-top .chip .lbl { display: none; }
  .steps span { font-size: 10.5px; padding: 3px 6px; }
  .crush-main { gap: 8px; }
  #crushCanvas, #calveCanvas { border-width: 2px; border-radius: 10px; box-shadow: 0 4px 0 var(--ink); }
  .crush-hint { font-size: 12.5px; padding: 4px 10px; bottom: 8px; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
  .phone { width: 176px; padding: 7px; border-radius: 22px; box-shadow: 0 4px 0 #000; }
  .phone-notch { display: none; }
  .phone-screen { height: 66vh; height: 66dvh; border-radius: 16px; }
  .app-head { padding: 8px 10px 6px; font-size: 10px; }
  .app-head b { font-size: 15px; }
  .app-body { padding: 7px; font-size: 11.5px; }
  .app-card { padding: 5px 8px; margin-bottom: 5px; border-radius: 8px; }
  .app-card h5 { font-size: 9px; margin-bottom: 1px; }
  .app-card .big { font-size: 18px; }
  .app-body .eid { font-size: 12px; }
  .check { padding: 2px 0; }
}
/* On the very shortest screens the gate button under the map would sit on the thumb buttons: it stays in the ☰ Menu. */
@media (max-height: 360px) { #btnGateToggle, #btnRoad, #btnPipe, #btnPipeBack, #btnAutoMuster { display: none !important; } }
/* A tablet on its side, or a short wide window: the phone app a size smaller, so the treatments list stays in view. */
@media (min-height: 481px) and (max-height: 700px) and (orientation: landscape) {
  .phone { width: min(250px, 34vw); padding: 9px; border-radius: 28px; }
  .phone-notch { display: none; }
  .phone-screen { height: min(520px, 70vh); height: min(520px, 70dvh); border-radius: 20px; }
  .app-head { padding: 10px 12px 8px; }
  .app-body { padding: 9px 10px; font-size: 12.5px; }
  .app-card { padding: 7px 10px; margin-bottom: 6px; }
  .app-card .big { font-size: 21px; }
  .app-body .eid { font-size: 15px; }
  .check { padding: 3px 0; }
  .crush-hint { white-space: normal; text-align: center; width: max-content; }
}
/* Touch screens: joystick bottom-left, buttons bottom-right, vehicle panel moved up out of the way. */
body.touch .keys { display: none; }
body.touch .mini-board { display: none; }   /* on a touch screen that corner belongs to the thumb buttons */
/* Shorter touch screens: a smaller map, so the column under it never reaches the thumb buttons. */
@media (min-height: 481px) and (max-height: 640px) and (orientation: landscape) {
  body.touch #minimap { width: 160px; height: 157px; }
  body.touch .hud-btn { width: 160px; }
}
body.touch #stick { left: 16px; bottom: 16px; width: 124px; height: 124px; }
body.touch .tbtns { right: 10px; bottom: 10px; grid-template-columns: repeat(4, 58px); grid-template-rows: repeat(2, 52px); gap: 8px; }
body.touch .tbtns button { height: 52px; }
body.touch .tbtns [data-code="ShiftLeft"] { background-image: linear-gradient(to top, rgba(244, 184, 46, 0.6) var(--boost, 100%), transparent 0); }
body.touch .prompt { max-width: min(92vw, 560px); }
/* Big touch screens (iPad): room for bigger controls. */
@media (min-width: 900px) and (min-height: 600px) {
  body.touch #stick { left: 28px; bottom: 28px; width: 150px; height: 150px; }
  body.touch .tbtns { right: 22px; bottom: 22px; grid-template-columns: repeat(4, 72px); grid-template-rows: repeat(2, 66px); gap: 10px; }
  body.touch .tbtns button { height: 66px; font-size: 24px; }
  body.touch .tbtns button small { font-size: 10.5px; }
}
/* Phones held upright: the map and its buttons shrink, the chips sit beside them, the prompt clears the thumbs. */
@media (max-width: 600px) and (orientation: portrait) {
  .hud-tl { top: 8px; left: 8px; gap: 4px; max-width: calc(100vw - 136px); }
  .chip { font-size: 13px; padding: 4px 7px; gap: 4px; }
  .chip .lbl { font-size: 9px; letter-spacing: 0.04em; }
  .chip .meter { display: none; }
  .hud-tr { top: 8px; right: 8px; gap: 5px; }
  #minimap { width: 116px; height: 114px; border-width: 2px; }
  .hud-btn { width: 116px; height: 28px; font-size: 11.5px; }
  .menu-btn { padding: 0 10px; font-size: 13px; border-radius: 9px; }
  .hud-menu .menu-btn { min-height: 42px; font-size: 14.5px; }
  .chip.fuel .meter { width: 26px; }
  .icon-btn { width: 34px; height: 34px; }
  .mini-board { display: none; }
  .prompt { bottom: 168px; font-size: 14px; padding: 7px 12px; }
  .pump-btn { bottom: 230px; padding: 11px 24px; font-size: 19px; }
  .pump-btn kbd { display: none; }
  .toast { font-size: 12.5px; padding: 5px 12px; }
  .rodeo-bar { bottom: 232px; }
  #plcPrompt { bottom: 150px; }
  .place-btns { bottom: 150px; top: auto; }
  body.placing #plcPrompt { bottom: 250px; }
  .house-use { bottom: 170px; }
  #hseHint { bottom: 240px; }
  .panel { padding: 14px; }
  .panel.hero, #scrHub .panel.hero { width: 100%; padding: 12px 14px; max-height: 88vh; max-height: 88dvh; }
  .btn.big { font-size: 15px; padding: 9px 12px; }
  .menu { grid-template-columns: 1fr 1fr; gap: 7px; }
  .menu .primary { grid-column: 1 / -1; }
  .stats b, #scrHub .stats b { font-size: 15px; }
  #scrHub .stats span { font-size: 8.5px; letter-spacing: 0.02em; }
  #scrHub .stats div { padding: 4px 6px; }
  .hub-menu .btn.big { font-size: 14px; padding: 7px 9px; }
  .hub-menu .btn small { font-size: 10.5px; }
  .phead h2 { font-size: 22px; }
}
/* Short upright phones: the homestead menu drops its small print so every button is on the screen at once. */
@media (max-width: 600px) and (orientation: portrait) and (max-height: 720px) {
  .hub-menu .btn small { display: none; }
  #scrHub h2 { font-size: 22px; }
  #scrHub .stats { grid-template-columns: 1fr 1fr; }
  #scrHub .stats div { display: flex; align-items: baseline; gap: 6px; }
}
/* A menu of nine on a screen that is not tall: two columns. */
@media (max-height: 620px) and (min-width: 560px) { .hud-menu { grid-template-columns: 1fr 1fr; } }
/* The narrowest phones: thumb controls a size down so the stick and the buttons do not meet. */
@media (max-width: 360px) {
  body.touch #stick { left: 10px; width: 104px; height: 104px; }
  body.touch .tbtns { right: 8px; grid-template-columns: repeat(4, 52px); gap: 6px; }
}
/* Tablets held upright: the crush puts the phone app under the picture instead of beside it. */
@media (orientation: portrait) and (min-width: 601px) {
  .crush-main { flex-direction: column; align-items: center; }
  .crush-stage { flex: none; width: 100%; }
  .phone { width: min(560px, 92vw); border-radius: 26px; }
  .phone-notch { display: none; }
  .phone-screen { height: auto; max-height: 34vh; max-height: 34dvh; }
  .app-head { padding-top: 12px; }
  .app-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .app-card { margin-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .btn { transition: none; }
}

/* The quick tour, and the first steps on the homestead screen, for new players */
#tourOffer { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 30; width: min(440px, calc(100vw - 32px)); background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 12px 16px; box-shadow: 0 5px 0 var(--ink); text-align: center; animation: wkIn 0.35s ease-out; }
#tourOffer b { font-size: 18px; }
#tourOffer p { margin: 6px 0 10px; font: 600 15px/1.35 var(--font); }
#tourOffer .row { justify-content: center; gap: 10px; }
#tourBox { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#tourBox .tour-stop { position: absolute; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); pointer-events: auto; height: 46px; font-size: 16px; }
.tour-cap { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(22px, env(safe-area-inset-bottom)); width: min(620px, calc(100vw - 32px)); background: rgba(255, 250, 240, 0.95); border: 3px solid var(--ink); border-radius: 16px; padding: 12px 18px; text-align: center; box-shadow: 0 5px 0 var(--ink); }
.tour-cap b { font-size: 20px; }
.tour-cap p { margin: 6px 0 8px; font: 600 16px/1.35 var(--font); }
.tour-dots { display: flex; gap: 6px; justify-content: center; }
.tour-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(26, 20, 13, 0.2); }
.tour-dots i.on { background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
body.touring #walkieBtn, body.touring #walkieMsg { display: none !important; }
@media (max-height: 480px) { .tour-cap b { font-size: 16px; } .tour-cap p { font-size: 14px; margin: 3px 0 5px; } }
.getting-started { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 4px; }
.getting-started b { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.getting-started span { padding: 4px 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); font: 700 13px var(--font); }
.getting-started span.done { opacity: 0.5; text-decoration: line-through; }
.btn.pulse { animation: pulseBtn 1s ease-in-out infinite; }
@keyframes pulseBtn { 50% { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(244, 184, 46, 0.55); } }

/* Land, bulls and the AgriEID tools */
.land-bank { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.card .pill.next { background: #e8f0ff; }
.card .btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.bull-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; font-size: 12px; }
.bull-figs div { background: #f6f1e4; border-radius: 8px; padding: 4px 6px; }
.bull-figs b { display: block; font: 700 15px var(--font-d); }
.agri-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 6px 0 10px; }
.agri-tools .tool { background: #f6f1e4; border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px; display: grid; gap: 6px; }
.agri-tools h4 { margin: 0; font: 700 15px var(--font-d); }
.agri-tools .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.agri-tools select { font: inherit; padding: 4px; border-radius: 8px; }
.tbl td.slow { color: var(--bad); font-weight: 700; }
.tbl td.fast { color: var(--good); font-weight: 700; }
#bullVideo { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.82); display: grid; place-items: center; padding: 16px; }
#bullVideo[hidden] { display: none; }
#bullVideo .bv-box { position: relative; width: min(960px, 100%); }
#bvCanvas { width: 100%; height: auto; display: block; border-radius: 12px; background: #8fc4e8; }
#bullVideo .bv-cap { position: absolute; left: 4%; top: 6%; color: #fff; font: 700 clamp(16px, 3vw, 30px) var(--font-d); text-shadow: 0 2px 6px #000; max-width: 80%; }
#bullVideo .bv-stats { position: absolute; left: 4%; bottom: 16%; color: #fff; font: 600 clamp(13px, 2vw, 20px) var(--font); text-shadow: 0 2px 6px #000; background: rgba(0, 0, 0, 0.35); padding: 6px 10px; border-radius: 8px; }
#bullVideo .bv-btns { display: flex; justify-content: center; margin-top: 10px; }
.pf-recovery { margin: 4px 0 8px; padding: 8px 10px; border: 2px dashed var(--ink); border-radius: 10px; background: var(--paper-2); font: 600 14px/1.35 var(--font); }
.pf-recovery b { font: 800 20px ui-monospace, Menlo, monospace; letter-spacing: 0.12em; }
#noticeBox { position: fixed; left: 50%; top: max(70px, env(safe-area-inset-top)); transform: translateX(-50%); z-index: 45; width: min(520px, calc(100vw - 32px)); background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 14px 18px; box-shadow: 0 6px 0 var(--ink); text-align: center; animation: wkIn 0.35s ease-out; }
#noticeBox p { margin: 0 0 12px; font: 700 17px/1.4 var(--font); user-select: text; -webkit-user-select: text; }
#noticeBox .row { justify-content: center; }
.give-any { margin-top: 8px; gap: 8px; }
.give-any input { flex: 1; min-width: 0; padding: 9px 12px; border: 2px solid var(--ink); border-radius: 10px; font: 700 15px var(--font); }
.crew-speeds { display: inline-flex; gap: 4px; }
.crew-speeds button { padding: 4px 9px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); font: 800 13px var(--font); color: var(--ink); cursor: pointer; }
.crew-speeds button.on { background: var(--gold); }
.saw-auto { position: absolute; left: 50%; transform: translateX(-50%); bottom: 214px; height: 42px; pointer-events: auto; }
