/* Tumbleworks — warm workshop chrome around a full-bleed canvas.
   Wall: deep umber. Wood: amber. Steel: cool grey-blue. One loud
   accent only: safety orange, used for the active tool and the goal. */
:root {
  --wall: #211c16;
  --panel: #2d2721;
  --panel-2: #372e25;
  --line: #4a3f32;
  --wood: #c08a4e;
  --wood-deep: #8a5a2b;
  --steel: #8fa3b0;
  --amber: #f0a13a;
  --safety: #e8862e;
  --green: #58b368;
  --danger: #d95f43;
  --ink: #f5efe3;
  --ink-dim: #c9bda6;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--wall); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- top bar ---- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 58px;
  display: flex; align-items: center; gap: 18px; padding: 0 14px;
  background: linear-gradient(#332b22, #2a231b);
  border-bottom: 2px solid var(--wood-deep);
  box-shadow: 0 4px 18px var(--shadow);
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--safety); color: #241708;
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
}
.brand-name { font-size: 20px; font-weight: 800; letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; color: var(--ink-dim); font-style: italic; }

.missions { display: flex; gap: 6px; }
.mission-btn, .grav-btn, .action-btn {
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; cursor: pointer;
}
.mission-btn:hover, .grav-btn:hover, .action-btn:hover { border-color: var(--wood); }
.mission-btn.active, .grav-btn.active { background: var(--safety); border-color: var(--safety); color: #241708; }
.action-btn[aria-pressed="true"] { background: var(--wood-deep); border-color: var(--wood); }

.gravity { display: flex; align-items: center; gap: 6px; }
.group-label { font-size: 12px; color: var(--ink-dim); font-weight: 600; }
.wind { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.wind input[type="range"] { width: 110px; accent-color: var(--safety); }
.wind-value { font-size: 13px; font-weight: 700; min-width: 28px; text-align: right; }
.actions { display: flex; gap: 6px; }

/* ---- left toolbar ---- */
.toolbar {
  position: fixed; top: 70px; left: 12px; width: 92px; z-index: 10;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 8px; box-shadow: 0 6px 20px var(--shadow);
}
.toolbar-title { font-size: 12px; font-weight: 700; color: var(--ink-dim); padding: 0 4px 8px; }
.tool-list { display: flex; flex-direction: column; gap: 6px; }
.tool-btn {
  display: flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13px; font-weight: 600; text-align: left;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 8px; cursor: pointer;
}
.tool-btn:hover { border-color: var(--wood); }
.tool-btn.active { background: var(--safety); border-color: var(--safety); color: #241708; }
.tool-btn .glyph { font-size: 16px; width: 18px; text-align: center; flex: none; }
.tool-btn .key {
  margin-left: auto; font-size: 10px; font-weight: 700;
  color: var(--ink-dim); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px;
}
.tool-btn.active .key { color: #241708; border-color: rgba(0, 0, 0, 0.35); }
.toolbar-hint { font-size: 11px; line-height: 1.45; color: var(--ink-dim); padding: 10px 4px 2px; }

/* ---- right mission panel ---- */
.mission-panel {
  position: fixed; top: 70px; right: 12px; width: 248px; z-index: 10;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: 0 6px 20px var(--shadow);
}
.mission-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--amber); text-transform: uppercase; }
.mission-name { font-size: 21px; margin: 5px 0 6px; }
.mission-desc { font-size: 13px; line-height: 1.5; color: var(--ink-dim); margin: 0 0 12px; }
.progress-wrap { display: flex; align-items: center; gap: 8px; }
.progress-track { flex: 1; height: 10px; background: #1a1510; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; background: var(--green); border-radius: 6px; transition: width 0.25s ease; }
.progress-text { font-size: 12px; font-weight: 700; min-width: 34px; text-align: right; }
.mission-stars { font-size: 22px; letter-spacing: 6px; color: var(--amber); margin: 10px 0 4px; }
.mission-meta { font-size: 12px; color: var(--ink-dim); margin-bottom: 12px; }
.mission-reset {
  font: inherit; font-size: 13px; font-weight: 700;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; width: 100%;
}
.mission-reset:hover { border-color: var(--wood); }

/* ---- toast + overlay ---- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(8px);
  background: var(--panel); border: 1px solid var(--wood); color: var(--ink);
  font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 20; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 15, 10, 0.72);
}
.overlay.hidden { display: none; }
.overlay-card {
  width: min(560px, 90vw); background: var(--panel);
  border: 1px solid var(--wood-deep); border-radius: 16px;
  padding: 28px 30px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}
.overlay-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--amber); text-transform: uppercase; }
.overlay-title { font-size: 44px; margin: 8px 0 10px; letter-spacing: 0.5px; }
.overlay-text { font-size: 15px; line-height: 1.6; color: var(--ink-dim); margin: 0 0 16px; }
.overlay-keys { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.overlay-keys b {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 7px; margin-right: 6px; font-size: 12px;
}
.start-btn {
  font: inherit; font-size: 16px; font-weight: 800;
  background: var(--safety); color: #241708; border: none; border-radius: 10px;
  padding: 12px 22px; cursor: pointer;
}
.start-btn:hover { filter: brightness(1.08); }

@media (max-width: 900px) {
  .brand-sub, .toolbar-hint, .wind { display: none; }
  .mission-panel { width: 200px; }
  .topbar { gap: 10px; flex-wrap: wrap; height: auto; padding: 8px 10px; }
  .toolbar { top: 108px; }
  .mission-panel { top: 108px; }
}
