: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; }
[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; 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; 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; 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 */
#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);
}
.chip .lbl { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #d9cdb6; }
.chip.dark { background: var(--ink); }
.hud-tl { position: absolute; 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; }
.hud-row { display: flex; gap: 6px; width: 220px; pointer-events: auto; }
.hud-row .hud-btn { flex: 1; width: auto; min-width: 0; padding: 0 4px; font-size: 12.5px; white-space: nowrap; }
.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); }
.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; white-space: nowrap;
}
.keys { position: absolute; right: 12px; bottom: 12px; max-width: 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 { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#houseHud button { pointer-events: auto; }
.house-use { font-size: 19px; padding: 13px 26px; bottom: 120px; 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; }
#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; }
#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; }
#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: 64px; 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; }
.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; 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; }
.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; }
.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; }
.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); 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 (pointer: coarse) {
  body.playing #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: 64px 64px; gap: 10px; pointer-events: auto; }
.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 .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; }
  .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, .hud-row { width: 160px; }
  .hud-row span { display: none; }
  .hud-row .hud-btn { font-size: 15px; }
  #minimap { height: 157px; }
  .keys { display: none; }
}
@media (max-height: 560px) {
  .phone-screen { height: 62vh; }
  .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); }
  .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: 6px; max-width: calc(100vw - 190px); }
  .hud-tl .chip:first-child { display: none; }
  .chip { font-size: 14px; padding: 4px 10px; }
  .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; }
  .hud-row { position: absolute; top: 186px; right: 0; width: 116px; gap: 4px; }
  .hud-row .hud-btn { position: static; font-size: 15px; }
  .hud-row span { display: none; }
  #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: 44px; }
  .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; 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; }
}
/* Touch screens: joystick bottom-left, buttons bottom-right, vehicle panel moved up out of the way. */
@media (pointer: coarse) {
  .turbo-btn { display: none; }   /* the thumb buttons already have turbo */
  .hud-bl { top: 58px; bottom: auto; }
  .keys { display: none; }
  #stick { left: 16px; bottom: 16px; width: 124px; height: 124px; }
  .tbtns { right: 10px; bottom: 10px; grid-template-columns: repeat(3, 58px); gap: 8px; }
  .tbtns button { height: 52px; }
  .tbtns .wide { grid-column: span 2; font-size: 14px; }
}
@media (pointer: coarse) and (max-height: 480px) {
  .hud-bl { top: 42px; left: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .btn { transition: none; }
}
