/* Furdoku — the game page. The site's paper, graphite and type; the book's
   board. The board stays a printed sheet in the dark theme too: the cats and
   the furniture are drawn for paper, and the areas' paint is the book's. The
   book's terracotta is the game's one accent (hints, pencil, warnings). */
:root {
  --fd-accent: #c9623f;
  --fd-accent-soft: #f6e3d8;
  --fd-card: #f6e3d8;
  --fd-card-ink: #2a2730;
  --fd-yes: #3d7a53;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --fd-accent: #e0805f; --fd-card: #2c2622; --fd-card-ink: #ECE8DF; }
}
:root[data-theme="dark"] { --fd-accent: #e0805f; --fd-card: #2c2622; --fd-card-ink: #ECE8DF; }

.fd-eyebrow { color: var(--fd-accent); }
.fd-num { color: var(--fd-accent); font-variant-numeric: lining-nums; }

/* -------------------------------------------------------------- the shelf */
.fd-shelf { padding: 1.8rem 0 1rem; }
.fd-shelf h1 { font-size: clamp(1.8rem, 4.4vw, 2.8rem); line-height: 1.08; max-width: 18ch; }
.fd-shelf .lead { margin: .8rem 0 1rem; }
.fd-howto-link { margin: 1.1rem 0 1.6rem; }
.fd-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; }
.fd-chip { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink); border: 1px solid var(--rule);
  border-radius: 999px; padding: .28rem .65rem .28rem .35rem; background: var(--sheet); }
.fd-chip img { width: 18px; height: 18px; border-radius: 3px; background: #fff; }
.fd-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.fd-item { display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: auto auto; gap: .15rem .9rem; align-items: center;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: .8rem .95rem; min-height: 44px; text-decoration: none; }
.fd-item:hover { border-color: var(--ink); }
.fd-item img { grid-row: 1 / span 2; width: 56px; height: 56px; background: var(--fd-accent-soft); border-radius: 12px; padding: 3px; }
.fd-item-text { display: grid; gap: .1rem; min-width: 0; }
.fd-item-meta { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--graphite); }
.fd-item-title { font-family: var(--font-display); font-variation-settings: "SOFT" 30, "WONK" 1, "opsz" 24; font-weight: 600; font-size: 1.12rem; line-height: 1.2; color: var(--ink); }
.fd-item-mood { font-style: italic; font-size: .92rem; color: var(--graphite); line-height: 1.3; }
.fd-item-state { grid-column: 2; font-family: var(--font-hand); font-size: 1.15rem; color: var(--graphite); line-height: 1.1; }
.fd-item.is-solved .fd-item-state { color: var(--fd-yes); }
.fd-note { margin-top: 1.4rem; max-width: 62ch; }
.fd-shelf-h { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--graphite); font-weight: 400; margin: 1.8rem 0 .7rem; }
.fd-days > .fd-shelf-h:first-child { margin-top: .4rem; }
.fd-month { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; margin: 1.3rem 0 .6rem; }
.fd-list + .fd-list { margin-top: .7rem; }
.fd-list-today { grid-template-columns: minmax(0, 34rem); }
.fd-item.is-today { border-color: var(--ink); border-width: 2px; }
.fd-item.is-today .fd-item-title { font-size: 1.5rem; }
.fd-feed-note { max-width: 62ch; margin: .4rem 0 0; }
.fd-shelf-status:empty { display: none; }
.fd-shelf-status { color: var(--fd-accent); margin: 0 0 .8rem; }
.fd-more-days { margin: 1rem 0 0; }

/* -------------------------------------------------------------- the game */
.fd-game { padding: .9rem 0 1rem; }
.fd-top { display: flex; align-items: center; gap: .8rem; justify-content: space-between; font-family: var(--font-mono);
  font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--graphite); margin-bottom: .5rem; }
.fd-back { display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; color: var(--ink); padding-right: .4rem; }
.fd-level { margin-left: auto; color: var(--fd-accent); }
.fd-clock { font-variant-numeric: tabular-nums; min-width: 3.4em; text-align: right; }

.fd-layout { display: grid; gap: .7rem; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "claim" "coach" "play" "hint" "status" "chips"; }
.fd-layout:has(.fd-coach[hidden]) { grid-template-areas: "head" "claim" "play" "hint" "status" "chips"; }
.fd-coach { grid-area: coach; margin: 0; padding: .55rem .8rem; border-left: 3px solid var(--fd-accent); background: var(--fd-accent-soft);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0; font-size: .93rem; line-height: 1.4; color: var(--ink); }
.fd-head { grid-area: head; }
.fd-head h1 { font-size: clamp(1.45rem, 4.2vw, 2.1rem); line-height: 1.1; }
.fd-mood { margin: .15rem 0 0; color: var(--graphite); font-style: italic; }
.fd-claim { grid-area: claim; display: flex; align-items: center; gap: .75rem; text-align: left; width: 100%;
  background: var(--fd-card); color: var(--fd-card-ink); border: 0; border-radius: var(--radius-lg); padding: .5rem .8rem .5rem .55rem;
  font: inherit; font-size: .95rem; line-height: 1.3; cursor: pointer; min-height: 44px; }
.fd-claim img { width: 52px; height: 52px; flex: none; background: #fff; border-radius: 50%; padding: 4px; }
.fd-claim-line, .fd-claim-trait { display: block; }
.fd-claim-trait { font-size: .85rem; font-style: italic; opacity: .78; }
.fd-claim.is-pulse { animation: fd-pulse .7s ease-out; }
@keyframes fd-pulse { 0% { box-shadow: 0 0 0 0 var(--fd-accent); } 100% { box-shadow: 0 0 0 10px transparent; } }

.fd-play { grid-area: play; min-width: 0; }
.fd-frame { width: 100%; display: flex; justify-content: center; }
.fd-frame.is-zoom { display: block; overflow: auto; max-height: min(74svh, 640px); -webkit-overflow-scrolling: touch;
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 6px; overscroll-behavior: contain; }
.fd-board { position: relative; flex: none; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; cursor: pointer; border-radius: 3px; outline: none;
  background: #fff; box-shadow: var(--shadow); }
.fd-frame.is-zoom .fd-board { touch-action: pan-x pan-y; margin: 0 auto; }
.fd-board:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }
.fd-board.is-pencil { cursor: crosshair; }
.fd-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.fd-svg .fd-walls { stroke-width: var(--wall, 3px); }
.fd-svg .fd-border { stroke-width: var(--border, 4px); }
.fd-svg .fd-hint-edge { stroke-width: max(2.5px, calc(var(--wall, 3px) * .9)); }
.fd-cells { position: absolute; inset: 0; display: grid; pointer-events: none; }
.fd-cells [role="row"] { display: contents; }
.fd-letters text { font-family: var(--font-mono); font-weight: 700; font-size: 17px; fill: #5a5560; }
.fd-board.is-tiny .fd-letter rect { fill-opacity: .8; }
.fd-letter { transition: opacity .4s; }
.fd-letter.is-faded { opacity: .25; }
.fd-letter.is-word rect { fill: var(--fd-accent-soft); fill-opacity: 1; stroke: #c9623f; stroke-width: 2; }
.fd-letter.is-word text { fill: #a3482a; }

.fd-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: .8rem auto 0; max-width: 560px; }
.fd-tool { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 48px; padding: .5rem .6rem;
  font-family: var(--font-mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; cursor: pointer; }
.fd-tool:hover { border-color: var(--ink); }
.fd-tool:disabled { opacity: .45; cursor: default; }
.fd-tool img { width: 22px; height: 22px; }
.fd-tool[aria-pressed="true"] { background: var(--fd-accent-soft); border-color: #c9623f; color: #7a3a22; box-shadow: inset 0 0 0 1px #c9623f; }
.fd-tool-hint { border-color: var(--ink); }
.fd-glyph { font-family: var(--font-display); font-size: 1.15rem; line-height: 1; text-transform: none; }
.fd-more { display: flex; flex-wrap: wrap; justify-content: center; gap: .1rem .4rem; margin: .4rem 0 0; }
.fd-link { background: none; border: 0; padding: .55rem .6rem; min-height: 44px; font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--graphite); cursor: pointer; text-decoration: underline;
  text-decoration-color: var(--rule); text-underline-offset: .25em; }
.fd-link:hover { color: var(--ink); text-decoration-color: var(--fd-accent); }
.fd-chips-game { grid-area: chips; justify-content: center; }
.fd-status { grid-area: status; min-height: 1.4em; margin: 0; text-align: center; font-size: .9rem; color: var(--graphite); }

/* the hint, as a card from the book */
.fd-hintcard { grid-area: hint; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .3rem .9rem; align-items: start;
  background: var(--fd-card); color: var(--fd-card-ink); border-radius: var(--radius-lg); padding: .9rem 1rem 1rem;
  box-shadow: 3px 3px 0 rgba(42, 39, 48, .14); }
.fd-hintcard[hidden] { display: none; }
.fd-hint-pic img { width: 72px; height: 72px; background: #fff; border-radius: 8px; padding: 4px; }
.fd-hint-pic:empty { display: none; }
.fd-hint-body { min-width: 0; }
.fd-hint-body .eyebrow { margin-bottom: .25rem; }
.fd-hint-body h2 { font-size: 1.2rem; margin-bottom: .2rem; color: inherit; }
.fd-hint-body p { margin: 0; }
.fd-hint-line { font-size: 1.02rem; line-height: 1.4; }
.fd-hint-rule { font-size: .85rem; opacity: .75; margin-top: .3rem !important; }
.fd-hint-row { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .55rem; }
.fd-hint-row .btn { min-height: 44px; padding: .6rem 1rem; }

/* -------------------------------------------------------------- dialogs */
.fd-dialog { border: 0; border-radius: 14px; padding: 1.2rem 1.2rem 1.1rem; width: min(440px, calc(100vw - 24px));
  max-height: calc(100svh - 24px); overflow: auto; background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-lift); }
.fd-dialog::backdrop { background: rgba(27, 26, 23, .45); }
.fd-dialog h2 { font-size: 1.7rem; }
.fd-dialog-x { position: absolute; top: .35rem; right: .35rem; margin: 0; }
.fd-close { width: 44px; height: 44px; border: 0; background: none; font-size: 1.6rem; line-height: 1; color: var(--graphite); cursor: pointer; border-radius: 50%; }
.fd-close:hover { color: var(--ink); }
.fd-dialog-row { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1rem; }
.fd-dialog-row .btn { flex: 1; }
.fd-dialog .btn:disabled { opacity: .35; cursor: default; transform: none; }

.fd-cards { margin-top: .9rem; min-height: 21rem; display: grid; }
.fd-card { background: var(--fd-card); color: var(--fd-card-ink); border-radius: 12px; padding: 1rem; display: grid; align-content: center; justify-items: center; gap: .7rem; text-align: center; touch-action: pan-y; }
.fd-mini { width: min(220px, 62vw); height: auto; display: block; background: #fff; }
.fd-card-cap { margin: 0; font-family: var(--font-display); font-variation-settings: "SOFT" 30, "WONK" 1, "opsz" 24; font-weight: 600; font-size: 1.15rem; }
.fd-card-note { margin: 0; font-family: var(--font-hand); font-size: 1.3rem; line-height: 1.2; }
.fd-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; justify-items: start; text-align: left; width: 100%; max-width: 300px; }
.fd-legend li { display: flex; align-items: center; gap: .8rem; font-size: 1rem; }
.fd-key { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: #fff; border: 1px solid rgba(38, 35, 43, .2); border-radius: 6px; }
.fd-key img, .fd-key svg { width: 36px; height: 36px; }
.fd-legend + .fd-card-cap { font-family: var(--font-body); font-weight: 400; font-size: .92rem; }
.fd-furn { display: flex; gap: .6rem; }
.fd-furn img { width: 52px; height: 52px; background: #fff; border-radius: 8px; padding: 5px; }
.fd-dots { display: flex; justify-content: center; gap: .45rem; margin-top: .7rem; }
.fd-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--rule); }
.fd-dots i.on { background: var(--fd-accent); }

.fd-win { text-align: center; }
.fd-solved { margin: .2rem 0 .6rem; font-family: var(--font-hand); font-size: 1.6rem; color: var(--graphite); }
.fd-solved b { color: var(--ink); font-weight: 700; padding: 0 .1em; border-bottom: 2px solid var(--fd-accent); }
.fd-portrait { display: grid; justify-items: center; gap: .3rem; }
.fd-portrait img { width: 132px; height: 132px; background: var(--fd-accent-soft); border-radius: 18px; padding: 10px; box-shadow: 4px 4px 0 rgba(42, 39, 48, .12); transform: rotate(-2deg); }
.fd-portrait p { margin: 0; }
.fd-cat-name { display: block; font-family: var(--font-hand); font-size: 1.8rem; line-height: 1.1; }
.fd-cat-trait { display: block; font-style: italic; color: var(--graphite); font-size: .95rem; }
.fd-word-lead { margin: 1rem 0 .4rem; font-family: var(--font-hand); font-size: 1.25rem; }
.fd-word { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px; margin: 0; }
.fd-word span { width: 2rem; height: 2.4rem; display: grid; place-items: center; border: 2px solid #c9623f; border-radius: 4px;
  background: #fff; font-family: var(--font-hand); font-weight: 700; font-size: 1.6rem; color: #a3482a;
  animation: fd-letter .45s cubic-bezier(.3, 1.4, .5, 1) both; }
.fd-word-small span { width: 1.7rem; height: 2rem; font-size: 1.35rem; animation: none; }
@keyframes fd-letter { from { opacity: 0; transform: translateY(8px) scale(.7); } to { opacity: 1; transform: none; } }

/* -------------------------------------------------------------- wide screens */
@media (min-width: 900px) {
  .fd-layout { grid-template-columns: minmax(0, 620px) minmax(260px, 360px); justify-content: center; column-gap: 2.2rem; align-items: start;
    grid-template-areas: "play head" "play claim" "play coach" "play hint" "play status" "play chips" "play ."; grid-template-rows: auto auto auto auto auto auto 1fr; }
  .fd-layout:has(.fd-coach[hidden]) { grid-template-areas: "play head" "play claim" "play hint" "play status" "play chips" "play ."; grid-template-rows: auto auto auto auto auto 1fr; }
  .fd-chips-game { justify-content: flex-start; }
  .fd-status { text-align: left; }
}
@media (max-width: 520px) {
  .fd-game .wrap, .fd-shelf .wrap { padding: 0 16px; }
  .fd-claim { font-size: .9rem; }
  .fd-claim img { width: 44px; height: 44px; }
  .fd-tool { font-size: .7rem; gap: .3rem; padding: .4rem .3rem; }
}
@media (max-width: 360px) {
  .fd-game .wrap { padding: 0 10px; }
  .fd-top { font-size: .66rem; letter-spacing: .06em; gap: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .fd-word span, .fd-claim.is-pulse, .fd-fx, .fd-fx path, .fd-tool-hint.is-glow { animation: none !important; }
  .fd-letter { transition: none; }
}

/* A row, column or area just done: a green outline that fades; the wash stays. */
.fd-flash { stroke-width: calc(var(--border, 4px) * 1.1); animation: fd-flash 1.2s ease-out forwards; }
@keyframes fd-flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

/* -------------------------------------------------------------- the ladder of levels */
.fd-levels { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; gap: .4rem;
  grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); max-width: 40rem; }
.fd-lv { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 1px solid var(--rule);
  border-radius: 10px; font-family: var(--font-mono); font-size: .8rem; color: var(--ink); background: var(--sheet); text-decoration: none; }
a.fd-lv:hover { border-color: var(--ink); }
.fd-lv.is-solved { background: var(--fd-accent-soft); border-color: transparent; color: var(--graphite); }
.fd-lv.is-solved::after { content: "✓"; margin-left: .2em; color: var(--fd-yes); font-size: .75em; }
.fd-lv.is-here { border: 2px solid var(--fd-accent); color: var(--fd-accent); font-weight: 700; }
.fd-lv.is-locked { color: var(--graphite); opacity: .45; border-style: dashed; background: transparent; }

/* -------------------------------------------------------------- a little life on the board
   Each mark that changes moves once: a cat drops in, a cross is drawn, a dot
   fades up, a wrong cat shakes its head, the cats of a line just done nod,
   and on the last cat all of them hop, top to bottom, the order of the word.
   Nothing moves under Reduce Motion. */
.fd-fx { transform-box: fill-box; transform-origin: 50% 60%; animation-delay: var(--d, 0ms); }
.fd-fx-pop { animation: fd-pop .3s cubic-bezier(.3, 1.5, .5, 1) both; }
@keyframes fd-pop { 0% { transform: translateY(-14%) scale(.55); opacity: 0; } 60% { transform: scale(1.07); opacity: 1; } 100% { transform: none; } }
.fd-fx-cross path { stroke-dasharray: 100; animation: fd-draw .18s ease-out both; }
@keyframes fd-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
.fd-fx-dot { animation: fd-fade .3s ease-out both; }
@keyframes fd-fade { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
.fd-fx-shake { animation: fd-shake .45s ease-in-out both; }
@keyframes fd-shake { 0%, 100% { transform: none; } 20% { transform: rotate(-9deg); } 45% { transform: rotate(8deg); } 70% { transform: rotate(-5deg); } 88% { transform: rotate(2deg); } }
.fd-fx-nod { animation: fd-nod .5s ease-in-out both; }
@keyframes fd-nod { 0%, 100% { transform: none; } 35% { transform: translateY(4%) scaleY(.93); } 65% { transform: translateY(-3%); } }
.fd-fx-hop { animation: fd-hop .55s cubic-bezier(.3, .7, .4, 1) both; }
@keyframes fd-hop { 0%, 100% { transform: none; } 35% { transform: translateY(-20%) scale(1.06); } 62% { transform: translateY(0) scaleY(.92); } 80% { transform: translateY(-4%); } }
.fd-tool-hint.is-glow { animation: fd-glow 1.8s ease-in-out infinite; }
@keyframes fd-glow { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 6px var(--fd-accent-soft); } }
