/* Sourceword: dark ink palette, matching the Froobaloo hub theme (#17142A). */
:root {
  --bg: #17142A;
  --surface: #221E3A;
  --line: #3A3560;
  --fg: #F2EFE6;
  --muted: #A29DBE;
  --tile: #FFFBEA;
  --tile-ink: #1E1B2E;
  --accent: #F5B82E;
  --good: #7FD6A8;
  --bad: #FF8A8A;
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 28rem;
  margin: 0 auto;
  padding-block: 1.25rem 2rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.date {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
}

.build {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  flex-wrap: nowrap;
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  white-space: nowrap;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  margin: 1rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.source strong {
  display: block;
  color: var(--accent);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
}

.source strong span {
  transition: opacity 0.15s ease;
}

.source strong span.used {
  opacity: 0.22;
}

/* Goal toggle, beside the title. */
.goal {
  display: inline-flex;
  flex: none;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.goal .seg {
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.goal .seg[aria-pressed="true"] {
  background: var(--surface);
  color: var(--fg);
}

/* The word box: a transparent input over a mirror that paints letters not in the source word red. */
.guess-field {
  grid-column: 1 / -1;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.guess-field:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.guess-field:has(input:disabled) {
  opacity: 0.5;
}

.guess-field input {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: transparent;
  caret-color: var(--fg);
  font-family: inherit;
}

.guess-mirror {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0.6rem 0.8rem;
  font-size: 1.25rem;
  font-family: inherit;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  color: var(--fg);
  text-transform: lowercase;
}

.guess-mirror span.bad {
  color: var(--bad);
}

/* Step tip: one at a time, fixed above the bottom edge. */
.tip {
  margin: 0.75rem 0 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.tip[hidden] {
  display: none;
}

.tip p {
  margin: 0;
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
}

.tip button {
  flex: none;
}

form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin: 0.9rem 0 0.25rem;
}

form input {
  grid-column: 1 / -1;
}

input {
  flex: 1;
  min-width: 0;
  font-size: 1.25rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  text-transform: lowercase;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input:disabled {
  opacity: 0.5;
}

button {
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.6rem 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
}

form button {
  flex: none;
  padding: 0.4rem 0.5rem;
}

button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
}

#message {
  min-height: 1.25rem;
  margin: 0;
  color: var(--good);
  font-size: 0.95rem;
}

#message.bad {
  color: var(--bad);
}

#message p,
#message ul {
  margin: 0;
}

/* Success message: the word on one line, then one bullet per thing it earned. */
.msg-list {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
  text-align: left;
  list-style: disc;
}

.msg-list li + li {
  margin-top: 0.1rem;
}

/* Score: label and number share one size. */
.score {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 700;
}

.score strong {
  color: var(--accent);
  font-size: inherit;
  font-variant-numeric: tabular-nums;
}

.score-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
}

.report-btn {
  margin-left: 0.6rem;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  vertical-align: middle;
}

.report-btn:disabled {
  opacity: 0.6;
}

.toasts {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  animation: toast-in 0.2s ease-out;
}

.toast strong {
  color: var(--accent);
  font-size: 0.95rem;
}

.toast span {
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.ach-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.ach-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.ach-list li span {
  color: var(--muted);
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: 0.35rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.settings-btn:hover {
  color: var(--fg);
}

.settings-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin: 0.75rem 0;
}

.setting .goal .seg[aria-pressed="true"] {
  background: var(--accent);
  color: var(--bg);
}

.setting-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.timer {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.timer:empty {
  display: none;
}

.rank {
  margin: 0;
  color: var(--fg);
  font-size: 1rem;
  font-weight: 700;
}

.rank[hidden] {
  display: none;
}

/* Found heading, with words left to its right. */
.found-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin: 1rem 0 0.5rem;
}

.found-head h2 {
  margin: 0;
}

.countdown {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.countdown[hidden] {
  display: none;
}

.lengths {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.lengths[hidden] {
  display: none;
}

.chips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-width: 0;
}

.chips li {
  background: var(--tile);
  color: var(--tile-ink);
  border-radius: 8px;
  padding: 0.25rem 0.55rem;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* Bonus slots: hollow until earned, then filled orange. */
#bonuses li {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

#bonuses li.filled {
  background: var(--accent);
  color: var(--bg);
}

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
}

.brand-mark {
  width: 20px;
  height: 20px;
}

.btn-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.brand:hover {
  color: var(--fg);
}

.admin-toggle {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
}

/* Mode row, under the source word. */
.mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.6rem;
  margin-top: 0.6rem;
}

.mode-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mode-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* Result card, shown when the day is finished. */
#results {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

#results[hidden] {
  display: none;
}

#results h2 {
  margin-top: 0;
}

.result-score {
  margin: 0.25rem 0 0;
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.result-score span {
  margin-left: 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.result-line {
  margin: 0.25rem 0 0;
  font-weight: 600;
}

/* How to play dialog. */
.howto {
  width: min(26rem, calc(100% - 2rem));
  max-height: 90vh;
  padding: 1.25rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.howto::backdrop {
  background: rgba(10, 8, 20, 0.7);
}

.howto-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.howto-head h2 {
  margin: 0;
}

.howto p {
  margin: 0.5rem 0;
  line-height: 1.5;
}

.howto .muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.tile-letter.used {
  opacity: 0.22;
}

.tile-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.4rem;
  background: var(--tile);
  color: var(--tile-ink);
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
}

.score-table td {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
}

.score-table td + td {
  text-align: right;
  font-weight: 700;
  color: var(--accent);
}

.ex-msg {
  min-height: 1.25rem;
  color: var(--good);
  font-size: 0.95rem;
}

.howto-score strong {
  color: var(--accent);
}

.howto-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
}

.howto-dots {
  display: flex;
  gap: 0.35rem;
}

.howto-dots .dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--line);
}

.howto-dots .dot.on {
  background: var(--accent);
}

/* Admin view: bonus words sit after the core words, in italics. */
#debug-words li.bonus {
  font-style: italic;
}

/* Stats and share. */
#share-box[hidden] {
  display: none;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 0;
}

.stat-grid div {
  background: var(--surface);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

.stat-grid dt {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-grid dd {
  margin: 0.15rem 0 0;
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.share {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--fg);
}

.share-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.6rem 0 0;
}

.muted-note {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Admin test view (#debug). Remove before shipping. */
#debug {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
}

#debug[hidden] {
  display: none;
}

.debug-summary {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#debug-words h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
}

#debug-words ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

#debug-words li {
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

#debug-words li.got {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* Result card at the top of the page, with the share button. */
#results {
  margin: 0.75rem 0 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 14px;
}

.result-kicker {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.result-top {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
}

.share-btn {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
}

#results .share {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

/* Archive list. */
.archive-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  max-height: 60vh;
  overflow: auto;
}

.archive-list li + li {
  border-top: 1px solid var(--line);
}

.archive-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.25rem;
  color: var(--fg);
  text-decoration: none;
}

.archive-row:hover,
.archive-row:focus-visible {
  background: var(--bg);
}

.archive-row .arch-word {
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
}

.archive-row .arch-status {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.next-game {
  display: block;
  margin-top: 0.6rem;
  padding: 0.7rem 1rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
}

.next-game:hover,
.next-game:focus-visible {
  border-color: var(--accent);
}

/* The most recent guess, highlighted. Kept last so it overrides the bonus styling. */
/* Tooltips: the text comes from data-tip. Hover only on real pointers, so taps on touch screens don't leave one stuck on. */
[data-tip] {
  position: relative;
}

[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  text-align: left;
  z-index: 30;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  [data-tip]:hover:not(.tip-off)::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: max-content;
    max-width: 240px;
    padding: 0.4rem 0.6rem;
    background: var(--surface);
    color: var(--fg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
    text-align: left;
    z-index: 30;
    pointer-events: none;
  }
}

[data-tip].tip-end:focus-visible::after {
  left: auto;
  right: 0;
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  [data-tip].tip-end:hover:not(.tip-off)::after {
    left: auto;
    right: 0;
    transform: none;
  }
}

[data-tip].tip-off::after {
  display: none;
}

/* Words left unfound, revealed when the day ends. */
.chips li.missed {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
  font-style: italic;
}

.chips li.latest {
  background: var(--good);
  color: var(--bg);
}

/* End-day dialog title: the big accent heading, like the game title. */
#done-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--accent);
}

/* Daily intro: today's word and targets, shown before the first guess. */
.intro-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intro-word {
  margin: 0.25rem 0 0.5rem;
  color: var(--accent);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.intro-max {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.intro-list {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
  line-height: 1.6;
}
