/* HomeTown.Oil — warm prairie colours, phone first. Dark mode via [data-iht-theme="dark"]. */
:root {
  --bg: #f3ead9; --panel: #fffaf0; --panel2: #f4ead6; --text: #2e2218; --muted: #7a6650; --line: #e2d3b8;
  --accent: #c2410c; --accent2: #1f6f8b; --good: #2f9e44; --bad: #c92a2a; --warn: #d9480f;
  --shadow: 0 6px 24px rgba(40, 25, 10, .22); --r: 14px;
}
[data-iht-theme="dark"] { --bg: #15110d; --panel: #221a13; --panel2: #2c2219; --text: #efe6d8; --muted: #b8a68f; --line: #3d3024; --accent: #f08c4a; --accent2: #63b3cf; color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
input { font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); min-height: 44px; max-width: 100%; }
input[type=range] { min-height: 0; padding: 0; flex: 1; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; }
a { color: var(--accent2); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .8125rem; }
.up { color: var(--good); } .down { color: var(--bad); }
#view { position: fixed; inset: 0; touch-action: none; display: block; max-width: 100%; }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #1d150e; color: #f6efe2; z-index: 90; font-size: 1.1rem; }

/* ---- heads-up display ---- */
#hud { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 6px calc(8px + env(safe-area-inset-left));
  background: linear-gradient(var(--panel), color-mix(in srgb, var(--panel) 88%, transparent)); box-shadow: 0 2px 10px rgba(0,0,0,.15); font-size: .875rem; }
#hud .home { text-decoration: none; font-size: 1.3rem; min-width: 36px; text-align: center; color: var(--text); }
#hud .co { background: none; border: 0; font-weight: 700; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 2px; cursor: pointer; }
#hud .when { display: flex; align-items: center; gap: 6px; }
#hud .speeds button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; min-width: 36px; min-height: 36px; cursor: pointer; }
#hud .speeds button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#hud .money { display: flex; flex-direction: column; line-height: 1.1; }
#hud .money b { font-size: 1rem; }
#hud .prices { display: flex; gap: 10px; flex-wrap: wrap; color: var(--muted); }
#hud .prices b { color: var(--text); }
#hfree { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
#hfree.low { background: var(--warn); color: #fff; border-color: var(--warn); }
#dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; overflow-x: auto; gap: 2px; padding: 4px calc(4px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left));
  background: var(--panel); box-shadow: 0 -2px 10px rgba(0,0,0,.15); scrollbar-width: none; }
#dock button { flex: 1 0 64px; min-height: 52px; border: 0; background: none; border-radius: 10px; font-size: .75rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; position: relative; }
#dock button span { font-size: 1.3rem; }
#dock button:hover, #dock button:focus-visible { background: var(--panel2); }
#dock button[data-badge]:not([data-badge=""])::after { content: attr(data-badge); position: absolute; top: 4px; right: 12px; background: var(--bad); color: #fff; border-radius: 9px; font-size: .7rem; padding: 0 5px; }
#tools { position: fixed; right: calc(8px + env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); z-index: 15; display: flex; flex-direction: column; gap: 8px; }
#tools button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--panel); box-shadow: var(--shadow); font-size: 1.3rem; cursor: pointer; }
#tools button.on { outline: 3px solid var(--accent); }
body.has-panel #tools { right: calc(min(400px, 100vw) + 12px); }

/* ---- side panel: a bottom sheet on phones ---- */
#panel { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; max-height: 58dvh; display: flex; flex-direction: column; background: var(--panel); border-radius: var(--r) var(--r) 0 0; box-shadow: var(--shadow); padding-bottom: env(safe-area-inset-bottom); }
.phead { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; border-bottom: 1px solid var(--line); }
.phead h3 { margin: 0; font-size: 1.05rem; flex: 1; }
.pbody { overflow-y: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--panel2); cursor: pointer; font-size: 1rem; flex: none; }
body.has-panel #dock { display: none; }
@media (min-width: 760px) {
  #panel { left: auto; top: 64px; right: 8px; bottom: 72px; width: min(400px, calc(100vw - 16px)); max-height: none; border-radius: var(--r); }
  body.has-panel #dock { display: flex; }
  #dock { left: 50%; right: auto; transform: translateX(-50%); bottom: 8px; border-radius: 16px; padding: 4px; max-width: calc(100vw - 16px); }
  #dock button { flex: 0 0 76px; }
}
@media (max-width: 759px) { body.has-panel #tools { right: 8px; top: 30%; } #hud .prices span:nth-child(2) { display: none; } }

/* ---- bits ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.alt { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.small { min-height: 40px; padding: 6px 10px; font-size: .875rem; }
.btn.danger { background: var(--bad); }
.btn.on { outline: 2px solid var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent2); cursor: pointer; padding: 6px 0; text-decoration: underline; min-height: 32px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.sticky { position: sticky; bottom: -16px; background: var(--panel); padding: 8px 0; margin-bottom: -8px; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.card.row { flex-direction: row; }
.note { background: color-mix(in srgb, var(--warn) 14%, var(--panel)); border-left: 4px solid var(--warn); padding: 8px 10px; border-radius: 8px; margin: 0; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-weight: 700; font-size: .875rem; color: #1b1208; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: .9375rem; }
.kv span { color: var(--muted); }
.bar { display: inline-block; width: 100%; max-width: 260px; height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--good); }
.bar.warn i { background: var(--warn); }
.tbl { border-collapse: collapse; width: 100%; font-size: .875rem; }
.tbl td, .tbl th { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; }
.scrollx { overflow-x: auto; }
.list { display: flex; flex-direction: column; gap: 4px; }
.item { text-align: left; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; min-height: 44px; }
ol.steps { margin: 4px 0; padding-left: 22px; font-size: .875rem; }
ol.steps li.done { color: var(--muted); text-decoration: line-through; }
ol.steps li.now { font-weight: 700; color: var(--accent); }
ul.log { list-style: none; padding: 0; margin: 0; font-size: .875rem; display: flex; flex-direction: column; gap: 4px; }
ul.log li { padding: 4px 8px; border-left: 3px solid var(--line); }
ul.log li.good { border-color: var(--good); } ul.log li.bad { border-color: var(--bad); } ul.log li.warn { border-color: var(--warn); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 8px; }
.big { font-size: 1.4rem; font-weight: 700; }
img.hero { width: 100%; max-width: 100%; border-radius: 12px; display: block; aspect-ratio: 16/9; object-fit: cover; }
h4 { margin: 6px 0 0; }
details summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }

/* ---- modal ---- */
#modalWrap { position: fixed; inset: 0; z-index: 56; background: rgba(20, 12, 4, .5); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--panel); width: 100%; max-width: 560px; max-height: 88dvh; border-radius: var(--r) var(--r) 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow); padding-bottom: env(safe-area-inset-bottom); }
.modal.wide { max-width: 860px; }
.mhead { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.mhead h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.mbody { overflow-y: auto; padding: 12px 14px 18px; display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 600px) { #modalWrap { align-items: center; } .modal { border-radius: var(--r); } }

/* ---- toast & ticker ---- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(76px + env(safe-area-inset-top)); z-index: 60; background: #2e2218; color: #fff; padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); max-width: min(92vw, 520px); }
#ticker { position: fixed; left: calc(8px + env(safe-area-inset-left)); bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 14; display: flex; flex-direction: column; gap: 4px; max-width: min(92vw, 480px); pointer-events: none; }
.tk { background: color-mix(in srgb, var(--panel) 92%, transparent); padding: 6px 10px; border-radius: 10px; font-size: .8125rem; box-shadow: 0 2px 8px rgba(0,0,0,.18); border-left: 4px solid var(--accent2); transition: opacity .9s; }
.tk.good { border-color: var(--good); } .tk.bad { border-color: var(--bad); } .tk.warn { border-color: var(--warn); }
.tk.fade { opacity: 0; }
body.has-panel #ticker { display: none; }
/* next-step hints */
#coach { position: fixed; left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 15; max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: var(--shadow, 0 4px 16px rgba(0,0,0,.18)); border: 2px solid #e2a23b; font-size: 14px; line-height: 1.35; }
#coach .ci { font-size: 20px; }
#coach .ct { flex: 1 1 200px; }
#coach .cb { display: flex; gap: 6px; align-items: center; margin-left: auto; }
#coach .cx { background: none; border: 0; color: var(--muted, #888); font-size: 16px; padding: 4px 6px; cursor: pointer; }
body.has-coach #ticker { bottom: calc(150px + env(safe-area-inset-bottom)); }
body.has-panel #coach { font-size: 13px; padding: 6px 8px; }
@media (min-width: 760px) { body.has-panel #coach { display: flex; left: 12px; right: auto; max-width: min(520px, calc(100vw - 460px)); } #coach { bottom: 76px; } }
@media (min-width: 760px) { body.has-panel #ticker { display: flex; } }

/* ---- start page: same look as HomeTown's (its colours, type, card and buttons, scoped here) ---- */
#title { --panel: rgba(253, 248, 238, .96); --panel2: #efe4cf; --text: #2e2218; --muted: #7a6650; --accent: #b5662b; --bad: #b23b2e; --line: rgba(80, 55, 30, .18); --shadow: 0 6px 24px rgba(40, 25, 10, .22);
  position: fixed; inset: 0; z-index: 50; background: #1d150e; display: flex; align-items: center; justify-content: center; overflow-y: auto; color: var(--text); font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
[data-iht-theme="dark"] #title { --panel: rgba(32, 26, 20, .96); --panel2: #2a2119; --text: #efe6d8; --muted: #b4a28a; --accent: #e08a45; --bad: #e0675a; --line: rgba(240, 220, 190, .14); --shadow: 0 6px 24px rgba(0, 0, 0, .5); }
#title .tbg { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
#title .box { position: relative; z-index: 1; background: var(--panel); border-radius: 18px; padding: 22px 26px; width: min(560px, 94%); box-shadow: var(--shadow); max-height: 94%; overflow-y: auto; }
#title h1 { margin: 0; font-size: 34px; letter-spacing: .5px; }
#title .tag { color: var(--muted); margin: 2px 0 14px; }
#title h3 { margin: 14px 0 6px; font-size: 1.17em; }
#title p { margin: 6px 0; }
#title a { color: var(--accent); }
#title .muted { color: var(--muted); font-size: 12.5px; }
#title .note { font-size: 13px; }
#title .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
#title .saves .card { display: flex; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; gap: 8px; margin: 6px 0; background: var(--panel2); border-radius: 10px; padding: 8px; border: 1px solid var(--line); }
#title .saves .card .row { margin: 0; flex-wrap: nowrap; }
#title .btn { white-space: nowrap; min-height: 36px; border-radius: 9px; padding: 7px 12px; background: var(--accent); color: #fff; font-size: 14px; }
#title .btn.alt { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
#title .btn.red { background: var(--bad); color: #fff; }
#title .btn.small { min-height: 32px; padding: 4px 9px; font-size: 12.5px; }
#title .btn.big { font-size: 16px; padding: 10px 18px; }
@media (max-width: 600px) {
  #title .box { padding: 18px 16px; }
  #title h1 { font-size: 28px; }
  #title .saves .card { flex-wrap: wrap; }
  #title .btn { min-height: 40px; }
  #title .btn.small { min-height: 36px; padding: 6px 10px; font-size: 13.5px; }
}
/* the delete check, as in HomeTown */
.confirm-back { position: fixed; inset: 0; background: rgba(20,14,8,.55); display: flex; align-items: center; justify-content: center; z-index: 60; }
.confirm { background: var(--panel, #fdf8ef); color: var(--text, #2e2218); border-radius: 14px; padding: 18px 20px; width: min(440px, 92vw); box-shadow: 0 12px 40px rgba(0,0,0,.35); max-height: 92%; overflow-y: auto; }
.confirm h3 { margin: 0 0 6px; }
.confirm .warn { color: var(--bad, #c0392b); font-weight: 600; }
.confirm input { width: 100%; }
iht-account { color: var(--text); margin-left: auto; }
@media (prefers-reduced-motion: reduce) { .tk { transition: none; } }
