/* ============================================================
   Stinky Pinky — editorial "daily paper puzzle" design
   Type: Fraunces (display serif) + Inter (UI)
   Ground: warm paper / ink. One accent: raspberry.
   Geometry: hard 2px rules, offset print shadows, no blur.
   ============================================================ */
:root {
  --paper: #faf6ef;
  --paper-raised: #fffdf8;
  --ink: #21201c;
  --ink-soft: #4f4c44;
  --muted: #6b665c;         /* ≥4.5:1 on every light surface (WCAG AA) */
  --rule: #21201c;
  --accent: #a93f55;        /* raspberry */
  --accent-ink: #fffdf8;
  --accent-wash: #f6e6e9;
  --good: #3d6b40;
  --good-wash: #e7efe4;
  --mid: #8a5d09;           /* AA ≥4.5:1 on raised, paper, and mid-wash */
  --mid-wash: #f7ecd4;
  --bad: #a53c2a;
  --bad-wash: #f6e3de;
  --shadow: 4px 4px 0 rgba(33, 32, 28, .9);
  --shadow-sm: 3px 3px 0 rgba(33, 32, 28, .9);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1a17;
    --paper-raised: #242320;
    --ink: #ece7db;
    --ink-soft: #c9c3b4;
    --muted: #9c9789;       /* ≥4.5:1 on every dark surface (WCAG AA) */
    --rule: #ece7db;
    --accent: #dc7389;      /* was #d76a81 — failed AA on accent-wash */
    --accent-ink: #1b1a17;
    --accent-wash: #38262b;
    --good: #8fbc8a;
    --good-wash: #24301f;
    --mid: #d9a743;
    --mid-wash: #332a14;
    --bad: #d97a63;
    --bad-wash: #33201a;
    --shadow: 4px 4px 0 rgba(0, 0, 0, .55);
    --shadow-sm: 3px 3px 0 rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:is(button, input, a):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  min-height: 100dvh;
}

#confetti {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 50;
}

.wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; min-height: 100dvh;
}

/* ---------- masthead ---------- */
.top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 2px 12px;
  border-bottom: 2px solid var(--rule);
  margin-bottom: 20px;
}
.logo {
  display: flex; align-items: center; gap: .38em;
  font-family: var(--serif);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(1.6rem, 6.5vw, 2.1rem);
  letter-spacing: -.01em;
  margin: 0;
  line-height: 1.1;
}
.logo em { font-style: italic; color: var(--accent); }
.logo-skunk {
  font-style: normal;
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.35em; height: 1.35em;
  border-radius: 50%;
  background: #f6e6e9;            /* fixed cream coin: keeps the dark emoji visible on the dark theme */
  border: 2px solid var(--rule);  /* ink ring: separates the coin from light paper too */
  transform: scaleX(-1);
  font-size: .72em;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--rule);
  background: var(--paper-raised); color: var(--ink);
  font-family: var(--serif); font-size: 1.05rem; font-weight: 700;
  cursor: pointer;
  align-self: center;
  transition: transform .1s ease, box-shadow .1s ease;
  box-shadow: var(--shadow-sm);
}
.icon-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 rgba(0,0,0,0); }

/* ---------- puzzle card ---------- */
.card {
  background: var(--paper-raised);
  border: 2px solid var(--rule);
  box-shadow: var(--shadow);
  padding: 20px 20px 22px;
}
.puzzle-head { margin: 0 0 14px; }
.puzzle-head-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 2px;
}
.puzzle-eyebrow {
  margin: 0;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
/* Difficulty — labeled information chip (no border/shadow/press: not a button) */
.diff-chip {
  display: inline-flex; flex-direction: column; align-items: flex-end; gap: 1px;
  padding: 4px 10px;
  animation: chip-pop .5s cubic-bezier(.2, 1.3, .4, 1) both .15s;
}
.diff-chip .dc-label {
  font-size: .58rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
}
.diff-chip .dc-value {
  font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.diff-chip.diff-1 { background: var(--good-wash); } .diff-chip.diff-1 .dc-value { color: var(--good); }
.diff-chip.diff-2 { background: var(--mid-wash); }  .diff-chip.diff-2 .dc-value { color: var(--mid); }
.diff-chip.diff-3 { background: var(--bad-wash); }  .diff-chip.diff-3 .dc-value { color: var(--bad); }
@keyframes chip-pop {
  0% { transform: scale(.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.puzzle-left {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.puzzle-date {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.15rem, 4.5vw, 1.35rem);
  letter-spacing: -.01em;
}

.type-slot { min-height: 30px; }
/* Information tag — deliberately no border/shadow/press so it never reads as a button */
.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: .7rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-wash);
  padding: 6px 10px;
}
.reveal-btn {
  font-family: var(--sans);
  font-size: .74rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft);
  background: transparent;
  border: 2px dashed var(--muted);
  padding: 6px 14px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
}
.reveal-btn:hover { color: var(--accent); border-color: var(--accent); }
.hint-confirm {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  border: 2px dashed var(--accent);
  padding: 8px 12px;
  animation: slide-in .18s ease both;
}
.hint-confirm .hc-text { font-size: .84rem; font-weight: 600; color: var(--ink-soft); }
.hc-yes, .hc-no {
  font-family: var(--sans);
  font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 12px;
  cursor: pointer;
  border: 2px solid var(--rule);
}
.hc-yes { background: var(--accent); color: var(--accent-ink); }
.hc-no  { background: transparent; color: var(--ink-soft); }
.puzzle-num { }
.form-explain {
  color: var(--muted); font-size: .82rem;
  margin: 8px 2px 0;
}

.hint {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.35rem, 5.4vw, 1.65rem);
  line-height: 1.4;
  margin: 20px 2px 24px;
  text-wrap: balance;
}
.hint::before {
  content: "";
  display: block;
  width: 44px; height: 3px;
  background: var(--accent);
  margin-bottom: 14px;
}

/* ---------- input ---------- */
.input-row { display: flex; gap: 0; }
#guessInput {
  flex: 1; min-width: 0;
  font-family: var(--sans);
  font-size: 1.05rem;            /* ≥16px: no iOS zoom */
  padding: 13px 14px;
  border: 2px solid var(--rule);
  border-right: none;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: background .12s ease;
}
#guessInput::placeholder { color: var(--muted); font-style: italic; }
#guessInput:focus { background: var(--paper-raised); box-shadow: inset 0 -3px 0 var(--accent); }
.go-btn {
  border: 2px solid var(--rule); border-radius: 0;
  padding: 13px 22px;
  font-family: var(--sans);
  font-size: .85rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
  box-shadow: var(--shadow-sm);
  touch-action: manipulation;
}
.go-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 rgba(0,0,0,0); }
.go-btn:disabled {
  background: transparent;
  color: var(--muted);
  border-color: var(--muted);
  box-shadow: none;
  cursor: default;
}
.go-btn:disabled:active { transform: none; }

/* ---------- feedback ---------- */
.feedback {
  min-height: 1.5em;
  margin: 14px 2px 0;
  font-weight: 600;
  font-size: .95rem;
}
.feedback.tier-nudge    { color: var(--ink-soft); font-weight: 500; }
.feedback.tier-none     { color: var(--bad); }
.feedback.tier-one      { color: var(--mid); }
.feedback.tier-reversed { color: var(--good); }
.feedback.tier-perfect  { color: var(--good); font-size: 1.05rem; }

/* ---------- solved panel ---------- */
.solved-panel {
  text-align: center; margin-top: 20px; padding-top: 18px;
  border-top: 2px solid var(--rule);
}
.solved-label {
  margin: 0;
  font-size: .78rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
}
.solved-panel.win-perfect .solved-label { color: var(--good); }
.solved-panel.win-reversed .solved-label { color: var(--mid); }
.answer-reveal {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(1.9rem, 8.5vw, 2.6rem);
  line-height: 1.15;
  margin: 10px 0 2px;
  color: var(--accent);
  animation: rise-in .55s cubic-bezier(.2, .9, .25, 1) both;
}
.solved-stats { color: var(--muted); margin: 4px 0 16px; font-size: .9rem; }

.share-row { margin-bottom: 18px; }
.share-btn {
  width: 100%;
  padding: 15px 22px;
  font-size: .92rem;
  background: var(--accent); color: var(--accent-ink);
  animation: beckon 2.6s ease-in-out 1.2s 3; /* three gentle pulses after the win, then rests */
}
.share-sub { display: block; margin-top: 8px; font-size: .74rem; color: var(--muted); }
.back-btn { display: inline-block; margin-bottom: 12px; }
.share-note {
  display: block; margin-top: 8px;
  font-size: .8rem; color: var(--good); font-weight: 600;
  overflow-wrap: anywhere;
}

.countdown-box {
  display: inline-flex; flex-direction: column; gap: 1px;
  border: 2px solid var(--rule);
  background: var(--paper);
  padding: 10px 26px 12px;
}
.countdown-label {
  font-size: .68rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .16em; font-weight: 600;
}
.countdown {
  font-family: var(--serif);
  font-size: 1.65rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ---------- shared-result banner ---------- */
.shared-banner[hidden] { display: none; }
.shared-banner {
  border: 2px solid var(--rule);
  background: var(--accent-wash);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: .9rem;
  display: flex; flex-direction: column; gap: 2px;
}
.shared-banner .sb-title { font-weight: 700; }
.shared-banner .sb-trail { letter-spacing: .1em; }
.shared-banner .sb-cta { color: var(--accent); font-weight: 600; font-style: italic; font-family: var(--serif); }

/* ---------- history ---------- */
.history { margin-top: 18px; display: flex; flex-direction: column; gap: 0; }
.guess-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper-raised);
  border: 2px solid var(--rule);
  border-top: none;
  padding: 9px 14px;
  font-size: .95rem;
  animation: slide-in .22s ease both;
}
.guess-chip:first-child { border-top: 2px solid var(--rule); }
.guess-chip .g-icon { font-size: .95rem; }
.guess-chip .g-text { flex: 1; overflow-wrap: anywhere; font-weight: 500; }
.guess-chip .g-note {
  color: var(--muted); font-size: .7rem; white-space: nowrap;
  letter-spacing: .03em; font-weight: 600;
}
.guess-chip.t-none     { box-shadow: inset 4px 0 0 var(--bad); }
.guess-chip.t-one      { box-shadow: inset 4px 0 0 var(--mid);  background: var(--mid-wash); }
.guess-chip.t-reversed { box-shadow: inset 4px 0 0 var(--good); }
.guess-chip.t-perfect  { box-shadow: inset 4px 0 0 var(--good); background: var(--good-wash); }
/* the winning guess is a trophy, not a log line */
.guess-chip.t-perfect .g-text, .guess-chip.t-reversed .g-text {
  font-family: var(--serif); font-style: italic; font-weight: 800;
  font-size: 1.05rem; color: var(--good);
}
.guess-chip.t-perfect .g-note, .guess-chip.t-reversed .g-note {
  border: 2px solid var(--good); color: var(--good);
  padding: 2px 8px;
  font-weight: 800; font-size: .66rem;
  letter-spacing: .1em; text-transform: uppercase;
  transform: rotate(-4deg);
  animation: stamp-in .45s cubic-bezier(.2, 1.6, .4, 1) both .1s;
}
@keyframes stamp-in {
  0% { transform: rotate(-14deg) scale(1.8); opacity: 0; }
  100% { transform: rotate(-4deg) scale(1); opacity: 1; }
}

/* ---------- footer ---------- */
.foot {
  margin-top: auto; padding: 26px 2px 6px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  color: var(--muted); font-size: .78rem;
  letter-spacing: .02em;
}

/* ---------- archive ---------- */
.link-btn {
  background: none; border: none; padding: 0;
  font-family: var(--sans); font-size: .78rem; font-weight: 600;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.archive { max-height: 80dvh; overflow-y: auto; }
.archive-list { display: flex; flex-direction: column; }
.arch-row {
  /* full button reset: UA button chrome wrecks contrast in both themes */
  display: block; width: 100%;
  background: transparent;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 0;
  text-align: left;
  font-family: var(--sans);
  color: var(--ink);
  padding: 12px 8px;
  cursor: pointer;
  transition: background .12s ease;
}
.arch-row:first-child { border-top: none; }
.arch-row:hover { background: var(--accent-wash); }
.arch-row:hover .arch-you { color: var(--accent); }
.arch-row:active { background: color-mix(in srgb, var(--accent-wash) 60%, var(--paper)); }
.arch-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.arch-num { font-size: .74rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.arch-diff { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.arch-diff.dv-1 { color: var(--good); } .arch-diff.dv-2 { color: var(--mid); } .arch-diff.dv-3 { color: var(--bad); }
.arch-hint { margin: 4px 0 2px; font-family: var(--serif); font-size: .98rem; line-height: 1.4; }
.arch-answer { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 800; color: var(--accent); font-size: 1.1rem; }
.arch-you { margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.arch-you:empty { display: none; }
.arch-note { color: var(--muted); }

/* ---------- help dialog ---------- */
.help {
  border: 2px solid var(--rule);
  border-radius: 0;
  max-width: min(30rem, calc(100vw - 36px));
  padding: 24px 24px 20px;
  background: var(--paper-raised); color: var(--ink);
  box-shadow: var(--shadow);
}
.help::backdrop { background: rgba(20, 18, 14, .55); }
.help h2 {
  font-family: var(--serif); font-style: italic; font-weight: 900;
  margin: 0 0 12px; font-size: 1.5rem;
}
.help p, .help li { font-size: .92rem; }
.help li { margin-bottom: 8px; }
.help .eg { color: var(--muted); }
.help .canon {
  background: var(--accent-wash);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
}
.help form { text-align: right; margin-top: 14px; }

/* ---------- struggle nudges ---------- */
.reveal-btn.pulse {
  border-color: var(--accent);
  color: var(--accent);
  animation: beckon 2s ease-in-out infinite;
}
.icon-btn.pulse { animation: beckon-scale 2.4s ease-in-out infinite; }
@keyframes beckon {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); }
  50% { transform: scale(1.04); box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
}
@keyframes beckon-scale { /* keeps the element's own print shadow intact */
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---------- give-up + lost state ---------- */
.giveup-row { margin: 12px 2px 0; }
.giveup-btn { color: var(--muted); }
.lost-panel { text-align: center; margin-top: 20px; padding-top: 18px; border-top: 2px solid var(--rule); }
.lost-label { color: var(--bad); }
.lost-body { color: var(--ink-soft); font-size: .92rem; margin: 8px 0 4px; }
.lost-panel .link-btn { margin-bottom: 16px; }
.lost-panel .share-row { margin-bottom: 4px; }

/* ---------- stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.stat-cell {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  border: 2px solid var(--rule); padding: 10px 4px 8px;
  background: var(--paper);
}
.stat-val { font-family: var(--serif); font-weight: 800; font-size: 1.5rem; line-height: 1.1; }
.stat-label { font-size: .68rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.histo-title { font-size: .78rem; font-weight: 700; color: var(--ink-soft); margin: 0 0 6px; }
.histo-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.histo-bucket { width: 2.4em; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.histo-bar { flex: 1; display: flex; align-items: center; gap: 6px; }
.histo-bar i { display: block; width: var(--w); min-width: 2px; height: 14px; background: var(--accent); }
.histo-bar b { font-size: .74rem; color: var(--ink-soft); }
.free-peek-note { margin: 6px 2px 0; font-size: .76rem; color: var(--good); font-weight: 600; }
.solved-streak { margin: 0 0 14px; font-size: .88rem; font-weight: 700; color: var(--accent); }
.top-btns { display: flex; gap: 8px; align-self: center; }

/* ---------- offline gate ---------- */
.card.offline > :not(.offline-panel) { display: none; }
.offline-panel { text-align: center; padding: 18px 6px 10px; }
.offline-title {
  font-family: var(--serif); font-style: italic; font-weight: 800;
  font-size: 1.4rem; margin: 0 0 8px;
}
.offline-body { color: var(--ink-soft); font-size: .92rem; margin: 0 0 18px; }

/* ---------- animations ---------- */
@keyframes rise-in {
  0% { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}
@keyframes slide-in {
  from { transform: translateY(-4px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
@keyframes glow-mid {
  0% { box-shadow: var(--shadow), 0 0 0 0 rgba(160, 109, 16, .5); }
  100% { box-shadow: var(--shadow), 0 0 0 18px rgba(160, 109, 16, 0); }
}
@keyframes tada {
  0% { transform: scale(1); }
  15% { transform: scale(.985) rotate(-.5deg); }
  40% { transform: scale(1.015) rotate(.5deg); }
  100% { transform: scale(1) rotate(0); }
}
.card.anim-shake { animation: shake .45s ease; }
.card.anim-glow  { animation: glow-mid .7s ease-out; }
.card.anim-tada  { animation: tada .6s cubic-bezier(.2, .9, .25, 1); }

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

/* small phones */
@media (max-width: 380px) {
  .card { padding: 16px 14px 18px; }
  .go-btn { padding: 13px 14px; }
  .meta { flex-wrap: wrap; }
}
