/* We Asked: warm paper page, dark ink, one tangerine accent, green for a solve. */

:root {
  --bg: #FBF7F0;
  --ink: #1F1B16;
  --muted: #6F665C;
  --accent: #E4572E;
  --accent-ink: #FFFFFF;
  --accent-text: #C2421D;
  --accent-soft: #FBE4DA;
  --card: #FFFFFF;
  --line: #E6DED2;
  --line-strong: #D5CABA;
  --down: #F1E9DC;
  --down-2: #EBE1D2;
  --bar: rgba(228, 87, 46, .10);
  --good: #2E9E5B;
  --good-ink: #FFFFFF;
  --good-soft: #DDF1E4;
  --bad: #B5412B;
  --disabled-bg: #ECE4D8;
  --shadow: 0 1px 0 rgba(60, 40, 20, .04), 0 8px 22px -14px rgba(60, 40, 20, .40);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130F;
    --ink: #F3EEE6;
    --muted: #A99F93;
    --accent: #F0683F;
    --accent-ink: #1B120D;
    --accent-text: #F58A66;
    --accent-soft: #3A2219;
    --card: #221E19;
    --line: #3A332B;
    --line-strong: #4A4137;
    --down: #2A251F;
    --down-2: #25201B;
    --bar: rgba(240, 104, 63, .16);
    --good: #4CC07E;
    --good-ink: #0F1D14;
    --good-soft: #1D3325;
    --bad: #F08A72;
    --disabled-bg: #2E2822;
    --shadow: 0 8px 22px -14px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, p { margin: 0; }

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 0 8px;
}
.brand { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; font-size: 18px; letter-spacing: -.01em; }
.brand svg { width: 22px; height: 22px; }
.meta { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.meta.past { color: var(--accent-text); }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only, .offscreen {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 12px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 750;
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .1s ease, background-color .2s ease, opacity .2s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { background: var(--disabled-bg); color: var(--muted); cursor: default; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line-strong); color: var(--ink); }
.btn.ghost:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; min-height: 54px; font-size: 18px; border-radius: 14px; }
.link { color: var(--accent-text); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- loading and messages ---------- */

.loading, .message {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  padding: 40px 8px 80px;
}
.spinner {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.message-mark { font-size: 40px; }
.message-title { font-size: 22px; font-weight: 800; text-wrap: balance; }

/* ---------- a board ---------- */

.board { display: flex; flex-direction: column; padding-top: 2px; }

.friend-note {
  margin-bottom: 8px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}

.board-head { display: flex; align-items: center; gap: 10px; min-height: 28px; }
.board-title { font-size: 14px; font-weight: 800; color: var(--muted); letter-spacing: .02em; }
.dots { display: inline-flex; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.dot.now { background: var(--accent); border-color: var(--accent); }
.dot.won { background: var(--good); border-color: var(--good); }
.dot.lost { background: var(--muted); border-color: var(--muted); }
.worth {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.worth.won { background: var(--good-soft); color: var(--good); }
.worth.lost { background: var(--disabled-bg); color: var(--muted); }

.draft-note {
  margin-top: 6px;
  padding: 5px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.35;
}

.asked { margin-top: 8px; color: var(--muted); font-size: 15px; font-weight: 600; }
.question {
  margin: 2px 0 12px;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -.01em;
}

/* The blank: one small rounded tile per letter, words a little apart. */
.blank { white-space: nowrap; }
.tiles { display: inline-flex; gap: .3em; vertical-align: -.16em; }
.tiles.small { font-size: .78em; }
.word { display: inline-flex; gap: 2px; }
.tile {
  display: inline-grid;
  place-items: center;
  width: .9em;
  height: 1.1em;
  border-radius: .22em;
  border: 1.5px solid var(--line-strong);
  background: var(--card);
  font-size: 1em;
  line-height: 1;
}
.tile.filled {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-size: .72em;
  width: 1.25em;
  height: 1.53em;
  font-weight: 850;
  animation: pop .34s cubic-bezier(.2, .8, .3, 1.25) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.tile.wide { width: 2.6em; color: var(--muted); font-size: .8em; height: 1.38em; font-weight: 800; }
.question.count-in .tiles .tile:not(.filled) { animation: pop .3s cubic-bezier(.2, .8, .3, 1.25) both; }
@media (prefers-reduced-motion: reduce) { .question.count-in .tiles .tile:not(.filled) { animation: none; } }
.question.solved .tile.filled { background: var(--good); border-color: var(--good); color: var(--good-ink); }

/* ---------- answer cards ---------- */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.card { position: relative; height: 40px; perspective: 700px; transition: height .2s ease; }
.card-inner {
  position: relative;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(180deg);
  transition: transform .45s cubic-bezier(.25, .8, .3, 1.1);
}
.card.up .card-inner { transform: none; }
.face {
  position: absolute;
  inset: 0;
  border-radius: 10px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
}
.front {
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px 0 13px;
  border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--bar) var(--w, 0%), transparent var(--w, 0%)), var(--card);
  box-shadow: var(--shadow);
}
.back {
  transform: rotateX(180deg);
  border: 1px solid var(--line);
  background: repeating-linear-gradient(135deg, var(--down) 0 7px, var(--down-2) 7px 14px);
}
.a-text { font-size: 16px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-n { font-size: 16px; font-weight: 850; font-variant-numeric: tabular-nums; color: var(--accent-text); }
.card.hit .front { border-color: var(--good); box-shadow: 0 0 0 2px var(--good-soft); }

/* Keyboard up on a phone: face-down cards shrink so the question and the guess box both fit above it. */
.typing .card:not(.up) { height: 12px; }
.typing .card:not(.up) .face { border-radius: 6px; }

/* ---------- guessing ---------- */

.play-area { margin-top: 12px; display: flex; flex-direction: column; }
.guess-form { position: relative; display: flex; gap: 8px; }
.guess-input {
  flex: 1;
  min-width: 0;
  height: 50px;
  padding: 0 14px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card);
  font-size: 18px;
  font-weight: 650;
  outline: none;
  transition: border-color .15s ease;
}
.guess-input::placeholder { color: var(--muted); opacity: .75; font-weight: 500; }
.guess-input:focus { border-color: var(--accent); }
.go { min-height: 50px; }
.shake .guess-input { animation: shake .34s ease; }
.glow .guess-input { animation: glow .7s ease-out; border-color: var(--accent); }

/* The verdict floats just above the guess box, so it stays in view with the keyboard up. */
.bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 2;
  max-width: 100%;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity .18s ease, transform .18s ease;
}
.bubble.show { opacity: 1; transform: translate(-50%, 0); }
.bubble.warm { background: var(--accent); color: var(--accent-ink); }

.tried { min-height: 1.45em; margin: 7px 2px 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.tried .warm { color: var(--accent-text); font-weight: 700; }
.skip { margin-top: 6px; width: 100%; font-size: 15px; }
.skip.giveup { color: var(--bad); border-color: var(--bad); }

/* ---------- a board's end ---------- */

.end { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.end-verdict { font-size: 19px; font-weight: 850; }
.end-verdict.won { color: var(--good); }
.extras { color: var(--muted); font-size: 14px; }
.crowd { color: var(--muted); font-size: 14px; font-weight: 600; }
.crowd:empty { display: none; }
.next { margin-top: 8px; width: 100%; min-height: 52px; font-size: 17px; }

/* ---------- first visit ---------- */

.intro { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 0 4px; }
.intro-title { font-size: 40px; font-weight: 850; letter-spacing: -.02em; line-height: 1.1; }
.intro-lead { margin: 8px 0 16px; max-width: 340px; font-size: 17px; text-wrap: balance; }
.example {
  width: 100%;
  max-width: 340px;
  margin: 0 0 16px;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
}
.ex-asked { color: var(--muted); font-size: 13px; font-weight: 600; }
.question.mini { font-size: 17px; margin: 1px 0 9px; }
.cards.mini { gap: 4px; }
.cards.mini .card { height: 28px; }
.cards.mini .face { border-radius: 8px; }
.cards.mini .front { box-shadow: none; padding: 0 10px; background: linear-gradient(90deg, var(--bar) var(--w, 0%), transparent var(--w, 0%)), var(--bg); }
.cards.mini .a-text, .cards.mini .a-n { font-size: 13.5px; }
.ex-guess {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .25s ease, transform .25s ease;
}
.ex-guess.show { opacity: 1; transform: none; }
.ex-chip { padding: 2px 12px; border: 1.5px solid var(--line-strong); border-radius: 8px; background: var(--bg); font-weight: 700; font-size: 15px; }
.ex-tick { color: var(--good); font-weight: 900; }
.ex-caption { margin-top: 8px; color: var(--muted); font-size: 14px; text-align: center; opacity: 0; transition: opacity .3s ease; }
.ex-caption.show { opacity: 1; }
.how { list-style: none; margin: 0 0 18px; padding: 0; max-width: 340px; width: 100%; display: grid; gap: 7px; text-align: left; font-size: 15px; }
.how li { position: relative; padding-left: 20px; }
.how li::before { content: ""; position: absolute; left: 3px; top: .5em; width: 8px; height: 8px; border-radius: 3px; background: var(--accent); }

/* ---------- results ---------- */

.results { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 10px; }
.kicker { color: var(--muted); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.total { margin-top: 4px; font-size: 60px; font-weight: 850; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.total-max { font-size: 26px; color: var(--muted); font-weight: 750; letter-spacing: 0; }
.label { margin-top: 6px; font-size: 22px; font-weight: 800; }
.rows { list-style: none; margin: 16px 0 0; padding: 0; width: 100%; max-width: 360px; display: grid; gap: 6px; }
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  text-align: left;
}
.row-emoji { font-size: 14px; letter-spacing: 1px; white-space: nowrap; }
.row-word { font-weight: 800; font-size: 14px; letter-spacing: .05em; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-pts { min-width: 26px; text-align: right; font-weight: 850; font-variant-numeric: tabular-nums; }
.row-pts.won { color: var(--good); }
.row-pts.lost { color: var(--muted); }
.friend-line {
  margin-top: 12px;
  padding: 8px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 800;
}
.after { width: 100%; max-width: 360px; margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.panel-title { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg-btn {
  min-height: 44px;
  border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: var(--bg);
  font-weight: 750;
  cursor: pointer;
  touch-action: manipulation;
}
.seg-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg-btn:disabled { cursor: default; }
.seg-btn:disabled:not([aria-pressed="true"]) { opacity: .5; }
.thanks { margin-top: 8px; }
.thanks:empty { display: none; }
.survey-slot:empty { display: none; }
.survey-start {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 2px;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
}
.survey-start .arrow { color: var(--accent); font-size: 22px; line-height: 1; }
.survey-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.survey-q { font-size: 17px; font-weight: 750; }
.survey-input {
  height: 48px;
  padding: 0 12px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  font-size: 17px;
  outline: none;
}
.survey-input:focus { border-color: var(--accent); }
.survey-actions { display: flex; justify-content: flex-end; gap: 8px; }
.survey-thanks { font-weight: 750; }
.streak { font-weight: 800; font-size: 17px; }
.midnight { margin-top: 2px; }
.today-link { align-self: center; padding: 6px; }

/* ---------- toast and dialog ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 10;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog {
  width: min(92vw, 400px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
}
dialog::backdrop { background: rgba(20, 15, 10, .45); }
.dialog-body { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.dialog-body h2 { font-size: 18px; }
.copybox { width: 100%; padding: 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg); font-size: 15px; resize: none; }
.noscript { padding: 24px; text-align: center; }

/* ---------- motion ---------- */

.enter { animation: enter .26s ease-out both; }
.fade-in { animation: fade .3s ease-out both; }
.pending { opacity: 0; }
.reveal { animation: enter .3s ease-out both; }

@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop {
  0% { opacity: 0; transform: scale(.4); }
  70% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: none; }
}
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes glow {
  from { box-shadow: 0 0 0 0 var(--accent-soft); }
  40% { box-shadow: 0 0 0 6px var(--accent-soft); }
  to { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .pending { opacity: 1; }
}

/* Small phones: a little tighter. */
@media (max-width: 350px) {
  .question { font-size: 20px; }
  .a-text, .a-n { font-size: 15px; }
  .total { font-size: 52px; }
}
