:root {
  --bg: #1f2a1c;
  --panel: #2f3d2a;
  --panel-border: #151d12;
  --text: #f2f0e6;
  --muted: #b9c2a8;
  --accent: #6ccf4f;
  --accent-dark: #3f8f2b;
  --wrong: #ff7a6b;
  --gold: #f5c518;
  font-family: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    linear-gradient(45deg, #24311f 25%, transparent 25%, transparent 75%, #24311f 75%),
    linear-gradient(45deg, #24311f 25%, transparent 25%, transparent 75%, #24311f 75%);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  color: var(--text);
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

canvas { image-rendering: pixelated; }

.title {
  text-align: center;
  font-size: 2.6rem;
  letter-spacing: 2px;
  margin: 8px 0;
  color: var(--gold);
  text-shadow: 4px 4px 0 #000;
}
.title.small { font-size: 1.6rem; margin: 0; }

h2 { margin: 0 0 12px; font-size: 1.2rem; color: var(--gold); }

.panel {
  background: var(--panel);
  border: 4px solid var(--panel-border);
  box-shadow: inset -4px -4px 0 #26321f, inset 4px 4px 0 #3c4d35;
  padding: 16px;
}

.btn {
  font: inherit;
  font-weight: bold;
  color: var(--text);
  background: #5c6b55;
  border: 4px solid #000;
  box-shadow: inset -4px -4px 0 #3e4a39, inset 4px 4px 0 #7f8f77;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-block;
}
.btn:hover, .btn:focus-visible { outline: 3px solid var(--gold); }
.btn:active { box-shadow: inset 4px 4px 0 #3e4a39; }
.btn.primary { background: var(--accent-dark); box-shadow: inset -4px -4px 0 #2b6a1c, inset 4px 4px 0 var(--accent); }
.btn.big { font-size: 1.5rem; padding: 16px 28px; }
.btn.small { font-size: 0.9rem; padding: 6px 12px; }
.btn.danger { background: #9b3a2f; }

.menu { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.chip { display: inline-block; padding: 2px 8px; margin: 4px 4px 0 0; border: 2px solid #000; font-size: 0.85rem; }
.stage-counts { margin-top: 6px; }
.chip.stage-0 { background: #6b6455; }
.chip.stage-1 { background: #4c7a8c; }
.chip.stage-2 { background: #4f8a4a; }
.chip.stage-3 { background: #7a5ca8; }
.chip.stage-4 { background: #a8841c; }

.camp-stats { display: grid; gap: 12px; font-size: 1.1rem; }
.fire { display: flex; align-items: center; gap: 12px; }
.fire-icon { font-size: 2.2rem; filter: grayscale(1) opacity(0.5); }
.fire.lit .fire-icon { filter: none; animation: flicker 0.8s infinite alternate; }
.fire small { color: var(--muted); }
@keyframes flicker { from { transform: scale(1); } to { transform: scale(1.12) rotate(-3deg); } }

.camp-lineup { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; min-height: 60px; }

.exp-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 1.2rem; }

.race { width: 100%; border: 4px solid #000; display: block; }

.question-panel { display: flex; align-items: center; gap: 24px; min-height: 140px; }
.question-main { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.question { font-size: 3rem; font-weight: bold; }
.answer {
  font: inherit;
  font-size: 3rem;
  width: 4.2ch;
  text-align: center;
  background: #10160e;
  color: var(--text);
  border: 4px solid #000;
  padding: 4px;
}
.answer:focus { outline: 4px solid var(--gold); }
.feedback { width: 100%; font-size: 1.4rem; min-height: 1.8rem; font-weight: bold; }
.feedback.good { color: var(--accent); }
.feedback.wrong { color: var(--wrong); }

.toasts { position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--gold);
  color: #000;
  font-weight: bold;
  padding: 10px 16px;
  border: 4px solid #000;
  animation: slide-in 0.3s ease-out;
}
@keyframes slide-in { from { transform: translateX(120%); } to { transform: none; } }

.results-main { text-align: center; display: grid; gap: 10px; font-size: 1.1rem; }
.results-main .time { font-size: 3.5rem; font-weight: bold; }
.record { color: var(--gold); font-size: 1.5rem; font-weight: bold; animation: pulse 0.9s infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.results-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 24px; }
.results-creatures { display: grid; gap: 16px; }

.card-row { display: flex; flex-wrap: wrap; gap: 12px; }
.card {
  background: #24301f;
  border: 4px solid #000;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  min-width: 110px;
}
.card > div { display: flex; flex-direction: column; }
.card small { color: var(--muted); }
.card .fact { font-size: 1.1rem; }
.card.stage-4 { border-color: var(--gold); box-shadow: 0 0 12px var(--gold); }
.card.stage-unknown { opacity: 0.6; }
.pop { animation: pop 0.5s ease-out both; }
@keyframes pop { 0% { transform: scale(0.3); } 70% { transform: scale(1.15); } 100% { transform: none; } }

.bestiary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }

.pin-panel { text-align: center; display: grid; gap: 12px; justify-items: center; }
.pin { width: 5ch; letter-spacing: 6px; }

.parent-summary { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.parent-grids { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 8px; }

.heatmap { border-collapse: collapse; }
.heatmap th, .heatmap td { width: 36px; height: 30px; text-align: center; font-size: 0.85rem; border: 2px solid var(--panel-border); }
.heatmap th { color: var(--muted); }
.heatmap td { color: #000; font-weight: bold; cursor: default; }
.lv-none { background: #4a4a45; color: #888 !important; }
.lv-1 { background: #e5584a; }
.lv-2 { background: #f0a040; }
.lv-3 { background: #d6d94a; }
.lv-4 { background: #5fcf4f; }
.legend span { padding: 2px 8px; margin-right: 6px; color: #000; font-weight: bold; }

.data { border-collapse: collapse; width: 100%; }
.data th, .data td { text-align: left; padding: 4px 10px; border-bottom: 2px solid var(--panel-border); }
.data th { color: var(--muted); }
