:root {
  --paper: #F6EFDF;
  --card: #FBF6EA;
  --ink: #2B2620;
  --ink-faint: #6E6355;
  --hairline: #D8CBAE;
  --green: #3F6B4A;
  --green-wash: #DCE8DA;
  --red: #A8442E;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1E1B16;
    --card: #2A2620;
    --ink: #EDE5D3;
    --ink-faint: #B6AC98;
    --hairline: #453F35;
    --green: #4C7D58;
    --green-wash: #25382A;
    --red: #C4614A;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Wraps #app so the game screen still centers horizontally. Keeps a full
   100vh floor so the site header/footer (added around the game) don't
   shrink the puzzle grid to fit above the fold — the footer sits below,
   reachable by scrolling, same as a hero section would. */
.game-shell {
  flex: 1;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  padding: 8px 0 12px;
}

.serif { font-family: Georgia, "Noto Serif", serif; }

/* Visually hidden but still reachable by screen readers — used for
   headings that exist purely to keep the document outline valid
   (e.g. a page whose only visible heading is its top-level title). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 0;
}

.topbar-spacer { width: 36px; }

.title {
  margin: 0;
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 22px;
  letter-spacing: 1.5px;
  color: var(--ink);
  text-align: center;
  flex: 1;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  padding: 8px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon-btn:hover { background: var(--card); }

.caption {
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  margin: 10px 0 0;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 0;
}

.progress-endpoint {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-weight: bold;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.progress-endpoint-total {
  background: #8AA98F;
  background: color-mix(in srgb, var(--green) 45%, transparent);
}

.progress-track {
  flex: 1;
  height: 4px;
  position: relative;
}
.track-line {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--hairline);
}
.track-dot {
  position: absolute;
  top: 2px;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--hairline);
}
.progress-fill {
  position: absolute;
  left: 0; top: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--green);
  width: 0%;
  transition: width 250ms ease;
}

.word-preview {
  height: 24px;
  margin: 8px 0 0;
  text-align: center;
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--green);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 0;
}

.pill-btn {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  color: var(--ink-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.pill-btn.is-disabled { opacity: 0.4; cursor: default; pointer-events: none; }
.pill-btn.icon-only { padding: 8px; }
.pill-btn svg { flex-shrink: 0; }

.active-hints {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
}

.hint-chip {
  display: flex;
  padding: 5px 6px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  gap: 3px;
}
.hint-chip .letter-box {
  width: 16px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 14px;
  color: var(--ink);
}
.hint-chip .letter-box.blank {
  border: 1px solid var(--hairline);
  border-radius: 3px;
}

.grid-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  min-height: 0;
}

.grid-wrap {
  position: relative;
  transition: transform 450ms ease;
  touch-action: none;
}

.path-svg {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.path-svg path {
  fill: none;
  stroke: var(--green);
  stroke-opacity: 0.55;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tiles { position: relative; }

.tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1.5px solid var(--hairline);
  color: var(--ink);
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  user-select: none;
  transition: background 100ms, border-color 100ms, box-shadow 100ms, transform 450ms ease;
}
.tile .letter { transition: opacity 450ms ease; }
.tile.hidden .letter { opacity: 0; }
.tile.selected {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 0 8px rgba(63,107,74,0.5);
  box-shadow: 0 0 8px color-mix(in srgb, var(--green) 35%, transparent);
}

.status-area {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
}

.prompt-text {
  text-align: center;
  font-size: 12px;
  color: var(--ink-faint);
  margin: 0;
}

.error-text {
  text-align: center;
  color: var(--red);
  font-weight: 600;
  font-size: 13px;
  margin: 0;
}

.win-block { text-align: center; }
.win-title {
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--ink);
}
.win-sub { font-size: 13px; color: var(--ink-faint); margin: 0; }

.found-words {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.found-chip {
  background: var(--green-wash);
  color: var(--green);
  font-family: Georgia, "Noto Serif", serif;
  font-weight: 600;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
}

/* Content pages (about-us, etc.) */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 14px 20px;
  max-width: 720px;
  margin: 0 auto;
  border-bottom: 1px solid var(--hairline);
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}
.brand-logo {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 7px;
}
.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.site-nav-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-faint);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 20px;
}
.site-nav-link:hover { color: var(--ink); background: var(--card); }
.site-nav-link.active { color: var(--green); background: var(--green-wash); }

.breadcrumbs {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  font-size: 12px;
  color: var(--ink-faint);
}
.breadcrumbs a { color: var(--ink-faint); display: inline-block; padding: 6px 4px; margin: -6px -4px; }
.breadcrumbs span[aria-current] { color: var(--ink); }
.breadcrumb-sep { margin: 0 6px; }

.content-main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.page-card h1 {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 30px;
  margin: 8px 0 20px;
  color: var(--ink);
}
.page-card h2 {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 19px;
  margin: 28px 0 10px;
  color: var(--ink);
}
.page-card p {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-faint);
  margin: 0 0 14px;
}
.page-card a { color: var(--green); }
.page-card strong { color: var(--ink); }
.page-card ul {
  margin: 0 0 14px;
  padding-left: 22px;
}
.page-card li {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-faint);
  margin: 0 0 6px;
}
.policy-meta {
  font-size: 12px;
  color: var(--ink-faint);
  margin: -12px 0 20px;
}

.about-modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 14px;
}
.about-mode-card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 14px 16px;
}
.about-mode-card h3 {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 16px;
  margin: 0 0 4px;
  color: var(--ink);
}
.about-mode-card p { margin: 0 0 8px; font-size: 14px; }
.about-mode-card a { font-weight: 600; text-decoration: none; }
.about-mode-card a:hover { text-decoration: underline; }

.site-footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 24px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--ink-faint);
}
.site-footer a { color: var(--ink-faint); text-decoration: none; }
.site-footer a:hover { color: var(--green); }
.footer-sep { margin: 0 6px; }

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
  text-align: center;
}
.footer-col { display: flex; flex-direction: column; align-items: center; gap: 0; }
.footer-col h3 {
  font-family: Georgia, "Noto Serif", serif;
  font-size: 13px;
  font-weight: bold;
  color: var(--ink);
  margin: 0 0 4px;
}
.footer-col a { font-size: 13px; display: inline-block; padding: 6px 6px; margin: 0 -6px; }

.footer-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  text-align: center;
}
.footer-copy { margin: 0; }
.footer-legal { display: flex; align-items: center; flex-wrap: wrap; }
.footer-legal a { display: inline-block; padding: 6px 4px; margin: -6px -4px; }
.footer-legal-sep { margin: 0 8px; }

/* Confetti */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  opacity: 0.9;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  from { transform: translate(var(--dx, 0px), 0) rotate(0deg); }
  to { transform: translate(var(--dx, 0px), 110vh) rotate(540deg); opacity: 0.2; }
}

/* Help dialog */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.dialog-overlay:not([hidden]) { display: flex; }
.dialog-card {
  position: relative;
  background: var(--paper);
  border-radius: 18px;
  max-width: 440px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
}
.dialog-close {
  position: absolute;
  top: 8px; right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 4px;
  text-decoration: none;
}
.dialog-title {
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 22px;
  margin: 0 0 12px;
  color: var(--ink);
}
.section-heading {
  font-family: Georgia, "Noto Serif", serif;
  font-weight: bold;
  font-size: 17px;
  margin: 0 0 6px;
  color: var(--ink);
}
.dialog-body p {
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.4;
  margin: 0 0 10px;
}
