/* Linky Words - browser daily. Papercraft palette, no dependencies. */

:root {
  --paper: #FFF9F0;
  --tile: #F2E8D5;
  --tile-edge: #E2D5BC;
  --ink: #3A332B;
  --ink-2: #6F6557;
  --accent: #C4693F;
  --accent-ink: #FFF9F0;
  --good: #5E8C4F;
  --hint: #D9A441;
  --hint-text: #9A6A12;
  --panel: #FFFDF8;
  --shadow: rgba(58, 51, 43, 0.14);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1E1B17;
    --tile: #2F2A23;
    --tile-edge: #413A30;
    --ink: #F4EADA;
    --ink-2: #B4A895;
    --accent: #D9835A;
    --accent-ink: #201C17;
    --good: #7FAE6E;
    --hint: #E3B461;
    --hint-text: #E3B461;
    --panel: #26221C;
    --shadow: rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Roboto, "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  overflow-x: hidden;
}

.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ---------- header ---------- */

.head { text-align: center; margin-bottom: 18px; }

.brand {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.brand a { color: inherit; text-decoration: none; }
.brand span { color: var(--accent); }

.tagline {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- day bar ---------- */

.daybar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
}

.daybar-main { display: flex; flex-direction: column; }
.category { font-weight: 800; font-size: 18px; }
.date { color: var(--ink-2); font-size: 13px; }

.daybar-stats { display: flex; gap: 12px; align-items: baseline; }
.stat { font-size: 13px; color: var(--ink-2); font-weight: 600; }
#d-timer { font-variant-numeric: tabular-nums; font-size: 16px; color: var(--ink); }

/* ---------- word list ---------- */

.words {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 0 0 12px;
  padding: 0;
}

.word {
  display: flex;
  gap: 1px;
  padding: 5px 9px;
  background: var(--panel);
  border: 1px solid var(--tile-edge);
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.6px;
}

.word-found {
  background: var(--good);
  border-color: var(--good);
  color: var(--accent-ink);
}

.ch { min-width: 8px; text-align: center; }
.ch-hidden { color: var(--ink-2); opacity: 0.55; }
.ch-hint { color: var(--hint-text); }
.word-found .ch-hidden { color: inherit; opacity: 1; }

/* ---------- board ---------- */

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--size, 4), 1fr);
  gap: 8px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.trail {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.trail-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.45;
}

.tile {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  z-index: 1;
  aspect-ratio: 1 / 1;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 800;
  font-size: clamp(18px, 6.5vw, 30px);
  color: var(--ink);
  background: var(--tile);
  border: 1px solid var(--tile-edge);
  border-bottom-width: 3px;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px var(--shadow);
  cursor: pointer;
  touch-action: none;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.tile-blank, .tile:disabled {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  cursor: default;
}

.tile.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  transform: scale(1.05);
}

.tile.is-found {
  background: var(--good);
  border-color: var(--good);
  color: var(--accent-ink);
}

.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* board sizes: keep 5x5 readable at 320px */
.board { font-size: inherit; }

.message {
  min-height: 1.5em;
  margin: 12px 0 4px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-2);
}

/* ---------- buttons ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.btn {
  appearance: none;
  -webkit-appearance: none;
  min-height: 48px;
  padding: 12px 20px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--tile-edge);
  border-bottom-width: 3px;
  border-radius: 999px;
  cursor: pointer;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-store { flex: 1 1 140px; max-width: 220px; }

/* ---------- panels, result, cta ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--tile-edge);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}

.panel-title { margin: 0 0 8px; font-size: 20px; }
/* focused by script so keyboard and screen reader users land on the result; not a control */
.panel-title[tabindex="-1"]:focus { outline: none; }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }

.result {
  margin: 12px 0 0;
  padding: 14px 10px;
  background: var(--tile);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
}

.streak { margin: 14px 0 0; font-weight: 700; }

.cta {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--tile-edge);
}

.cta-title { margin: 0 0 6px; font-size: 17px; }
.cta-line { margin: 0; font-size: 15px; color: var(--ink-2); }
.cta .controls { margin-top: 14px; }
.foot a { color: inherit; }
.foot-links a { margin: 0 2px; }

.foot { margin-top: 28px; text-align: center; }

@media (max-width: 360px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .board { gap: 6px; }
  .tile { border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .tile.is-active { transform: none; }
  .btn:active { transform: none; }
}
