:root {
  color-scheme: light;
  --ink: #22302b;
  --ink-soft: #52615a;
  --paper: #f4efe4;
  --paper-deep: #e8dcc9;
  --wood: #8d6f4e;
  --wood-dark: #5a432f;
  --wood-light: #b89163;
  --moss: #69745c;
  --moss-dark: #3f4b3f;
  --indigo: #38475a;
  --cinnabar: #a94f38;
  --stone: #bcc0b1;
  --line: rgba(42, 48, 42, 0.18);
  --shadow: rgba(32, 24, 15, 0.24);
  --tile-size: 92px;
  --gap: 12px;
  --radius: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 12%, rgba(188, 192, 177, 0.35), transparent 28rem),
    radial-gradient(circle at 82% 76%, rgba(169, 79, 56, 0.14), transparent 22rem),
    linear-gradient(90deg, rgba(255, 255, 255, 0.10) 0 1px, transparent 1px 72px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 54px),
    repeating-linear-gradient(
      94deg,
      #74583d 0,
      #8d6f4e 10px,
      #967854 18px,
      #6d5138 30px,
      #a27f58 44px,
      #73563b 58px
    );
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(120deg, rgba(244, 239, 228, 0.48), rgba(244, 239, 228, 0.12) 45%, rgba(34, 48, 43, 0.22)),
    radial-gradient(circle at 50% 0, rgba(244, 239, 228, 0.34), transparent 34rem);
  mix-blend-mode: screen;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid rgba(41, 45, 40, 0.18);
  border-radius: var(--radius);
  color: #f9f4e8;
  background: linear-gradient(180deg, var(--moss), var(--moss-dark));
  box-shadow: 0 9px 20px rgba(35, 42, 35, 0.18);
  cursor: pointer;
  min-height: 44px;
  padding: 0 16px;
  transition:
    transform 160ms var(--ease),
    box-shadow 160ms var(--ease),
    border-color 160ms var(--ease),
    opacity 160ms var(--ease);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(35, 42, 35, 0.22);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(169, 79, 56, 0.48);
  outline-offset: 3px;
}

.secondary-action,
.icon-button {
  color: var(--ink);
  background: linear-gradient(180deg, rgba(244, 239, 228, 0.86), rgba(226, 216, 199, 0.9));
  box-shadow: 0 8px 18px rgba(55, 43, 31, 0.10);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-weight: 800;
}

.garden-shell {
  min-height: 100vh;
  padding: 22px;
  display: grid;
  place-items: center;
}

.garden-stage {
  width: min(1180px, 100%);
  min-height: min(820px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 18px;
  border: 1px solid rgba(244, 239, 228, 0.28);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(244, 239, 228, 0.84), rgba(232, 220, 201, 0.72)),
    repeating-linear-gradient(88deg, rgba(90, 67, 47, 0.08) 0 2px, transparent 2px 11px);
  box-shadow:
    0 24px 70px rgba(20, 18, 16, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px);
}

.garden-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
}

.game-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-link {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 13px;
  background: rgba(244, 239, 228, 0.68);
}

.kicker,
.panel-label,
.quiet-note {
  display: block;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 2.05rem;
  line-height: 1;
  letter-spacing: 0;
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: 18px;
  align-items: stretch;
}

.board-zone {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  place-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.36), transparent 26rem),
    linear-gradient(180deg, rgba(232, 220, 201, 0.70), rgba(213, 199, 176, 0.48));
  border: 1px solid rgba(50, 42, 34, 0.13);
}

.garden-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(244, 239, 228, 0.74);
  border: 1px solid var(--line);
  text-align: center;
}

.garden-status.is-good {
  color: #f7f1e6;
  background: rgba(63, 75, 63, 0.92);
}

.garden-status.is-bad {
  color: #fff7ef;
  background: rgba(169, 79, 56, 0.92);
}

.board-frame {
  position: relative;
  inline-size: calc(var(--tile-size) * 4 + var(--gap) * 5 + 34px);
  block-size: calc(var(--tile-size) * 4 + var(--gap) * 5 + 34px);
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 35%),
    repeating-linear-gradient(92deg, var(--wood-dark) 0 10px, var(--wood) 10px 24px, var(--wood-light) 24px 32px);
  box-shadow:
    0 24px 50px rgba(54, 38, 24, 0.26),
    inset 0 0 0 11px rgba(66, 47, 31, 0.32),
    inset 0 0 0 13px rgba(245, 236, 219, 0.18);
  perspective: 900px;
}

.board-compass {
  position: absolute;
  inset: 9px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  color: rgba(244, 239, 228, 0.58);
  font-size: 0.68rem;
  font-weight: 800;
  pointer-events: none;
}

.board-compass span:nth-child(1) {
  grid-column: 2;
  justify-self: center;
}

.board-compass span:nth-child(2) {
  grid-column: 3;
  grid-row: 2;
  align-self: center;
  justify-self: end;
}

.board-compass span:nth-child(3) {
  grid-column: 2;
  grid-row: 3;
  align-self: end;
  justify-self: center;
}

.board-compass span:nth-child(4) {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
}

.letter-board {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, var(--tile-size));
  grid-template-rows: repeat(4, var(--tile-size));
  gap: var(--gap);
  padding: var(--gap);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(64, 45, 29, 0.52), rgba(44, 32, 23, 0.56)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.10) 0 1px, transparent 1px 12px);
  transform-origin: center;
  transition: transform 900ms var(--ease), filter 900ms var(--ease);
}

.letter-board.is-hidden {
  filter: blur(1.5px) saturate(0.82);
}

.letter-board.is-flipped {
  transform: rotate(180deg);
}

.letter-board.is-turning {
  filter: saturate(0.82) brightness(0.96);
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 7px;
  border: 1px solid rgba(93, 68, 45, 0.34);
  color: var(--ink);
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.76), transparent 1.7rem),
    linear-gradient(145deg, #f7f0df, #d9c6a7 58%, #b89463);
  box-shadow:
    0 9px 0 #735433,
    0 14px 22px rgba(31, 23, 16, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    inset 0 -5px 12px rgba(94, 68, 43, 0.18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.45rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.tile::after {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(58, 43, 30, 0.13);
  border-radius: 5px;
  content: "";
  pointer-events: none;
}

.tile small {
  font-size: 1.36rem;
}

.tile.is-selected {
  color: #fff9ec;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.34), transparent 1.7rem),
    linear-gradient(145deg, #738063, #465542);
  box-shadow:
    0 7px 0 #303d31,
    0 13px 22px rgba(31, 39, 31, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.tile.is-path {
  animation: tilePulse 780ms var(--ease);
}

.tile.is-wrong {
  animation: tileShake 320ms ease-out;
}

.tile--hidden {
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.36), transparent 2rem),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0 4px, transparent 4px 12px),
    linear-gradient(145deg, #c7ae86, #8b6843 62%, #674930);
}

.tile-back-mark {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(245, 236, 219, 0.36);
  box-shadow:
    inset 0 0 0 7px rgba(55, 39, 26, 0.13),
    0 1px 0 rgba(255, 255, 255, 0.22);
}

.tile-face {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  transition: transform 900ms var(--ease);
}

.letter-board.keep-letters-upright.is-flipped .tile-face {
  transform: rotate(180deg);
}

.tile-letter {
  display: block;
}

.tile-orientation-mark {
  position: absolute;
  left: 50%;
  bottom: 13px;
  width: 24px;
  height: 4px;
  border-radius: 999px;
  background: rgba(34, 48, 43, 0.72);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  transform: translateX(-50%);
}

.tile.is-selected .tile-orientation-mark {
  background: rgba(255, 249, 236, 0.82);
  box-shadow: 0 1px 0 rgba(31, 39, 31, 0.34);
}

.word-entry {
  width: min(560px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

.word-entry input {
  min-width: 0;
  min-height: 48px;
  border: 1px solid rgba(52, 48, 40, 0.18);
  border-radius: var(--radius);
  padding: 0 16px;
  color: var(--ink);
  background: rgba(255, 250, 238, 0.84);
  box-shadow: inset 0 2px 6px rgba(65, 50, 34, 0.08);
}

.control-rail {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
}

.clock-block,
.score-grid,
.actions-panel,
.leaderboard-panel,
.found-panel {
  border: 1px solid rgba(44, 39, 32, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(248, 241, 228, 0.86), rgba(231, 220, 202, 0.80)),
    repeating-linear-gradient(88deg, rgba(90, 67, 47, 0.06) 0 2px, transparent 2px 12px);
  box-shadow: 0 12px 26px rgba(42, 31, 20, 0.12);
}

.clock-block {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.wood-clock {
  --progress: 0deg;
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #f5ead5 0 46%, transparent 47%),
    conic-gradient(var(--cinnabar) var(--progress), rgba(79, 70, 58, 0.18) 0),
    repeating-conic-gradient(from 2deg, rgba(80, 55, 33, 0.20) 0 7deg, rgba(255, 255, 255, 0.10) 7deg 14deg),
    linear-gradient(135deg, var(--wood-light), var(--wood-dark));
  box-shadow:
    inset 0 0 0 7px rgba(84, 59, 37, 0.72),
    inset 0 0 0 10px rgba(250, 241, 224, 0.34),
    0 10px 18px rgba(54, 38, 24, 0.18);
}

.clock-hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 3px;
  border-radius: 999px;
  background: var(--ink);
  transform-origin: bottom center;
}

.clock-hand--minute {
  height: 25px;
  transform: translateX(-50%) rotate(0deg);
  opacity: 0.48;
}

.clock-hand--second {
  height: 31px;
  background: var(--cinnabar);
  transform: translateX(-50%) rotate(0deg);
}

.clock-pin {
  position: absolute;
  inset: 34px;
  border-radius: 50%;
  background: var(--ink);
}

.time-readout {
  display: block;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: rgba(44, 39, 32, 0.14);
}

.score-grid > div {
  min-width: 0;
  padding: 13px;
  background:
    linear-gradient(180deg, rgba(248, 241, 228, 0.92), rgba(231, 220, 202, 0.86));
}

.score-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.42rem;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

#goBtn,
#newGameBtn,
#themeBtn {
  grid-column: 1 / -1;
}

.leaderboard-panel {
  min-height: 0;
  padding: 14px;
}

.leaderboard-heading,
.leaderboard-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-heading {
  margin-bottom: 8px;
}

.leaderboard-heading h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.leaderboard-heading span,
.leaderboard-empty,
.leaderboard-list small {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.leaderboard-toggle {
  min-height: 0;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  box-shadow: none;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: underline dotted rgba(42, 48, 42, 0.4);
  text-underline-offset: 3px;
  transition: color 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease);
}

.leaderboard-toggle:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  color: var(--cinnabar);
  border-color: var(--line);
  background: rgba(169, 79, 56, 0.08);
}

.leaderboard-toggle[aria-expanded="true"] {
  color: var(--cinnabar);
  border-color: var(--line);
  background: rgba(169, 79, 56, 0.1);
  text-decoration: none;
}

.leaderboard-list {
  margin: 0;
  padding-left: 22px;
}

.leaderboard-list li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(44, 39, 32, 0.08);
  color: var(--ink);
  font-weight: 800;
}

.leaderboard-entry-score {
  color: var(--cinnabar);
  font-variant-numeric: tabular-nums;
}

.leaderboard-entry-label,
.leaderboard-list small {
  display: block;
}

.leaderboard-list small {
  margin-top: 1px;
  font-weight: 700;
}

.leaderboard-empty {
  margin: 0;
}

.found-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.found-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.found-heading h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.found-heading span {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.found-list {
  min-height: 0;
  margin: 0;
  padding: 10px 14px 14px 34px;
  overflow: auto;
}

.found-list li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(44, 39, 32, 0.08);
  color: var(--ink);
  font-weight: 700;
}

.found-list span {
  float: right;
  color: var(--cinnabar);
  font-weight: 800;
}

.rules-modal,
.end-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(32, 26, 20, 0.54);
  backdrop-filter: blur(8px);
}

.hidden {
  display: none !important;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.34);
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(248, 242, 231, 0.98), rgba(228, 216, 196, 0.98)),
    repeating-linear-gradient(90deg, rgba(101, 82, 61, 0.05) 0 2px, transparent 2px 12px);
  box-shadow: 0 30px 70px rgba(10, 8, 6, 0.42);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-header h2,
.end-panel h2 {
  font-size: 1.8rem;
  line-height: 1.1;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rules-grid article,
.missed-block {
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 250, 239, 0.56);
  border: 1px solid var(--line);
}

.rules-grid h3,
.missed-block h3 {
  margin-bottom: 7px;
  color: var(--moss-dark);
  font-size: 1rem;
}

.rules-grid p,
.dictionary-note {
  color: var(--ink-soft);
  line-height: 1.55;
}

.dictionary-note {
  margin-top: 14px;
}

.end-panel {
  display: grid;
  gap: 16px;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.end-stats > div {
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 250, 239, 0.64);
  border: 1px solid var(--line);
}

.end-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.missed-block ul {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--ink-soft);
}

.score-save-block {
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 250, 239, 0.56);
  border: 1px solid var(--line);
}

.score-save-block h3 {
  margin-bottom: 10px;
  color: var(--moss-dark);
  font-size: 1rem;
}

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

.score-save-row input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid rgba(52, 48, 40, 0.18);
  border-radius: var(--radius);
  padding: 0 13px;
  color: var(--ink);
  background: rgba(255, 250, 238, 0.84);
  box-shadow: inset 0 2px 6px rgba(65, 50, 34, 0.08);
}

.score-save-block .quiet-note {
  margin-top: 8px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.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;
}

@keyframes tilePulse {
  0% {
    transform: translateY(0);
  }
  38% {
    transform: translateY(-5px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes tileShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

@media (max-width: 980px) {
  :root {
    --tile-size: 78px;
    --gap: 10px;
  }

  .garden-stage {
    min-height: calc(100vh - 24px);
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .control-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
  }

  .found-panel {
    grid-column: 1 / -1;
    min-height: 190px;
  }
}

@media (max-width: 620px) {
  :root {
    --tile-size: 62px;
    --gap: 8px;
  }

  .garden-shell {
    padding: 8px;
    place-items: start center;
  }

  .garden-stage {
    min-height: calc(100vh - 16px);
    padding: 11px;
    gap: 11px;
  }

  .garden-header {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .game-links {
    grid-column: 1 / -1;
  }

  .home-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 8px 11px;
    font-size: 0.78rem;
    line-height: 1;
  }

  h1 {
    font-size: 1.55rem;
  }

  .board-zone {
    padding: 10px;
  }

  .board-frame {
    inline-size: calc(var(--tile-size) * 4 + var(--gap) * 5 + 24px);
    block-size: calc(var(--tile-size) * 4 + var(--gap) * 5 + 24px);
  }

  .tile {
    font-size: 1.85rem;
  }

  .tile-orientation-mark {
    bottom: 9px;
    width: 18px;
    height: 3px;
  }

  .tile small {
    font-size: 1.05rem;
  }

  .word-entry {
    grid-template-columns: 1fr 92px;
  }

  .word-entry .secondary-action {
    grid-column: 1 / -1;
  }

  .control-rail {
    grid-template-columns: 1fr;
  }

  .clock-block {
    grid-template-columns: 72px 1fr;
  }

  .wood-clock {
    width: 66px;
    height: 66px;
  }

  .clock-hand--minute {
    height: 20px;
  }

  .clock-hand--second {
    height: 26px;
  }

  .clock-pin {
    inset: 29px;
  }

  .actions-panel {
    grid-template-columns: 1fr 1fr;
  }

  .score-save-row {
    grid-template-columns: 1fr;
  }

  .rules-grid,
  .end-stats {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ============================================================
   THEME SKINS
   Zen is the default (:root above). Space and Candy override
   the palette tokens plus the few signature multi-layer
   surfaces (backdrop, tiles, clock, panels, modals). Applied
   via [data-theme] on <html>. The reduced-motion block above
   already neutralizes the drift animations (1ms, 1 iteration).
   ============================================================ */

/* ---------------------- SPACE: cyber + cosmic vastness ---------------------- */
:root[data-theme="space"] {
  color-scheme: dark;
  --ink: #e8ecff;
  --ink-soft: #9aa6cf;
  --paper: #0a0e24;
  --paper-deep: #060917;
  --wood: #26305e;
  --wood-dark: #131a3d;
  --wood-light: #46538f;
  --moss: #4455c7;
  --moss-dark: #232a78;
  --indigo: #3a4a7a;
  --cinnabar: #ff5ca8;
  --stone: #2a3566;
  --line: rgba(150, 170, 255, 0.2);
  --shadow: rgba(0, 0, 0, 0.55);
}

:root[data-theme="space"] body {
  background:
    radial-gradient(circle at 22% 22%, rgba(120, 80, 220, 0.32), transparent 42%),
    radial-gradient(circle at 82% 76%, rgba(30, 140, 210, 0.26), transparent 46%),
    radial-gradient(circle at 60% 48%, rgba(90, 60, 180, 0.14), transparent 60%),
    linear-gradient(160deg, #0b1030 0%, #070a1c 62%, #04050f 100%);
  background-attachment: fixed;
}

:root[data-theme="space"] body::before {
  background-image:
    radial-gradient(1px 1px at 25% 30%, rgba(255, 255, 255, 0.95), transparent),
    radial-gradient(1px 1px at 70% 65%, rgba(210, 230, 255, 0.85), transparent),
    radial-gradient(1.5px 1.5px at 45% 85%, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(1px 1px at 85% 20%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1px 1px at 15% 72%, rgba(200, 220, 255, 0.75), transparent);
  background-size: 200px 200px, 260px 260px, 320px 320px, 170px 170px, 300px 300px;
  background-repeat: repeat;
  mix-blend-mode: screen;
  animation: zwgStarDrift 60s linear infinite;
}

@keyframes zwgStarDrift {
  from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  to { background-position: 200px 380px, -260px 300px, 320px -320px, 170px 220px, -300px 260px; }
}

:root[data-theme="space"] .garden-stage {
  border-color: rgba(140, 165, 255, 0.22);
  background:
    linear-gradient(180deg, rgba(22, 28, 66, 0.72), rgba(10, 14, 34, 0.74)),
    repeating-linear-gradient(88deg, rgba(120, 150, 255, 0.05) 0 2px, transparent 2px 12px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(160, 190, 255, 0.14);
}

:root[data-theme="space"] .board-zone {
  border-color: rgba(120, 150, 255, 0.18);
  background:
    radial-gradient(circle at 50% 18%, rgba(90, 130, 255, 0.16), transparent 26rem),
    linear-gradient(180deg, rgba(18, 24, 58, 0.55), rgba(9, 13, 32, 0.55));
}

:root[data-theme="space"] .letter-board {
  background:
    linear-gradient(180deg, rgba(12, 18, 48, 0.7), rgba(6, 10, 26, 0.75)),
    repeating-linear-gradient(90deg, rgba(90, 130, 255, 0.06) 0 1px, transparent 1px 12px);
}

:root[data-theme="space"] .tile {
  border-color: rgba(120, 160, 255, 0.4);
  color: #eaf2ff;
  background:
    radial-gradient(circle at 30% 22%, rgba(130, 210, 255, 0.55), transparent 1.7rem),
    linear-gradient(145deg, #2b3b7f, #1a2352 58%, #0f1538);
  box-shadow:
    0 9px 0 #0b1030,
    0 14px 22px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(150, 200, 255, 0.5),
    inset 0 -5px 12px rgba(10, 20, 60, 0.55),
    0 0 20px rgba(90, 150, 255, 0.28);
  text-shadow: 0 0 10px rgba(130, 190, 255, 0.55);
}

:root[data-theme="space"] .tile::after {
  border-color: rgba(150, 190, 255, 0.16);
}

:root[data-theme="space"] .tile.is-selected {
  color: #fff;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.45), transparent 1.7rem),
    linear-gradient(145deg, #ff6cb0, #b12e93);
  box-shadow:
    0 7px 0 #611a55,
    0 13px 22px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 0 24px rgba(255, 100, 180, 0.5);
  text-shadow: 0 0 10px rgba(255, 150, 210, 0.6);
}

:root[data-theme="space"] .tile--hidden {
  background:
    radial-gradient(circle at 50% 35%, rgba(150, 190, 255, 0.28), transparent 2rem),
    linear-gradient(145deg, #1b2452, #0d1230 62%, #080b22);
}

:root[data-theme="space"] .tile-back-mark {
  border-color: rgba(150, 190, 255, 0.4);
  box-shadow: inset 0 0 0 7px rgba(20, 30, 70, 0.5), 0 0 10px rgba(90, 150, 255, 0.3);
}

:root[data-theme="space"] .tile-orientation-mark {
  background: rgba(180, 210, 255, 0.7);
}

:root[data-theme="space"] .garden-status {
  border-color: rgba(120, 150, 255, 0.2);
  background: rgba(16, 22, 52, 0.8);
}

:root[data-theme="space"] .garden-status.is-good {
  color: #fff;
  background: #10785c;
  border-color: rgba(60, 200, 160, 0.5);
}

:root[data-theme="space"] .garden-status.is-bad {
  color: #fff;
  background: #b83066;
  border-color: rgba(255, 120, 160, 0.5);
}

:root[data-theme="space"] .home-link {
  background: rgba(16, 22, 52, 0.7);
}

:root[data-theme="space"] .word-entry input {
  border-color: rgba(120, 150, 255, 0.25);
  background: rgba(14, 20, 48, 0.85);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

:root[data-theme="space"] .clock-block,
:root[data-theme="space"] .score-grid,
:root[data-theme="space"] .actions-panel,
:root[data-theme="space"] .leaderboard-panel,
:root[data-theme="space"] .found-panel {
  border-color: rgba(120, 150, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(20, 26, 62, 0.72), rgba(11, 15, 38, 0.68)),
    repeating-linear-gradient(88deg, rgba(120, 150, 255, 0.05) 0 2px, transparent 2px 12px);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4);
}

:root[data-theme="space"] .score-grid {
  background: rgba(120, 150, 255, 0.14);
}

:root[data-theme="space"] .score-grid > div {
  background: linear-gradient(180deg, rgba(20, 26, 62, 0.85), rgba(12, 16, 40, 0.82));
}

:root[data-theme="space"] .secondary-action,
:root[data-theme="space"] .icon-button {
  color: #e8ecff;
  background: linear-gradient(180deg, rgba(40, 50, 100, 0.85), rgba(24, 30, 66, 0.9));
  border-color: rgba(130, 160, 255, 0.3);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

:root[data-theme="space"] .wood-clock {
  background:
    radial-gradient(circle at center, #0b1030 0 46%, transparent 47%),
    conic-gradient(var(--cinnabar) var(--progress), rgba(120, 150, 255, 0.16) 0),
    radial-gradient(circle at 32% 28%, rgba(130, 190, 255, 0.35), transparent 60%),
    linear-gradient(135deg, #2b3566, #10163a);
  box-shadow:
    inset 0 0 0 7px rgba(30, 40, 90, 0.7),
    inset 0 0 0 10px rgba(160, 190, 255, 0.18),
    0 10px 18px rgba(0, 0, 0, 0.4),
    0 0 22px rgba(90, 150, 255, 0.25);
}

:root[data-theme="space"] .leaderboard-list li,
:root[data-theme="space"] .found-list li {
  border-bottom-color: rgba(150, 170, 255, 0.12);
}

:root[data-theme="space"] .leaderboard-toggle {
  text-decoration-color: rgba(150, 170, 255, 0.4);
}

:root[data-theme="space"] .modal-panel {
  border-color: rgba(140, 170, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(24, 30, 68, 0.98), rgba(12, 16, 40, 0.98)),
    repeating-linear-gradient(90deg, rgba(120, 150, 255, 0.05) 0 2px, transparent 2px 12px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
}

:root[data-theme="space"] .rules-grid article,
:root[data-theme="space"] .missed-block,
:root[data-theme="space"] .score-save-block,
:root[data-theme="space"] .end-stats > div {
  background: rgba(30, 38, 82, 0.6);
  border-color: rgba(120, 150, 255, 0.2);
}

:root[data-theme="space"] .rules-grid h3,
:root[data-theme="space"] .missed-block h3,
:root[data-theme="space"] .score-save-block h3 {
  color: #7fdfff;
}

:root[data-theme="space"] .score-save-row input {
  background: rgba(14, 20, 48, 0.85);
  border-color: rgba(120, 150, 255, 0.25);
}

/* ---------------------- CANDY: bright, loud, sugar rush ---------------------- */
:root[data-theme="candy"] {
  --ink: #5a1e63;
  --ink-soft: #a5559f;
  --paper: #fff0f7;
  --paper-deep: #ffdcee;
  --wood: #ff8fc4;
  --wood-dark: #e14f9b;
  --wood-light: #ffd0e6;
  --moss: #ff5aa0;
  --moss-dark: #d63384;
  --indigo: #b23aa8;
  --cinnabar: #ff7a18;
  --stone: #ffd0e6;
  --line: rgba(196, 60, 140, 0.22);
  --shadow: rgba(150, 20, 90, 0.28);
}

:root[data-theme="candy"] body {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.5), transparent 40%),
    linear-gradient(150deg, #ff9ed2 0%, #ffd06b 40%, #7fe0d0 72%, #8fb6ff 100%);
  background-attachment: fixed;
}

:root[data-theme="candy"] body::before {
  background-image:
    radial-gradient(6px 6px at 20% 30%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(5px 5px at 70% 60%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(7px 7px at 45% 85%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(5px 5px at 85% 25%, rgba(255, 255, 255, 0.45), transparent);
  background-size: 220px 220px, 280px 280px, 200px 200px, 320px 320px;
  background-repeat: repeat;
  mix-blend-mode: soft-light;
  opacity: 0.9;
  animation: zwgDotDrift 40s linear infinite;
}

@keyframes zwgDotDrift {
  from { background-position: 0 0, 0 0, 0 0, 0 0; }
  to { background-position: 0 220px, 0 -280px, 0 200px, 0 -320px; }
}

:root[data-theme="candy"] .garden-stage {
  border-color: rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(180deg, rgba(255, 250, 253, 0.92), rgba(255, 228, 242, 0.86)),
    repeating-linear-gradient(88deg, rgba(255, 120, 190, 0.05) 0 2px, transparent 2px 12px);
  box-shadow: 0 24px 60px rgba(150, 30, 90, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

:root[data-theme="candy"] .board-zone {
  border-color: rgba(255, 120, 190, 0.25);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.6), transparent 26rem),
    linear-gradient(180deg, rgba(255, 214, 236, 0.8), rgba(255, 190, 224, 0.6));
}

:root[data-theme="candy"] .letter-board {
  background:
    linear-gradient(180deg, rgba(210, 60, 130, 0.55), rgba(150, 40, 105, 0.6)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 12px);
}

:root[data-theme="candy"] .tile {
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.95), transparent 2rem),
    linear-gradient(145deg, #ff86c6, #ff3d92 52%, #cf1a72);
  box-shadow:
    0 9px 0 #b21866,
    0 14px 22px rgba(150, 20, 80, 0.34),
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    inset 0 -6px 12px rgba(180, 20, 90, 0.3);
  text-shadow: 0 2px 3px rgba(150, 20, 80, 0.45);
}

:root[data-theme="candy"] .tile::after {
  border-color: rgba(255, 255, 255, 0.4);
}

:root[data-theme="candy"] .tile.is-selected {
  color: #093f39;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.95), transparent 2rem),
    linear-gradient(145deg, #8ff0d6, #34d6b4 52%, #12b492);
  box-shadow:
    0 7px 0 #0d8f74,
    0 13px 22px rgba(15, 120, 95, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

:root[data-theme="candy"] .tile--hidden {
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.7), transparent 2rem),
    linear-gradient(145deg, #ffd36e, #ff9e3d 62%, #ff7a1f);
}

:root[data-theme="candy"] .tile-back-mark {
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 7px rgba(200, 90, 20, 0.18), 0 1px 0 rgba(255, 255, 255, 0.5);
}

:root[data-theme="candy"] .garden-status {
  border-color: rgba(214, 51, 132, 0.25);
  background: rgba(255, 245, 250, 0.8);
}

:root[data-theme="candy"] .garden-status.is-good {
  color: #fff;
  background: #0a7654;
  border-color: rgba(10, 118, 84, 0.7);
}

:root[data-theme="candy"] .garden-status.is-bad {
  color: #fff;
  background: #c62860;
  border-color: rgba(198, 40, 96, 0.7);
}

:root[data-theme="candy"] .home-link {
  background: rgba(255, 245, 250, 0.75);
}

:root[data-theme="candy"] .word-entry input {
  border-color: rgba(214, 51, 132, 0.28);
  background: rgba(255, 250, 253, 0.92);
}

:root[data-theme="candy"] .clock-block,
:root[data-theme="candy"] .score-grid,
:root[data-theme="candy"] .actions-panel,
:root[data-theme="candy"] .leaderboard-panel,
:root[data-theme="candy"] .found-panel {
  border-color: rgba(255, 120, 190, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 250, 253, 0.94), rgba(255, 230, 244, 0.88)),
    repeating-linear-gradient(88deg, rgba(255, 120, 190, 0.05) 0 2px, transparent 2px 12px);
  box-shadow: 0 12px 26px rgba(150, 30, 90, 0.16);
}

:root[data-theme="candy"] .score-grid {
  background: rgba(196, 60, 140, 0.16);
}

:root[data-theme="candy"] .score-grid > div {
  background: linear-gradient(180deg, rgba(255, 250, 253, 0.95), rgba(255, 232, 245, 0.9));
}

:root[data-theme="candy"] .secondary-action,
:root[data-theme="candy"] .icon-button {
  color: #7a1f6b;
  background: linear-gradient(180deg, rgba(255, 245, 250, 0.95), rgba(255, 214, 235, 0.95));
  border-color: rgba(214, 51, 132, 0.3);
  box-shadow: 0 8px 18px rgba(150, 30, 90, 0.14);
}

:root[data-theme="candy"] .wood-clock {
  background:
    radial-gradient(circle at center, #fff 0 44%, transparent 45%),
    conic-gradient(var(--cinnabar) var(--progress), rgba(255, 150, 200, 0.35) 0),
    repeating-conic-gradient(from 0deg, #ff6fb0 0 18deg, #fff7fb 18deg 36deg),
    linear-gradient(135deg, #ff9ed2, #ff5aa0);
  box-shadow:
    inset 0 0 0 7px rgba(214, 51, 132, 0.55),
    inset 0 0 0 10px rgba(255, 255, 255, 0.5),
    0 10px 18px rgba(150, 30, 90, 0.2);
}

:root[data-theme="candy"] .modal-panel {
  border-color: rgba(255, 255, 255, 0.6);
  background:
    linear-gradient(180deg, rgba(255, 250, 253, 0.98), rgba(255, 224, 240, 0.98)),
    repeating-linear-gradient(90deg, rgba(255, 120, 190, 0.05) 0 2px, transparent 2px 12px);
}

:root[data-theme="candy"] .rules-grid article,
:root[data-theme="candy"] .missed-block,
:root[data-theme="candy"] .score-save-block,
:root[data-theme="candy"] .end-stats > div {
  background: rgba(255, 240, 248, 0.7);
}

:root[data-theme="candy"] .score-save-row input {
  background: rgba(255, 250, 253, 0.92);
  border-color: rgba(214, 51, 132, 0.28);
}
