/* Kid-texto - deliberately large type and high contrast. The youngest players
   are six years old, often on a school Chromebook or a tablet, so tap targets
   are >=44px and nothing depends on hover. */

:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --ink: #16202e;
  --ink-soft: #5b6b80;
  --line: #dde5ef;
  --brand: #1d4ed8;
  --brand-dark: #1739a8;

  --hot: #16a34a;    /* very close */
  --warm: #f59e0b;   /* getting there */
  --cold: #64748b;   /* far away */
  --hint: #7c3aed;   /* revealed by a hint, not guessed */

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 14px rgba(16, 32, 56, .07);
  --tap: 46px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151d; --surface: #19212c; --ink: #eef3fa; --ink-soft: #9fb0c4;
    --line: #2c3745; --brand: #6b93ff; --brand-dark: #4b74e8;
    --hot: #34d399; --warm: #fbbf24; --cold: #94a3b8; --hint: #c4a2ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1rem 5rem;
  background: var(--bg);
  color: var(--ink);
  font: 400 clamp(17px, 1.6vw, 19px)/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main, .topbar, .footer, .win { max-width: 40rem; margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem;
  padding: 1.25rem 0 .75rem;
}
.wordmark {
  margin: 0; font-size: clamp(1.6rem, 5vw, 2.1rem); font-weight: 800;
  letter-spacing: -.02em; line-height: 1;
}
.wordmark .kid { color: var(--brand); }
.wordmark .dash { color: var(--ink-soft); }
.wordmark .texto { color: var(--ink); }

.controls { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-wrap: wrap; }
.control { display: flex; align-items: center; gap: .4rem; }
.control-label { font-size: .85rem; font-weight: 700; color: var(--ink-soft); }

select, .btn {
  font: inherit; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink);
  min-height: var(--tap); padding: 0 .8rem; cursor: pointer;
}
select { font-weight: 700; min-width: 4.2rem; }
select:focus-visible, .btn:focus-visible, input:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px;
}

.btn { font-weight: 700; transition: background-color .12s, border-color .12s; }
.btn-quiet:hover { border-color: var(--brand); }
.btn-go { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-go:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: #b91c1c; }
@media (prefers-color-scheme: dark) { .btn-danger { color: #fca5a5; } }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.puzzle-line {
  margin: .25rem 0 1rem; color: var(--ink-soft);
  font-size: .95rem; font-weight: 600;
}

/* ---------- input ---------- */
.input-wrap { position: relative; display: flex; gap: .5rem; }
#guess {
  flex: 1 1 auto; min-width: 0; min-height: var(--tap);
  padding: 0 .9rem; font: inherit; font-size: 1.15rem; font-weight: 600;
  border: 2px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
#guess:focus { border-color: var(--brand); }
#submit { flex: 0 0 auto; }

.suggestions {
  position: absolute; top: calc(var(--tap) + 4px); left: 0; right: 0; z-index: 20;
  margin: 0; padding: .25rem; list-style: none;
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 15rem; overflow-y: auto;
}
.suggestions li {
  padding: .55rem .7rem; border-radius: 8px; cursor: pointer;
  font-weight: 600; min-height: 40px; display: flex; align-items: center;
}
.suggestions li[aria-selected="true"], .suggestions li:hover {
  background: var(--brand); color: #fff;
}

.feedback { min-height: 1.6em; margin: .6rem 0 0; font-weight: 700; }
.feedback.error { color: #b91c1c; }
.feedback.info { color: var(--ink-soft); }
@media (prefers-color-scheme: dark) { .feedback.error { color: #fca5a5; } }

/* ---------- guess rows ---------- */
.latest { margin-top: 1rem; }
.row.is-latest { outline: 3px solid var(--brand); outline-offset: 2px; }

.board { margin-top: 1rem; }
.guesses { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }

.row {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .9rem; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
/* The bar is a background fill sized by closeness, on a log scale so early
   progress from rank 4000 to rank 400 is visible rather than invisible. */
.row::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--fill, 0%);
  background: var(--tone); opacity: .17; pointer-events: none;
}
.row > * { position: relative; }
.row .word { font-weight: 700; font-size: 1.1rem; flex: 1 1 auto; word-break: break-word; }
.row .rank { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--tone); }
.row .tag {
  font-size: .72rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em; color: var(--hint);
}
.row.is-hot   { --tone: var(--hot); }
.row.is-warm  { --tone: var(--warm); }
.row.is-cold  { --tone: var(--cold); }
.row.is-hint  { --tone: var(--hint); border-style: dashed; }
.row.is-answer { --tone: var(--hot); border-color: var(--hot); border-width: 2px; }

.empty-hint { color: var(--ink-soft); margin: 1.25rem 0; }
.empty-hint[hidden] { display: none; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* ---------- win ---------- */
.win {
  margin-top: 1.5rem; padding: 1.25rem; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--hot); box-shadow: var(--shadow);
}
.win h2 { margin: 0 0 .35rem; font-size: 1.5rem; }
.win p { margin: 0 0 1rem; color: var(--ink-soft); }
.win-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- help ---------- */
.help {
  max-width: 34rem; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; background: var(--surface); color: var(--ink);
  /* The credits are longer than a phone screen, so the dialog scrolls itself
     rather than letting the page clip its top. */
  max-height: min(85vh, 48rem); overflow-y: auto;
}
.help::backdrop { background: rgba(8, 14, 24, .55); }
.help h2 { margin-top: 0; }
.help li { margin-bottom: .6rem; }

.footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  align-items: center;
  padding: 2.5rem 0 1rem; color: var(--ink-soft); font-size: .85rem;
}
.footer a { color: inherit; }
.footer-links { display: flex; align-items: center; gap: 1rem; }

/* A footer control that reads as a link but is a real button for assistive tech. */
.linkbtn {
  font: inherit; color: inherit; background: none; border: 0; padding: .4rem 0;
  text-decoration: underline; cursor: pointer; min-height: auto;
}
.linkbtn:hover { color: var(--brand); }
.linkbtn:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.help section { margin-bottom: 1.5rem; }
.help section:last-of-type { margin-bottom: 1rem; }
.help h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.help .lede { font-weight: 700; color: var(--ink); }
.help ul { margin: .4rem 0; padding-left: 1.2rem; }
.help ul li { margin-bottom: .45rem; }
.help .sources li { margin-bottom: .6rem; }
.help .lic {
  display: inline-block; font-size: .75rem; font-weight: 700;
  padding: .1rem .45rem; border-radius: 6px; white-space: nowrap;
  background: var(--line); color: var(--ink-soft);
}
.help .fineprint { font-size: .85rem; color: var(--ink-soft); }

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