:root {
  --ground: #0c0b10;
  --panel: rgba(22, 20, 26, 0.84);
  --line: rgba(240, 220, 170, 0.14);
  --ink: #efe8d8;
  --quiet: #a79f8e;
  --ember: #d8763f;
  --gold: #f0c24c;
  --k1: #f0c24c;
  --k2: #7fb7d9;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--ink);
  font: 12px/1.45 var(--mono);
  overflow: hidden;
}

#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  image-rendering: pixelated;
}

#view.dragging { cursor: grabbing; }

.panel {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(6px);
  padding: 12px 14px;
}

h1 {
  margin: 0;
  font: 600 22px/1 var(--serif);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

h2 {
  margin: 14px 0 6px;
  font: 600 11px/1.2 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--quiet);
}

.panel > h2:first-child { margin-top: 0; }

.quiet { color: var(--quiet); margin: 4px 0 0; }

#left {
  top: 12px;
  left: 12px;
  width: 264px;
  max-height: calc(100vh - 150px);
  overflow-y: auto;
}

#when { margin: 6px 0 10px; color: var(--ink); font: 14px/1.3 var(--serif); }

#counts { margin: 0 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
#counts div { display: flex; flex-direction: column; }
#counts dt { color: var(--quiet); font-size: 10px; letter-spacing: 0.06em; }
#counts dd { margin: 0; font-size: 18px; font-variant-numeric: tabular-nums; }

.group { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

button {
  font: inherit;
  color: var(--ink);
  background: rgba(240, 220, 170, 0.07);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 9px;
  cursor: pointer;
}

button:hover { background: rgba(240, 220, 170, 0.14); }
button:disabled { opacity: 0.4; cursor: default; }
button.on { background: var(--ember); border-color: var(--ember); color: #1a1208; }
#pace button { flex: 1; padding: 6px 0; letter-spacing: -0.12em; }

label { display: block; margin: 9px 0 0; color: var(--ink); }
label output { float: right; color: var(--gold); font-variant-numeric: tabular-nums; }
label.check { display: flex; gap: 7px; align-items: center; color: var(--quiet); }

input[type=range] { width: 100%; margin: 3px 0 0; accent-color: var(--ember); }
input[type=checkbox] { accent-color: var(--ember); margin: 0; }

#right {
  top: 12px;
  right: 12px;
  width: 300px;
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
}

#chronicle {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  font: 13px/1.45 var(--serif);
}

#chronicle li {
  padding: 6px 0 6px 10px;
  border-left: 2px solid var(--line);
  margin-bottom: 4px;
  color: #d9d1bf;
  animation: arrive 1.2s ease-out;
}

#chronicle li.night { border-left-color: #5d6fc4; }
#chronicle li.day { border-left-color: var(--gold); }
#chronicle li small { display: block; font: 10px/1.2 var(--mono); color: var(--quiet); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 1px; }

@keyframes arrive {
  from { background: rgba(240, 194, 76, 0.22); }
  to { background: transparent; }
}

#bottom {
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding: 8px 14px 10px;
}

figure { margin: 0; min-width: 0; }
figcaption { color: var(--quiet); font-size: 10px; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
figcaption b { color: var(--ink); font-weight: 400; font-variant-numeric: tabular-nums; }
figcaption i { font-style: normal; }
figcaption i.k1 { color: var(--k1); }
figcaption i.k2 { color: var(--k2); }
figure canvas { width: 100%; height: 64px; display: block; margin-top: 3px; }

#inspector {
  left: 290px;
  top: 12px;
  width: 232px;
  font-size: 11px;
}

#inspector h2 { color: var(--gold); letter-spacing: 0.08em; }
#inspector dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
#inspector dt { color: var(--quiet); }
#inspector dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

#guide {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 20px 24px;
  font: 14px/1.55 var(--serif);
  background: rgba(18, 16, 22, 0.95);
}

#guide p { margin: 0 0 10px; }
#guide b { color: var(--gold); font-weight: 600; }
kbd { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }

@media (max-width: 1100px) {
  #bottom { grid-template-columns: repeat(3, 1fr); }
  #bottom figure:nth-child(n+4) { display: none; }
  #right { width: 240px; }
}

@media (max-width: 760px) {
  #right, #inspector { display: none; }
  #left { width: 220px; }
  #bottom { grid-template-columns: 1fr 1fr; }
  #bottom figure:nth-child(n+3) { display: none; }
}
