:root {
  --bg: #0f1a0f;
  --panel: rgba(14, 24, 14, 0.62);
  --panel-solid: #142014;
  --line: rgba(220, 235, 190, 0.18);
  --ink: #eef2dc;
  --ink-dim: #b8c4a0;
  --accent: #d9b24c;
  --good: #8cd070;
  --bad: #e0705a;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
kbd { font: 11px var(--sans); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; margin-left: 4px; color: var(--ink-dim); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 4px 18px rgba(0,0,0,.25); }
.row { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.row.sub { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.lbl { color: var(--ink-dim); font-size: 12px; }
.bar { height: 5px; background: rgba(255,255,255,.12); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8cb85a, var(--accent)); transition: width .25s linear; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { position: absolute; pointer-events: none; }
#hud-day { top: max(12px, env(safe-area-inset-top)); left: 12px; min-width: 190px; }
#hud-weather { top: max(12px, env(safe-area-inset-top)); right: 12px; min-width: 170px; }
#hud-basket { bottom: 14px; right: 12px; display: flex; gap: 10px; align-items: baseline; font-size: 18px; }
#hud-basket b { font-family: var(--serif); font-size: 24px; color: var(--accent); }
#hud-buttons { bottom: 14px; left: 12px; display: flex; gap: 8px; pointer-events: auto; flex-wrap: wrap; }
#hud-hints { bottom: 62px; left: 14px; font-size: 12px; color: rgba(238,242,220,.7); text-shadow: 0 1px 3px #000; }
.chip, #inspect-actions button, .btn { pointer-events: auto; font: 600 14px var(--sans); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; cursor: pointer; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.chip:hover, #inspect-actions button:hover, .btn:hover { background: rgba(60, 86, 40, .7); }
.btn.primary, #inspect-actions button.primary { background: linear-gradient(#e2bd55, #bf9535); color: #1c1608; border-color: #f0d37a; }
.btn.primary:hover, #inspect-actions button.primary:hover { background: linear-gradient(#efca62, #cba03d); }

#crosshair { left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: rgba(255,255,255,.55); box-shadow: 0 0 0 1px rgba(0,0,0,.35); transition: all .12s; }
#crosshair.target { width: 26px; height: 26px; margin: -13px 0 0 -13px; background: transparent; border: 2px solid var(--accent); box-shadow: 0 0 10px rgba(217,178,76,.6); }
#prompt { left: 50%; top: calc(50% + 34px); transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; font-size: 15px; white-space: nowrap; }
#toasts { top: 96px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(92vw, 520px); }
.toast { background: rgba(14,24,14,.82); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; font-size: 14px; text-align: center; animation: toastIn .25s ease-out; transition: opacity .5s; }
.toast.good { border-color: rgba(140,208,112,.6); }
.toast.bad { border-color: rgba(224,112,90,.7); background: rgba(48,16,10,.85); }
.toast.note { border-color: rgba(217,178,76,.6); }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }

#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#joy { position: absolute; left: 24px; bottom: 28px; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.28); background: rgba(255,255,255,.07); opacity: .8; }
#joy i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: rgba(255,255,255,.35); border: 1px solid rgba(255,255,255,.5); }
#touch .big { position: absolute; right: 22px; bottom: 90px; pointer-events: auto; font: 700 18px var(--sans); padding: 16px 26px; border-radius: 999px; border: 2px solid #f0d37a; background: linear-gradient(#e2bd55, #bf9535); color: #1c1608; }
body.touch #hud-hints { display: none; }
body.touch #hud-buttons { bottom: auto; top: 112px; left: 12px; }
body.touch #hud-buttons kbd, body.touch kbd { display: none; }
body.touch #hud-basket { bottom: 16px; right: 16px; }
body.touch #hud-weather { min-width: 0; }

#inspect { position: fixed; inset: 0; z-index: 8; pointer-events: none; }
#inspect > * { position: absolute; pointer-events: auto; }
#inspect-title { top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font: 22px var(--serif); text-shadow: 0 2px 8px #000; text-align: center; width: 92vw; pointer-events: none; }
#inspect-hint { top: 52px; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--ink-dim); text-shadow: 0 1px 4px #000; text-align: center; width: 90vw; pointer-events: none; }
#inspect-result { top: 84px; left: 50%; transform: translateX(-50%); width: min(92vw, 560px); background: rgba(10,18,10,.82); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 15px; line-height: 1.45; }
#inspect-result b { color: var(--accent); }
#inspect-result.is-true { border-color: rgba(140,208,112,.7); }
#inspect-result.is-false { border-color: rgba(224,112,90,.8); }
#inspect-actions { bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 96vw; pointer-events: none !important; }
#inspect-actions button { pointer-events: auto; padding: 12px 20px; font-size: 15px; }
body.touch #inspect-actions button { padding: 14px 18px; font-size: 16px; }
#inspect-actions button:disabled { opacity: .4; cursor: default; }
body.inspecting #hud-buttons, body.inspecting #hud-hints, body.inspecting #crosshair, body.inspecting #prompt { display: none; }
body.inspecting #toasts { top: auto; bottom: 88px; }

#vignette-sick { position: fixed; inset: 0; z-index: 4; pointer-events: none; background: radial-gradient(ellipse at center, rgba(120,170,60,0) 30%, rgba(60,110,30,.5) 100%); animation: sick 2.4s ease-in-out infinite; }
@keyframes sick { 50% { opacity: .55; } }

#overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(6, 12, 6, 0.58); padding: 12px; touch-action: pan-y; }
#overlay.clear { background: rgba(6, 12, 6, 0.28); }
#overlay.title { background: radial-gradient(ellipse at 50% 18%, rgba(150,170,70,.30), transparent 62%), linear-gradient(#0a130a, #15251a 55%, #0a120a); overflow: hidden; }
#overlay.title::before { content: ''; position: absolute; inset: -20% -10%; pointer-events: none; filter: blur(14px);
  background: linear-gradient(104deg, transparent 12%, rgba(255,236,170,.10) 16%, transparent 24%, transparent 38%, rgba(255,236,170,.07) 42%, transparent 50%, transparent 66%, rgba(255,236,170,.09) 70%, transparent 78%); }
#overlay.title .card { position: relative; background: rgba(14, 24, 15, .78); backdrop-filter: blur(4px); }
.card { width: min(94vw, 640px); max-height: 92vh; overflow: auto; scrollbar-width: thin; scrollbar-color: #53663f #101a10; background: linear-gradient(#18281a, #101a10); border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.55); user-select: text; -webkit-user-select: text; touch-action: pan-y; }
.card h1 { font: 34px var(--serif); margin: 0 0 4px; letter-spacing: .5px; }
.card h2 { font: 24px var(--serif); margin: 0 0 8px; }
.card h3 { font: 15px var(--sans); text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); margin: 18px 0 8px; }
.card p { margin: 6px 0; line-height: 1.5; color: #dce4c8; }
.card .sub { color: var(--ink-dim); font-size: 14px; }
.card .actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.card .actions .btn { padding: 12px 22px; font-size: 15px; }
.card input[type=text] { font: 14px var(--sans); background: rgba(0,0,0,.35); border: 1px solid var(--line); color: var(--ink); padding: 8px 10px; border-radius: 8px; width: 120px; user-select: text; -webkit-user-select: text; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font: 30px var(--serif); color: var(--accent); }
.stat span { font-size: 12px; color: var(--ink-dim); }
.stat.bad b { color: var(--bad); }
.stat.good b { color: var(--good); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl th { color: var(--ink-dim); font-weight: 600; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.unknown { color: #7d8a68; font-style: italic; }
.tabs { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.tab { font: 600 13px var(--sans); padding: 7px 14px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--ink-dim); cursor: pointer; }
.tab.on { background: rgba(217,178,76,.22); color: var(--ink); border-color: rgba(217,178,76,.6); }
.diagram { display: flex; gap: 14px; justify-content: space-around; margin: 8px 0; flex-wrap: wrap; }
.diagram figure { margin: 0; text-align: center; font-size: 12px; color: var(--ink-dim); }
.diagram svg { width: 120px; height: 150px; background: rgba(255,255,255,.04); border-radius: 8px; border: 1px solid var(--line); }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 56px; margin-top: 6px; }
.spark i { flex: 1; background: linear-gradient(#e2bd55, #8a6a20); border-radius: 2px 2px 0 0; min-height: 2px; }
.spark i.future { background: rgba(255,255,255,.12); }

#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #223520, #0b130b); transition: opacity .6s; }
#loading.done { opacity: 0; pointer-events: none; }
.load-card { text-align: center; width: min(86vw, 380px); }
.load-card h1 { font: 38px var(--serif); margin: 0 0 6px; }
.load-card p { color: var(--ink-dim); margin: 0 0 14px; }
#fatal { position: fixed; inset: 0; z-index: 60; background: #1a0d0a; color: #f2d6cf; padding: 30px; font: 15px var(--sans); overflow: auto; }

@media (max-width: 640px) {
  .card { padding: 16px 16px; }
  .card h1 { font-size: 28px; }
  #hud-day, #hud-weather { padding: 6px 9px; }
  #hud-day { min-width: 0; }
  .row { gap: 8px; }
  #hud-basket { font-size: 14px; }
  #inspect-title { font-size: 18px; }
}
