/* Sudoku — one stylesheet, light and dark from the same variables. */
:root {
  color-scheme: light dark;
  --bg: #f4ede1;
  --panel: #fffcf6;
  --ink: #302e29;
  --ink-soft: #5c554a;
  --given: #302e29;
  --line: #c7bdaa;
  --line-strong: #746957;
  --accent: #185569;
  --accent-ink: #fffcf6;
  --peer: #f0e8d9;
  --same: #d9e8df;
  --selected: #bcd8dd;
  --wrong: #922e42;
  --wrong-bg: #f6e0dc;
  --hint: #356031;
  --btn: #fffcf6;
  --btn-border: #b6aa96;
  --btn-hover: #eae0ce;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .08);
  --radius: 14px;
  --cell: min((100vw - 28px) / 9, 56px);
  --board: calc(var(--cell) * 9 + 4px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #201e1b;
    --panel: #292722;
    --ink: #f4ebdc;
    --ink-soft: #d0c4b1;
    --given: #f4ebdc;
    --line: #514b40;
    --line-strong: #ad9e86;
    --accent: #9dd4e3;
    --accent-ink: #202e31;
    --peer: #353126;
    --same: #304539;
    --selected: #345360;
    --wrong: #ffb4bb;
    --wrong-bg: #4d2d31;
    --hint: #bbdb91;
    --btn: #302d27;
    --btn-border: #786d5b;
    --btn-hover: #423c31;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
/* Phones: the board takes the full width (6px margins), for cells that are easy to tap. */
@media (max-width: 599px) {
  :root { --cell: min((100vw - 16px) / 9, 56px); }
}
@media (min-width: 600px) {
  :root { --cell: min(10.5vw, 7.5vh, 58px); }
}
/* Wide screens: the controls sit beside the board, phone-keypad style, so a
   short landscape window still shows everything without scrolling. */
@media (min-width: 820px) {
  :root { --cell: min(8.5vh, 60px); --panel-w: 280px; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { height: 100%; }
body { min-height: 100%; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; /* no font inflation on rotate */
  touch-action: manipulation; /* no double-tap zoom, no 300ms tap delay */
  overscroll-behavior: none; /* no pull-to-refresh or rubber-band mid-game */
}
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; z-index: 10; }

.top {
  width: var(--board);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title nav" "meta clock";
  row-gap: 8px;
  align-items: center;
  column-gap: 12px;
  margin-bottom: 10px;
}
.top h1 { grid-area: title; font-size: 22px; margin: 0; line-height: 1.2; white-space: nowrap; min-width: 0; }
.top h1 img { height: 22px; width: auto; display: block; }
.nav { grid-area: nav; display: flex; gap: 8px; justify-content: flex-end; }
.lands-btn {
  min-height: 44px; min-width: 120px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--btn-border); background: var(--btn);
  display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.lands-btn:hover { background: var(--btn-hover); }
.lands-btn .drop { width: 16px; height: 16px; color: var(--accent); margin-left: auto; }
.lands-btn #lands-drops { color: var(--accent); font-weight: 600; }
.lands-btn.guest .drop { display: none; }
.account-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--btn-border); background: var(--btn);
  display: inline-grid; place-items: center; padding: 0; cursor: pointer; color: var(--ink-soft);
}
.account-btn:hover { background: var(--btn-hover); }
.account-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-btn .person { width: 22px; height: 22px; fill: currentColor; }
.account-btn .initial { font-size: 17px; font-weight: 600; color: var(--accent); }
.account-btn.signed-in .person, .account-btn:not(.signed-in) .initial { display: none; }
/* Below 420px the title shrinks and the nav slims so title and nav still share one row:
   two header rows, not three, leave the board, controls and land strip on a phone's screen. */
@media (max-width: 419px) {
  .top { row-gap: 4px; column-gap: 8px; margin-bottom: 6px; }
  .top h1 { font-size: 18px; overflow: hidden; text-overflow: ellipsis; }
  .nav { gap: 6px; }
  .lands-btn { min-height: 40px; min-width: 0; padding: 0 10px; }
  .account-btn { width: 40px; height: 40px; }
  .top .meta { font-size: 13px; gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
  .top .clock { font-size: 16px; }
}
.meta { grid-area: meta; margin: 0; color: var(--ink-soft); font-size: 14px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline dotted; cursor: pointer; font-variant-numeric: tabular-nums; }
.link:hover { color: var(--accent); }
.clock { grid-area: clock; justify-self: end; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-size: 18px; }
.clock[hidden] { display: none; }
#pause {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--btn-border); background: var(--btn);
  display: inline-grid; place-items: center; cursor: pointer;
}
#pause svg { width: 18px; height: 18px; fill: currentColor; }

main { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }

/* ---- board ---- */
.board-wrap { position: relative; width: var(--board); height: var(--board); }
#board {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%; height: 100%;
  background: var(--panel);
  border: 2px solid var(--line-strong);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: var(--shadow);
}
.cell {
  position: relative;
  display: grid; place-items: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: calc(var(--cell) * .52);
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  outline: none;
  transition: background-color .08s;
}
/* Rows are wrapper elements, so nth-child counts within a row: box edges key off data-r / data-c. */
.cell[data-c="8"] { border-right: 0; }
.cell[data-r="8"] { border-bottom: 0; }
.cell[data-c="2"], .cell[data-c="5"] { border-right: 2px solid var(--line-strong); }
.cell[data-r="2"], .cell[data-r="5"] { border-bottom: 2px solid var(--line-strong); }
.cell.given { color: var(--given); font-weight: 600; }
.cell.hinted { color: var(--hint); }
.cell.peer { background: var(--peer); }
.cell.same { background: var(--same); }
.cell.wrong { color: var(--wrong); }
.cell.wrong.same, .cell.wrong.peer, .cell.wrong { background: var(--wrong-bg); }
.cell.selected { background: var(--selected); }
.cell.wrong.selected { background: var(--selected); }
.cell:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
/* Status is never colour alone (design/BRAND.md): a wrong digit gets a short underline,
   a hinted one a hollow top-right ring. Both draw in the digit's own colour, keep showing
   on a selected cell, and take no pointer events. Geometry steps up once cells reach 48px. */
.cell.wrong::before, .cell.hinted::before {
  content: ""; position: absolute; pointer-events: none; box-sizing: border-box;
}
.cell.wrong::before {
  width: 14px; height: 2px; left: calc(50% - 7px); bottom: 5px;
  background: currentColor; border-radius: 1px;
}
.cell.hinted::before {
  width: 5.5px; height: 5.5px; top: 4.25px; right: 4.25px;
  box-shadow: inset 0 0 0 1.5px currentColor; border-radius: 50%; /* a border would snap to 1px */
}
#board { container-type: inline-size; }
@container (min-width: 436px) {
  .cell.wrong::before { width: 20px; left: calc(50% - 10px); bottom: 11px; }
  .cell.hinted::before { width: 7.5px; height: 7.5px; top: 8.25px; right: 8.25px; }
}
.cell .notes {
  display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%;
  font-size: calc(var(--cell) * .23); font-weight: 500; line-height: 1; color: var(--ink-soft);
}
.cell .notes span { display: grid; place-items: center; visibility: hidden; }
.cell .notes span.on { visibility: visible; }
.cell .notes span.on.hot { color: var(--accent); font-weight: 700; }

.cover {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.cover[hidden] { display: none; }
.cover .big { display: grid; gap: 2px; padding: 16px 28px; font-size: 18px; }
.cover .big small { font-size: 13px; opacity: .8; font-weight: 400; }

/* ---- controls ---- */
.tools, .numpad, .actions { width: var(--board); display: grid; gap: 8px; }
.tools { grid-template-columns: repeat(4, 1fr); }
.tools button, .actions button, .numpad button {
  min-height: 48px; border-radius: 12px; border: 1px solid var(--btn-border); background: var(--btn);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 8px;
}
.tools button:hover, .actions button:hover, .numpad button:hover { background: var(--btn-hover); }
.tools button:disabled { opacity: .45; cursor: default; }
.tools button { flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-soft); }
.tools svg { width: 22px; height: 22px; fill: currentColor; }
.tools button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--peer); }
.tools #notes b, .tools #hint b { font-weight: 600; }

.numpad { grid-template-columns: repeat(9, 1fr); gap: 6px; position: relative; }
.numpad button {
  flex-direction: column; gap: 0; font-size: 26px; color: var(--accent); min-height: 56px; padding: 2px; font-weight: 500;
  touch-action: none; /* a vertical drag on a digit is ours, not the page's scroll */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transform: translateY(calc(-1 * var(--lift, 0px)));
  transition: transform .15s, font-size .12s, background-color .12s, border-color .12s;
}
.numpad button.pressed { background: var(--btn-hover); transition: font-size .12s, background-color .12s, border-color .12s; z-index: 2; }
/* Past the drag threshold the digit shrinks to a pencil mark: this is what letting go places. */
.numpad button.note { font-size: 15px; font-weight: 600; color: var(--ink-soft); border: 1px dashed var(--accent); background: var(--peer); }
.pad-tip {
  position: absolute; transform: translateX(-50%); z-index: 3; pointer-events: none; white-space: nowrap;
  background: var(--ink); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 13px; font-weight: 500;
}
.pad-tip::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink); }
.pad-tip[hidden] { display: none; }
.numpad button.done { opacity: .3; }
.numpad button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.actions { grid-template-columns: 2fr 1fr; }
/* Phones: slimmer controls, so the land strip stays on screen without scrolling. */
@media (max-width: 599px) {
  body {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right));
  }
  main { gap: 8px; }
  .tools button { min-height: 44px; padding: 3px 6px; gap: 0; }
  .tools svg { width: 18px; height: 18px; }
  .numpad button { min-height: 50px; }
  .actions button { min-height: 42px; }
  .land-strip { min-height: 56px; padding: 4px; }
  .scene.strip { height: 46px; width: 84px; }
  #pause { width: 32px; height: 32px; }
}
.primary { background: var(--accent) !important; color: var(--accent-ink) !important; border-color: var(--accent) !important; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }

/* ---- dialogs ---- */
dialog {
  border: 0; border-radius: var(--radius); padding: 20px 22px; max-width: min(92vw, 380px); width: 100%;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 12, 20, .45); }
dialog h2 { margin: 0 0 14px; font-size: 20px; }
dialog fieldset { border: 0; padding: 0; margin: 0 0 14px; }
dialog legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
dialog label { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; }
dialog input[type="radio"], dialog input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.levels { display: grid; gap: 6px; margin-bottom: 10px; }
.levels label { border: 1px solid var(--btn-border); border-radius: 10px; padding: 10px 12px; }
.levels label:has(:checked) { border-color: var(--accent); background: var(--peer); }
.warn { color: var(--wrong); font-size: 14px; margin: 0 0 10px; }
.tip { color: var(--ink-soft); font-size: 13px; margin: 4px 0 0; }
.buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.buttons button { min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--btn-border); background: var(--btn); cursor: pointer; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; font-variant-numeric: tabular-nums; }
.stats dt { color: var(--ink-soft); }
.stats dd { margin: 0; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Satisfying feedback for a correct digit: the cell pops, a ring ripples out. */
.cell.pop { animation: pop .32s cubic-bezier(.2, 1.6, .4, 1); }
.cell.pop::after {
  content: ""; position: absolute; inset: 0; border-radius: 4px; pointer-events: none;
  box-shadow: 0 0 0 0 var(--accent); animation: ripple .5s ease-out forwards;
}
.cell.done-unit { animation: unit .5s ease-out; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes ripple { 0% { box-shadow: 0 0 0 0 var(--accent); opacity: .7; } 100% { box-shadow: 0 0 0 14px var(--accent); opacity: 0; } }
@keyframes unit { 0% { filter: brightness(1); } 40% { filter: brightness(1.35); } 100% { filter: brightness(1); } }
@media (prefers-reduced-motion: reduce) { .cell.pop, .cell.pop::after, .cell.done-unit { animation: none !important; } }
@media (prefers-reduced-motion: reduce) { *, ::backdrop { transition: none !important; } }

.panel { display: contents; }
@media (min-width: 820px) {
  .top { width: calc(var(--board) + 20px + var(--panel-w)); }
  main { flex-direction: row; align-items: stretch; justify-content: center; gap: 20px; width: auto; }
  .panel { display: flex; flex-direction: column; gap: 10px; width: var(--panel-w); }
  .tools, .numpad, .actions { width: 100%; }
  .tools { grid-template-columns: repeat(2, 1fr); }
  .numpad { grid-template-columns: repeat(3, 1fr); flex: 1; gap: 8px; }
  .numpad button { min-height: 0; font-size: 30px; }
  .actions { grid-template-columns: 1fr 1fr; }
}

/* ---- the land strip: the Lands on the game screen, signed in only ---- */
.land-strip {
  width: var(--board); min-height: 64px; padding: 6px; border-radius: 12px; border: 1px solid var(--btn-border); background: var(--btn);
  display: flex; align-items: center; gap: 12px; cursor: pointer; text-align: left; font-size: 14px;
}
.land-strip[hidden] { display: none; }
.land-strip:hover { background: var(--btn-hover); }
.land-strip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scene.strip { flex: none; width: 96px; height: 52px; border-radius: 8px; }
.strip-words { flex: 1; min-width: 0; display: grid; gap: 3px; }
.strip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.strip-head b { font-weight: 600; }
.strip-gain { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.strip-gain:not(:empty)::after { content: " drops"; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.strip-next { color: var(--ink-soft); font-size: 13px; line-height: 1.25; }
.strip-bar { display: flex; height: 4px; border-radius: 2px; overflow: hidden; background: var(--peer); }
.strip-bar span { transition: width .6s; }
#strip-done { background: var(--accent); }
#strip-ahead { background: color-mix(in srgb, var(--accent) 35%, transparent); }
@media (min-width: 820px) {
  .land-strip { width: 100%; }
}
/* The page takes on the land the caravan is in: a faint wash of its sand. */
body[data-land] { background: color-mix(in srgb, var(--bg) 86%, var(--land-tint)); }
body[data-land="dunes"] { --land-tint: #E6CCA5; }
body[data-land="salt"] { --land-tint: #DAD5BE; }
body[data-land="wadi"] { --land-tint: #D5BD98; }
body[data-land="mesa"] { --land-tint: #CF9D7C; }
body[data-land="grove"] { --land-tint: #D7C7A1; }
body[data-land="serai"] { --land-tint: #DEBF98; }
body[data-land="gardens"] { --land-tint: #D5C9AD; }
@media (prefers-color-scheme: dark) {
  body[data-land] { background: color-mix(in srgb, var(--bg) 92%, var(--land-tint)); }
}

.site-foot {
  margin-top: auto; /* sticky footer: at the bottom at minimum, pushed down by content */
  font-size: 12px; text-align: center; padding: 16px 8px 4px;
}
.site-foot a { color: var(--ink-soft); }

/* ---- the Lands: a full page in place of the game, never an overlay ---- */
body.in-lands > .top, body.in-lands > main { display: none; }
.lands { width: min(100%, 1000px); }
.lands[hidden] { display: none; }
.lands-bar { display: flex; align-items: center; gap: 16px; min-height: 44px; margin-bottom: 10px; }
.lands-bar h2 { margin: 0; font-size: 18px; }
.lands-bar .account-btn { margin-left: auto; }
#lands-back {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--btn-border); background: var(--btn);
  cursor: pointer; font-size: 15px;
}
#lands-back:hover { background: var(--btn-hover); }
.lands button:focus-visible, .lands-btn:focus-visible, #win-see:focus-visible, #win-explore:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lands-intro {
  margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-soft); font-size: 15px;
}
.lands-intro[hidden] { display: none; }
.lands-body[hidden], .lands-guest[hidden], .win-guest[hidden] { display: none; }
.lands-body { display: grid; grid-template-areas: "head" "scene" "next" "route" "journey"; }
.land-head { grid-area: head; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.land-head h3 { margin: 0; font-size: 24px; font-weight: 600; }
#land-stage { font-size: 13px; color: var(--ink-soft); }
#lands-scene { grid-area: scene; aspect-ratio: 4 / 3; border-radius: 8px; }
.lands-next { grid-area: next; margin: 12px 0 18px; font-size: 15px; color: var(--accent); }
.route { grid-area: route; }
.route h3, .journey h3 { margin: 0 0 8px; }
.route h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.route ol { list-style: none; margin: 0; padding: 0; }
.route li { display: flex; align-items: center; gap: 10px; min-height: 29px; padding: 0 8px; border-radius: 8px; font-size: 14px; }
.route li svg { width: 16px; height: 16px; flex: none; color: var(--ink-soft); }
.route li > button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: calc(100% + 16px); min-height: 29px; margin: 0 -8px; padding: 0 8px; border-radius: 8px; cursor: pointer; }
.route li > button:hover { background: var(--peer); }
.route li > button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.route li.shown { background: var(--peer); font-weight: 600; }
.route li.here svg, .route li.done svg { color: var(--accent); }
.route li .state { margin-left: auto; font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.calm { display: none; color: var(--ink-soft); font-size: 13px; margin: 48px 0 0; }
.journey {
  grid-area: journey; margin-top: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.journey-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.journey-head h3 { font-size: 16px; }
.journey-head p { margin: 0 0 8px; font-size: 12px; color: var(--ink-soft); }
.journey table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.journey th, .journey td { padding: 3px 0; text-align: right; font-weight: 400; }
.journey th:first-child { text-align: left; }
.journey thead th { font-size: 12px; color: var(--ink-soft); }
.journey td:last-child { width: 84px; }
.journey-note { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }
@media (min-width: 820px) {
  .lands-body { grid-template-columns: minmax(320px, 624px) 328px; column-gap: clamp(24px, 4vw, 48px); grid-template-areas: "head route" "scene route" "next route" "journey route"; align-items: start; }
  #lands-scene { aspect-ratio: 16 / 9; }
  .route { padding-top: 8px; }
  .journey { margin-top: 0; }
  .calm { display: block; }
}

/* The scenes take their palette from here (design/lands/LANDS.md); the art carries
   the dunes as fallbacks. Lands without art of their own borrow the dunes. */
.scene { position: relative; overflow: hidden; background: var(--land-sky, #F3EBDD); }
.scene svg { display: block; width: 100%; height: 100%; transition: filter .6s; }
/* A dry land is washed out; each stage brings the colour back, up to a rich oasis. */
.scene[data-grown="1"] svg { filter: saturate(.45) brightness(1.04); }
.scene[data-grown="2"] svg { filter: saturate(.6) brightness(1.03); }
.scene[data-grown="3"] svg { filter: saturate(.75) brightness(1.02); }
.scene[data-grown="4"] svg { filter: saturate(.9) brightness(1.01); }
.scene[data-grown="6"] svg { filter: saturate(1.12); }
.scene .layer { position: absolute; inset: 0; }
.scene[data-land="salt"] { --land-sky: #EEECE2; --land-sand: #DAD5BE; --land-water: #83AFAC; --land-plant: #728C78; --land-settlement: #AF826A; }
.scene[data-land="wadi"] { --land-sky: #EDE8DA; --land-sand: #D5BD98; --land-water: #719F9C; --land-plant: #64816A; --land-settlement: #AF795D; }
.scene[data-land="mesa"] { --land-sky: #F0E4D6; --land-sand: #CF9D7C; --land-water: #80A6A0; --land-plant: #6F8064; --land-settlement: #A66651; }
.scene[data-land="grove"] { --land-sky: #E8EBDB; --land-sand: #D7C7A1; --land-water: #70A09B; --land-plant: #55765E; --land-settlement: #B38560; }
.scene[data-land="serai"] { --land-sky: #EFE7DB; --land-sand: #DEBF98; --land-water: #78A4A0; --land-plant: #68836A; --land-settlement: #AD7456; }
.scene[data-land="gardens"] { --land-sky: #E7EBDF; --land-sand: #D5C9AD; --land-water: #7CAAA3; --land-plant: #597C65; --land-settlement: #B68D71; }
@media (prefers-color-scheme: dark) {
  .scene, .scene[data-land] {
    --land-sky: #252E32; --land-sun: #8E7757; --land-horizon: #394044; --land-sand: #62594E; --land-sand-shadow: #514B43;
    --land-sand-light: #746957; --land-water: #477A7D; --land-water-light: #7FA8A2; --land-plant: #6D9077; --land-plant-dark: #466A5A;
    --land-trunk: #9B8265; --land-settlement: #AD785E; --land-canvas: #C2B394; --land-ink: #423D36; --land-glow: #E4B66A;
  }
}

/* ---- the Lands for a guest: a labelled preview and the way in, no progress ---- */
.lands-guest { display: grid; gap: 16px; grid-template-areas: "preview" "pitch" "note"; }
.guest-pitch { grid-area: pitch; }
.guest-pitch h3 { margin: 0; font-size: 24px; font-weight: 600; }
.guest-sub { margin: 2px 0 12px; color: var(--ink-soft); font-size: 15px; }
.guest-pitch p { margin: 0 0 14px; font-size: 15px; }
.guest-pitch .guest-sub { margin-bottom: 12px; }
.guest-signin { color: var(--ink-soft); }
.guest-signin .link { min-height: 44px; font-size: 15px; color: var(--accent); }
.guest-preview { grid-area: preview; margin: 0; }
#guest-scene { aspect-ratio: 4 / 3; border-radius: 8px; }
.guest-preview figcaption { margin-top: 6px; font-size: 13px; color: var(--ink-soft); }
.guest-note { grid-area: note; margin: 0; color: var(--ink-soft); font-size: 13px; }
@media (min-width: 820px) {
  .lands-guest { grid-template-columns: 328px minmax(320px, 624px); column-gap: clamp(24px, 4vw, 48px); grid-template-areas: "pitch preview" "note preview"; align-items: start; }
  #guest-scene { aspect-ratio: 16 / 9; }
}

/* ---- the win dialog's land ---- */
.win-land { margin: 0 0 14px; }
.win-land[hidden] { display: none; }
.scene.thumb { height: 100px; border-radius: 8px; }
.win-line { margin: 10px 0 12px; font-weight: 600; color: var(--accent); }
#win-see, #win-explore, .wide { width: 100%; min-height: 44px; border-radius: 10px; border: 1px solid var(--btn-border); background: var(--btn); cursor: pointer; }
#win-see:hover, #win-explore:hover { background: var(--btn-hover); }
.win-guest { margin: 0 0 14px; }
.win-guest p { margin: 0 0 10px; color: var(--ink-soft); }
/* What grew fades in over 600ms; a finished land holds, then the next one arrives. */
.scene .grow { animation: grow .6s linear both; }
.scene.moving-on .arrive { animation: arrive 1s linear both; }
@keyframes grow { from { opacity: 0; } to { opacity: 1; } }
@keyframes arrive { 0%, 60% { opacity: 0; } 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .scene .grow, .scene.moving-on .arrive { animation: none; } }

/* ---- the account dialog ---- */
dialog.account { position: fixed; max-height: calc(100dvh - 24px); overflow-y: auto; padding-top: 18px; }
.account .close {
  position: absolute; top: 10px; right: 14px; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-soft);
}
.account .close svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; }
.account .close:hover { background: var(--btn-hover); }
.account h2 { padding-right: 44px; line-height: 28px; }
.account button:focus-visible, .account a:focus-visible, .guest-pitch button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.account-copy { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; }
.account-copy.small { font-size: 13px; margin: 8px 0 4px; }
/* Sign in and Create account are links: they leave for id.blackbridge.so. */
.account a.button { display: grid; place-items: center; box-sizing: border-box; color: var(--ink); text-decoration: none; margin: 0 0 10px; }
.account a.button.primary { color: var(--accent-ink); }
/* Errors have a fixed slot, so the buttons never jump. */
.slot { min-height: 44px; margin: -4px 0 8px; font-size: 13px; }
.slot p { margin: 0; }
.error { color: var(--ink); font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.error:empty { display: none; }
.error::before {
  content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; line-height: 1;
}
.account .wide { min-height: 48px; border-radius: 10px; border: 1px solid var(--btn-border); background: var(--btn); cursor: pointer; }
.account .wide:hover { background: var(--btn-hover); }
.account .link.quiet { display: block; margin: 6px auto 0; min-height: 44px; padding: 0 8px; font-size: 14px; color: var(--ink-soft); }
.account .link.quiet:hover { color: var(--accent); }
.profile-email { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.profile-since { margin: 2px 0 14px; color: var(--ink-soft); font-size: 14px; }
.account .journey { margin: 0 0 14px; }
#account-delete p:not(.error) { margin: 0 0 14px; }
#account-delete .buttons { flex-wrap: wrap; }
.account-foot { margin: 8px 0 0; text-align: center; font-size: 12px; }
.account-foot a { display: inline-block; padding: 12px 8px; color: var(--ink-soft); }

/* ---- friends and challenges (docs/challenges.md) ---- */
body.in-friends > .top, body.in-friends > main { display: none; }
.friends-btn { position: relative; }
.friends-btn .people { width: 24px; height: 24px; fill: currentColor; }
.friends-btn .badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.friends-btn .badge[hidden] { display: none; }
.versus { font-weight: 600; color: var(--accent); }
.versus[hidden] { display: none; }
.friends { width: min(100%, 640px); }
.friends-guest[hidden], .friends-body[hidden], .friends .card[hidden], .friends .small[hidden], .win-challenge[hidden] { display: none; }
.friends-guest h3 { margin: 0 0 8px; font-size: 22px; }
.friends-guest p { font-size: 15px; margin: 0 0 14px; }
.friends-body { display: grid; gap: 14px; }
.friends .card { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.friends .card h3 { margin: 0 0 6px; font-size: 16px; }
.friends .small { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); }
.friends .row { display: flex; gap: 8px; }
.friends input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--btn-border);
  background: var(--bg); color: var(--ink); font: inherit;
}
.friends input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.friends .row button, .rows button {
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--btn-border); background: var(--btn); color: var(--ink); cursor: pointer; flex: none;
}
.friends button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.friends .error { margin: 8px 0 0; font-size: 13px; }
.me-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; font-size: 17px; }
.me-head span { font-size: 14px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; color: var(--ink); user-select: all; }
.friends-list h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.rows li.to-play { border-color: var(--accent); }
.rows li.expired { opacity: .7; }
.rows .words { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rows .words b { font-weight: 600; overflow-wrap: anywhere; }
.rows .words span { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.rows .state { font-size: 13px; color: var(--ink-soft); }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.delta.up { color: var(--hint); }
.delta.down { color: var(--wrong); }
.friends .calm { display: block; margin: 8px 0 0; }
.win-challenge { margin: 0 0 14px; font-size: 15px; color: var(--accent); }
#challenge-dialog .small { margin: -6px 0 12px; font-size: 14px; color: var(--ink-soft); }
#challenge-dialog .link.quiet { display: block; margin: 10px auto 0; min-height: 44px; font-size: 14px; color: var(--ink-soft); }
#challenge-dialog .error { margin: 0 0 8px; font-size: 13px; }
