:root {
  --bg: #fbf8f1;
  --surface: #ffffff;
  --ink: #1d1b18;
  --muted: #6f6a61;
  --line: #e4dfd3;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --bar: #e9e4d8;
  --you: #1f6f5c;
  --high: #2e8b57;
  --mid: #d4a017;
  --low: #d9772b;
  --none: #9a958b;
  --error: #b3261e;
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #201e1b;
    --ink: #f1ede4;
    --muted: #a39d92;
    --line: #34312c;
    --accent: #4fb596;
    --accent-ink: #0d1f19;
    --bar: #2d2a26;
    --you: #4fb596;
    --high: #4fb57a;
    --mid: #e0b43a;
    --low: #e88a45;
    --none: #77726a;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.45;
  min-height: 100vh;
}

[hidden] { display: none !important; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.6rem;
  letter-spacing: 0.01em;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

/* Play */

.dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 8px 0 4px;
}
.dots li {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bar);
  transition: background 0.2s, transform 0.2s;
}
.dots li.done { background: var(--accent); }
.dots li.current { background: var(--ink); transform: scale(1.25); }

#play-count { text-align: center; margin: 0; }

.prompt-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34vh;
}

.prompt {
  font-family: var(--serif);
  font-size: clamp(3rem, 14vw, 5rem);
  font-weight: 600;
  margin: 0;
  text-align: center;
  word-break: break-word;
}
.prompt.enter { animation: pop 0.25s ease-out; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

form#answer-form {
  display: flex;
  gap: 8px;
}

input#answer {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.15rem;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
input#answer:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button.primary, #next-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button:disabled { opacity: 0.6; cursor: default; }

.error {
  color: var(--error);
  min-height: 1.4em;
  margin: 8px 0 0;
  font-size: 0.95rem;
}

/* Results */

.score-card {
  text-align: center;
  padding: 20px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.score {
  margin: 0;
  font-family: var(--serif);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
}
.out-of {
  font-size: 1.3rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.status { margin: 10px 0 4px; font-weight: 600; }
.status .tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 6px;
  background: var(--bar);
  color: var(--ink);
}
.status .tag.final { background: var(--accent); color: var(--accent-ink); }

.actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 4px;
}
#share-msg { min-height: 1.3em; margin: 4px 0 12px; }

.word {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.word-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.word-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
}
.pts {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pts.high { color: var(--high); }
.pts.mid { color: var(--mid); }
.pts.low { color: var(--low); }
.pts.none { color: var(--none); }
.said { margin: 0 0 12px; color: var(--muted); }
.said strong { color: var(--ink); }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: 8px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.row .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--bar);
  border-radius: 8px;
  z-index: 0;
  transform-origin: left;
  animation: grow 0.6s ease-out;
}
@keyframes grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .row .fill, .prompt.enter { animation: none; }
}
.row span { position: relative; z-index: 1; }
.row.you { font-weight: 700; }
.row.you .fill { background: color-mix(in srgb, var(--you) 30%, var(--bar)); }
.row.gap { justify-content: center; padding: 0; color: var(--muted); }

.examples-note { margin: 0 0 8px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.chips li {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  color: var(--muted);
}

/* Help dialog */

dialog {
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  max-width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin-top: 0; font-family: var(--serif); }
dialog .example {
  text-align: center;
  font-size: 1.1rem;
  padding: 10px;
  border-radius: 8px;
  background: var(--bg);
}
dialog .example span { font-family: var(--serif); font-weight: 700; }
dialog button { width: 100%; margin-top: 8px; }
