:root {
  --panel: rgba(32, 24, 16, 0.78);
  --panel-edge: rgba(255, 236, 200, 0.12);
  --text: #f3e6cf;
  --muted: #c2ae8e;
  --accent: #e9a45b;
  --warn: #ff8a6b;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #2a2018;
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view.dragging { cursor: grabbing; }
#view.brush { cursor: crosshair; }
#view.resize { cursor: row-resize; }
#view.resize-col { cursor: col-resize; }

.pane-button {
  position: absolute;
  left: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 13px;
}
.pane-button[hidden] { display: none; }

.hud, .follow-card, .chronicle, .away-card, .toast {
  position: absolute;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.hud {
  top: 16px;
  left: 16px;
  padding: 12px 14px;
  min-width: 220px;
  pointer-events: none;
}
.hud-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hud .panel-toggle { pointer-events: auto; }
.hud.collapsed .hud-stats, .hud.collapsed .hud-title em { display: none; }
.panel-toggle { padding: 0 8px; line-height: 1.6; font-size: 15px; }
.hud-title span { font-weight: 600; }
.hud-title em { display: block; color: var(--muted); font-size: 12px; }
.hud-clock { margin-top: 6px; color: var(--accent); font-variant-numeric: tabular-nums; }
.hud-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin: 10px 0 0;
}
.hud-stats div { display: flex; flex-direction: column; }
.hud-stats dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.hud-stats dd { margin: 0; font-size: 18px; font-variant-numeric: tabular-nums; }
.hud-warning { margin-top: 8px; color: var(--warn); font-weight: 600; }

.follow-card {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  text-align: center;
  min-width: 240px;
}
.follow-title { font-weight: 600; }

.away-card {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 20px;
  width: min(380px, calc(100% - 32px));
  z-index: 2;
}
.away-card h2 { margin: 0 0 8px; font-size: 16px; color: var(--accent); }
.away-card ul { margin: 0 0 14px; padding-left: 18px; }
.away-card li { margin: 4px 0; }
.away-card[hidden], .toast[hidden] { display: none; }

.toast {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  font-size: 13px;
  z-index: 2;
}
.follow-detail { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }

.chronicle {
  top: 16px;
  right: 16px;
  width: 300px;
  max-height: min(38%, calc(100% - 110px));
  display: flex;
  flex-direction: column;
}
.chronicle header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 6px 14px;
}
.chronicle h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.chronicle ol {
  list-style: none;
  margin: 0;
  padding: 0 14px 12px;
  overflow-y: auto;
}
.chronicle li { padding: 5px 0; border-top: 1px solid var(--panel-edge); font-size: 13px; }
.chronicle li b { color: var(--accent); font-weight: 600; margin-right: 6px; font-variant-numeric: tabular-nums; }
.chronicle.collapsed ol { display: none; }

/* Hide UI: just the colony, plus one small button to bring the controls back. */
.app.ui-hidden .toolbar,
.app.ui-hidden .hud,
.app.ui-hidden .chronicle,
.app.ui-hidden .pane-button,
.app.ui-hidden .perf { display: none; }
.ui-restore {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  opacity: 0.6;
  z-index: 3;
}
.ui-restore:hover, .ui-restore:focus-visible { opacity: 1; }
.ui-restore[hidden] { display: none; }

.toolbar {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background: #201810;
  border-top: 1px solid var(--panel-edge);
}
.group { display: flex; gap: 4px; }

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 240, 215, 0.07);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: rgba(255, 240, 215, 0.14); }
button.active { background: rgba(233, 164, 91, 0.25); border-color: rgba(233, 164, 91, 0.6); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#seed-label { color: var(--accent); font-variant-numeric: tabular-nums; }
button.pause { min-width: 92px; }
button.pause.paused { background: rgba(233, 164, 91, 0.85); color: #20160d; font-weight: 600; }
.paused-badge {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(233, 164, 91, 0.85);
  color: #20160d;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.paused-badge[hidden], .weather-badge[hidden] { display: none; }
.weather-badge {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(110, 160, 220, 0.85);
  color: #0f1a26;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.perf {
  position: absolute;
  right: 12px;
  bottom: 6px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  /* Phones: smaller panels, and the toolbar becomes one row you can swipe sideways. */
  .hud { top: 8px; left: 8px; min-width: 0; max-width: calc(58vw - 12px); padding: 8px 10px; font-size: 13px; }
  .hud-title em { display: none; }
  .hud-stats dt { font-size: 10px; }
  .hud-stats { gap: 2px 12px; margin-top: 6px; }
  .hud-stats dd { font-size: 15px; }
  .chronicle { top: 8px; right: 8px; width: calc(42vw - 12px); max-height: 40%; }
  .chronicle header { padding: 6px 8px 4px 10px; }
  .chronicle h2 { font-size: 11px; }
  .chronicle ol { padding: 0 10px 8px; }
  .chronicle li { font-size: 12px; }
  .follow-card { top: auto; bottom: 12px; min-width: 0; width: calc(100% - 24px); }
  .pane-button { left: 8px !important; font-size: 12px; padding: 4px 8px; }
  .toolbar {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 10px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    scrollbar-width: none;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  button { padding: 7px 9px; }
  .perf { display: none; }
}
