:root {
  --cream: #f8f0da;
  --cream-2: #fff8e6;
  --ink: #1a120c;
  --line: #3a2718;
  --barn: #9b2d1f;
  --amber: #f6b73c;
  --good: #215c28;
  --bad: #9b2d1f;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; }
body {
  font-family: "Trebuchet MS", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: #3d5a32;
  display: flex;
  flex-direction: column;
}
button, input, select { font: inherit; color: inherit; }
.hud {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(#fff6e4, #f3e4c4);
  border-bottom: 3px solid var(--line);
  z-index: 20;
}
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand strong { font-size: 16px; }
.tag { font-size: 12px; color: #5a4030; }
.hud-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.hud-stats b { color: var(--barn); }
.hud-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.btn, .tab-btn {
  border: 2px solid var(--line);
  background: var(--cream-2);
  padding: 7px 12px;
  min-height: 36px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex; align-items: center;
}
.tab-btn.active, .btn.primary { background: var(--amber); }
.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: #2a4a28;
}
canvas { width: 100%; height: 100%; display: block; image-rendering: auto; }
.prompt, .visit-banner {
  position: absolute; left: 50%; transform: translateX(-50%);
  background: rgba(248,240,218,.94);
  border: 2px solid var(--line);
  padding: 8px 14px;
  max-width: min(90vw, 520px);
  text-align: center;
  z-index: 12;
}
.prompt { bottom: 88px; }
.visit-banner { top: 12px; background: #fff3c8; }
.stick-wrap {
  position: absolute; left: 18px; bottom: 18px; z-index: 14;
}
.stick-base {
  width: 112px; height: 112px; border-radius: 50%;
  background: rgba(26,18,12,.28);
  border: 3px solid rgba(248,240,218,.7);
  position: relative;
  touch-action: none;
}
.stick-knob {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--line);
  position: absolute; left: 30px; top: 30px;
}
.interact {
  position: absolute; right: 18px; bottom: 22px; z-index: 14;
  min-width: 96px; min-height: 56px; background: var(--amber);
}
.panel {
  position: fixed; right: 16px; top: 76px; bottom: 16px;
  width: min(420px, 94vw);
  background: var(--cream);
  border: 3px solid var(--line);
  box-shadow: 8px 8px 0 rgba(26,18,12,.35);
  z-index: 30;
  overflow: auto;
  padding: 0 0 16px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 10px 12px;
  background: var(--barn); color: var(--cream-2);
  border-bottom: 3px solid var(--line);
  position: sticky; top: 0;
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-head .btn { background: var(--cream-2); color: var(--ink); }
.tabs { display: flex; gap: 6px; }
.panel .note, .panel p, .panel label, .totals { padding: 0 14px; }
.levels { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; }
.chip { background: #fff8e6; border: 1px solid var(--line); padding: 4px 8px; font-size: 13px; }
.list { display: grid; gap: 8px; padding: 8px 14px; }
.item {
  background: #fff8e6; border: 2px solid var(--line); padding: 8px 10px;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  cursor: pointer;
}
.item:hover { background: #f6e6b8; }
.filter-label { display: block; margin: 8px 0; }
.field, select {
  width: calc(100% - 28px); margin: 6px 14px 0;
  display: block;
  border: 2px solid var(--line);
  background: #fffdf6;
  padding: 8px;
  min-height: 40px;
}
.filter-label select { width: 100%; margin: 6px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
.msg { min-height: 1.3em; font-size: 14px; }
.msg.ok { color: var(--good); }
.msg.err { color: var(--bad); font-weight: 700; }
@media (min-width: 901px) {
  .stick-wrap { display: none; }
}
@media (max-width: 900px) {
  .panel { top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-height: 58vh; }
}
