/* Word Forge: Caveman Circus "Paper and sun" look. Cream paper, black outlines, white stones around an ember centre. */
.wf-root {
  --wf-ink: #1A1814;
  --wf-cream: #F3EBD8;
  --wf-paper: #FAF8F3;
  --wf-white: #FFFFFF;
  --wf-ember: #E2531B;
  --wf-ember-l: #F6B48F;
  --wf-yellow: #F5E04A;
  --wf-muted: #5C554B;
  --wf-track: #D9CDB2;
  position: relative;
  max-width: 520px;
  margin: 0 auto 24px;
  background: var(--wf-cream);
  color: var(--wf-ink);
  font-family: Rubik, system-ui, -apple-system, "Segoe UI", sans-serif;
  border: 1px solid var(--wf-ink);
  box-shadow: 4px 4px 0 var(--wf-ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1.35;
  box-sizing: border-box;
}
.wf-root *, .wf-root *::before, .wf-root *::after { box-sizing: border-box; }
.wf-root button { font-family: inherit; cursor: pointer; margin: 0; }

/* ---------- One-strip header: title and buttons on the left, the caveman scene on the right ---------- */
.wf-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 0 14px;
  background: var(--wf-cream);
  border-bottom: 1px solid var(--wf-ink);
  overflow: hidden;
}
.wf-strip-artwrap { position: absolute; top: 0; right: 0; bottom: 0; display: block; pointer-events: none; }
.wf-strip-art { display: block; height: 100%; width: auto; }
.wf-brand, .wf-tools { position: relative; z-index: 1; }
.wf-logo { font-weight: 800; font-size: 20px; line-height: 1.1; letter-spacing: 0.01em; white-space: nowrap; }
.wf-logo span { color: var(--wf-ember); }
.wf-sub { font-size: 12px; color: var(--wf-muted); white-space: nowrap; }
.wf-tools { display: flex; gap: 5px; }
.wf-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--wf-white); color: var(--wf-ink);
  border: 1px solid var(--wf-ink); border-radius: 0;
}
.wf-icon svg { width: 16px; height: 16px; }
.wf-root button:focus-visible, .wf-cell:focus-visible { outline: 3px solid var(--wf-ember); outline-offset: 2px; }

/* ---------- 5 minute clock ---------- */
.wf-clock { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px; background: var(--wf-white); border: 1px solid var(--wf-ink); font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.wf-clock svg { width: 15px; height: 15px; }
.wf-clock-idle { color: var(--wf-muted); }
.wf-clock-low { background: var(--wf-yellow); animation: wf-tick 1s steps(1) infinite; }
.wf-clock-done { background: var(--wf-ink); color: var(--wf-white); }
@keyframes wf-tick { 50% { background: #FFF6B8; } }
.wf-is-done .wf-hive { opacity: .45; }
.wf-is-done .wf-cell { cursor: default; }
.wf-is-done .wf-actions .wf-btn { opacity: .5; }
.wf-entry-done { font-size: 22px; letter-spacing: .02em; color: var(--wf-ember); }
.wf-yday .wf-miss { color: var(--wf-muted); }

/* Admin preview strip */
.wf-preview { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px; background: var(--wf-yellow); border-bottom: 1px solid var(--wf-ink); font-size: 13px; font-weight: 800; }
.wf-preview-reset { padding: 3px 10px; background: var(--wf-white); color: var(--wf-ink); border: 1px solid var(--wf-ink); font-size: 12px; font-weight: 700; }

/* ---------- Rank bar ---------- */
.wf-status { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.wf-status-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 2px 0; background: transparent; border: 0; color: inherit; text-align: left;
}
.wf-trophy { flex: none; }
.wf-rank { font-weight: 800; font-size: 15px; color: var(--wf-ember); min-width: 78px; white-space: nowrap; }
.wf-track { flex: 1; position: relative; height: 22px; display: flex; align-items: center; }
.wf-track-line, .wf-track-fill { position: absolute; left: 5px; right: 5px; top: 50%; height: 2px; margin-top: -1px; background: var(--wf-track); }
.wf-track-fill { right: auto; background: var(--wf-ember); max-width: calc(100% - 10px); transition: width .4s ease; }
.wf-dots { position: relative; display: flex; justify-content: space-between; width: 100%; align-items: center; }
.wf-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--wf-track); border: 1px solid var(--wf-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: var(--wf-white); transition: all .25s ease;
}
.wf-dot.wf-on { background: var(--wf-ember); }
.wf-dot.wf-here { width: auto; min-width: 26px; height: 26px; padding: 0 4px; border-radius: 13px; font-size: 11px; box-shadow: 2px 2px 0 var(--wf-ink); }

/* ---------- Found words ---------- */
.wf-found { margin: 0 14px; background: var(--wf-white); border: 1px solid var(--wf-ink); position: relative; z-index: 6; }
.wf-found-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; background: transparent; border: 0; color: inherit; font-size: 14px; text-align: left;
}
.wf-found-peek { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.wf-found-peek .wf-w { margin-right: 8px; }
.wf-found-empty { color: var(--wf-muted); }
.wf-w-pangram { color: var(--wf-ember); font-weight: 800; }
.wf-found-count { flex: none; font-weight: 700; }
.wf-found-count::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-3px) rotate(45deg); transition: transform .2s; }
.wf-open .wf-found-count::after { transform: translateY(1px) rotate(-135deg); }
.wf-found-list {
  display: none; position: absolute; left: -1px; right: -1px; top: 100%; z-index: 5;
  padding: 4px 12px 12px; background: var(--wf-white); border: 1px solid var(--wf-ink); box-shadow: 4px 4px 0 var(--wf-ink);
  max-height: 330px; overflow: auto;
}
.wf-open .wf-found-list { display: block; }
.wf-open .wf-found-peek { visibility: hidden; }
.wf-found-head { font-size: 13px; color: var(--wf-muted); margin: 6px 0 8px; }
.wf-found-cols { list-style: none; margin: 0; padding: 0; columns: 3 110px; column-gap: 14px; font-size: 14px; }
.wf-found-cols li { padding: 4px 0; border-bottom: 1px solid #E7DFCC; break-inside: avoid; }

/* ---------- Play area ---------- */
.wf-play { position: relative; padding: 0 14px 16px; }
.wf-entry {
  text-align: center; font-weight: 800; font-size: 32px; letter-spacing: 0.06em;
  min-height: 46px; margin: 16px 0 2px; white-space: nowrap; overflow: hidden;
}
.wf-entry.wf-long { font-size: 24px; }
.wf-ch-center { color: var(--wf-ember); }
.wf-ch-bad { color: #B4AC9C; }
.wf-caret { display: inline-block; width: 2px; height: 30px; background: var(--wf-ember); vertical-align: -4px; margin-left: 2px; animation: wf-blink 1s steps(2) infinite; }
@keyframes wf-blink { 50% { opacity: 0; } }
.wf-shake { animation: wf-shake .4s ease; }
@keyframes wf-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }

.wf-hive { display: block; width: 100%; max-width: 330px; margin: 0 auto; touch-action: manipulation; transition: opacity .16s; }
.wf-hive.wf-shuffling { opacity: 0; }
.wf-cell { cursor: pointer; outline: none; transition: transform .1s ease; }
.wf-cell-shadow { fill: var(--wf-ink); }
.wf-cell-face { fill: var(--wf-white); stroke: var(--wf-ink); stroke-width: 2.4; stroke-linejoin: round; transition: fill .12s; }
.wf-cell-letter { font-family: Rubik, system-ui, sans-serif; font-weight: 800; font-size: 34px; fill: var(--wf-ink); pointer-events: none; }
.wf-cell-center .wf-cell-face { fill: var(--wf-ember); stroke-width: 2.6; }
.wf-cell-center .wf-cell-letter { font-size: 40px; font-weight: 900; fill: var(--wf-white); }
@media (hover: hover) {
  .wf-cell:hover .wf-cell-face { fill: #FFF6D6; }
  .wf-cell-center:hover .wf-cell-face { fill: #EE6230; }
  .wf-icon:hover { background: var(--wf-yellow); }
}
.wf-cell.wf-pressed { transform: translate(2px, 2px) scale(0.94); }

.wf-actions { display: flex; gap: 10px; justify-content: center; padding-top: 10px; }
.wf-btn {
  flex: 1; max-width: 160px; height: 46px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--wf-white); color: var(--wf-ink);
  border: 1px solid var(--wf-ink); border-radius: 0; box-shadow: 3px 3px 0 var(--wf-ink);
  font-weight: 700; font-size: 15px;
  transition: transform .08s, box-shadow .08s;
}
.wf-btn svg { width: 20px; height: 20px; }
.wf-btn-sq { flex: none; width: 46px; padding: 0; }
.wf-btn-go { background: var(--wf-yellow); font-weight: 800; }
.wf-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--wf-ink); }

.wf-toast {
  position: absolute; left: 50%; top: 4px; transform: translate(-50%, -6px);
  padding: 6px 12px; background: var(--wf-ink); color: var(--wf-white);
  font-weight: 800; font-size: 14px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s, transform .15s; z-index: 4;
}
.wf-toast.wf-show { opacity: 1; transform: translate(-50%, 0); }
.wf-toast-pangram { background: var(--wf-ember); border: 1px solid var(--wf-ink); box-shadow: 2px 2px 0 var(--wf-ink); }
.wf-toast-rank { background: var(--wf-yellow); color: var(--wf-ink); border: 1px solid var(--wf-ink); box-shadow: 2px 2px 0 var(--wf-ink); }

/* ---------- Dialogs ---------- */
.wf-modal {
  position: fixed; inset: 0; z-index: 100000; display: none;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(26, 24, 20, 0.45);
}
.wf-modal.wf-show { display: flex; }
.wf-dialog {
  width: 100%; max-width: 440px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--wf-cream); color: var(--wf-ink);
  border: 1px solid var(--wf-ink); box-shadow: 6px 6px 0 var(--wf-ink);
  font-family: Rubik, system-ui, sans-serif; user-select: text; -webkit-user-select: text;
  animation: wf-pop .18s ease;
}
@keyframes wf-pop { from { transform: translateY(10px); opacity: 0; } }
.wf-dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--wf-white); border-bottom: 1px solid var(--wf-ink); }
.wf-dialog-title { font-weight: 800; font-size: 19px; }
.wf-close { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--wf-white); color: var(--wf-ink); border: 1px solid var(--wf-ink); }
.wf-close svg { width: 16px; height: 16px; }
.wf-dialog-body { padding: 14px 16px 18px; overflow: auto; font-size: 15px; }
.wf-dialog-body p { margin: 0 0 10px; }
.wf-lead { font-weight: 600; }
.wf-muted { color: var(--wf-muted); font-size: 14px; }
.wf-hl { color: var(--wf-ember); }
.wf-rules { margin: 0 0 12px; padding-left: 20px; }
.wf-rules li { margin: 4px 0; }
.wf-help-h { font-weight: 800; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--wf-ember); margin: 16px 0 8px; }
.wf-cta {
  display: block; width: 100%; height: 46px; margin-top: 14px;
  background: var(--wf-yellow); color: var(--wf-ink); border: 1px solid var(--wf-ink); box-shadow: 3px 3px 0 var(--wf-ink);
  font-weight: 800; font-size: 16px;
}
.wf-cta:disabled { opacity: .5; cursor: default; }
.wf-cta-sm { width: auto; height: 42px; margin: 0; padding: 0 16px; font-size: 15px; flex: none; }

/* Hints */
.wf-grid-wrap { overflow-x: auto; border: 1px solid var(--wf-ink); background: var(--wf-white); }
.wf-grid { border-collapse: collapse; width: 100%; font-size: 14px; text-align: center; }
.wf-grid th, .wf-grid td { padding: 6px 4px; border-bottom: 1px solid #E7DFCC; }
.wf-grid th { font-weight: 800; }
.wf-grid tr:first-child th { background: var(--wf-cream); border-bottom: 1px solid var(--wf-ink); }
.wf-grid .wf-zero { color: #C4BCAA; }
.wf-grid .wf-sum { font-weight: 800; background: #FBF6EA; }
.wf-grid .wf-tot th, .wf-grid .wf-tot td { border-top: 1px solid var(--wf-ink); border-bottom: 0; }
.wf-two { display: flex; flex-wrap: wrap; gap: 6px; }
.wf-two-item { padding: 4px 8px; background: var(--wf-white); border: 1px solid var(--wf-ink); font-weight: 700; font-size: 13px; }

/* Rank */
.wf-badge { display: flex; align-items: center; gap: 14px; }
.wf-badge-num {
  flex: none; min-width: 64px; height: 64px; padding: 0 8px; display: flex; align-items: center; justify-content: center;
  background: var(--wf-ember); color: var(--wf-white); font-weight: 900; font-size: 28px;
  border: 1px solid var(--wf-ink); box-shadow: 3px 3px 0 var(--wf-ink);
}
.wf-badge-rank { font-weight: 800; font-size: 22px; line-height: 1.15; }
.wf-ladder { list-style: none; margin: 16px 0 0; padding: 0; border: 1px solid var(--wf-ink); background: var(--wf-white); }
.wf-ladder li { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid #E7DFCC; font-size: 14px; }
.wf-ladder li:last-child { border-bottom: 0; }
.wf-ladder-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--wf-ink); background: var(--wf-track); flex: none; }
.wf-ladder-name { flex: 1; }
.wf-ladder-pts { font-weight: 700; color: var(--wf-muted); }
.wf-ladder .wf-done .wf-ladder-dot { background: var(--wf-ember); }
.wf-ladder .wf-cur { background: var(--wf-yellow); font-weight: 800; }
.wf-ladder .wf-cur .wf-ladder-dot { background: var(--wf-ember); width: 14px; height: 14px; }
.wf-ladder .wf-cur .wf-ladder-pts { color: var(--wf-ink); }

/* Leaderboard */
.wf-lb-form { padding: 12px; background: var(--wf-white); border: 1px solid var(--wf-ink); }
.wf-lb-note { font-size: 14px; margin-bottom: 8px; }
.wf-lb-row { display: flex; gap: 8px; }
.wf-root .wf-lb-input, .wf-dialog .wf-lb-input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px; margin: 0;
  font-family: Rubik, system-ui, sans-serif; font-weight: 800; font-size: 18px; letter-spacing: .12em; text-transform: uppercase;
  background: var(--wf-cream); color: var(--wf-ink); border: 1px solid var(--wf-ink); border-radius: 0; box-shadow: none;
}
.wf-dialog .wf-lb-input:focus { outline: none; border-color: var(--wf-ember); box-shadow: 0 0 0 2px var(--wf-ember-l); }
.wf-lb-msg { font-size: 14px; font-weight: 700; min-height: 0; margin-top: 6px; }
.wf-lb-msg:empty { display: none; }
.wf-lb-box { margin-top: 10px; }
.wf-lb-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--wf-ink); background: var(--wf-white); }
.wf-lb-list li { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid #E7DFCC; font-size: 14px; }
.wf-lb-list li:last-child { border-bottom: 0; }
.wf-lb-rank { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--wf-ink); font-weight: 800; font-size: 12px; flex: none; }
.wf-lb-list li:first-child .wf-lb-rank { background: var(--wf-yellow); }
.wf-lb-init { font-weight: 800; letter-spacing: .08em; flex: 1; }
.wf-lb-words { color: var(--wf-muted); font-size: 13px; }
.wf-lb-pts { font-weight: 800; min-width: 34px; text-align: right; }
.wf-lb-mine { background: var(--wf-ember); color: var(--wf-white); }
.wf-lb-mine .wf-lb-words { color: #FFE3D4; }
.wf-lb-mine .wf-lb-rank { border-color: var(--wf-white); }
.wf-lb-empty { padding: 12px; font-size: 14px; color: var(--wf-muted); border: 1px solid var(--wf-ink); background: var(--wf-white); }

/* Yesterday */
.wf-yday { margin-top: 16px; border: 1px solid var(--wf-ink); background: var(--wf-white); }
.wf-yday summary { padding: 10px 12px; font-weight: 800; cursor: pointer; }
.wf-yday[open] summary { border-bottom: 1px solid var(--wf-ink); }
.wf-yday-letters { padding: 10px 12px 2px; font-weight: 800; letter-spacing: .14em; }
.wf-yday .wf-found-cols { padding: 4px 12px 12px; }
.wf-yday .wf-got::after { content: " \2713"; color: var(--wf-ember); font-weight: 800; }
.wf-next { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--wf-ink); }
.wf-next-clock { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }

@media (min-width: 768px) {
  .wf-head { min-height: 72px; padding: 0 18px; }
  .wf-logo { font-size: 24px; }
  .wf-icon { width: 36px; height: 36px; }
  .wf-status { padding: 12px 18px; }
  .wf-found { margin: 0 18px; }
  .wf-play { padding: 0 18px 20px; }
}
/* ---------- Wide screens: two columns, words on the right, named rank bar on top ---------- */
.wf-wrap { container-type: inline-size; }
@container (min-width: 800px) {
  .wf-root {
    max-width: 1040px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "head head" "preview preview" "status status" "play found";
    grid-template-rows: auto auto auto 1fr;
  }
  .wf-head { grid-area: head; min-height: 80px; padding: 0 24px; }
  .wf-preview { grid-area: preview; }
  .wf-logo { font-size: 30px; }
  .wf-sub { font-size: 14px; }
  .wf-head .wf-icon { width: 40px; height: 40px; }
  .wf-head .wf-icon svg { width: 19px; height: 19px; }
  .wf-strip-artwrap { right: 0; }

  .wf-status { grid-area: status; padding: 14px 24px 38px; border-bottom: 1px solid var(--wf-ink); background: #FBF6EA; gap: 14px; }
  .wf-status-main { padding: 0 44px 0 14px; }
  .wf-rank { display: none; }
  .wf-dot { position: relative; width: 13px; height: 13px; }
  .wf-dot.wf-here { min-width: 32px; height: 32px; border-radius: 16px; font-size: 13px; }
  .wf-dot::after { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--wf-muted); }
  .wf-dot.wf-on:not(.wf-here)::after { color: var(--wf-ink); }
  .wf-dot.wf-here::after { color: var(--wf-ember); font-weight: 800; font-size: 13px; }
  .wf-dot:nth-child(1)::after { content: "Cold"; }
  .wf-dot:nth-child(2)::after { content: "Warm"; }
  .wf-dot:nth-child(3)::after { content: "Glowing"; }
  .wf-dot:nth-child(4)::after { content: "Red-hot"; }
  .wf-dot:nth-child(5)::after { content: "White-hot"; }
  .wf-dot:nth-child(6)::after { content: "Forged"; }
  .wf-dot:nth-child(7)::after { content: "Master Smith"; }
  .wf-clock { height: 40px; padding: 0 12px; font-size: 18px; }
  .wf-clock svg { width: 18px; height: 18px; }
  .wf-trophy { width: 40px; height: 40px; }

  .wf-play { grid-area: play; padding: 0 28px 24px; align-self: start; }
  .wf-entry { font-size: 40px; min-height: 56px; margin: 14px 0 0; }
  .wf-caret { height: 40px; }
  .wf-hive { max-width: 400px; }
  .wf-actions { gap: 14px; padding-top: 12px; }
  .wf-btn { height: 56px; max-width: 180px; font-size: 17px; }
  .wf-btn-sq { width: 56px; }

  .wf-found { grid-area: found; margin: 0; border: 0; border-left: 1px solid var(--wf-ink); display: flex; flex-direction: column; z-index: auto; }
  .wf-found-bar { display: none; }
  .wf-found-list { display: block; position: static; border: 0; box-shadow: none; max-height: 520px; padding: 20px 22px; flex: 1; }
  .wf-found-head { font-size: 15px; font-weight: 800; color: var(--wf-ink); margin: 0 0 12px; }
  .wf-found-cols { columns: 2; font-size: 16px; }
  .wf-found-cols li { padding: 6px 0; }
}

@media (max-width: 440px) {
  .wf-head { gap: 8px; padding: 0 12px; }
  .wf-logo { font-size: 18px; }
  .wf-head .wf-icon { width: 30px; height: 30px; }
  .wf-strip-artwrap { right: -8px; }
}
@media (max-width: 360px) {
  .wf-logo { font-size: 16px; }
  .wf-sub { font-size: 11px; }
  .wf-strip-artwrap { right: -22px; }
  .wf-rank { min-width: 64px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .wf-root *, .wf-dialog { animation: none !important; transition: none !important; }
}

/* Keep theme list styles out of the game. */
.wf-root .wf-found-cols, .wf-root .wf-ladder, .wf-root .wf-lb-list { padding-left: 0; margin-left: 0; list-style: none; }
.wf-root .wf-found-cols li, .wf-root .wf-ladder li, .wf-root .wf-lb-list li { margin-left: 0; }
.wf-root .wf-found-cols li::before, .wf-root .wf-ladder li::before, .wf-root .wf-lb-list li::before { content: none; }
