:root {
  --carnelian: #b31b1b;
  --carnelian-dark: #8c1515;
  --ink: #1d1d1f;
  --paper: #faf7f2;
  --muted: #6b6b70;
  --line: #e4ded5;
  --actual: #1e8e3e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  /* vintage postcard palette */
  --cream: #f6ecd6;
  --cream-dark: #e9d9b6;
  --sepia: #4a3426;
  --faded-red: #a8322d;
  --postmark: rgba(74, 52, 38, 0.55);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--ink);
}

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }

/* ---------- Buttons & cards ---------- */

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.8em 1.6em;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.btn.primary { background: var(--carnelian); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--carnelian-dark); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { background: #8e8e93; cursor: not-allowed; }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* ---------- Start (vintage postcard) ---------- */

#screen-start {
  padding: 16px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(40, 8, 8, 0.55) 100%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 14px, transparent 14px 28px),
    #8e1d1b;
}
#screen-start.active { display: grid; place-items: center; }

.postcard {
  position: relative;
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  padding: 34px;
  color: var(--sepia);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(ellipse at 30% 20%, #fbf4e3, var(--cream) 55%, var(--cream-dark));
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), 0 22px 50px rgba(0, 0, 0, 0.45);
  transform: rotate(-1.2deg);
  animation: postcard-in 0.6s cubic-bezier(0.2, 0.8, 0.25, 1.1) both;
}
.postcard::before {
  /* double inner border */
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid var(--faded-red);
  outline: 1px solid var(--faded-red);
  outline-offset: 4px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0.75;
}
@keyframes postcard-in {
  from { opacity: 0; transform: translateY(24px) rotate(-4deg); }
}

.pc-front {
  padding: 14px 30px 10px 14px;
  text-align: center;
  border-right: 2px dashed rgba(74, 52, 38, 0.3);
}

.kicker {
  margin: 0;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faded-red);
}

.title { margin: 0.1em 0 0.35em; line-height: 0.9; }
.title-script {
  display: block;
  font-family: "Yellowtail", cursive;
  font-weight: 400;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  color: var(--sepia);
  transform: rotate(-6deg) translateX(-18%);
  margin-bottom: -0.15em;
  position: relative;
  z-index: 1;
}
.title-block {
  display: block;
  font-family: "Abril Fatface", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.8rem, 11vw, 5rem);
  letter-spacing: 0.04em;
  color: var(--faded-red);
  text-shadow: 3px 3px 0 var(--cream), 5px 5px 0 var(--sepia);
}

.tagline {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0 auto 1.3em;
  max-width: 34ch;
}

.rules {
  list-style: none;
  padding: 0;
  margin: 0 0 1.6em;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rules li {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.82rem;
  padding: 0.45em 0.9em;
  background: #fffaf0;
  border: 1.5px dashed var(--sepia);
  border-radius: 4px;
  transform: rotate(var(--tilt, 0deg));
}
.rules li:nth-child(1) { --tilt: -2deg; }
.rules li:nth-child(2) { --tilt: 1.5deg; }
.rules li:nth-child(3) { --tilt: -1deg; }
.rules strong { color: var(--faded-red); }

.btn.vintage {
  font-family: "Abril Fatface", Georgia, serif;
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  padding: 0.7em 2em;
  color: var(--cream);
  background: var(--faded-red);
  border: 2px solid var(--sepia);
  border-radius: 999px;
  box-shadow: 4px 4px 0 var(--sepia);
  transition: transform 0.12s, box-shadow 0.12s, background 0.15s;
}
.btn.vintage:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--sepia); }
.btn.vintage:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--sepia); }
.btn.vintage:disabled { background: #b9a88c; color: var(--cream); cursor: wait; }

.error {
  font-family: "Special Elite", "Courier New", monospace;
  color: var(--faded-red);
  font-size: 0.85rem;
  margin: 1.2em 0 0;
}

/* Back half: stamp, postmark, address */
.pc-back {
  position: relative;
  padding: 6px 6px 10px 30px;
  display: flex;
  flex-direction: column;
}

.stamp {
  position: relative;
  align-self: flex-end;
  width: 92px;
  padding: 7px;
  /* perforated edge: paper-coloured holes around a white border */
  background:
    radial-gradient(circle, var(--cream) 3.2px, transparent 3.7px) -5px -5px / 10px 10px,
    #fffdf7;
  transform: rotate(4deg);
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);
}
.stamp svg { display: block; width: 100%; border: 1.5px solid var(--faded-red); }
.stamp-value {
  position: absolute;
  left: 12px;
  bottom: 10px;
  font-family: "Abril Fatface", Georgia, serif;
  font-size: 0.9rem;
  color: #fffdf7;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.postmark {
  position: absolute;
  top: 34px;
  right: 46px;
  width: 190px;
  color: var(--postmark);
  font-family: "Special Elite", "Courier New", monospace;
  transform: rotate(-12deg);
  pointer-events: none;
  mix-blend-mode: multiply;
}

.address {
  margin-top: auto;
  padding-top: 40px;
}
.address p {
  margin: 0;
  padding: 0.55em 0 0.1em 0.4em;
  border-bottom: 1.5px solid rgba(74, 52, 38, 0.35);
  font-family: "Yellowtail", cursive;
  font-size: 1.45rem;
  color: #2f3f6b; /* fountain-pen blue */
  transform: rotate(-1deg);
}

@media (max-width: 720px) {
  .postcard { grid-template-columns: 1fr; padding: 26px 18px; transform: rotate(-0.6deg); }
  .pc-front { border-right: 0; padding: 10px 4px 4px; }
  .title-script { transform: rotate(-6deg) translateX(-12%); }

  /* The back of the card folds underneath: address on the left, stamp and
     postmark on the right, below a dashed fold line. */
  .pc-back {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 14px;
    margin: 18px 4px 2px;
    padding: 18px 2px 4px 0;
    border-top: 2px dashed rgba(74, 52, 38, 0.3);
  }
  .stamp {
    grid-column: 2;
    grid-row: 1;
    width: 70px;
    padding: 6px;
    margin-right: 4px;
    transform: rotate(5deg);
  }
  .stamp-value { left: 10px; bottom: 8px; font-size: 0.8rem; }
  .postmark {
    top: 22px;
    right: 22px;
    width: 150px;
    transform: rotate(-10deg);
  }
  .address {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    padding: 0;
    min-width: 0;
    text-align: left;
  }
  .address p {
    padding: 0.35em 0 0.05em 0.3em;
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ---------- Round ---------- */

#pano { position: absolute; inset: 0; }

.timer-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.35);
  z-index: 10;
}
#timer-fill {
  height: 100%;
  background: var(--carnelian);
  transform-origin: left;
  transition: transform 0.1s linear;
}

.hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: rgba(20, 20, 22, 0.78);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: 12px;
  padding: 6px;
  z-index: 10;
}
.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 14px;
  min-width: 72px;
}
.hud-item + .hud-item { border-left: 1px solid rgba(255, 255, 255, 0.15); }
.hud .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.hud-item span:last-child {
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
#hud-timer-item.warning span:last-child { color: #ff6b6b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* Guess map panel */
.guess-panel {
  /* size when open; set by the size-N class (bigger/smaller buttons) */
  --open-w: 640px;
  --open-h: 500px;
  --open-h-mobile: 55vh;
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 320px;
  height: 240px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  transition: width 0.2s ease, height 0.2s ease;
}
.guess-panel.size-0 { --open-w: 640px;  --open-h: 500px;  --open-h-mobile: 55vh; }
.guess-panel.size-1 { --open-w: 100vw;  --open-h: 100vh;  --open-h-mobile: 100vh; }

.guess-map-wrap {
  position: relative;
  flex: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  opacity: 0.8;
  transition: opacity 0.2s;
}
#guess-map { position: absolute; inset: 0; cursor: crosshair; }
.guess-panel .btn { width: 100%; }

/* Open states: tapped open (touch), pinned, or hovered (mouse) */
.guess-panel.expanded,
.guess-panel.pinned {
  width: min(var(--open-w), calc(100vw - 32px));
  height: min(var(--open-h), calc(100vh - 110px));
}
.guess-panel.expanded .guess-map-wrap,
.guess-panel.pinned .guess-map-wrap { opacity: 1; }

/* Size / pin / close buttons */
.map-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 600;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.guess-panel.expanded .map-tools,
.guess-panel.pinned .map-tools { opacity: 1; pointer-events: auto; }

.map-tool {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.85);
  color: #fff;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}
.map-tool svg { width: 16px; height: 16px; }
.map-tool:hover:not(:disabled) { background: var(--carnelian); }
.map-tool:disabled { opacity: 0.35; cursor: default; }
.map-tool[aria-pressed="true"] { background: var(--carnelian); }

@media (hover: hover) {
  .guess-panel:hover {
    width: min(var(--open-w), calc(100vw - 32px));
    height: min(var(--open-h), calc(100vh - 110px));
  }
  .guess-panel:hover .guess-map-wrap { opacity: 1; }
  .guess-panel:hover .map-tools { opacity: 1; pointer-events: auto; }
  .map-cover, .map-collapse { display: none !important; }
}
@media (hover: none) {
  #map-pin { display: none; }
}

/* Touch: tap the small map to open it, × to close */
.map-cover {
  position: absolute;
  inset: 0;
  z-index: 500;
  border: 0;
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.map-collapse { display: none; }
.guess-panel.expanded .map-cover { display: none; }
.guess-panel.expanded .map-collapse { display: grid; }

@media (max-width: 600px) {
  .hud-item { min-width: 0; padding: 2px 10px; }
  .guess-panel { left: 16px; width: auto; height: 190px; }
  .guess-panel.expanded,
  .guess-panel.pinned { width: auto; height: min(var(--open-h-mobile), calc(100vh - 110px)); }
}

/* ---------- Pins ---------- */

.pin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.pin-guess { background: var(--carnelian); }
.pin-actual { background: var(--actual); }

/* ---------- Result & summary ---------- */

#result-map { position: absolute; inset: 0; }

.overlay-card {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  text-align: center;
  z-index: 1001;
}
.overlay-card[hidden] { display: none; }

.result-place {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--actual);
}
.result-points {
  margin: 0.15em 0 0.4em;
  font-size: 2.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.result-points small, .summary-total small {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}
.score-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
#result-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #e0a526, var(--carnelian));
  transition: width 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.result-distance { color: var(--muted); margin: 0.9em 0 1.2em; }

/* Final score: a vintage postcard like the start page */
.summary-card {
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 30px 30px 22px;
  color: var(--sepia);
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .25  0 0 0 0 .15  0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(ellipse at 30% 20%, #fbf4e3, var(--cream) 55%, var(--cream-dark));
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), 0 22px 50px rgba(0, 0, 0, 0.45);
  outline: 2px solid rgba(168, 50, 45, 0.75);
  outline-offset: -12px;
  transform: translateX(-50%) rotate(-0.6deg);
  animation: summary-in 0.55s cubic-bezier(0.2, 0.8, 0.25, 1.1) both;
}
@keyframes summary-in {
  from { opacity: 0; transform: translate(-50%, 24px) rotate(-3deg); }
}
.summary-card h2 {
  margin: 0;
  font-family: "Yellowtail", cursive;
  font-weight: 400;
  font-size: 2.3rem;
  line-height: 1.1;
  color: var(--sepia);
  transform: rotate(-3deg);
}
.summary-total {
  margin: 0 0 0.5em;
  font-family: "Abril Fatface", Georgia, serif;
  font-weight: 400;
  font-size: 3.4rem;
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--faded-red);
  text-shadow: 2px 2px 0 var(--cream), 4px 4px 0 var(--sepia);
  font-variant-numeric: tabular-nums;
}
.summary-total small {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 1rem;
  color: var(--sepia);
  text-shadow: none;
  opacity: 0.8;
}
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.1em;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
}
.summary-table th, .summary-table td {
  padding: 6px 4px;
  border-bottom: 1px dashed rgba(74, 52, 38, 0.35);
  text-align: left;
}
.summary-table th {
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  border-bottom: 1.5px solid rgba(74, 52, 38, 0.45);
}
.summary-table td:first-child { color: var(--faded-red); }
.summary-table td:last-child { color: var(--faded-red); font-weight: 700; }
.summary-table td:last-child, .summary-table th:last-child,
.summary-table td:nth-child(3), .summary-table th:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-card .kicker { font-size: 0.75rem; }
.summary-card .next-in {
  font-family: "Special Elite", "Courier New", monospace;
  color: var(--sepia);
  opacity: 0.75;
}
.summary-actions .btn.vintage { font-size: 1rem; padding: 0.6em 1.4em; }
.btn.vintage.ghost { background: #fffaf0; color: var(--sepia); }
.btn.vintage.ghost:hover:not(:disabled) { background: #fff; }

/* Round postmark with the verdict, stamped over the corner */
.verdict-stamp {
  position: absolute;
  top: 20px;
  right: 22px;
  width: 92px;
  height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2.5px solid currentColor;
  border-radius: 50%;
  outline: 1.5px solid currentColor;
  outline-offset: -8px;
  color: rgba(168, 50, 45, 0.72);
  font-family: "Special Elite", "Courier New", monospace;
  text-transform: uppercase;
  transform: rotate(14deg);
  pointer-events: none;
  animation: stamp-in 0.35s 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
.verdict-top, .verdict-bottom { font-size: 0.55rem; letter-spacing: 0.12em; }
.verdict-word {
  margin: 2px 0;
  font-family: "Abril Fatface", Georgia, serif;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
@keyframes stamp-in {
  from { opacity: 0; transform: rotate(14deg) scale(1.8); }
}
@media (max-width: 600px) {
  .summary-card { padding: 26px 22px 18px; }
  .summary-total { font-size: 2.8rem; }
  .verdict-stamp { top: 16px; right: 14px; width: 74px; height: 74px; outline-offset: -6px; }
  .verdict-top, .verdict-bottom { font-size: 0.45rem; }
  .verdict-word { font-size: 0.64rem; letter-spacing: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .summary-card, .verdict-stamp { animation: none; }
}

/* Fun fact: a little vintage note taped to the result card */
.result-fact {
  position: relative;
  margin: 0.6em 6px 1.5em;
  padding: 1.5em 1.1em 1em;
  background: linear-gradient(170deg, #fbf4e3, var(--cream) 60%, var(--cream-dark));
  border: 1.5px dashed rgba(74, 52, 38, 0.45);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(74, 52, 38, 0.18);
  transform: rotate(-0.8deg);
  text-align: left;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--sepia);
  animation: fact-in 0.45s 0.35s cubic-bezier(0.2, 0.8, 0.25, 1.1) both;
}
.result-fact[hidden] { display: none; }
.result-fact::before {
  content: "Fun fact!";
  position: absolute;
  top: -0.85em;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  padding: 0 0.35em;
  background: var(--paper);
  font-family: "Yellowtail", cursive;
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--faded-red);
  white-space: nowrap;
}
.result-fact::after {
  /* strip of tape */
  content: "";
  position: absolute;
  top: -10px;
  right: 18px;
  width: 64px;
  height: 20px;
  background: rgba(233, 217, 182, 0.8);
  border-left: 1px dashed rgba(74, 52, 38, 0.15);
  border-right: 1px dashed rgba(74, 52, 38, 0.15);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transform: rotate(7deg);
}
@keyframes fact-in {
  from { opacity: 0; transform: translateY(10px) rotate(-3deg); }
}

/* ---------- Loading screen (waving bear on a postcard) ---------- */

/* Themed backdrop behind the photo instead of the viewer's grey pattern */
#pano,
#pano.pnlm-container {
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(40, 8, 8, 0.55) 100%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 14px, transparent 14px 28px),
    #8e1d1b;
}
/* Hide the viewer's built-in loading box; ours replaces it */
#pano .pnlm-load-box { display: none !important; }

.pano-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
  animation: loader-in 0.15s ease-out both;
}
.pano-loading[hidden] { display: none; }
@keyframes loader-in {
  from { opacity: 0; transform: translateY(8px); }
}

.loader-card {
  width: min(280px, 100%);
  padding: 22px 22px 18px;
  text-align: center;
  color: var(--sepia);
  background: radial-gradient(ellipse at 30% 20%, #fbf4e3, var(--cream) 55%, var(--cream-dark));
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  outline: 2px solid var(--faded-red);
  outline-offset: -10px;
  transform: rotate(-1.5deg);
}

.bear {
  display: block;
  width: 108px;
  height: 108px;
  margin: 0 auto 4px;
  animation: bear-bob 1.6s ease-in-out infinite;
}
.bear-arm {
  transform-box: view-box;
  transform-origin: 90px 90px; /* shoulder */
  animation: bear-wave 0.9s ease-in-out infinite alternate;
}
.bear-eyes {
  transform-box: view-box;
  transform-origin: 60px 47px;
  animation: bear-blink 3.6s infinite;
}
@keyframes bear-wave {
  from { transform: rotate(-4deg); }
  to { transform: rotate(28deg); }
}
@keyframes bear-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
@keyframes bear-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.loader-title {
  margin: 0;
  font-family: "Yellowtail", cursive;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--faded-red);
}
.dots span {
  display: inline-block;
  animation: dot-hop 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-hop {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.loader-line {
  margin: 0.4em 0 0;
  min-height: 1.4em;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  .bear, .bear-arm, .bear-eyes, .dots span { animation: none; }
}

/* ---------- Daily puzzle: start page additions ---------- */

.puzzle-no {
  margin: 0.3em 0 0.8em;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sepia);
  opacity: 0.8;
}

/* Name written on the postcard in "fountain pen" */
.name-field {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 1.3em;
  max-width: 330px;
}
.name-field span {
  flex: none;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.name-field input {
  flex: 1;
  min-width: 0;
  padding: 0 0.2em 0.05em;
  border: 0;
  border-bottom: 1.5px dashed var(--sepia);
  border-radius: 0;
  background: transparent;
  font-family: "Yellowtail", cursive;
  font-size: 1.6rem;
  line-height: 1.2;
  color: #2f3f6b;
  text-align: center;
}
.name-field input::placeholder {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
  color: rgba(74, 52, 38, 0.45);
}
.name-field input:focus { outline: none; border-bottom-style: solid; border-bottom-color: var(--faded-red); }

.played-today {
  margin: -0.4em 0 1.2em;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.9rem;
}
.played-today p { margin: 0.2em 0; }
.played-today strong { color: var(--faded-red); }

.link-btn {
  display: block;
  margin: 1em auto 0;
  padding: 0.2em 0.4em;
  border: 0;
  background: none;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.9rem;
  color: var(--faded-red);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { text-decoration-style: solid; }

.next-in {
  margin: 0.8em 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.played-today .next-in { color: inherit; opacity: 0.75; }

/* ---------- Round: send errors ---------- */

.guess-error {
  margin: 0;
  padding: 0.5em 0.8em;
  border-radius: 8px;
  background: rgba(179, 27, 27, 0.95);
  color: #fff;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}
.guess-error[hidden] { display: none; }

/* ---------- Summary: mini leaderboard ---------- */

.mini-board {
  margin: 0 0 1em;
  padding: 0.8em 0.9em 0.6em;
  background: rgba(255, 250, 240, 0.75);
  border: 1.5px dashed rgba(74, 52, 38, 0.4);
  border-radius: 6px;
}
.mini-board h3 {
  margin: 0 0 0.3em;
  font-family: "Yellowtail", cursive;
  font-weight: 400;
  font-size: 1.5rem;
  color: var(--faded-red);
}
.summary-rank {
  margin: 0.5em 0 0;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
  color: var(--sepia);
}
.summary-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn.ghost {
  background: transparent;
  border: 2px solid var(--line);
  color: var(--ink);
}
.btn.ghost:hover { border-color: var(--muted); }

/* ---------- Leaderboard screen ---------- */

#screen-leaderboard {
  padding: 16px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at center, transparent 40%, rgba(40, 8, 8, 0.55) 100%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 14px, transparent 14px 28px),
    #8e1d1b;
}
#screen-leaderboard.active { display: grid; place-items: center; }

.board-card {
  width: min(520px, 100%);
  padding: 30px 28px 24px;
  text-align: center;
  color: var(--sepia);
  background: radial-gradient(ellipse at 30% 20%, #fbf4e3, var(--cream) 55%, var(--cream-dark));
  border-radius: 6px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
  outline: 2px solid var(--faded-red);
  outline-offset: -12px;
  transform: rotate(-0.6deg);
  animation: postcard-in 0.5s cubic-bezier(0.2, 0.8, 0.25, 1.1) both;
}
.board-title {
  margin: 0.05em 0 0;
  font-family: "Yellowtail", cursive;
  font-weight: 400;
  font-size: clamp(2.4rem, 9vw, 3.2rem);
  line-height: 1.1;
  color: var(--faded-red);
}
.board-meta {
  margin: 0.2em 0 1em;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
}
.board-you {
  margin: 0.8em 0 0;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.9rem;
  color: var(--faded-red);
}
.board-card .btn { margin-top: 1.2em; }
.board-card .next-in { color: var(--sepia); opacity: 0.75; }

/* Rows: rank · name · score */
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 52vh;
  overflow-y: auto;
  text-align: left;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.95rem;
}
.board-list li {
  display: grid;
  grid-template-columns: 3.2em 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 0.45em 0.5em;
  border-bottom: 1px dashed rgba(74, 52, 38, 0.3);
}
.board-list li:last-child { border-bottom: 0; }
.board-list .rank { color: var(--faded-red); }
.board-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .score { font-variant-numeric: tabular-nums; }
.board-list li.you {
  background: rgba(168, 50, 45, 0.1);
  border-radius: 4px;
  font-weight: 700;
}
.board-list li.you .name::after { content: " (you)"; font-weight: 400; opacity: 0.7; }
.board-list li.board-empty,
.board-list li.board-gap {
  display: block;
  text-align: center;
  color: rgba(74, 52, 38, 0.7);
}
.board-list.compact { max-height: none; font-size: 0.85rem; }
.board-list.compact li { padding: 0.3em 0.4em; }
