/* Vogelblitz: looks like a page of an old field guide.
   Paper tone, ink lines, serif headings from the system (no web fonts). */

:root {
  --paper: #efe6d2;
  --paper-2: #f7f1e3;
  --ink: #2c2a24;
  --ink-soft: #6b6457;
  --line: #c9bc9f;
  --moss: #4f6b3a;
  --moss-dark: #3c5329;
  --rust: #a4472e;
  --sky-top: #b9d3e4;
  --sky-bottom: #eef3ef;
  --gold: #c99a2e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.45), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(120,90,40,.10), transparent 45%);
  color: var(--ink);
  font: 17px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

#app { min-height: 100%; display: flex; }
.screen { display: none; width: 100%; }
.screen.active { display: flex; }

/* ---------- start ---------- */
#start { justify-content: center; align-items: flex-start; padding: 28px 16px 40px; }
.page {
  width: min(640px, 100%);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 1px 0 #fff inset, 0 18px 40px -24px rgba(60,40,10,.45);
  padding: 34px clamp(18px, 5vw, 48px) 26px;
  position: relative;
}
.page::before { /* inner ruled border like a printed plate */
  content: ""; position: absolute; inset: 10px; border: 1px solid var(--line); border-radius: 3px; pointer-events: none;
}
.kicker { font: italic 15px var(--serif); color: var(--ink-soft); margin: 0; text-align: center; }
h1 {
  font: 700 clamp(44px, 9vw, 68px)/1 var(--serif); letter-spacing: .5px; margin: 6px 0 4px; text-align: center;
}
h1::after { content: ""; display: block; width: 70px; height: 2px; background: var(--rust); margin: 12px auto 0; }
.lead { text-align: center; color: var(--ink-soft); margin: 12px 0 22px; }

.modes { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.mode {
  background: transparent; border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 12px 14px; text-align: left; transition: background .15s, transform .1s;
}
.mode span { display: block; font: 600 19px var(--serif); }
.mode small { color: var(--ink-soft); font-size: 13.5px; }
.mode:hover { background: rgba(79,107,58,.08); }
.mode:active { transform: translateY(1px); }
.mode.main { grid-column: 1 / -1; background: var(--moss); border-color: var(--moss-dark); color: #fff; padding: 16px 18px; }
.mode.main span { font-size: 25px; }
.mode.main small { color: #e3ead9; }
.mode.main:hover { background: var(--moss-dark); }
.mode.muted { opacity: .55; }

.start-row { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 4px; gap: 10px; flex-wrap: wrap; }
.toggle { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-size: 15px; }
.toggle.off { color: var(--ink-soft); text-decoration: line-through; }
.best { margin: 0; color: var(--ink-soft); font-size: 15px; }
.best b { color: var(--ink); font: 700 19px var(--serif); }
.msg { min-height: 1.4em; margin: 6px 0; color: var(--rust); font-size: 15px; }

.fame { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.fame h2 { font: 600 20px var(--serif); margin: 0 0 8px; text-align: center; }
.fame ol { margin: 0; padding: 0; list-style: none; counter-reset: f; columns: 2; column-gap: 28px; }
.fame li { counter-increment: f; display: flex; gap: 8px; align-items: baseline; padding: 3px 0; border-bottom: 1px dotted var(--line); break-inside: avoid; font-size: 15px; }
.fame li::before { content: counter(f) "."; width: 1.6em; color: var(--ink-soft); font-family: var(--serif); }
.fame li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fame li b { font-family: var(--serif); }
.fame li.empty { columns: 1; color: var(--ink-soft); border: 0; justify-content: center; }
.fame li.empty::before { content: none; }
.fame ol:has(.empty) { columns: 1; }

.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 20px; font-size: 13.5px; }
.foot a { color: var(--ink-soft); }

/* ---------- play ---------- */
#play { flex-direction: column; align-items: center; padding: 12px 14px 18px; gap: 12px; max-width: 760px; margin: 0 auto; min-height: 100dvh; }
.bar { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.streak { display: flex; align-items: baseline; gap: 8px; }
.streak span { font: italic 16px var(--serif); color: var(--ink-soft); }
.streak b { font: 700 34px/1 var(--serif); display: inline-block; }
.streak b.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: var(--moss); } }
.bar-right { display: flex; gap: 8px; }
.icon-btn { background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; min-width: 40px; height: 40px; padding: 0 12px; }
.icon-btn.off { color: var(--ink-soft); text-decoration: line-through; }

.hint { width: 100%; position: relative; }
.frame {
  position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: 52vh;
  margin: 0 auto; overflow: hidden; border-radius: 18px;
  background: #ddd3bb; border: 1px solid var(--line);
  box-shadow: 0 14px 30px -20px rgba(40,30,10,.6);
}
.frame img { width: 100%; height: 100%; object-fit: contain; display: block; background: #e7dfcb; }
.frame.type-photo img { position: relative; z-index: 1; object-fit: contain; background: none; }
.frame.type-photo img.backdrop { position: absolute; inset: -8%; width: 116%; height: 116%; z-index: 0; object-fit: cover; filter: blur(22px) saturate(.8) brightness(.85); }
/* binocular vignette */
.frame.type-photo::after, .frame.type-detail::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(20,15,5,.35) 100%);
}
.frame.type-detail img { position: absolute; max-width: none; object-fit: fill; background: none; }
.frame.type-flight { background: linear-gradient(var(--sky-top), var(--sky-bottom)); }
.frame.type-flight img { background: none; object-fit: contain; padding: 6%; }
.frame.type-voice { background: radial-gradient(circle at 50% 60%, #f4eddb, #ddd3bb); display: grid; place-items: center; }
.frame.loading img { opacity: 0; }
.frame img { transition: opacity .2s; }

.wave { display: flex; gap: 7px; align-items: center; height: 40%; }
.wave i { width: 9px; height: 18%; background: var(--moss); border-radius: 6px; opacity: .55; }
.frame.singing .wave i { animation: sing 0.9s ease-in-out infinite; opacity: 1; }
.wave i:nth-child(2n) { animation-delay: -.3s !important; }
.wave i:nth-child(3n) { animation-delay: -.6s !important; }
.wave i:nth-child(5n) { animation-delay: -.15s !important; }
@keyframes sing { 50% { height: 100%; } }

.replay {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; font-size: 15px;
}

.timer { width: 100%; height: 7px; background: rgba(0,0,0,.08); border-radius: 9px; overflow: hidden; }
#timer-bar { height: 100%; background: var(--moss); transform-origin: left; transform: scaleX(1); }
#timer-bar.low { background: var(--rust); }

.cards { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 10px; min-height: 58px;
  background: var(--paper-2); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; text-align: left; font: 600 18px/1.2 var(--serif);
  transition: background .15s, border-color .15s, transform .1s;
}
.card kbd { font: 600 12px var(--sans); color: var(--ink-soft); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.card:hover:not(:disabled) { border-color: var(--ink); }
.card:active:not(:disabled) { transform: translateY(1px); }
.card:disabled { cursor: default; }
.card.right { background: #dfe9d3; border-color: var(--moss); animation: flutter .4s ease; }
.card.wrong { background: #f1d9cf; border-color: var(--rust); animation: shake .35s ease; }
@keyframes flutter { 30% { transform: scale(1.04) rotate(-1deg); } 60% { transform: scale(1.02) rotate(1deg); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.link-btn { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; font-size: 14px; padding: 4px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(40,32,18,.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.overlay[hidden] { display: none; }
.sheet {
  width: min(460px, 100%); max-height: 100%; overflow: auto;
  background: var(--paper-2); border-radius: 10px; border: 1px solid var(--line);
  padding: 20px 22px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5);
  animation: page .35s ease;
}
@keyframes page { from { transform: perspective(900px) rotateY(-18deg); opacity: 0; } }
.sheet h2 { font: 700 28px/1.1 var(--serif); margin: 8px 0 2px; }
.sol-head { margin: 0 0 10px; color: var(--rust); font: italic 16px var(--serif); }
#sol-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: #e7dfcb; }
.sci { margin: 0; font: italic 15px var(--serif); color: var(--ink-soft); }
.mnemonic { margin: 12px 0 4px; font-size: 17px; border-left: 3px solid var(--gold); padding-left: 10px; }
.sheet-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.primary, .secondary { border-radius: 999px; padding: 10px 22px; font-weight: 600; }
.primary { background: var(--moss); color: #fff; border: 1px solid var(--moss-dark); }
.primary:hover { background: var(--moss-dark); }
.secondary { background: none; border: 1px solid var(--ink); }
.end-best { font: 20px var(--serif); margin: 6px 0; }
.end-best b { font-size: 34px; }
.record { color: var(--moss); font-weight: 600; margin: 0; }
#fame-form label, #report-form > label { display: block; margin-top: 10px; font-size: 15px; color: var(--ink-soft); }
#fame-form input, textarea {
  width: 100%; font: 18px var(--sans); padding: 8px 10px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.choices { display: grid; gap: 6px; margin: 8px 0; }
.choices label { display: flex; gap: 8px; align-items: center; }

/* milestone: a small bird crosses the screen */
#flyby { position: fixed; top: 22%; left: -80px; width: 64px; height: 34px; pointer-events: none; z-index: 20; opacity: 0;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 34'%3E%3Cpath d='M2 20 C14 6 24 8 32 18 C40 8 50 6 62 20 C50 14 42 16 32 26 C22 16 14 14 2 20 Z' fill='%232c2a24'/%3E%3C/svg%3E"); }
#flyby.go { animation: fly 1.6s ease-in-out; }
@keyframes fly { 0% { opacity: 1; transform: translate(0, 0) scale(.8); } 50% { transform: translate(55vw, -40px) scale(1); } 100% { opacity: 1; transform: translate(115vw, 10px) scale(.8); } }

/* ---------- phones ---------- */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .modes { grid-template-columns: 1fr; }
  .fame ol { columns: 1; }
  #play { padding: 8px 10px 12px; gap: 8px; }
  .frame { aspect-ratio: 1 / 1; max-height: 50vh; }
  .card { min-height: 52px; font-size: 16.5px; padding: 6px 10px; }
  .card kbd { display: none; }
  .cards.six { gap: 7px; }
  .cards.six .card { min-height: 46px; }
}
@media (max-height: 700px) and (min-width: 561px) { .frame { max-height: 44vh; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- credits page ---------- */
body.credits-page { display: block; height: auto; min-height: 100%; padding: 24px 14px; }
.credits { margin: 0 auto; }
.credits h1 { font-size: 34px; text-align: left; }
.credits h1::after { margin-left: 0; }
.credits h2 { font: 600 19px var(--serif); margin: 18px 0 4px; }
.credits ul { margin: 0; padding-left: 18px; font-size: 14px; }
.credits li { margin: 3px 0; overflow-wrap: anywhere; }
.credits a { color: var(--moss-dark); }
.credits input { width: 100%; font: 16px var(--sans); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
