/* Gissa kattrasen – Femkryss design system, see CLAUDE.md. Accent: plum. */
:root {
  --bg: #EEF2EF;
  --surface: #FFFFFF;
  --ink: #17302A;
  --muted: #5C6B66;
  --accent: #7B4B94;
  --accent-ink: #FFFFFF;
  --ok: #2C8A5A;
  --bad: #C64B3B;
  --square: #D5DDD9;
  --line: #CFD8D3;
  --photo-bg: #17302A;
  --radius: 14px;
  --sans: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --shadow: 0 10px 30px rgba(23, 48, 42, 0.12);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
button, input { font: inherit; }
[hidden] { display: none !important; }

/* Header: one compact row, brand + puzzle number + nav */
.top {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 8px 14px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-mark { width: 18px; height: 18px; fill: var(--ink); }
.puzzle-meta { color: var(--muted); font-size: 0.8rem; display: inline-flex; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.puzzle-meta span:first-child { color: var(--ink); font-weight: 600; }
.top-nav { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 0.85rem; white-space: nowrap; }
.top-nav a { color: var(--ink); text-decoration: none; border-bottom: 1.5px solid var(--line); padding-bottom: 1px; }
.top-nav a:hover { border-color: var(--ink); }
.link-btn {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 50%; width: 24px; height: 24px; padding: 0;
  color: var(--ink); cursor: pointer; font-weight: 700; font-size: 0.85rem; line-height: 1;
}
.link-btn:hover { border-color: var(--ink); }

/* Game column */
.game, .archive {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 0 14px 24px;
}

.photo {
  position: relative;
  margin: 0;
  background: var(--photo-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: max(150px, calc(var(--vvh, 100vh) - 300px));
  object-fit: contain;
  background: var(--photo-bg);
  transition: opacity .25s ease;
}
.photo img.is-loading { opacity: 0; }
.photo img { cursor: zoom-in; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.photo.is-zooming img { cursor: zoom-out; }
.loupe {
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(0, 0, 0, .15);
  background-repeat: no-repeat;
  background-color: var(--photo-bg);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 3;
}
/* Facit for an earlier or finished photo: a compact overlay in the photo's bottom-right corner */
.review {
  position: absolute;
  right: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  border-left: 5px solid var(--square);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  line-height: 1.25;
}
.review.is-ok { border-left-color: var(--ok); }
.review.is-bad { border-left-color: var(--bad); }
.review-name { margin: 0; }
.review-name i { font-family: var(--serif); color: var(--muted); font-size: 1.1em; }
.review-name .guess { color: var(--bad); }
.review-back {
  border: 1.5px solid var(--ink); background: #fff; color: var(--ink); border-radius: 8px;
  padding: 4px 9px; font-size: 0.8rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* Guess input */
.guess { margin-top: 10px; }
.combo { display: flex; gap: 6px; }
.field { position: relative; flex: 1; min-width: 0; display: flex; }
.field.is-open #guess-input { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
#guess-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}
#guess-input:focus { border-color: var(--accent); outline: none; }
#guess-input::placeholder { color: #8A9793; }
.suggestions {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin: 0;
  background: var(--surface);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 18px rgba(23, 48, 42, 0.18);
  border: 2px solid var(--accent);
  border-top: 0;
  max-height: 46vh;
  overflow-y: auto;
  z-index: 5;
}
.suggestions li {
  padding: 5px 12px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.3;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: #EFE6F3; }

.btn { padding: 8px 14px; }

/* Guess input */
.guess { margin-top: 10px; }
.combo { display: flex; gap: 6px; }
.field { position: relative; flex: 1; min-width: 0; display: flex; }
.field.is-open #guess-input { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
#guess-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
}
#guess-input:focus { border-color: var(--accent); outline: none; }
#guess-input::placeholder { color: #8A9793; }
.suggestions li i { font-family: var(--serif); color: var(--muted); font-size: 1.05em; white-space: nowrap; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: #EFE6F3; }
.suggestions mark { background: none; color: var(--accent); font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: #24463E; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* The five squares */
.squares {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
}
.squares button {
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--square);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  cursor: default;
}
.squares button.is-current { box-shadow: inset 0 0 0 3px var(--ink); }
.squares button.is-viewing { outline: 3px solid var(--accent); outline-offset: 2px; }
.squares button.is-ok, .squares button.is-bad, .squares button.is-current:not([disabled]) { cursor: pointer; }
.squares button.is-ok { background: var(--ok); animation: pop .35s cubic-bezier(.2,.9,.3,1.4); }
.squares button.is-bad { background: var(--bad); animation: pop .35s cubic-bezier(.2,.9,.3,1.4); }
.squares button.is-ok::after { content: "🐈"; font-size: 1.35rem; }
.squares button.is-bad::after { content: "✗"; }

/* Fireworks around a square when the guess was right */
.squares li { position: relative; }
.spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  pointer-events: none;
  animation: spark .9s cubic-bezier(.15,.8,.3,1) forwards;
}
.spark.is-streak { width: 3px; height: 14px; border-radius: 2px; margin: -7px 0 0 -1.5px; }
@keyframes spark {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; }
}

/* Result */
.result {
  margin-top: 22px;
  padding: 20px 18px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise .35s ease-out;
}
.result-title {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.9rem, 7vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.result-sub { margin: 8px 0 0; color: var(--muted); }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.result-actions .btn { flex: 1 1 auto; }
.countdown { margin: 16px 0 0; color: var(--muted); font-size: 0.95rem; }
.stats {
  margin: 14px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stats div { text-align: center; }
.stats dt { font-size: 0.8rem; color: var(--muted); order: 2; }
.stats dd { margin: 0; font-size: 1.5rem; font-weight: 700; }
.answers { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 6px; }
.answers h3 { margin: 8px 0 4px; font-size: 0.95rem; color: var(--muted); font-weight: 600; }
.answer {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 4px 10px;
  padding: 8px 0;
  border-bottom: 1px solid #E6ECE9;
  align-items: start;
}
.answer:last-child { border-bottom: 0; }
.answer .sq { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: .9rem; font-weight: 800; }
.answer .sq.is-ok { background: var(--ok); }
.answer .sq.is-bad { background: var(--bad); }
.answer .name { font-weight: 600; }
.answer .name i { font-family: var(--serif); font-weight: 400; color: var(--muted); font-size: 1.05em; }
.answer .guessed { color: var(--bad); font-size: .9rem; }
.answer .credit { color: var(--muted); font-size: .8rem; grid-column: 2; }

.loading { text-align: center; color: var(--muted); margin: 40px 0; }

/* Archive */
.archive h1 { font-size: 2rem; margin: 10px 0 4px; letter-spacing: -0.01em; }
.archive-intro { color: var(--muted); margin: 0 0 16px; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li a {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  border: 1.5px solid transparent;
}
.archive-list li a:hover { border-color: var(--ink); }
.archive-list .no { font-weight: 700; }
.archive-list .date { color: var(--muted); font-size: .9rem; margin-left: 8px; }
.archive-list .status { color: var(--muted); font-size: .9rem; }
.mini { display: inline-flex; gap: 4px; }
.mini i { width: 16px; height: 16px; border-radius: 4px; background: var(--square); display: block; }
.mini i.is-ok { background: var(--ok); }
.mini i.is-bad { background: var(--bad); }
.archive-list li.is-today a { border-color: var(--accent); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Help dialog */
.help {
  border: 0;
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  width: min(92vw, 440px);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.help::backdrop { background: rgba(23, 48, 42, .45); }
.help h2 { margin: 0 0 10px; font-size: 1.4rem; }
.help ol { margin: 0 0 16px; padding-left: 22px; }
.help li { margin-bottom: 6px; }

/* Flock on a full score */
.flock { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 15; }
.flock svg {
  position: absolute;
  width: 34px;
  height: 34px;
  fill: var(--ink);
  left: -60px;
  opacity: 0;
}
.flock.is-on svg { animation: fly 2.6s cubic-bezier(.3,.1,.4,1) forwards; }

@keyframes fly {
  0%   { transform: translate(0, 0) scale(.7) rotate(-6deg); opacity: 0; }
  10%  { opacity: 1; }
  50%  { transform: translate(55vw, -14vh) scale(1) rotate(4deg); }
  100% { transform: translate(120vw, -30vh) scale(.8) rotate(-4deg); opacity: 0; }
}
@keyframes pop {
  0% { transform: scale(.6); }
  100% { transform: scale(1); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

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

@media (min-width: 600px) {
  body { font-size: 18px; }
  .top { padding-top: 14px; }
  .brand { font-size: 1.15rem; }
  .squares button { width: 52px; height: 52px; }
}
