:root {
  --font-game: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #fffaf0;
  --panel: #fffdf6;
  --panel-soft: #f6efd9;
  --ink: #263322;
  --muted: #657058;
  --soft: #8c8060;
  --line: rgba(89, 103, 66, 0.2);
  --line-strong: rgba(89, 103, 66, 0.36);
  --gold: #9a7627;
  --meadow: #3d9daa;
  --forest: #4f9257;
  --ruins: #9778b8;
  --goal: #f5edda;
  --goal-ink: #263322;
  --path: #f7d96c;
  --miss: #c24343;
  --alphabet-unused: #f3e8c8;
  --surface-glow: rgba(88, 72, 32, 0.1);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

[data-theme="dark"] {
  --bg: #111713;
  --panel: #182119;
  --panel-soft: #202b20;
  --ink: #f1ead7;
  --muted: #c8c0a6;
  --soft: #aaa17f;
  --line: rgba(231, 221, 182, 0.18);
  --line-strong: rgba(231, 221, 182, 0.32);
  --gold: #e6c662;
  --goal: #efe1c4;
  --path: #ffe37a;
  --alphabet-unused: #3a3423;
  --surface-glow: rgba(0, 0, 0, 0.34);
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: clip;
  display: grid;
  place-items: start center;
  background:
    radial-gradient(circle at 22% 12%, rgba(252, 225, 142, 0.42), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(96, 171, 143, 0.2), transparent 30%),
    linear-gradient(135deg, #fffdf6, var(--bg));
  color: var(--ink);
  font-family: var(--font-game);
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at 20% 12%, rgba(230, 198, 98, 0.16), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(61, 157, 170, 0.16), transparent 32%),
    linear-gradient(135deg, #0b100d, var(--bg));
}

.shell {
  width: min(540px, calc(100% - 12px));
  display: grid;
  gap: 7px;
  padding: 8px 0 12px;
}

.game-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 8vw, 42px);
  font-weight: 950;
  line-height: 1;
}

.logo-tiles {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  max-width: 410px;
  margin: 0 auto 1px;
  width: min(410px, 100%);
}

.logo-tiles span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 9px;
  color: #fffdf6;
  font-size: clamp(18px, 5.5vw, 30px);
  font-weight: 950;
  line-height: 1;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.12), 0 8px 18px rgba(88, 72, 32, 0.12);
}

.logo-tiles .meadow { background: var(--meadow); }
.logo-tiles .forest { background: var(--forest); }
.logo-tiles .ruins { background: var(--ruins); }
.logo-tiles .goal { background: var(--goal); color: var(--goal-ink); text-shadow: none; }

[data-theme="dark"] .logo-tiles span {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.08), 0 8px 18px rgba(0, 0, 0, 0.24);
}

.top-panel,
.bottom-panel,
.rules-strip {
  position: relative;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 253, 246, 0.9);
  box-shadow: none;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

[data-theme="dark"] .top-panel,
[data-theme="dark"] .bottom-panel {
  background: rgba(24, 33, 25, 0.92);
}

.bottom-panel {
  display: grid;
  gap: 6px;
  padding: 9px;
}

.info-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.info-row strong {
  display: flex;
  align-items: center;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  flex-wrap: nowrap;
}

.intro {
  margin: 0;
  color: color-mix(in srgb, var(--ink) 82%, var(--muted) 18%);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.25;
  font-weight: 700;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rules-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  min-width: 0;
  max-width: 100%;
}

.rules-strip div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.72);
}

[data-theme="dark"] .rules-strip div {
  background: rgba(24, 33, 25, 0.72);
}

.rules-strip i {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 4px;
}

.rules-strip span {
  color: color-mix(in srgb, var(--muted) 86%, var(--ink) 14%);
  font-size: 9.5px;
  font-weight: 750;
  line-height: 1;
}

.status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.status-row div,
.route-card,
.history-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 246, 0.76);
}

.status-row div {
  min-width: 64px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  background: rgba(255, 253, 246, 0.52);
}

.status-row button {
  justify-self: auto;
}

[data-theme="dark"] .status-row div {
  background: rgba(255, 255, 255, 0.06);
}

.status-row span,
.route-card span,
.history-card span {
  display: block;
  color: var(--soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.status-row strong {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: var(--ink);
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.status-row b {
  font: inherit;
}

.status-row small {
  color: var(--soft);
  font: 800 10px/1 var(--font-game);
}

.route-card {
  padding: 0;
  border: 0;
  background: transparent;
}

.history-card {
  padding: 0;
  border: 0;
  background: transparent;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-head small {
  display: flex;
  align-items: center;
  gap: 4px;
  color: color-mix(in srgb, var(--soft) 88%, var(--ink) 12%);
  font-size: 9px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.history-head b {
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.hit-dot { background: #4f9257; }
.near-dot { background: rgba(94, 97, 88, 0.34); border: 1px solid rgba(94, 97, 88, 0.28); }
.miss-dot { background: rgba(194, 67, 67, 0.24); border: 1px solid rgba(194, 67, 67, 0.32); }

.route-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.word-slots {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  margin-top: 3px;
  padding: 5px;
  border: 1px solid rgba(222, 200, 107, 0.28);
  border-radius: 12px;
  background: rgba(255, 248, 222, 0.72);
  color: var(--ink);
}

[data-theme="dark"] .word-slots {
  background: rgba(230, 198, 98, 0.09);
}

.route-card .word-slot {
  display: grid;
  place-items: center;
  min-width: 0;
  width: auto;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--ink);
  font: 950 18px/1 var(--font-game);
  text-align: center;
  text-shadow: none;
}

.route-card .word-slot.empty {
  color: rgba(38, 51, 34, 0.3);
  background: rgba(74, 82, 56, 0.07);
}

.route-card .word-slot.meadow { background: color-mix(in srgb, var(--meadow) 72%, #fff 28%); }
.route-card .word-slot.forest { background: color-mix(in srgb, var(--forest) 76%, #fff 24%); }
.route-card .word-slot.ruins { background: color-mix(in srgb, var(--ruins) 74%, #fff 26%); }
.route-card .word-slot.goal {
  background: color-mix(in srgb, var(--goal) 82%, #fff 18%);
  color: var(--goal-ink);
  text-shadow: none;
}
.route-card .word-slot.unused {
  visibility: hidden;
  background: transparent;
  border: 0;
  color: transparent;
}

[data-theme="dark"] .route-card .word-slot.unused {
  background: transparent;
  border-color: transparent;
}

.history-list {
  display: grid;
  gap: 3px;
  margin-top: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 246, 0.42);
}

[data-theme="dark"] .history-list {
  background: rgba(255, 255, 255, 0.035);
}

.history-empty {
  margin: 0;
  color: color-mix(in srgb, var(--soft) 88%, var(--ink) 12%);
  font-size: 11px;
  font-weight: 650;
}

.guess-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
}

.history-card .guess-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 27px;
  border-radius: 8px;
  font: 950 16px/1 var(--font-game);
  text-align: center;
  letter-spacing: 0;
  text-transform: uppercase;
}

.history-card .guess-cell.hit {
  background: #4f9257;
  color: #fffdf6;
}

.history-card .guess-cell.near {
  background: rgba(94, 97, 88, 0.2);
  color: rgba(38, 41, 35, 0.72);
  border: 1px solid rgba(94, 97, 88, 0.24);
}

.history-card .guess-cell.miss {
  background: rgba(194, 67, 67, 0.16);
  color: #9f3030;
  border: 1px solid rgba(194, 67, 67, 0.26);
}

.history-card .guess-cell.unused {
  visibility: hidden;
  background: transparent;
  border: 0;
}

[data-theme="dark"] .history-card .guess-cell.near {
  background: rgba(231, 221, 182, 0.16);
  color: rgba(241, 234, 215, 0.76);
}

[data-theme="dark"] .history-card .guess-cell.miss {
  background: rgba(194, 67, 67, 0.22);
  color: #ff9a93;
}

[data-theme="dark"] .history-card .guess-cell.unused {
  background: transparent;
  border-color: transparent;
}

.message {
  min-height: 17px;
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  font-weight: 850;
}

.message:empty {
  display: none;
}

.site-footer {
  padding: 4px 8px 0;
  color: color-mix(in srgb, var(--soft) 82%, var(--ink) 18%);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
}

.play-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 6px;
  width: calc((min(24vw, 104px) * 3) + (min(1.2vw, 7px) * 2));
  max-width: 100%;
  justify-self: center;
  margin-top: 9px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#letterInput {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  background: rgba(255, 253, 246, 0.72);
  color: var(--ink);
  font: 850 15px/1 var(--font-game);
  text-transform: uppercase;
}

.play-controls .compact-control {
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding-inline: 0;
  font-size: 15px;
  font-weight: 950;
}

.undo-icon {
  display: block;
  width: 21px;
  height: 21px;
  fill: currentColor;
  transform: translateX(7px) scale(1.08);
  transform-origin: center;
}

#letterInput::placeholder {
  color: var(--soft);
  text-transform: none;
}

#letterInput:focus {
  outline: 2px solid color-mix(in srgb, var(--path) 78%, transparent);
  outline-offset: 2px;
}

[data-theme="dark"] #letterInput {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .play-controls {
  background: transparent;
  box-shadow: none;
}

button {
  cursor: pointer;
  align-self: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(236, 244, 203, 0.9);
  color: var(--ink);
  font: 850 11px/1 var(--font-game);
}

[data-theme="dark"] button {
  background: rgba(230, 198, 98, 0.18);
  color: var(--ink);
}

.theme-toggle {
  padding: 6px 10px;
  font-size: 10.5px;
}

.help-button {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 14px;
  font-weight: 950;
}

button:hover {
  border-color: rgba(154, 118, 39, 0.7);
  background: rgba(225, 239, 177, 0.96);
}

[data-theme="dark"] button:hover {
  background: rgba(230, 198, 98, 0.28);
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

#restart {
  justify-self: end;
  touch-action: manipulation;
}

.status-row button {
  white-space: nowrap;
}

.rules-strip .meadow { background: var(--meadow); }
.rules-strip .forest { background: var(--forest); }
.rules-strip .ruins { background: var(--ruins); }
.rules-strip .goal { background: var(--goal); }

.board-wrap {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: calc((min(24vw, 104px) * 3) + (min(1.2vw, 7px) * 2) + (min(1.8vw, 11px) * 2));
  justify-self: center;
  padding: min(1.8vw, 11px);
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: rgba(255, 253, 246, 0.68);
  box-shadow: none;
}

.board-wrap.alphabet-open {
  max-width: calc((min(24vw, 104px) * 3) + (min(1.2vw, 7px) * 2) + (min(1.8vw, 11px) * 2));
}

.board-wrap.alphabet-open .board-core {
  grid-template-columns: 1fr;
}

.board-wrap.alphabet-open .play-controls {
  width: 100%;
}

.board-wrap:not(.alphabet-open) .play-controls {
  justify-self: start;
}

[data-theme="dark"] .board-wrap {
  background: rgba(24, 33, 25, 0.7);
}

.board-core {
  display: grid;
  grid-template-columns: auto auto;
  align-items: start;
  justify-content: center;
  gap: 9px;
  width: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, min(24vw, 104px));
  grid-template-rows: repeat(3, min(24vw, 104px));
  gap: min(1.2vw, 7px);
  width: auto;
  justify-self: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  touch-action: none;
  user-select: none;
}

.alphabet-panel {
  width: 100%;
  box-sizing: border-box;
  display: grid;
  align-content: start;
  gap: 0;
  align-self: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 253, 246, 0.48);
}

.alphabet-panel[hidden] {
  display: none;
}

[data-theme="dark"] .alphabet-panel {
  background: rgba(255, 255, 255, 0.035);
}

.alphabet-panel > span {
  display: none;
}

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 4px;
}

.alphabet-letter {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 25px;
  border: 1px solid rgba(89, 103, 66, 0.18);
  border-radius: 8px;
  background: var(--alphabet-unused);
  color: color-mix(in srgb, var(--ink) 82%, var(--muted) 18%);
  font: 950 14px/1 var(--font-game);
}

.alphabet-letter.hit {
  background: #4f9257;
  color: #fffdf6;
}

.alphabet-letter.near {
  background: rgba(94, 97, 88, 0.24);
  color: color-mix(in srgb, var(--ink) 86%, var(--muted) 14%);
  border-color: rgba(94, 97, 88, 0.28);
}

.alphabet-letter.miss {
  background: rgba(194, 67, 67, 0.16);
  color: #9f3030;
  border-color: rgba(194, 67, 67, 0.28);
}

[data-theme="dark"] .alphabet-letter.unused {
  color: rgba(241, 234, 215, 0.78);
  border-color: rgba(231, 221, 182, 0.13);
}

[data-theme="dark"] .alphabet-letter.near {
  color: rgba(241, 234, 215, 0.76);
}

[data-theme="dark"] .alphabet-letter.miss {
  background: rgba(194, 67, 67, 0.22);
  color: #ff9a93;
}

[data-theme="dark"] .board {
  background: transparent;
  box-shadow: none;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(18, 24, 17, 0.9);
  font: 850 28px/1 var(--font-game);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.08);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
  touch-action: none;
  user-select: none;
}

.tile.meadow { background: var(--meadow); color: #eefaff; }
.tile.forest { background: var(--forest); color: #eef6df; }
.tile.ruins { background: var(--ruins); color: #fff3ff; }
.tile.goal {
  background: var(--goal);
  color: var(--goal-ink);
  text-shadow: none;
}

.tile.goal:empty::before {
  content: "";
  width: 9px;
  height: 9px;
  border: 2px solid color-mix(in srgb, var(--ink) 48%, transparent);
  border-radius: 50%;
  opacity: 0.5;
}

.tile.player {
  transform: translateY(-2px);
  filter: brightness(1.07);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.14),
    0 0 0 2px var(--path),
    0 10px 24px rgba(90, 73, 30, 0.16);
}

.tile.visited {
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.12),
    0 0 0 2px var(--path),
    0 0 16px rgba(247, 217, 108, 0.34);
}

.tile.visited::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid rgba(255, 248, 184, 0.24);
  border-radius: 11px;
  pointer-events: none;
}

.tile.locked {
  opacity: 0.82;
}

.tutorial {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 24, 18, 0.38);
  backdrop-filter: blur(5px);
}

.tutorial[hidden] {
  display: none;
}

.tutorial-card {
  width: min(430px, calc(100vw - 28px));
  max-height: calc(100dvh - 44px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 72px rgba(44, 35, 18, 0.26);
}

[data-theme="dark"] .tutorial-card {
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.48);
}

.tutorial-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tutorial h2 {
  margin: -6px 0 0;
  font-size: 24px;
  line-height: 1;
}

.tutorial-step {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.tutorial-step[hidden] {
  display: none;
}

.tutorial-step p {
  margin: 0;
  color: color-mix(in srgb, var(--ink) 88%, var(--muted) 12%);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.tutorial-step small {
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.tutorial-playthrough {
  --loop: 13s;
  display: grid;
  gap: 7px;
}

.tutorial-demo {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.62);
}

[data-theme="dark"] .tutorial-demo {
  background: rgba(255, 255, 255, 0.04);
}

.tutorial-demo > b {
  min-height: 23px;
  color: color-mix(in srgb, var(--ink) 90%, var(--muted) 10%);
  font-size: 16px;
  line-height: 1.2;
}

.tutorial-demo > b.caption-enter {
  animation: tutorial-caption-enter 620ms ease both;
}

@keyframes tutorial-caption-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.demo-board {
  width: 174px;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 246, 0.58);
}

[data-theme="dark"] .demo-board {
  background: rgba(255, 255, 255, 0.035);
}

.demo-board span {
  display: grid;
  place-items: center;
  height: 50px;
  border-radius: 10px;
  color: #fffdf6;
  font: 950 18px/1 var(--font-game);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.demo-board .meadow { background: var(--meadow); }
.demo-board .forest { background: var(--forest); }
.demo-board .ruins { background: var(--ruins); }
.demo-board .goal {
  background: var(--goal);
  color: var(--goal-ink);
}

.demo-board .demo-path {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 0 0 3px var(--path), inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.tutorial-demo small {
  color: var(--soft);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 1;
  text-transform: uppercase;
}

.demo-word,
.demo-result {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
}

.demo-word span,
.demo-result span {
  display: grid;
  place-items: center;
  height: 24px;
  border-radius: 7px;
  font: 950 12px/1 var(--font-game);
}

.demo-word span {
  background: rgba(246, 239, 217, 0.78);
  color: var(--ink);
}

.demo-word .meadow {
  background: color-mix(in srgb, var(--meadow) 72%, #fff 28%);
}

.demo-word .forest {
  background: color-mix(in srgb, var(--forest) 76%, #fff 24%);
}

.demo-word .ruins {
  background: color-mix(in srgb, var(--ruins) 74%, #fff 26%);
}

.demo-word .goal {
  background: color-mix(in srgb, var(--goal) 82%, #fff 18%);
  color: var(--goal-ink);
}

.demo-word .empty,
.demo-result .empty {
  background: rgba(246, 239, 217, 0.42);
  border: 1px dashed rgba(89, 103, 66, 0.16);
  color: transparent;
}

[data-theme="dark"] .demo-word .empty,
[data-theme="dark"] .demo-result .empty {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(231, 221, 182, 0.12);
}

.demo-history {
  min-height: 24px;
  display: grid;
  gap: 4px;
}

.demo-result .hit {
  background: #4f9257;
  color: #fffdf6;
}

.demo-result .near {
  background: rgba(94, 97, 88, 0.2);
  color: rgba(38, 41, 35, 0.72);
  border: 1px solid rgba(94, 97, 88, 0.24);
}

.demo-result .miss {
  background: rgba(194, 67, 67, 0.16);
  color: #9f3030;
  border: 1px solid rgba(194, 67, 67, 0.26);
}

[data-theme="dark"] .demo-result .near {
  color: rgba(241, 234, 215, 0.76);
}

[data-theme="dark"] .demo-result .miss {
  color: #ff9a93;
}

.demo-win {
  min-height: 15px;
  color: var(--gold);
  font-size: 13px;
  line-height: 1;
}

.play-attempt {
  display: grid;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 246, 0.62);
}

[data-theme="dark"] .play-attempt {
  background: rgba(255, 255, 255, 0.04);
}

.play-attempt > b {
  color: color-mix(in srgb, var(--ink) 90%, var(--muted) 10%);
  font-size: 12px;
  line-height: 1.15;
}

.play-grid {
  width: 138px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 246, 0.58);
}

[data-theme="dark"] .play-grid {
  background: rgba(255, 255, 255, 0.035);
}

.play-grid span {
  position: relative;
  display: grid;
  place-items: center;
  height: 38px;
  border-radius: 8px;
  color: #fffdf6;
  font: 950 15px/1 var(--font-game);
}

.play-grid .meadow { background: var(--meadow); }
.play-grid .forest { background: var(--forest); }
.play-grid .ruins { background: var(--ruins); }
.play-grid .goal {
  background: var(--goal);
  color: var(--goal-ink);
}

.play-path {
  animation: play-path-highlight var(--loop) ease-in-out infinite both;
  animation-delay: calc(var(--d) + (var(--i) * 0.16s));
}

.play-path em {
  opacity: 0;
  transform: translateY(3px);
  font-style: normal;
  animation: play-letter-type var(--loop) ease-in-out infinite both;
  animation-delay: calc(var(--d) + 1.05s + (var(--i) * 0.1s));
}

.play-word,
.play-result {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.play-word.nine,
.play-result.nine {
  grid-template-columns: repeat(9, 1fr);
}

.play-word span,
.play-result span {
  display: grid;
  place-items: center;
  height: 21px;
  border-radius: 6px;
  font: 950 11px/1 var(--font-game);
}

.play-word span {
  opacity: 0;
  transform: translateY(3px);
  background: color-mix(in srgb, var(--forest) 72%, #fff 28%);
  color: var(--ink);
  animation: play-letter-type var(--loop) ease-in-out infinite both;
  animation-delay: calc(var(--d) + 1.05s + (var(--i) * 0.1s));
}

.play-result {
  opacity: 0;
  transform: translateY(5px);
  animation: play-result-show var(--loop) ease-in-out infinite both;
  animation-delay: calc(var(--d) + 2.15s);
}

.play-result.win {
  animation-delay: calc(var(--d) + 2.1s);
}

.play-result .hit {
  background: #4f9257;
  color: #fffdf6;
}

.play-result .near {
  background: rgba(94, 97, 88, 0.2);
  color: rgba(38, 41, 35, 0.72);
  border: 1px solid rgba(94, 97, 88, 0.24);
}

.play-result .miss {
  background: rgba(194, 67, 67, 0.16);
  color: #9f3030;
  border: 1px solid rgba(194, 67, 67, 0.26);
}

[data-theme="dark"] .play-result .near {
  color: rgba(241, 234, 215, 0.76);
}

[data-theme="dark"] .play-result .miss {
  color: #ff9a93;
}

.play-win {
  opacity: 0;
  justify-self: start;
  color: var(--gold);
  font-size: 13px;
  animation: play-win-show var(--loop) ease-in-out infinite both;
  animation-delay: calc(var(--d) + 2.75s);
}

@keyframes play-path-highlight {
  0%, 7% {
    transform: none;
    box-shadow: none;
  }
  10%, 92% {
    transform: translateY(-1px);
    box-shadow: 0 0 0 3px var(--path), inset 0 0 0 2px rgba(255, 255, 255, 0.18);
  }
  100% {
    transform: none;
    box-shadow: none;
  }
}

@keyframes play-letter-type {
  0%, 15% {
    opacity: 0;
    transform: translateY(3px);
  }
  20%, 92% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(3px);
  }
}

@keyframes play-result-show {
  0%, 18% {
    opacity: 0;
    transform: translateY(5px);
  }
  23%, 92% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes play-win-show {
  0%, 20% {
    opacity: 0;
    transform: translateY(4px);
  }
  25%, 92% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(4px);
  }
}

.tutorial-mini-board {
  width: min(210px, 100%);
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.58);
}

[data-theme="dark"] .tutorial-mini-board {
  background: rgba(255, 255, 255, 0.04);
}

.tutorial-mini-board span,
.tutorial-slots span,
.tutorial-feedback span {
  position: relative;
  display: grid;
  place-items: center;
  height: 52px;
  border-radius: 10px;
  color: #fffdf6;
  font: 950 18px/1 var(--font-game);
}

.tutorial-mini-board .meadow,
.tutorial-slots .meadow { background: var(--meadow); }
.tutorial-mini-board .forest,
.tutorial-slots .forest { background: var(--forest); }
.tutorial-mini-board .ruins,
.tutorial-slots .ruins { background: var(--ruins); }
.tutorial-mini-board .goal,
.tutorial-slots .goal {
  background: var(--goal);
  color: var(--goal-ink);
}

.tutorial-mini-board .path {
  box-shadow: 0 0 0 3px var(--path), inset 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.tutorial-mini-board .arrow-right::after,
.tutorial-mini-board .arrow-down::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 0;
  height: 0;
}

.tutorial-mini-board .arrow-right::after {
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid var(--path);
}

.tutorial-mini-board .arrow-down::after {
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid var(--path);
}

.tutorial-slots,
.tutorial-feedback {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.tutorial-feedback .hit {
  background: #4f9257;
}

.tutorial-feedback .near {
  background: rgba(94, 97, 88, 0.28);
  color: color-mix(in srgb, var(--ink) 86%, var(--muted) 14%);
  border: 1px solid rgba(94, 97, 88, 0.26);
}

.tutorial-feedback .miss {
  background: rgba(194, 67, 67, 0.18);
  color: #9f3030;
  border: 1px solid rgba(194, 67, 67, 0.28);
}

[data-theme="dark"] .tutorial-feedback .near {
  color: rgba(241, 234, 215, 0.78);
}

[data-theme="dark"] .tutorial-feedback .miss {
  color: #ff9a93;
}

.tutorial-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.tutorial-actions button[hidden] {
  display: none;
}

#nextTutorial {
  margin-left: auto;
}

.end-dialog {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 236, 156, 0.34), transparent 34%),
    rgba(29, 33, 24, 0.34);
  backdrop-filter: blur(7px);
}

.end-dialog[hidden] {
  display: none;
}

.end-card {
  position: relative;
  width: min(410px, calc(100vw - 30px));
  overflow: hidden;
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 26px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 253, 242, 0.96), rgba(255, 247, 218, 0.92));
  color: var(--ink);
  text-align: center;
  box-shadow: 0 24px 70px rgba(112, 86, 35, 0.2);
}

[data-theme="dark"] .end-card {
  background:
    linear-gradient(145deg, rgba(26, 38, 30, 0.98), rgba(18, 28, 23, 0.96));
  box-shadow: 0 24px 74px rgba(0, 0, 0, 0.42);
}

.sunburst {
  display: none;
}

.end-dialog.success .sunburst {
  display: none;
}

.end-dialog.failure .end-card {
  background:
    linear-gradient(145deg, rgba(255, 253, 242, 0.98), rgba(244, 238, 219, 0.94));
}

[data-theme="dark"] .end-dialog.failure .end-card {
  background:
    linear-gradient(145deg, rgba(28, 34, 29, 0.98), rgba(18, 25, 21, 0.96));
}

@keyframes sun-turn {
  to { transform: rotate(1turn); }
}

.end-kicker,
.end-card h2,
.end-word,
.end-text,
.end-actions {
  position: relative;
  z-index: 1;
}

.end-kicker {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.end-card h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

.end-word {
  --end-word-length: 9;
  width: min(100%, max-content);
  min-height: 48px;
  display: grid;
  grid-template-columns: repeat(var(--end-word-length), minmax(0, 38px));
  gap: clamp(3px, 1.2vw, 5px);
  justify-content: center;
}

.end-letter {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  color: #f9f5e8;
  font-size: clamp(15px, 5.1vw, 22px);
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
}

.end-letter.meadow {
  background: var(--meadow);
}

.end-letter.forest {
  background: var(--forest);
}

.end-text {
  display: grid;
  gap: 5px;
}

.end-text p {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
  line-height: 1.2;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 2px;
}

.tutorial-example,
.tutorial-replay {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.example-board,
.replay-board {
  width: min(230px, 100%);
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.6);
}

[data-theme="dark"] .example-board,
[data-theme="dark"] .replay-board {
  background: rgba(255, 255, 255, 0.04);
}

.example-board span,
.replay-board span {
  display: grid;
  place-items: center;
  height: 58px;
  border-radius: 10px;
  color: #fffdf6;
  font: 950 20px/1 var(--font-game);
}

.example-board .meadow,
.replay-board .meadow { background: var(--meadow); }
.example-board .forest,
.replay-board .forest { background: var(--forest); }
.example-board .ruins,
.replay-board .ruins { background: var(--ruins); }
.example-board .goal,
.replay-board .goal {
  background: var(--goal);
  color: var(--goal-ink);
}

.example-board .path,
.replay-board .replay-path {
  box-shadow: 0 0 0 3px var(--path), inset 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.replay-board .replay-path {
  opacity: 0.45;
  animation: replay-path-tile 7.4s ease-in-out infinite both;
  animation-delay: calc(var(--i) * 0.24s);
}

.example-panel,
.replay-panel {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 246, 0.62);
}

[data-theme="dark"] .example-panel,
[data-theme="dark"] .replay-panel {
  background: rgba(255, 255, 255, 0.04);
}

.example-stats,
.replay-stats {
  display: flex;
  gap: 8px;
}

.example-stats span,
.replay-stats span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.example-stats b,
.replay-stats b {
  color: var(--ink);
  font-size: 15px;
}

.example-panel small,
.replay-panel small {
  color: var(--soft);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.example-word,
.example-guesses div,
.replay-word,
.replay-guesses div {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
}

.replay-word {
  grid-template-columns: repeat(5, 1fr);
}

.replay-guesses div {
  grid-template-columns: repeat(5, 1fr);
}

.example-word span,
.example-guesses span,
.replay-word span,
.replay-guesses span {
  display: grid;
  place-items: center;
  height: 25px;
  border-radius: 7px;
  font: 950 13px/1 var(--font-game);
}

.example-word span,
.replay-word span {
  background: color-mix(in srgb, var(--forest) 76%, #fff 24%);
  color: var(--ink);
}

.replay-word span {
  opacity: 0;
  transform: translateY(4px);
  animation: replay-letter-in 7.4s ease-in-out infinite both;
  animation-delay: calc(1.05s + (var(--i) * 0.12s));
}

.example-guesses,
.replay-guesses {
  display: grid;
  gap: 4px;
}

.replay-guess {
  opacity: 0;
  transform: translateY(5px);
  animation: replay-guess-in 7.4s ease-in-out infinite both;
  animation-delay: var(--delay);
}

.example-guesses .hit,
.replay-guesses .hit { background: #4f9257; color: #fffdf6; }
.example-guesses .near,
.replay-guesses .near {
  background: rgba(94, 97, 88, 0.2);
  color: rgba(38, 41, 35, 0.72);
  border: 1px solid rgba(94, 97, 88, 0.24);
}
.example-guesses .miss,
.replay-guesses .miss {
  background: rgba(194, 67, 67, 0.16);
  color: #9f3030;
  border: 1px solid rgba(194, 67, 67, 0.26);
}

[data-theme="dark"] .example-guesses .near,
[data-theme="dark"] .replay-guesses .near {
  color: rgba(241, 234, 215, 0.76);
}

[data-theme="dark"] .example-guesses .miss,
[data-theme="dark"] .replay-guesses .miss {
  color: #ff9a93;
}

@keyframes replay-path-tile {
  0%, 7% {
    opacity: 0.45;
    transform: none;
    box-shadow: none;
  }
  12%, 82% {
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: 0 0 0 3px var(--path), inset 0 0 0 3px rgba(255, 255, 255, 0.18);
  }
  100% {
    opacity: 0.45;
    transform: none;
    box-shadow: none;
  }
}

@keyframes replay-letter-in {
  0%, 13% {
    opacity: 0;
    transform: translateY(4px);
  }
  18%, 82% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes replay-guess-in {
  0%, 8% {
    opacity: 0;
    transform: translateY(5px);
  }
  15%, 82% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .play-path,
  .play-path em,
  .play-word span,
  .play-result,
  .play-win,
  .tutorial-demo > b.caption-enter,
  .replay-board .replay-path,
  .replay-word span,
  .replay-guess {
    opacity: 1;
    transform: none;
    animation: none;
  }
}

@media (max-width: 900px) {
  body {
    place-items: start center;
    padding: 0;
  }

  .shell { gap: 6px; }

}

@media (max-width: 520px) {
  .info-row {
    align-items: center;
    gap: 8px;
  }

  .top-actions {
    gap: 6px;
  }

  .rules-strip {
    gap: 4px;
  }

  .rules-strip div {
    padding-inline: 3px;
  }

  .rules-strip span {
    font-size: 8.5px;
  }

  .board-core {
    grid-template-columns: 1fr;
  }

  .alphabet-panel {
    width: 100%;
    align-self: auto;
  }

  .alphabet-grid {
    grid-template-columns: repeat(13, 1fr);
  }

  .alphabet-letter {
    height: 22px;
    border-radius: 7px;
    font-size: 11px;
  }

  .status-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .status-row div {
    min-width: 0;
  }

  .status-row button {
    justify-self: auto;
  }
}

@media (max-height: 760px) {
  .top-panel,
  .bottom-panel {
    padding: 7px;
  }

  .intro {
    font-size: 12px;
  }

  .board-wrap:not(.alphabet-open) {
    max-width: calc((min(22vw, 88px) * 3) + (min(1.2vw, 7px) * 2) + (min(1.8vw, 11px) * 2));
  }

  .board-wrap.alphabet-open {
    max-width: calc((min(22vw, 88px) * 3) + (min(1.2vw, 7px) * 2) + (min(1.8vw, 11px) * 2));
  }

  .board {
    grid-template-columns: repeat(3, min(22vw, 88px));
    grid-template-rows: repeat(3, min(22vw, 88px));
  }

  .play-controls {
    width: calc((min(22vw, 88px) * 3) + (min(1.2vw, 7px) * 2));
  }

  .board-wrap.alphabet-open .play-controls {
    width: 100%;
  }

  .tile {
    font-size: 24px;
  }

  .route-card .word-slot {
    height: 30px;
    font-size: 17px;
  }

  .history-card .guess-cell {
    height: 25px;
    font-size: 15px;
  }

  .history-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 280px) {
  .tutorial-card {
    width: calc(100vw - 20px);
    padding: 14px;
  }

  .tutorial-mini-board,
  .example-board,
  .replay-board {
    width: 190px;
    gap: 5px;
    padding: 7px;
  }

  .tutorial-mini-board span,
  .example-board span,
  .replay-board span {
    height: 45px;
  }

  .end-dialog {
    padding: 10px;
  }

  .end-card {
    width: calc(100vw - 20px);
    padding: 22px 12px 16px;
    border-radius: 22px;
  }

  .end-word {
    min-height: 34px;
  }

  .end-letter {
    border-radius: 8px;
  }

  .end-card h2 {
    font-size: 29px;
  }

  .end-text p {
    font-size: 15px;
  }
}
