:root {
  color-scheme: light;
  --paper: #f6f3eb;
  --paper-deep: #ece7dc;
  --surface: #fffdf8;
  --surface-soft: #fbf9f3;
  --ink: #30392f;
  --ink-soft: #4f584e;
  --muted: #737a70;
  --line: #ddd8ca;
  --line-strong: #c9c2b2;
  --sage: #657d65;
  --sage-deep: #425d49;
  --sage-pale: #e3eade;
  --clay: #a85f48;
  --clay-deep: #824632;
  --clay-pale: #f3e4dc;
  --gold: #cc9b54;
  --gold-pale: #f4ead6;
  --shadow: 0 5px 16px rgba(58, 53, 43, 0.035);
  --shadow-small: 0 2px 8px rgba(58, 53, 43, 0.035);
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 7px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--paper); }
body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
}
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 3px solid #bb8652;
  outline-offset: 3px;
}
a { color: var(--sage-deep); text-underline-offset: 0.18em; }
a:hover { color: var(--clay-deep); }
::selection { color: var(--ink); background: #e6d7b6; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.7rem 1rem;
  border-radius: 0.75rem;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: relative;
  z-index: 30;
  width: 100%;
  padding: 0.8rem max(1rem, calc((100vw - 1200px) / 2));
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1.3rem;
  min-height: 3.4rem;
  padding-right: 7.8rem;
}
.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 8.6rem;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.brand-mark { display: block; width: 126px; height: auto; flex: none; }
.top-nav { display: flex; align-items: center; gap: 0.28rem; margin-left: auto; }
.nav-button, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: 0.5rem 0.82rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 620;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}
.nav-button:hover, .text-button:hover { border-color: var(--line); background: rgba(255, 253, 248, 0.7); color: var(--ink); }
.settings-fab {
  position: fixed;
  z-index: 60;
  top: max(0.9rem, env(safe-area-inset-top));
  right: max(1rem, calc((100vw - 1200px) / 2));
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  min-height: 2.7rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 4px 12px rgba(58, 53, 43, 0.06);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  backdrop-filter: blur(10px);
}
.settings-fab span:first-child { color: var(--sage-deep); font-size: 1rem; line-height: 1; }
.settings-fab:hover { border-color: var(--sage); background: white; box-shadow: var(--shadow-small); }

#main { min-height: calc(100vh - 4.2rem); }
.app-shell { width: min(100% - 2rem, 1160px); margin: 0 auto; padding: 1rem 0 2.4rem; }
.loading-card {
  display: grid;
  place-items: center;
  gap: 0.8rem;
  min-height: 55vh;
  color: var(--muted);
  text-align: center;
}
.loading-card p { margin: 0; }
.loading-mark {
  display: grid;
  width: 3.3rem;
  height: 3.3rem;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 1.1rem;
  background: var(--surface);
  color: var(--sage-deep);
  font-family: Georgia, serif;
  font-size: 1.5rem;
  box-shadow: var(--shadow-small);
}

h1, h2, h3, p { margin-top: 0; }
h1, h2 {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.025em;
}
h1 { margin-bottom: 0.65rem; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.05; }
h2 { margin-bottom: 0.65rem; font-size: clamp(1.42rem, 2.8vw, 2rem); line-height: 1.14; }
h3 { font-size: 1rem; }
p { color: var(--ink-soft); line-height: 1.62; }
.eyebrow, .small-label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  line-height: 1.3;
  text-transform: uppercase;
}
.small-label { margin-bottom: 0.2rem; letter-spacing: 0.1em; }
.muted-note { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

.button {
  display: inline-flex;
  min-height: 2.9rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 680;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.button:hover:not(:disabled) { border-color: var(--sage); box-shadow: 0 4px 12px rgba(58, 53, 43, 0.08); }
.button:active:not(:disabled) { background: var(--paper-deep); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button--primary { border-color: var(--sage-deep); background: var(--sage-deep); color: white; }
.button--primary:hover:not(:disabled) { border-color: #344c3a; background: #344c3a; color: white; }
.button--secondary { border-color: #c4d0c0; background: #edf2e9; color: #354f3c; }
.button--secondary:hover:not(:disabled) { border-color: var(--sage); background: #e3ecdf; }
.button--quiet { border-color: transparent; background: transparent; color: var(--ink-soft); }
.button--quiet:hover:not(:disabled) { border-color: var(--line); background: var(--surface); }
.button--danger { border-color: #923f31; background: #923f31; color: white; }
.button--danger:hover:not(:disabled) { border-color: #783225; background: #783225; }
.button--danger-quiet { border-color: #e4c9bf; background: #fff8f4; color: #834b3b; }
.button--danger-quiet:hover:not(:disabled) { border-color: var(--clay); background: var(--clay-pale); }
.button--large { min-width: 9.5rem; min-height: 3.35rem; padding-inline: 1.3rem; }
.button--small { min-height: 2.45rem; padding: 0.48rem 0.84rem; font-size: 0.82rem; }
.button--wide { width: 100%; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1.25rem; }
.modal-actions--stack { display: grid; }
.tool-spacer { flex: 1; }

.home-screen { min-height: min(760px, calc(100vh - 8rem)); padding: clamp(1.8rem, 6vh, 4rem) 1rem 1rem; }
.home-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 0.88fr); align-items: center; gap: clamp(2rem, 5vw, 5rem); max-width: 1060px; margin: 0 auto; }
.home-copy { min-width: 0; }
.hero-mark { display: block; width: clamp(190px, 25vw, 270px); height: auto; margin-bottom: clamp(2rem, 5vh, 3.5rem); }
.home-copy > .eyebrow { margin-bottom: 1.1rem; }
.word-of-day-card { display: grid; gap: 0.45rem; padding-bottom: 0.65rem; border-bottom: 1px solid var(--line-strong); }
.word-of-day-card h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.8rem); }
.word-of-day { max-width: 100%; overflow-wrap: anywhere; color: var(--sage-deep); font-family: Georgia, serif; font-size: clamp(2rem, 4.3vw, 3.4rem); font-weight: 500; letter-spacing: 0.115em; line-height: 1.15; }
.home-intro { max-width: 39ch; margin: 1.3rem 0 1.55rem; font-size: 1rem; }
.word-rollover { animation: word-arrive 520ms ease-out both; }
.home-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.home-actions .button { border-radius: 8px; }
.home-understated { display: flex; min-height: 2rem; align-items: center; gap: 1rem; margin-top: 0.65rem; color: var(--muted); font-size: 0.8rem; }
.streak-chip { display: inline-flex; align-items: center; gap: 0.28rem; color: var(--clay-deep); font-weight: 650; }
.home-puzzle { min-width: 0; padding: 1.4rem 0 0.6rem clamp(1.5rem, 4vw, 4rem); border-left: 1px solid var(--line); }
.home-grid { position: relative; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); width: min(100%, 420px); aspect-ratio: 1; margin: 0 auto; border: 1px solid var(--line-strong); background: repeating-linear-gradient(90deg, transparent 0, transparent calc(33.333% - 1px), rgba(129, 137, 117, 0.08) calc(33.333% - 1px), rgba(129, 137, 117, 0.08) 33.333%), repeating-linear-gradient(0deg, var(--surface-soft) 0, var(--surface-soft) calc(33.333% - 1px), rgba(129, 137, 117, 0.09) calc(33.333% - 1px), rgba(129, 137, 117, 0.09) 33.333%); }
.home-grid-path { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; }
.home-grid-path polyline { fill: none; stroke: var(--clay); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 730; animation: trace-arrive 1.8s ease-out both; }
.home-grid-node { position: relative; z-index: 2; display: grid; width: 54%; aspect-ratio: 1; place-self: center; place-items: center; border: 1.5px solid var(--sage); border-radius: 50%; background: var(--surface); box-shadow: 0 2px 5px rgba(58, 53, 43, 0.04); }
.home-grid-node span { color: var(--sage-deep); font-family: Georgia, serif; font-size: clamp(1.1rem, 2.3vw, 1.5rem); }
.home-grid-caption { display: flex; justify-content: space-between; gap: 0.6rem; width: min(100%, 420px); margin: 0.9rem auto 0; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.055em; }
.home-grid-caption span::before { display: inline-block; width: 0.4rem; height: 0.4rem; margin-right: 0.4rem; border: 1px solid var(--sage); background: var(--sage-pale); content: ''; }
.home-footer { display: flex; align-items: center; justify-content: flex-start; max-width: 1060px; gap: 1rem; margin: 1.8rem auto 0; color: var(--muted); font-size: 0.76rem; }
.home-footer .text-button { min-height: 2rem; padding: 0.3rem 0.45rem; font-size: 0.76rem; }

.screen-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.3rem;
  margin: 0.4rem 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-strong);
}
.screen-heading > div:first-child { max-width: 730px; }
.screen-heading h1 { margin-bottom: 0.45rem; }
.screen-heading p:not(.eyebrow) { max-width: 640px; margin-bottom: 0; }
.heading-actions { display: flex; gap: 0.5rem; padding-bottom: 0.1rem; }
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(270px, 0.75fr);
  align-items: start;
  gap: clamp(1rem, 2.5vw, 1.8rem);
}
.board-panel, .archive-detail, .tutorial-board-panel {
  padding: clamp(1rem, 2.5vw, 1.65rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.board-topline { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.source-word { color: var(--sage-deep); font-family: Georgia, serif; font-size: 1.05rem; letter-spacing: 0.16em; }
.board-frame {
  position: relative;
  isolation: isolate;
  width: min(100%, 490px);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #e1dccf;
  border-radius: 8px;
  background-color: #f4f1e9;
  background-image: linear-gradient(90deg, transparent calc(33.333% - 1px), rgba(119, 133, 112, 0.12) calc(33.333% - 1px), rgba(119, 133, 112, 0.12) 33.333%, transparent 33.333%, transparent calc(66.666% - 1px), rgba(119, 133, 112, 0.12) calc(66.666% - 1px), rgba(119, 133, 112, 0.12) 66.666%, transparent 66.666%), linear-gradient(transparent calc(33.333% - 1px), rgba(119, 133, 112, 0.12) calc(33.333% - 1px), rgba(119, 133, 112, 0.12) 33.333%, transparent 33.333%, transparent calc(66.666% - 1px), rgba(119, 133, 112, 0.12) calc(66.666% - 1px), rgba(119, 133, 112, 0.12) 66.666%, transparent 66.666%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.board-grid {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  gap: 0;
}
.trace-layer { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.trace-layer polyline {
  fill: none;
  stroke: var(--gold);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.88;
  vector-effect: non-scaling-stroke;
}
.board-node {
  position: relative;
  display: grid;
  width: min(78%, 96px);
  aspect-ratio: 1;
  place-items: center;
  padding: 0;
  border: 2px solid #d3d9ce;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  cursor: pointer;
  touch-action: none;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, color 120ms ease;
}
.board-node:hover { border-color: var(--sage); box-shadow: 0 0 0 4px rgba(101, 125, 101, 0.12); }
.board-node--static { cursor: default; }
.board-node--static:hover { border-color: #d3d9ce; box-shadow: none; }
.board-node.is-empty { border-style: dashed; background: rgba(255, 253, 248, 0.55); }
.board-node.is-legal { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(204, 155, 84, 0.18); }
.board-node.is-selected { border-color: var(--sage-deep); background: var(--sage-deep); color: white; }
.node-number { position: absolute; top: 12%; left: 15%; color: var(--muted); font-size: clamp(0.52rem, 1.3vw, 0.68rem); line-height: 1; opacity: 0.72; }
.is-selected .node-number { color: rgba(255, 255, 255, 0.72); }
.node-letter { font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.55rem, 5vw, 2.55rem); font-weight: 600; line-height: 1; }
.board-hint-row, .current-trace {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: min(100%, 490px);
  min-height: 2.65rem;
  margin: 0.8rem auto 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}
.hint-dot { width: 0.5rem; height: 0.5rem; flex: none; border-radius: 50%; background: var(--gold); }
.path-count { flex: none; margin-left: auto; color: var(--muted); font-size: 0.77rem; font-variant-numeric: tabular-nums; }
.trace-path-display { display: grid; gap: 0.28rem; width: min(100%, 490px); min-height: 2.9rem; margin: 0.2rem auto 0; padding: 0.6rem 0.1rem; border-top: 1px solid var(--line); }
.trace-path-display strong { color: var(--sage-deep); font-size: 0.86rem; font-weight: 650; }
.current-trace { margin-top: 0.7rem; padding: 0.62rem 0.82rem; border: 1px solid #e5dece; border-radius: 14px; background: #fbf8ef; }
.current-trace .small-label { margin: 0; }
.current-trace strong { min-width: 5.5rem; color: var(--clay-deep); font-family: Georgia, serif; font-size: 1rem; letter-spacing: 0.07em; }
.board-tools { display: flex; align-items: center; gap: 0.4rem; width: min(100%, 490px); margin: 0.55rem auto 0; }
.keyboard-hint { width: min(100%, 490px); margin: 0.65rem auto 0; color: var(--muted); font-size: 0.73rem; line-height: 1.45; }
.game-aside { display: grid; gap: 1rem; }
.instruction-card, .paper-card, .soft-note {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
}
.instruction-card { position: relative; padding-left: 4.8rem; }
.instruction-card h2 { margin-bottom: 0.48rem; font-size: 1.36rem; }
.instruction-card p { margin-bottom: 0; font-size: 0.9rem; }
.step-number {
  position: absolute;
  top: 0.9rem;
  left: 0;
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border-radius: 50%;
  background: var(--sage-pale);
  color: var(--sage-deep);
  font-family: Georgia, serif;
  font-size: 1.1rem;
}
.step-number small { margin-left: -0.25rem; font-family: inherit; font-size: 0.62rem; }
.letter-strip { display: flex; flex-wrap: wrap; gap: 0.32rem; margin-top: 0.68rem; }
.letter-strip span { display: grid; width: 1.85rem; height: 2rem; place-items: center; border: 1px solid var(--line); border-radius: 0.62rem; background: var(--surface); color: var(--ink-soft); font-family: Georgia, serif; font-size: 0.9rem; }
.letter-strip .letter-used { border-color: var(--sage); background: var(--sage-pale); color: var(--sage-deep); }
.paper-card > .muted-note { font-size: 0.78rem; }
.soft-note { display: flex; align-items: flex-start; gap: 0.7rem; color: var(--clay-deep); }
.soft-note > span { color: var(--clay); font-size: 1.1rem; }
.soft-note p { margin: 0; font-family: Georgia, serif; font-size: 0.92rem; line-height: 1.45; }
.score-strip { display: grid; grid-template-columns: 1fr 1.25fr; gap: 0.6rem; margin-bottom: 0.55rem; }
.score-box, .timer-box { display: grid; align-content: start; gap: 0.08rem; min-height: 4.85rem; padding: 0.7rem 0.85rem; border: 1px solid #e4ddce; border-radius: 7px; background: #fbf8ef; }
.score-box strong, .timer-box strong { color: var(--sage-deep); font-family: Georgia, serif; font-size: 1.65rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer-box strong { font-size: 1.38rem; }
.score-box small, .timer-box small { overflow: hidden; color: var(--muted); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.score-progress { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 0.3rem; height: 0.6rem; }
.score-progress span { display: block; border: 1px solid var(--line-strong); background: #e8e3d8; transition: background-color 260ms ease; }
.score-progress span.is-earned { border-color: var(--sage); background: var(--sage); }
.tutorial-progress { height: 0.35rem; overflow: hidden; border-radius: 999px; background: #e8e3d8; }
.tutorial-progress span { display: block; height: 100%; border-radius: inherit; background: var(--sage); transition: width 260ms ease; }
.completion-inline { min-height: 1.55rem; margin: 0.4rem 0 0.5rem; color: var(--muted); font-size: 0.75rem; text-align: center; }
.completion-inline.is-visible { color: var(--sage-deep); font-weight: 700; }
.play-aside { align-content: start; }
.found-section { padding: 1rem 0; border-top: 1px solid var(--line-strong); }
.found-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.found-heading h2 { margin: 0; font-size: 1.15rem; }
.found-heading > span { display: grid; min-width: 1.8rem; height: 1.8rem; place-items: center; border-radius: 50%; background: var(--paper-deep); color: var(--ink-soft); font-size: 0.78rem; font-weight: 700; }
.found-word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 0.35rem; max-height: 345px; overflow-y: auto; margin: 0; padding: 0.2rem 0.25rem 0.2rem 0; list-style: none; overscroll-behavior: contain; }
.found-word-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.35rem; padding: 0.46rem 0.58rem; border: 1px solid #ece6d9; border-radius: 9px; background: #fdfbf6; font-size: 0.78rem; letter-spacing: 0.045em; }
.found-word-list li strong { color: var(--sage-deep); font-size: 0.72rem; }
.empty-found { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.82rem; }
.anagram-banner { margin: -0.15rem 0 0.8rem; padding: 0.62rem 0.7rem; border: 1px solid #e6c98e; border-radius: 10px; background: #fbf0d7; color: #765622; font-size: 0.82rem; font-weight: 760; letter-spacing: 0.07em; text-align: center; }
.construction-layout { grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.75fr); }

.archive-screen { padding-bottom: 1.5rem; }
.archive-layout { display: grid; grid-template-columns: minmax(310px, 1fr) minmax(300px, 0.8fr); align-items: start; gap: 1.2rem; }
.calendar-card { padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.calendar-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 1rem; }
.calendar-heading h2 { flex: 1; margin: 0; font-size: 1.35rem; text-align: center; }
.calendar-pickers { display: flex; justify-content: center; gap: 0.35rem; min-width: 0; }
.calendar-pickers select { min-height: 2.5rem; padding: 0.35rem 0.55rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--ink); font-weight: 650; cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.calendar-nav { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-soft); color: var(--ink); font-size: 1.45rem; line-height: 1; cursor: pointer; }
.calendar-nav:hover:not(:disabled) { border-color: var(--sage); background: var(--sage-pale); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.36rem; }
.calendar-weekdays { margin-bottom: 0.35rem; color: var(--muted); font-size: 0.7rem; font-weight: 750; text-align: center; }
.calendar-weekdays span { padding: 0.35rem 0; }
.calendar-empty { display: block; aspect-ratio: 1; }
.calendar-day { position: relative; display: grid; aspect-ratio: 1; place-items: center; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink-soft); font-size: 0.88rem; cursor: pointer; }
.calendar-day:hover { border-color: var(--line-strong); background: var(--paper); }
.calendar-day.is-selected { border-color: var(--sage-deep); background: var(--sage-deep); color: white; font-weight: 750; }
.calendar-day.is-today:not(.is-selected) { border-color: var(--gold); background: #fbf4e4; color: var(--ink); font-weight: 750; }
.calendar-day i, .legend-dot { position: absolute; bottom: 14%; left: 50%; width: 0.28rem; height: 0.28rem; border-radius: 50%; background: var(--clay); transform: translateX(-50%); }
.calendar-day.is-selected i { background: #f4d698; }
.calendar-legend { display: flex; justify-content: center; gap: 1rem; margin: 0.8rem 0 0; color: var(--muted); font-size: 0.72rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.calendar-legend .legend-dot { position: static; transform: none; }
.legend-today { width: 0.62rem; height: 0.62rem; border: 1px solid var(--gold); border-radius: 50%; background: #fbf4e4; }
.archive-detail { min-height: 16rem; }
.archive-detail h2 { margin-bottom: 0.3rem; }
.archive-word-label { margin: 0.4rem 0 0.15rem; color: var(--muted); font-size: 0.8rem; }
.archive-word { color: var(--sage-deep); font-family: Georgia, serif; font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: 0.12em; }
.archive-detail .attempt-list { margin: 0.85rem 0; }
.archive-detail .button--wide { margin-top: 0.8rem; }
.archive-detail--empty { display: grid; min-height: 16rem; align-content: center; justify-items: start; }
.archive-detail--empty p { max-width: 22rem; margin-bottom: 0; }
.attempt-list { display: grid; gap: 0.45rem; }
.attempt-card { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; padding: 0.65rem 0.7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.attempt-card > div { display: grid; gap: 0.14rem; min-width: 0; }
.attempt-card strong { font-size: 0.84rem; }
.attempt-card small { color: var(--muted); font-size: 0.72rem; }
.attempt-kicker { color: var(--muted); font-size: 0.63rem; font-weight: 740; letter-spacing: 0.09em; text-transform: uppercase; }
.attempt-card--draft { background: #faf6eb; }

.tutorial-screen { padding-bottom: 2rem; }
.tutorial-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin: 0.4rem 0 1rem; }
.tutorial-header > div:first-child { max-width: 730px; }
.tutorial-header h1 { margin-bottom: 0.45rem; font-size: clamp(2rem, 4vw, 3rem); }
.tutorial-header p:not(.eyebrow) { margin-bottom: 0; }
.tutorial-header-actions { display: flex; align-items: center; gap: 0.25rem; flex: none; }
.tutorial-progress { height: 0.3rem; margin-bottom: 1.25rem; }
.tutorial-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(270px, 0.8fr); align-items: start; gap: 1.15rem; }
.tutorial-board-panel .board-frame { max-width: 450px; }
.tutorial-board-panel .found-section { margin-top: 0.8rem; }
.tutorial-score-badge { margin-left: auto; padding: 0.35rem 0.65rem; border-radius: 999px; background: var(--sage-pale); color: var(--sage-deep); font-size: 0.78rem; font-weight: 700; }
.tutorial-example-summary { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0.2rem 0 0.8rem; padding: 0.6rem 0.75rem; border-radius: 10px; background: var(--sage-pale); color: var(--sage-deep); font-size: 0.82rem; }
.tutorial-example-summary span { color: var(--ink-soft); }
.tutorial-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.tutorial-mini-board { padding: 0.65rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.tutorial-mini-board > strong { display: block; margin-bottom: 0.5rem; color: var(--ink-soft); font-size: 0.76rem; }
.tutorial-mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.15rem; }
.tutorial-mini-grid span { display: grid; aspect-ratio: 1; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--sage-deep); font-family: Georgia, serif; font-size: 1rem; }
.tutorial-explain { display: grid; align-content: start; gap: 0.9rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.tutorial-explain > p { margin: 0; }
.tutorial-fact { padding: 0.9rem; border-left: 3px solid var(--gold); border-radius: 0 12px 12px 0; background: #faf4e7; font-size: 0.84rem; }
.route-hint { display: grid; gap: 0.4rem; padding: 0.85rem 0.9rem; border: 1px solid #e4ddce; border-radius: 14px; background: #fbf8ef; }
.route-hint strong { color: var(--sage-deep); font-size: 0.92rem; letter-spacing: 0.04em; }
.tutorial-score-table { display: grid; gap: 0.4rem; }
.tutorial-score-table > div { display: flex; justify-content: space-between; gap: 0.7rem; padding: 0.65rem 0.75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 0.83rem; }
.tutorial-score-table strong { color: var(--sage-deep); }
.tutorial-score-line { display: flex; justify-content: space-between; padding: 0.65rem 0.1rem; color: var(--muted); font-size: 0.82rem; }
.tutorial-score-line strong { color: var(--sage-deep); }
.tutorial-result { display: grid; justify-items: center; gap: 0.55rem; padding: 1.35rem; border: 1px solid #e4d4b5; border-radius: 18px; background: #fbf3e3; text-align: center; }
.tutorial-result strong { color: var(--sage-deep); font-family: Georgia, serif; font-size: 1.7rem; }
.tutorial-result span:not(.result-spark) { color: var(--muted); font-size: 0.84rem; }
.tutorial-result p { margin: 0; font-size: 0.84rem; }
.result-spark { color: var(--gold); font-size: 2rem; }
.tutorial-attempts { display: grid; gap: 0.55rem; }
.attempt-demo { display: flex; min-height: 4rem; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); text-align: left; cursor: pointer; }
.attempt-demo:hover, .attempt-demo.is-opened { border-color: var(--sage); background: var(--sage-pale); }
.attempt-demo span { color: var(--muted); font-size: 0.75rem; }
.attempt-demo strong { color: var(--sage-deep); font-size: 0.83rem; }

.home-footer .text-button, .text-button { white-space: nowrap; }
.fatal-screen { display: grid; max-width: 620px; justify-items: start; gap: 0.65rem; margin: 9vh auto; padding: 2rem; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.fatal-screen > p:not(.eyebrow) { margin-bottom: 0.25rem; }
.fatal-screen .text-button { min-height: 2rem; padding-left: 0; }

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: rgba(36, 42, 35, 0.4);
  backdrop-filter: blur(5px);
}
.modal-dialog {
  position: relative;
  width: min(100%, 520px);
  max-height: min(90vh, 850px);
  overflow: auto;
  padding: 1.4rem clamp(1.15rem, 4vw, 1.8rem) 1.65rem;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(20, 28, 20, 0.22);
  overscroll-behavior: contain;
}
.modal-top { display: flex; align-items: start; justify-content: space-between; min-height: 1.6rem; }
.modal-top .eyebrow { margin-bottom: 0.5rem; }
.icon-close { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-soft); font-size: 1.35rem; cursor: pointer; }
.icon-close:hover { border-color: var(--clay); color: var(--clay-deep); }
.modal-dialog h2 { margin-right: 1.5rem; }
.modal-copy { margin: 0.15rem 0 1rem; font-size: 0.91rem; }
.modal-dialog .attempt-list { margin: 1rem 0; }
.modal-dialog .attempt-card { padding: 0.7rem; }
.modal-dialog .attempt-card .button { flex: none; }
.toggle-row { display: flex; align-items: center; gap: 0.8rem; min-height: 4.2rem; padding: 0.7rem 0.1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle-row input { width: 1.25rem; height: 1.25rem; flex: none; margin: 0; accent-color: var(--sage-deep); }
.toggle-row span { display: grid; gap: 0.22rem; }
.toggle-row strong { font-size: 0.9rem; }
.toggle-row small { color: var(--muted); font-size: 0.76rem; line-height: 1.35; }
.settings-about { display: grid; gap: 0.7rem; margin-top: 1rem; }
.settings-about p { margin: 0; font-size: 0.86rem; }
.help-content { display: grid; gap: 0.85rem; }
.help-content > p { margin: 0; font-size: 0.9rem; }
.notice-block { padding: 0.9rem; border: 1px solid var(--line); border-radius: 13px; background: #faf8f1; }
.notice-block h3 { margin: 0 0 0.35rem; color: var(--ink); font-size: 0.84rem; }
.notice-block p { margin: 0; color: var(--ink-soft); font-size: 0.77rem; line-height: 1.55; }
.share-preview-label { display: block; margin: 0.9rem 0 0.35rem; color: var(--muted); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.share-preview { display: block; width: 100%; min-height: 10rem; resize: vertical; padding: 0.85rem; border: 1px solid var(--line-strong); border-radius: 12px; background: #fbf9f3; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.82rem; line-height: 1.5; white-space: pre-wrap; }
.completion-modal { text-align: center; }
.completion-modal .modal-top { text-align: left; }
.completion-modal h2 { margin-right: 0; }
.completion-celebration { display: flex; justify-content: center; gap: 1.4rem; margin: 0.4rem 0 0.7rem; color: var(--gold); font-size: 1.35rem; }
.completion-celebration span { animation: celebration-spark 900ms ease-out both; }
.completion-celebration span:nth-child(2n) { color: var(--clay); font-size: 0.95rem; }
.completion-celebration span:nth-child(2) { animation-delay: 90ms; }
.completion-celebration span:nth-child(3) { animation-delay: 170ms; }
.completion-celebration span:nth-child(4) { animation-delay: 250ms; }
.completion-celebration span:nth-child(5) { animation-delay: 330ms; }
.completion-result { display: grid; gap: 0.35rem; margin: 0 auto 0.75rem; color: var(--muted); font-size: 0.85rem; }
.completion-result strong { color: var(--sage-deep); font-family: Georgia, serif; font-size: 2.3rem; font-weight: 500; animation: celebration-score 540ms 160ms cubic-bezier(.2,1.3,.35,1) both; }
.completion-anagram { margin: 0.75rem 0; color: #775822; font-size: 0.84rem; font-weight: 800; letter-spacing: 0.06em; }
.completion-modal .modal-copy { max-width: 360px; margin-inline: auto; }
.completion-modal .modal-actions { justify-content: center; }
.toast-root { position: fixed; z-index: 100; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); left: 1rem; display: flex; justify-content: center; pointer-events: none; }
.toast:empty { display: none; }
.toast { max-width: min(100%, 560px); padding: 0.78rem 1rem; border: 1px solid #d6d1c4; border-radius: 999px; background: var(--ink); box-shadow: var(--shadow); color: white; font-size: 0.86rem; text-align: center; animation: toast-in 160ms ease-out both; }
.toast--error { border-color: #875042; background: #754637; }
.toast--success { border-color: #49634d; background: #3f5b45; }
.toast--duplicate { border-color: #997b48; background: #6d5b3d; }
.feedback-error { animation: board-shake 280ms ease-in-out; }
.screen-enter { animation: screen-in 240ms ease-out both; }

@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes word-arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes trace-arrive { from { stroke-dashoffset: 730; } to { stroke-dashoffset: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes board-shake { 0%, 100% { transform: translateX(0); } 28% { transform: translateX(-5px); } 68% { transform: translateX(4px); } }
@keyframes celebration-spark { from { opacity: 0; transform: translateY(-1.3rem) rotate(-35deg) scale(0.45); } 55% { opacity: 1; } to { opacity: 1; transform: translateY(0) rotate(0) scale(1); } }
@keyframes celebration-score { from { opacity: 0; transform: scale(0.72); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 930px) {
  .home-screen { min-height: 0; }
  .home-hero { grid-template-columns: minmax(0, 1fr) minmax(240px, 0.85fr); gap: 1.8rem; }
  .home-puzzle { padding-left: 1.8rem; }
  .play-layout, .construction-layout, .tutorial-layout { grid-template-columns: minmax(0, 1fr); }
  .game-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .play-aside { grid-template-columns: minmax(0, 1fr); }
  .archive-layout { grid-template-columns: minmax(0, 1fr); }
  .archive-detail { min-height: 0; }
}
@media (max-width: 620px) {
  .site-header { padding: 0.7rem 0.8rem 0.2rem; }
  .header-inner { min-height: 3rem; flex-wrap: wrap; gap: 0.3rem; padding-right: 0; }
  .brand-button { min-width: 0; }
  .brand-mark { width: 98px; }
  .top-nav { width: 100%; justify-content: center; gap: 0.15rem; margin: 0; padding-right: 4.9rem; }
  .nav-button { min-height: 2.25rem; padding: 0.4rem 0.6rem; font-size: 0.77rem; }
  .settings-fab { top: max(0.65rem, env(safe-area-inset-top)); right: 0.8rem; min-height: 2.45rem; padding: 0.4rem 0.7rem; font-size: 0.77rem; }
  .app-shell { width: min(100% - 1rem, 1160px); padding-top: 0.8rem; }
  .home-screen { padding: 1.2rem 0.25rem 0.5rem; }
  .home-hero { grid-template-columns: 1fr; gap: 2rem; }
  .home-copy { max-width: 480px; margin-inline: auto; width: 100%; }
  .home-hero h1 { max-width: none; }
  .home-intro { max-width: 38ch; }
  .hero-mark { width: 204px; margin-bottom: 1.8rem; }
  .word-of-day { font-size: clamp(1.8rem, 8.3vw, 2.8rem); letter-spacing: 0.09em; }
  .home-puzzle { width: min(100%, 420px); padding: 0; margin: 0 auto; border: 0; }
  .home-grid-node span { font-size: 1.3rem; }
  .home-actions { width: 100%; gap: 0.45rem; }
  .home-actions .button { flex: 1 1 auto; min-width: 0; padding-inline: 0.75rem; font-size: 0.84rem; }
  .home-actions .button--large { min-height: 3.1rem; }
  .home-understated { flex-wrap: wrap; gap: 0.45rem 0.8rem; }
  .home-footer { flex-wrap: wrap; justify-content: center; gap: 0.2rem 0.5rem; }
  .screen-heading, .tutorial-header { align-items: flex-start; flex-direction: column; gap: 0.75rem; margin-top: 0.2rem; }
  .screen-heading h1, .tutorial-header h1 { font-size: 2.2rem; }
  .heading-actions { align-self: flex-end; margin-top: -3.3rem; }
  .play-heading .heading-actions { margin-top: -3.4rem; }
  .board-panel, .archive-detail, .tutorial-board-panel { padding: 0.85rem; border-radius: 10px; }
  .board-frame { border-radius: 6px; }
  .board-grid { inset: 0; }
  .board-node { width: 78%; border-width: 1.5px; }
  .node-letter { font-size: clamp(1.35rem, 9vw, 2.25rem); }
  .board-tools { flex-wrap: wrap; gap: 0.3rem; }
  .board-tools .button, .board-tools .text-button { min-height: 2.55rem; padding-inline: 0.72rem; font-size: 0.79rem; }
  .tool-spacer { display: none; }
  .game-aside { grid-template-columns: minmax(0, 1fr); }
  .game-aside .found-section { grid-row: auto; }
  .score-strip { grid-template-columns: 0.8fr 1.2fr; }
  .calendar-card { padding: 0.8rem; }
  .calendar-grid { gap: 0.18rem; }
  .calendar-day { border-radius: 5px; font-size: 0.78rem; }
  .calendar-detail { padding: 1rem; }
  .tutorial-header-actions { align-self: flex-end; margin-top: -0.4rem; }
  .tutorial-explain { padding: 1rem; border-radius: 10px; }
  .tutorial-score-table > div { font-size: 0.76rem; }
  .attempt-card { align-items: flex-start; }
  .attempt-card .button { min-height: 2.25rem; padding: 0.4rem 0.7rem; }
  .modal-dialog { padding: 1.1rem 1rem 1.3rem; border-radius: 10px; }
  .modal-actions .button { flex: 1 1 auto; }
  .modal-actions--stack .button { width: 100%; }
  .completion-modal .modal-actions { flex-direction: column; }
}
@media (max-width: 365px) {
  .hero-mark { width: 210px; }
  .home-actions { gap: 0.3rem; }
  .home-actions .button { font-size: 0.76rem; }
  .nav-button { padding-inline: 0.45rem; font-size: 0.72rem; }
  .current-trace strong { min-width: 4rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .feedback-error { animation: none !important; outline: 3px solid var(--clay); outline-offset: 3px; }
}
