:root {
  --bg: #14161d; --panel: #1e2129; --cellborder: #2a2e3a; --cell: #232733;
  --wall: #0c0d12; --tile: #e8c86a; --tile-text: #2a2005; --ghost: #7aa2f7;
  --start: #3fbf7f; --goal: #e05b71; --bonus: #9d7cd8; --text: #e6e6ef;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, "Segoe UI", sans-serif; display: flex; justify-content: center; }
#app { max-width: 720px; width: 100%; padding: 12px; }
header { display: block; }
h1 { font-size: 1.3rem; margin: 8px 0 4px; letter-spacing: 2px; }
#hud {
  display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 8px;
  font-variant-numeric: tabular-nums; font-size: 0.9rem; color: #b8bcc8;
}
#hud span { white-space: nowrap; }
#board { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px;
  background: var(--panel); padding: 6px; border-radius: 10px; user-select: none; }
.cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--cell); border-radius: 4px; font-weight: 700;
  font-size: clamp(10px, 2.6vw, 20px); cursor: pointer; position: relative; }
.cell.wall { background: var(--wall); cursor: default; }
.cell.start { outline: 2px solid var(--start); }
.cell.goal { outline: 2px solid var(--goal); }
.cell.bonus { box-shadow: inset 0 0 0 2px var(--bonus); }
.cell.tile { background: var(--tile); color: var(--tile-text); }
.cell.ghost { background: color-mix(in srgb, var(--ghost) 45%, var(--cell)); color: #fff; }
.cell .arrow { position: absolute; top: 1px; right: 2px; font-size: 0.55em; line-height: 1.3;
  color: #fff; background: var(--ghost); border-radius: 3px; padding: 0 2px; pointer-events: none; }
.cell.anchor { outline: 2px solid var(--ghost); outline-offset: -2px; }
.cell.shake { animation: shake 0.3s; }
@keyframes shake { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
#rack-row { display: flex; justify-content: space-between; margin-top: 10px; gap: 8px; flex-wrap: wrap; }
#rack { display: flex; gap: 6px; }
.rack-tile { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: var(--tile); color: var(--tile-text); font-weight: 700; font-size: 20px;
  border-radius: 6px; cursor: pointer; }
.rack-tile.used { opacity: 0.25; }
.rack-tile.selected { outline: 3px solid var(--ghost); }
#controls { display: flex; gap: 6px; flex-wrap: wrap; }
button { background: var(--panel); color: var(--text); border: 1px solid var(--cellborder);
  border-radius: 6px; padding: 8px 14px; font-size: 0.95rem; cursor: pointer; }
button:hover { border-color: var(--ghost); }
#words-possible.warn { color: #e5b567; font-weight: 600; }
#ghost-progress { color: #9d7cd8; }
#ghost-progress.warn { color: #e0779a; font-weight: 600; }
.cell.ghost-trail { color: #b9a3e8; font-weight: 700;
  background: color-mix(in srgb, #9d7cd8 22%, var(--cell));
  outline: 1px dashed rgb(157 124 216 / 70%); outline-offset: -2px; }
.cell.ghost-new { animation: ghostPulse 1.2s ease-in-out 2; }
.cell.chisel-target { outline: 2px dashed #e5b567; outline-offset: -2px; }
.cell.ghost-under::before { content: ''; position: absolute; top: 2px; left: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: #9d7cd8; }
@keyframes ghostPulse {
  0%, 100% { background: color-mix(in srgb, #9d7cd8 22%, var(--cell)); }
  50% { background: color-mix(in srgb, #9d7cd8 48%, var(--cell)); }
}
#objectives { list-style: none; padding: 0; margin: 10px 0; text-align: left; }
#objectives li { padding: 2px 0; }
h2.ace { color: #ffd76a; text-shadow: 0 0 14px rgb(255 215 106 / 45%);
  animation: acePulse 1s ease-in-out infinite alternate; }
.ace-plus { color: #fff; }
.ace-line { color: #ffd76a; font-weight: 600; }
@keyframes acePulse { from { text-shadow: 0 0 8px rgb(255 215 106 / 30%); }
  to { text-shadow: 0 0 20px rgb(255 215 106 / 70%); } }
.cell.hintable { box-shadow: inset 0 0 0 2px rgb(122 162 247 / 55%); }
.cell.ml { box-shadow: inset 0 0 0 2px #4ec9b0; font-size: clamp(8px, 1.8vw, 12px); color: #4ec9b0; }
.cell.mw { box-shadow: inset 0 0 0 2px #d7a65f; font-size: clamp(8px, 1.8vw, 12px); color: #d7a65f; }
.cell.tile.ml, .cell.tile.mw, .cell.ghost.ml, .cell.ghost.mw {
  font-size: clamp(10px, 2.6vw, 20px); color: inherit; box-shadow: none;
}
.cell.tile { color: var(--tile-text); }
.cell[data-value]::after, .rack-tile[data-value]::after {
  content: attr(data-value); position: absolute; right: 2px; bottom: 1px;
  font-size: 0.45em; font-weight: 600; opacity: 0.75;
}
.cell { position: relative; }
.rack-tile { position: relative; }
.rack-tile.challenge { margin-left: 14px; outline: 2px dashed var(--bonus); }
#message { padding: 6px 10px; border-radius: 6px; margin: 8px 0; }
#message.error { background: #55232c; }
#message.info { background: #223355; }
#message.success { background: #1f4633; }
#overlay { position: fixed; inset: 0; background: rgb(0 0 0 / 60%);
  display: flex; align-items: center; justify-content: center; }
#overlay[hidden] { display: none; }
#overlay-card { background: var(--panel); padding: 24px; border-radius: 12px;
  min-width: 280px; text-align: center; }
#overlay-card button { display: block; width: 100%; margin: 8px 0; }
.pack-title { margin: 14px 0 2px; font-size: 0.85rem; letter-spacing: 1px;
  text-transform: uppercase; color: #8a8fa3; }

/* The beacon: a row of chips naming the next earned reward. Text labels
   carry the meaning (audience note) — lit/next are never colour-only. */
#beacon { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; }
.beacon-label { color: #8a8fa3; font-size: 0.85rem; margin-right: 2px; }
.beacon-notch { border: 1px solid var(--cellborder); border-radius: 10px;
  padding: 2px 8px; font-size: 0.8rem; color: #8a8fa3; background: var(--panel); }
.beacon-notch.lit { color: var(--tile-text); background: var(--tile);
  border-color: var(--tile); font-weight: 600; }
.beacon-notch.lit::before { content: '✓ '; }
.beacon-notch.next { border-color: var(--ghost); color: var(--text); font-weight: 600; }

.rack-tile.wild { outline: 2px solid var(--ghost); outline-offset: -2px; }
