:root {
  color-scheme: dark;
  --ink: #f4ecda;
  --muted: #b9c6b8;
  --accent: #e4b768;
  --ground: #1d322c;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  background:
    radial-gradient(110% 70% at 50% 28%, #3a6355 0%, #24413a 42%, #172a25 78%, #101d1a 100%) fixed,
    var(--ground);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.stage {
  margin: auto;
  width: 100%;
  max-width: 640px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* ---------- Telephone ---------- */
.telephone {
  display: block;
  width: min(100%, calc((100vh - 150px) * 500 / 580));
  width: min(100%, calc((100svh - 150px) * 500 / 580));
  min-width: min(100%, 280px);
  height: auto;
  overflow: visible;
  touch-action: none;
}
.cord { fill: none; stroke: #2c2a24; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.plunger { fill: url(#g-chrome); stroke: #6d7174; stroke-width: 1; }
.number-plate { fill: #fbf7ee; stroke: #c9b791; stroke-width: 1.5; }
.plate-digits text {
  font: 600 26px/1 "DIN Alternate", "Bahnschrift", "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  fill: #26231d;
  text-anchor: middle;
  dominant-baseline: central;
}
.hole-rims circle { fill: none; stroke: #8d7a55; stroke-opacity: .55; stroke-width: 2; }
.card-text { font: 700 11px/1 system-ui, sans-serif; letter-spacing: .32em; fill: #6a5d45; }
.dial-hit { fill: transparent; cursor: grab; pointer-events: all; }
.dial.winding .dial-hit { cursor: grabbing; }
.hole-target { fill: transparent; stroke: none; pointer-events: none; outline: none; }
.hole-target:focus-visible { stroke: var(--accent); stroke-width: 4; }

.handset { cursor: pointer; outline: none; }
.handset:focus-visible .handset-shape { stroke: var(--accent); stroke-width: 3; }
.waves path {
  fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round;
  opacity: 0; transition: opacity .3s;
}
.telephone.playing .waves path { animation: wave 1.5s ease-out infinite; }
.telephone.playing .waves path:nth-child(2) { animation-delay: .25s; }
.telephone.playing .waves path:nth-child(3) { animation-delay: .5s; }
@keyframes wave {
  0% { opacity: 0; }
  30% { opacity: .95; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .telephone.playing .waves path { animation: none; opacity: .8; }
}

/* ---------- Text below the telephone ---------- */
.display {
  margin: 10px 0 0;
  min-height: 1.25em;
  font: 600 clamp(1.9rem, 8vw, 2.7rem)/1.25 "Courier Prime", "Courier New", ui-monospace, monospace;
  letter-spacing: .28em;
  padding-left: .28em; /* Balance the trailing letter-spacing. */
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: opacity .6s;
}
.display.done { opacity: .55; }
.hint {
  margin: 4px 0 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 1.02rem;
  letter-spacing: .01em;
}
.play {
  margin-top: 14px;
  border: 0;
  border-radius: 999px;
  padding: 12px 26px;
  font: 600 1.05rem/1 system-ui, sans-serif;
  color: #1d322c;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 6px 18px #0006;
}
.play:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.noscript { margin: auto; padding: 24px; }

/* ---------- Login ---------- */
.login { max-width: 380px; gap: 10px; }
.login h1 { margin: 6px 0 14px; font-weight: 600; letter-spacing: .02em; }
.login-icon { border-radius: 20px; box-shadow: 0 10px 30px #0007; }
.login-form { width: 100%; text-align: left; -webkit-user-select: text; user-select: text; }
.login-form label { display: block; margin: 0 0 8px; font-weight: 600; font-size: .95rem; }
.login-form input {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 1.05rem;
  color: #1d2a26;
  background: #fbf7ee;
  border: 0;
  border-radius: 10px;
}
.login-form button {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  font: 600 1.05rem/1 system-ui, sans-serif;
  color: #1d322c;
  background: var(--accent);
  cursor: pointer;
}
.login-form input:focus-visible, .login-form button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.login-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: #6b2a22; color: #ffe9e4; }
.login-note { color: var(--muted); font-size: .92rem; text-align: center; }

/* ---------- Number list ---------- */
.book-open {
  margin-top: 14px;
  padding: 9px 20px;
  border: 1.5px solid #f4ecda55;
  border-radius: 999px;
  font: 600 .95rem/1 system-ui, sans-serif;
  letter-spacing: .04em;
  color: var(--ink);
  background: #0000001f;
  cursor: pointer;
}
.book-open:hover { border-color: #f4ecdaaa; }
.book-open:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.book {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100svh - 48px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: #26231d;
  background: #fbf7ee;
  box-shadow: 0 24px 60px #000a;
  overflow: auto;
}
.book::backdrop { background: #07110ecc; }
.book-card { padding: 18px 20px 20px; text-align: left; }
.book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #a8392c;
  padding-bottom: 8px;
}
.book h2 {
  margin: 0;
  font: 700 .95rem/1.2 system-ui, sans-serif;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: #6a5d45;
}
.book-close {
  width: 40px;
  height: 40px;
  margin: -8px -10px -8px 0;
  border: 0;
  border-radius: 50%;
  font: 400 1.7rem/1 system-ui, sans-serif;
  color: #6a5d45;
  background: none;
  cursor: pointer;
}
.book-list { list-style: none; margin: 6px 0 0; padding: 0; }
.book-list li + li { border-top: 1px solid #e3d8c1; }
.book-entry {
  display: flex;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  padding: 12px 6px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  text-align: left;
  color: inherit;
  background: none;
  cursor: pointer;
}
.book-entry:hover { background: #f0e7d3; }
.book-number {
  flex: 0 0 auto;
  min-width: 3.2em;
  font: 700 1.25rem/1.2 "Courier Prime", "Courier New", ui-monospace, monospace;
  letter-spacing: .08em;
  color: #a8392c;
}
.book-text { font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.book-tip, .book-empty { margin: 8px 0 0; color: #7a6f5c; font-size: .9rem; }
.book h3 {
  margin: 20px 0 6px;
  font: 700 .78rem/1.2 system-ui, sans-serif;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6a5d45;
}
.book-howto { margin: 0; padding-left: 1.2em; font-size: .92rem; line-height: 1.45; color: #4a4336; }
.book-howto li + li { margin-top: 4px; }
.book button:focus-visible { outline: 3px solid #a8392c; outline-offset: 1px; }
