:root {
  --paper: #f7f2e8;
  --ink: #33291f;
  --ink-dim: #8a7d6a;
  --rule: #cbbfa8;
  --accent: #7a2e1d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #201b15;
    --ink: #e6dcc8;
    --ink-dim: #93876f;
    --rule: #4a4032;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16svh 24px 96px;
}

#screen {
  width: 100%;
  max-width: 36ch;
  font-size: 1.15rem;
  line-height: 1.75;
}

.line {
  opacity: 0;
  animation: rise 0.9s ease var(--d, 0s) forwards;
}
.line.dim {
  color: var(--ink-dim);
  font-size: 0.9em;
  font-style: italic;
}
.gap { height: 1.4em; }

.reveal {
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
  opacity: 0;
  animation: rise 1.6s ease var(--d, 0s) forwards;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

img.ill {
  max-width: 100%;
  border-radius: 4px;
  display: block;
}

.barcode {
  background: #fff;
  padding: 14px 12px 8px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(60, 45, 20, 0.18);
  width: min(280px, 100%);
}
.barcode svg { display: block; width: 100%; height: auto; }

#entry {
  width: 100%;
  max-width: 36ch;
  margin-top: 2.6em;
}
#code {
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  font: inherit;
  font-size: 1.15rem;
  color: var(--ink);
  padding: 0.35em 0.1em;
  caret-color: var(--accent);
}
#code:focus {
  outline: none;
  border-bottom-color: var(--ink-dim);
}
#entry.empty #code { animation: breathe 3.5s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { border-bottom-color: var(--rule); }
  50%      { border-bottom-color: var(--ink-dim); }
}

.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

#aside {
  min-height: 1.5em;
  margin-top: 0.9em;
  color: var(--ink-dim);
  font-style: italic;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.5s;
}
#aside.show { opacity: 1; }

#dots {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
}
#dots button {
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: radial-gradient(circle at center, var(--rule) 0 3.5px, transparent 4px);
}
#dots button.cur {
  background: radial-gradient(circle at center, var(--ink-dim) 0 3.5px, transparent 4px);
}

.noscript {
  margin-top: 2em;
  color: var(--ink-dim);
  font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
  .line, .reveal { animation: none; opacity: 1; }
  #entry.empty #code { animation: none; }
  .shake { animation: none; }
}
