/* Crosswordle — static, no framework, mobile-first. Forked from Crossmind's chassis;
   only the feedback/keyboard layer differs. */
:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --panel: #171a21;
  --ink: #eef0f4;
  --muted: #9aa3b2;
  --accent: #5b8def;
  --ok: #3fb87f;
  --err: #e5636b;
  --locked: #c9a24b;
  --border: #2a2e38;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --ink: #161a22;
    --muted: #5b6372;
    --border: #e1e4ec;
  }
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
body {
  min-height: 100vh;
  padding: 0 0 2.5rem;
}
header.top {
  text-align: center;
  padding: 1.1rem 1rem 0.6rem;
}
header.top h1 {
  margin: 0 0 0.2rem;
  font-size: 1.6rem;
  letter-spacing: 0.02em;
}
.tag {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.meta {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
main {
  max-width: 420px;
  margin: 0 auto;
  padding: 0.75rem 1rem 0;
}
section {
  margin-bottom: 1rem;
}

/* Feedback legend */
.legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
  margin-bottom: 0.9rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink);
}
.legend-item .tile {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
}

/* Board: fixed 5x5, cells belonging to no slot are blank/invisible */
.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  max-width: 320px;
  margin: 0 auto;
}
.cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(1rem, 5vw, 1.4rem);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.cell.blank {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.locked { color: var(--locked); }
.cell.solved { background: var(--ok); color: #05210f; border-color: var(--ok); }
.cell:focus-visible { outline: 3px solid var(--accent); }

/* Slot chips */
.slots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.5rem;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.chip.sel { border-color: var(--accent); }
.chip.solved { border-color: var(--ok); opacity: 0.85; }
.chip:disabled { cursor: default; }
.chip-lbl { font-size: 0.7rem; color: var(--muted); letter-spacing: 0.04em; }
.chip-boxes { display: flex; gap: 2px; }
.chip-boxes .box {
  width: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 3px;
  text-transform: uppercase;
}
.chip-boxes .box.locked { color: var(--locked); border-color: var(--locked); }
.chip-state { font-size: 0.65rem; color: var(--muted); }

/* Entry */
.budget { text-align: center; font-size: 0.85rem; color: var(--muted); margin: 0 0 0.4rem; }
.entry { display: flex; gap: 0.5rem; }
#guess {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
}
button {
  font: inherit;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 44px;
}
button:active { opacity: 0.85; }
.msg { min-height: 1.2em; text-align: center; font-size: 0.85rem; color: var(--ink); margin: 0.4rem 0 0; }
.msg.err { color: var(--err); }

/* History: per-letter colored/shaped tiles instead of exact/loose text */
#history-sec h2 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.hrow {
  display: grid;
  grid-template-columns: 1.1rem 2.4rem 1fr;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.hnum { color: var(--muted); }
.hlabel { color: var(--muted); font-size: 0.7rem; }
.htiles { display: flex; gap: 2px; }
.tile {
  position: relative;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 4px;
  text-transform: uppercase;
  font-style: normal;
  color: #fff;
}
.tile-g { background: var(--ok); }
.tile-y { background: var(--locked); color: #241a00; }
.tile-x { background: var(--border); color: var(--muted); }
/* Shape/label cue so feedback is never color-only (color-blind safe) */
.tile .cue {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 0.5rem;
  line-height: 1;
  font-style: normal;
  opacity: 0.85;
}

/* On-screen per-slot keyboard */
#keyboard-sec { margin-top: 0.75rem; }
.keyboard { display: flex; flex-direction: column; gap: 6px; }
.kbd-row { display: flex; justify-content: center; gap: 4px; }
.key {
  flex: 1;
  max-width: 2.1rem;
  min-width: 0;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
  position: relative;
}
.key-special { max-width: 3.2rem; font-size: 1rem; }
.key.k-g { background: var(--ok); color: #05210f; border-color: var(--ok); }
.key.k-y { background: var(--locked); color: #241a00; border-color: var(--locked); }
.key.k-x { background: var(--border); color: var(--muted); }
.kbd-note { font-size: 0.68rem; color: var(--muted); text-align: center; margin: 0.4rem 0 0; }

/* End state */
#end-sec {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  text-align: center;
}
.end-text { margin: 0 0 0.5rem; font-weight: 600; }
.answers-reveal { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; }
.share-msg { font-size: 0.8rem; color: var(--ok); min-height: 1.1em; margin: 0.4rem 0 0; }

/* Stats */
#stats-sec h2, #stats-sec h3 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.stat-row { display: flex; justify-content: space-between; gap: 0.3rem; text-align: center; }
.stat { flex: 1; }
.stat span { display: block; font-size: 1.2rem; font-weight: 700; }
.stat label { font-size: 0.65rem; color: var(--muted); }
.dist { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.4rem; }
.drow { display: grid; grid-template-columns: 1rem 1fr 1.6rem; align-items: center; gap: 0.4rem; font-size: 0.75rem; }
.dbar { height: 0.8rem; background: var(--accent); border-radius: 3px; }

/* Ad slot — discreet, reserved space, below the fold on a phone, never during active play */
.ad-slot {
  margin-top: 1.5rem;
  min-height: 90px;
}
.ad-placeholder {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.5rem;
}

footer.foot {
  max-width: 420px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
}
