:root {
  --paper: #f3ede2; --paper2: #ebe3d4; --ink: #2b241d; --ink2: #6b5f52; --line: #cdbfa9;
  --accent: #9a4a26; --ok: #4f7a3a; --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.45 var(--sans); }
body { background-image: radial-gradient(rgba(120,90,50,0.05) 1px, transparent 1px); background-size: 5px 5px; }
h2 { font: 600 18px/1.2 var(--serif); margin: 0 0 10px; letter-spacing: 0.01em; }
h3 { font: 600 14px/1.2 var(--serif); margin: 14px 0 6px; color: var(--ink2); }
button { font: inherit; color: inherit; cursor: pointer; }
small { color: var(--ink2); font-size: 12px; }

#app {
  max-width: 1500px; margin: 0 auto; padding: 12px 18px 40px;
  display: grid; gap: 14px 22px;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-areas: "top top" "stage hunters" "tray hunters" "charts puzzles" "foot foot";
}
#top { grid-area: top; display: flex; align-items: center; gap: 18px; }
#stage { grid-area: stage; }
#tray { grid-area: tray; }
#hunters { grid-area: hunters; }
#charts { grid-area: charts; }
#puzzles { grid-area: puzzles; }

.home { color: var(--ink2); text-decoration: none; font: 14px var(--serif); white-space: nowrap; }
.home:hover { color: var(--ink); }
#goal { flex: 1; min-width: 0; }
.goal-title { font: 600 17px/1.2 var(--serif); }
.goal-text { color: var(--ink2); font-size: 14px; }
.goal-bar { height: 4px; background: var(--paper2); border-radius: 2px; margin-top: 5px; overflow: hidden; }
#goal-fill { height: 100%; width: 0; background: var(--ok); transition: width 0.6s ease; }
.time { display: flex; gap: 4px; }
.speed, .speed-like { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 5px 9px; font-size: 13px; min-width: 40px; min-height: 38px; }
.speed.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

#plate {
  position: relative; border-radius: 6px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 0 0 1px rgba(60,40,20,0.25), 0 10px 30px -12px rgba(60,40,20,0.45);
  background: #6a5a40;
}
#field { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
#caption { font: italic 13px var(--serif); color: var(--ink2); margin-top: 6px; text-align: center; }
#toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%) translateY(-8px);
  background: rgba(30,24,18,0.82); color: #f6efe4; padding: 7px 14px; border-radius: 18px; font-size: 14px;
  opacity: 0; transition: opacity 0.35s, transform 0.35s; pointer-events: none; max-width: 90%; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#lens-tag {
  position: absolute; left: 12px; bottom: 12px; background: rgba(255,236,140,0.9); color: #3a2a10;
  padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; display: none;
}
#plate.lens #lens-tag { display: block; }

.tray-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.size { font-size: 13px; color: var(--ink2); display: flex; align-items: center; gap: 8px; }
#swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 62px; border: none; background: none; padding: 0; text-align: center; font-size: 11px; color: var(--ink2);
}
.swatch canvas { display: block; width: 62px; height: 62px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(60,40,20,0.3), 0 3px 6px -3px rgba(60,40,20,0.5); transition: transform 0.15s, box-shadow 0.15s; }
.swatch span { display: block; margin-top: 4px; line-height: 1.15; }
.swatch[aria-checked="true"] canvas { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); transform: scale(1.04); }
.swatch[aria-checked="true"] span { color: var(--ink); font-weight: 600; }

#hunters { background: var(--paper2); border-radius: 10px; padding: 14px 16px 16px; align-self: start; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: none; background: transparent; padding: 7px 4px; font-size: 13px; line-height: 1.15; border-left: 1px solid var(--line); min-height: 40px; }
.seg button:first-child { border-left: none; }
.seg button small { display: block; font-size: 10.5px; }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg button.on small { color: #d8cdbd; }
.seg.small button { font-size: 12px; padding: 6px 3px; }
.slider { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink2); margin-bottom: 10px; }
.slider input { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.row { display: flex; gap: 8px; margin-top: 14px; }
.toggle { flex: 1; border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 8px 6px; font-size: 13px; min-height: 40px; }
.toggle[aria-pressed="true"] { background: #f7e48c; border-color: #c9a92a; }
#eyes.off { opacity: 0.45; pointer-events: none; }

#charts { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: start; }
#charts figure { margin: 0; }
#charts canvas { display: block; width: 100%; height: auto; }
#charts figcaption { font: italic 12px var(--serif); color: var(--ink2); margin-top: 4px; }
#birds-fig { grid-column: 1 / -1; display: none; }
#birds-fig.on { display: block; }

#puzzle-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
#puzzle-list button {
  width: 100%; text-align: left; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 8px 10px;
}
#puzzle-list button b { font: 600 14px var(--serif); display: block; }
#puzzle-list button span { font-size: 12px; color: var(--ink2); }
#puzzle-list button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
#puzzle-list button.on span { color: #d8cdbd; }
#puzzle-list button.done b::after { content: " ✓"; color: var(--ok); }

input[type=range] { accent-color: var(--ink); }

@media (max-width: 1050px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "stage" "tray" "hunters" "charts" "puzzles" "foot"; padding: 8px 10px 30px; gap: 12px; }
  #top { flex-wrap: wrap; gap: 8px 12px; }
  #goal { order: 3; flex-basis: 100%; }
  .time { margin-left: auto; }
  #swatches { flex-wrap: nowrap; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: none; }
  .swatch { flex: 0 0 auto; }
}
@media (max-width: 560px) {
  #charts { grid-template-columns: 1fr; }
  #charts figure:first-child { max-width: 260px; margin: 0 auto; }
  .swatch, .swatch canvas { width: 54px; } .swatch canvas { height: 54px; }
}

/* Credit (DB-0202/1 B): the words and the † open a one-line note; on paper the note prints at the foot.
   It sits in its own row under the puzzles, so the open note pushes nothing over the game's controls. */
.credit summary { display: inline-block; cursor: pointer; list-style: none; }
.credit summary::-webkit-details-marker { display: none; }
.credit summary::marker { content: ""; }
.credit sup { line-height: 0; margin-left: .15em; font-size: 1.05em; }
.credit .cnote { display: block; line-height: 1.4; }
.credit .cnote a { color: inherit; }
.cfoot { display: none; }
#foot { grid-area: foot; border-top: 1px solid var(--line); padding-top: 10px; }
#foot .credit { font: 14px/1.4 var(--serif); color: var(--ink2); max-width: 34rem; }
#foot .credit summary { padding: 6px 0; }
#foot .credit sup { color: var(--ink); }
#foot .credit .cnote { margin: 4px 0 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper2); color: var(--ink); font: 13px/1.4 var(--sans); }
@media print { #foot { display: none; } .cfoot { display: block; font-size: 9pt; color: #333; border-top: 1px solid #999; padding-top: .5em; margin-top: 2em; } }
