/* Ranch Builder additions on top of ../style.css */
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
#statCard { width: 380px; }
#statCard .stats { grid-template-columns: repeat(5, 1fr); }
#statCard .stats b { font-size: 24px; }
#elevChip { margin-top: 4px; color: #d9cfb2; font-size: 12px; }
#minimap { width: 220px; height: 220px; }
#labels { position: absolute; inset: 0; pointer-events: none; z-index: 3; overflow: hidden; }
.plabel { position: absolute; left: 0; top: 0; font: 400 22px/1 var(--display); letter-spacing: 1.5px; text-shadow: 0 2px 6px #000, 0 0 2px #000; white-space: nowrap; text-align: center; will-change: transform; }
.plabel small { display: block; font: 700 12px Inter, sans-serif; color: #fff; letter-spacing: 0; }
#typebar { position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); z-index: 6; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: min(1080px, calc(100vw - 520px)); }
.tcard { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 10px; min-width: 118px; text-align: left; background: var(--glass); backdrop-filter: blur(8px); }
.tcard b { font-size: 12px; font-weight: 700; }
.tcard small { color: var(--muted); font-size: 10.5px; max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard.active { border-color: var(--gold); box-shadow: 0 0 16px rgba(255, 216, 74, .35); }
.tcard.active b { color: var(--gold); }
#hud { bottom: 176px; }
#toolName { bottom: 214px; }
#title { background: linear-gradient(90deg, rgba(8,7,4,.9) 0%, rgba(8,7,4,.5) 38%, rgba(8,7,4,0) 66%), linear-gradient(0deg, rgba(8,7,4,.65), rgba(8,7,4,0) 30%); }
#title .big:disabled { filter: grayscale(.6) brightness(.8); cursor: wait; }
@media (max-width: 1100px) { #typebar { max-width: calc(100vw - 32px); bottom: 100px; } #statCard { width: 300px; } }

.ttabs { display: flex; gap: 4px; width: 100%; justify-content: center; margin-bottom: 2px; }
.ttab { padding: 3px 10px; font-size: 11px; font-weight: 700; border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); }
.ttab.active { background: var(--gold); color: #1b1a12; border-color: var(--gold); }

/* ---------------- town */
body.intown #hudLayer, body.intown #labels { display: none; }
#townHud { position: fixed; inset: 0; pointer-events: none; z-index: 20; font-family: Inter, sans-serif; }
#townHud .th-top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
#townHud .th-top b { font: 400 20px var(--display); letter-spacing: 2px; color: var(--gold); }
#townHud .th-speed { position: absolute; right: 22px; bottom: 22px; padding: 10px 18px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); text-align: right; }
#townHud .th-speed b { font: 400 54px/1 var(--display); color: #fff; }
#townHud .th-speed small { margin-left: 4px; color: var(--muted); }
#townHud .th-speed i { display: block; font-size: 11px; color: var(--gold); font-style: normal; }
#townHud .th-keys { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-size: 12px; white-space: nowrap; }
#thPrompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); font: 400 26px var(--display); letter-spacing: 2px; color: var(--gold); text-shadow: 0 2px 8px #000; }
#thTalk { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); width: min(720px, 90vw); padding: 14px 18px; border-radius: 12px; background: rgba(14, 15, 11, .92); border: 2px solid var(--gold); }
#thTalk b { font: 400 24px var(--display); letter-spacing: 1.5px; color: var(--gold); }
#thTalk small { margin-left: 10px; color: var(--muted); }
#thTalk p { margin: 6px 0; font-size: 16px; }
#thTalk span { float: right; font-size: 11px; color: var(--muted); }
#townBtn { color: var(--gold) !important; border-color: var(--gold) !important; }

/* ---------------- touch controls */
#tStick, .tgroup { display: none; }
body.touch canvas#view { touch-action: none; }
body.touch #tStick { position: fixed; left: 18px; bottom: 150px; z-index: 30; }
body.touch #tStick .ring { width: 124px; height: 124px; border-radius: 50%; background: rgba(20, 18, 12, .35); border: 2px solid rgba(255, 216, 74, .45); display: grid; place-items: center; touch-action: none; }
body.touch #tStick .knob { width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 216, 74, .8); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); pointer-events: none; }
body.touch .tgroup { position: fixed; z-index: 30; flex-direction: column; gap: 8px; }
body.touch .tb { min-width: 74px; padding: 11px 12px; font: 600 13px Inter, sans-serif; border-radius: 12px; background: var(--glass); backdrop-filter: blur(8px); touch-action: manipulation; }
body.touch .tb.go { background: linear-gradient(180deg, #ffe27a, var(--gold2)); color: #19160a; border-color: #fff3c0; }
body.touch .tb.on { background: var(--gold); color: #19160a; }
/* edit buttons show only while a tool that needs them is out */
body.touch #tEdit { right: 10px; top: 50%; transform: translateY(-50%); }
body.touch.tool-fence #tEdit, body.touch.tool-lay #tEdit, body.touch.tool-build #tEdit, body.touch.tool-place #tEdit, body.touch.tool-move #tEdit, body.touch.tool-select #tEdit { display: flex; }
body.touch.tool-select #tEdit .tb:nth-child(-n+3) { display: none; }
body.touch.tool-measure #tEdit { display: flex; }
body.touch.tool-measure #tEdit .tb:not(:nth-child(2)) { display: none; }
@media (max-width: 760px) { body.touch #photoBtn { display: none; } }
/* hidden HUD means hidden: no ghost panels in photos */
body.nohud #statCard, body.nohud #quick, body.nohud #hotbar, body.nohud #minimap, body.nohud #compass, body.nohud #typebar, body.nohud #hud, body.nohud #notify { opacity: 0 !important; pointer-events: none; }
body.touch:not(.tool-fence):not(.tool-lay) #tEdit .tb:nth-child(1) { display: none; }
body.touch:not(.tool-build):not(.tool-place):not(.tool-move) #tEdit .tb:nth-child(3) { display: none; }
body.touch.walking #tStick, body.touch.intown #tStick { display: block; }
body.touch.walking #tWalk { display: flex; right: 14px; bottom: 150px; }
body.touch.walking #tEdit { top: 40%; }
body.touch.intown #tTown { display: flex; right: 14px; bottom: 40px; }
body.touch.intown #tStick { bottom: 40px; }
body.touch.intown #tEdit, body.touch.nohud #tEdit, body.touch #title:not(.out) ~ #tEdit { display: none !important; }
body.touch #townHud .th-keys { display: none; }
body.touch #title .foot { display: none; }
body.touch #walkHint { top: auto; bottom: 290px; font-size: 11px; }
body.touch #crosshair { display: none; }

/* ---------------- phone layout */
@media (max-width: 760px) {
  #title .inner { left: 20px; right: 20px; max-width: none; }
  #title .kicker { letter-spacing: 3px; font-size: 11px; }
  #title { background: linear-gradient(0deg, rgba(8,7,4,.92) 0%, rgba(8,7,4,.6) 55%, rgba(8,7,4,.2) 100%); }

  #statCard { top: 8px; left: 8px; width: calc(100vw - 120px); padding: 8px 10px; border-radius: 10px; }
  #statCard .ranch { font-size: 17px; margin-bottom: 4px; }
  #statCard .stats { grid-template-columns: repeat(5, 1fr); gap: 2px; }
  #statCard .stats b { font-size: 17px; }
  #statCard .stats small { font-size: 8px; letter-spacing: .3px; }
  #timeChip, #elevChip { display: none; }
  #quests { display: none; }
  #statCard.open #quests { display: block; }
  #statCard.open #timeChip { display: block; }
  #compass { display: none; }
  #minimap { top: 8px; right: 8px; bottom: auto; width: 100px; height: 100px; }

  #hotbar { left: 0; right: 0; bottom: 0; transform: none; border-radius: 0; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  #hotbar::-webkit-scrollbar { display: none; }
  .slot { flex: none; width: 54px; height: 54px; }
  .slot svg { width: 21px; height: 21px; }
  .slot i { display: none; }
  .slot.active, .slot:hover { transform: none; }
  #quick { left: 0; right: 0; bottom: calc(68px + env(safe-area-inset-bottom)); flex-direction: row; gap: 6px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
  #quick::-webkit-scrollbar { display: none; }
  #quick button { flex: none; min-width: 0; padding: 7px 11px; }
  #quick kbd, #hideBtn { display: none; }

  #typebar { left: 8px; right: 8px; top: 92px; bottom: auto; transform: none; width: auto; max-width: none; display: block; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
  #typebar::-webkit-scrollbar { display: none; }
  .ttabs { justify-content: flex-start; overflow-x: auto; margin-bottom: 4px; }
  .ttab { flex: none; }
  .tcard { display: inline-flex; vertical-align: top; min-width: 104px; margin-right: 6px; }
  #hud { top: 178px; bottom: auto; white-space: normal; font-size: 12px; border-radius: 12px; }
  #toolName { bottom: auto; top: 50%; font-size: 26px; }
  #notify { top: auto; bottom: 120px; left: 8px; right: 8px; width: auto; }
  #toast { top: 120px; max-width: 90vw; }
  #panel { top: 0; left: 0; bottom: 0; width: 100vw; max-width: none; border-radius: 0; }
  #panel .scroll { padding-bottom: 40px; }

  #townHud .th-top { top: 8px; font-size: 12px; padding: 6px 12px; max-width: 94vw; white-space: nowrap; }
  #townHud .th-top b { font-size: 16px; }
  #townHud .th-speed { right: 50%; transform: translateX(50%); bottom: auto; top: 50px; padding: 4px 12px; }
  #townHud .th-speed b { font-size: 30px; }
  #thPrompt { bottom: 190px; font-size: 20px; }
  #thTalk { bottom: 180px; }
  #thTalk p { font-size: 14px; }
}

/* ---------------- budget table, visiting plan, print sheet */
.budget { width: 100%; border-collapse: collapse; margin: 6px 0 4px; font-size: 11.5px; }
.budget th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 2px 3px; }
.budget td { padding: 2px 3px; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.budget td:nth-child(n+2), .budget th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.budget tr.tot td { font-weight: 700; color: var(--gold); border-bottom: 0; }
#guestSection { border: 1px solid #ff5ad0; border-radius: 10px; padding: 8px 10px; margin-top: 8px; }
#guestSection h2 { color: #ff8ade; }
#printSheet { display: none; }
@media print {
  @page { margin: 12mm; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; }
  body > *:not(#printSheet) { display: none !important; }
  #printSheet { display: block; color: #111; font: 11pt/1.35 Inter, Arial, sans-serif; }
  #printSheet h1 { font: 700 18pt Inter, Arial, sans-serif; margin: 0; color: #111; }
  #printSheet h2 { font: 700 12pt Inter, Arial, sans-serif; margin: 12pt 0 4pt; color: #111; letter-spacing: 0; text-transform: none; }
  #printSheet .ps-sub { color: #555; font-size: 9pt; margin: 2pt 0 8pt; }
  #printSheet img { width: 100%; max-height: 105mm; object-fit: cover; border: 1px solid #999; }
  #printSheet table { width: 100%; border-collapse: collapse; font-size: 10pt; break-inside: avoid; }
  #printSheet th { text-align: left; border-bottom: 1.5px solid #333; padding: 2pt 4pt; }
  #printSheet td { border-bottom: 1px solid #ccc; padding: 2pt 4pt; }
  #printSheet tr.tot td { font-weight: 700; border-bottom: 0; }
}
