/* Fonts are self-hosted (latin subsets, licenses alongside in /fonts) so they
   render the same everywhere. Fraunces includes its real italic rather than a
   synthesized slant. */
@font-face {
  font-family: Fraunces;
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url(/fonts/fraunces-latin.woff2) format("woff2");
}

@font-face {
  font-family: Fraunces;
  font-style: italic;
  font-weight: 500 800;
  font-display: swap;
  src: url(/fonts/fraunces-italic-latin.woff2) format("woff2");
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/fonts/inter-latin.woff2) format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/fonts/ibm-plex-mono-500-latin.woff2) format("woff2");
}

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --ink: #1d1a16;
  --muted: #6f675c;
  --line: #ddd3c2;
  --accent: #d9481e;
  --yes: #2f7d4f;
  --yes-bg: #e3f1e7;
  --no: #b3261e;
  --no-bg: #f8e2df;
  --maybe: #8a6d1a;
  --maybe-bg: #f5ecd0;
  --shadow: 0 1px 0 rgba(29, 26, 22, 0.08), 0 8px 24px -16px rgba(29, 26, 22, 0.35);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171512;
    --surface: #211e1a;
    --ink: #f1eadf;
    --muted: #a39887;
    --line: #3a342c;
    --accent: #ff7a4d;
    --yes: #7fd3a0;
    --yes-bg: #1f3a2a;
    --no: #ff9a8f;
    --no-bg: #43231f;
    --maybe: #e9c76a;
    --maybe-bg: #3d3420;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 24px -16px rgba(0, 0, 0, 0.8);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, sans-serif;
}

.shell {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 16px 80px;
}

.masthead {
  text-align: center;
}

h1 {
  font: 800 clamp(2.6rem, 9vw, 3.6rem) / 1 Fraunces, Georgia, serif;
  letter-spacing: -0.03em;
  margin: 0;
}

h1 span {
  color: var(--accent);
  font-style: italic;
  /* The italic d's ascender curl overhangs its advance by ~0.14em, which
     with the -0.03em tracking would run into the upright i that follows.
     The w clears the s on its own; the left margin is set by eye so the
     gaps on both sides of the word look even. */
  margin: 0 0.16em 0 0.1em;
}

.env-tag {
  /* With no offsets, an absolute box sits where it would have been inline,
     right after the y, but takes up no room, so the wordmark doesn't move. */
  position: absolute;
  /* Tucked a little over the y's arm, tilted like a sticker slapped on. */
  margin: 0.05em 0 0 -8px;
  transform: rotate(8deg);
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--surface);
  font: 500 0.7rem / 1.2 IBM Plex Mono, ui-monospace, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.env-tag[hidden] {
  display: none;
}

.meta {
  margin: 12px 0 0;
  font: 500 0.8rem IBM Plex Mono, ui-monospace, monospace;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.board {
  margin: 32px 0 24px;
  text-align: center;
}

.secret {
  display: flex;
  justify-content: center;
  align-items: center;
  /* Full height of the revealed word at its max size, so shrinking long words doesn't shift the page. */
  min-height: calc(48px * 1.1);
}

/* Fixed-width blank while playing, so it doesn't hint at the word's length. */
.blank {
  width: 160px;
  border-bottom: 3px solid var(--line);
  text-align: center;
  font: 800 1.75rem / 1.2 Fraunces, Georgia, serif;
  color: var(--muted);
}

/* Revealed word; app.js sets its font-size so it always fits on one line. */
.answer {
  font: 800 48px / 1.1 Fraunces, Georgia, serif;
  color: var(--accent);
  white-space: nowrap;
  animation: flip 0.45s ease both;
}

.won .answer {
  color: var(--yes);
}

/* Dictionary-style part of speech under the word. */
.pos {
  margin: 6px 0 0;
  font: italic 500 1rem Fraunces, Georgia, serif;
  color: var(--muted);
}

@keyframes flip {
  from {
    transform: rotateX(90deg);
  }
}

.pips {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 4px;
  max-width: 420px;
  margin: 22px auto 8px;
}

.pip {
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  transition: background 0.3s;
}

.pip.used {
  background: var(--line);
}

.remaining {
  margin: 0;
  font: 500 0.85rem IBM Plex Mono, ui-monospace, monospace;
  color: var(--muted);
}

.composer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.mode {
  display: inline-flex;
  background: var(--bg);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 10px;
}

.mode button {
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 0.85rem Inter, sans-serif;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
}

.mode button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.mode button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* A one-row textarea that app.js grows to fit, so long questions wrap instead of scrolling. */
#input {
  flex: 1;
  min-width: 0;
  display: block;
  resize: none;
  overflow: hidden;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.4;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
}

/* Shrink the placeholder with the viewport so it fits on phones. Typed text stays at its
   full size because iOS Safari zooms the page when focusing inputs under 16px. */
#input::placeholder {
  font-size: clamp(13px, calc((100vw - 175px) / 13.6), 1.05rem);
}

#input:focus {
  outline: none;
  border-color: var(--accent);
}

form button {
  /* Matches the textarea's single-row height and stays put as it grows. */
  height: calc(1.05rem * 1.4 + 28px);
  border: 0;
  border-radius: 10px;
  padding: 0 20px;
  background: var(--ink);
  color: var(--bg);
  font: 600 1rem Inter, sans-serif;
  cursor: pointer;
}

form button:disabled {
  opacity: 0.5;
  cursor: progress;
}

.composer.guessing form button {
  background: var(--accent);
  color: #fff;
}

.hint,
.error {
  margin: 8px 2px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.error {
  color: var(--no);
}

.error:empty {
  display: none;
}

.result {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 16px;
  box-shadow: var(--shadow);
}

.result h2 {
  font: 800 1.8rem Fraunces, Georgia, serif;
  margin: 0 0 4px;
}

.result p {
  margin: 0;
  color: var(--muted);
}

.result button {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 18px;
  font: 600 0.9rem Inter, sans-serif;
  cursor: pointer;
}

.log {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.turn {
  display: grid;
  /* Number column just fits "20" in the number font. */
  grid-template-columns: 1.3rem 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.turn .num {
  font: 500 0.8rem IBM Plex Mono, ui-monospace, monospace;
  color: var(--muted);
  text-align: right;
}

.turn .text {
  overflow-wrap: anywhere;
}

.turn .text small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  font: 600 0.8rem Inter, sans-serif;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.yes,
.badge.correct {
  background: var(--yes-bg);
  color: var(--yes);
}

.badge.no,
.badge.incorrect {
  background: var(--no-bg);
  color: var(--no);
}

.badge.unclear,
.badge.not_yes_no {
  background: var(--maybe-bg);
  color: var(--maybe);
}

.badge.reveal {
  animation: pop 0.3s ease both;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}

/* Fades in alongside the answer badge's pop. */
.num.reveal {
  animation: fade 0.3s ease both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.turn.pending .badge {
  background: var(--bg);
  color: var(--muted);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

.credits {
  margin-top: 48px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.credits p {
  margin: 2px 0;
}

.credits a {
  color: inherit;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.credits a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.dev-tools {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.dev-tools[hidden],
.dev-answer[hidden] {
  display: none;
}

.dev-tools button,
.dev-answer {
  border: 1px dashed var(--accent);
  background: var(--surface);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font: 500 0.8rem IBM Plex Mono, ui-monospace, monospace;
  box-shadow: var(--shadow);
}

.dev-tools button {
  cursor: pointer;
}

.dev-answer {
  border-style: solid;
  color: var(--ink);
}

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