/* Muamma – "Mühür". Tokens and components follow docs/design.md. */

:root {
  --bg: #f7f2eb;
  --card: #fff9f0;
  --card-border: #e6dccb;
  --chip: #d0e3ff;
  --ink: #081f5c;
  --muted: #4a5578;
  --navy: #081f5c;
  --blue: #334eac;
  --blue-light: #7096d1;
  --blue-deep: #1f357f;
  --sky: #bad6eb;
  --red: #b31b1b;
  --red-ink: #b31b1b;
  --seal-ring: #b31b1b;
  --fodder: #334eac;
  --field-bg: #fffdf9;

  --card-shadow:
    0 24px 50px -24px rgb(8 31 92 / 45%),
    0 2px 0 rgb(255 255 255 / 70%) inset;

  --tile-border: #d9cdba;
  --tile-fill: linear-gradient(165deg, #fffdf9 0%, #f6efe3 100%);
  --tile-shadow: inset 0 2px 3px rgb(8 31 92 / 8%);
  --tile-typed-border: var(--blue);
  --tile-typed-fill: linear-gradient(160deg, #ffffff 0%, #fffaf2 50%, #f3ece0 100%);
  --tile-typed-shadow:
    inset 0 2px 0 rgb(255 255 255 / 95%),
    inset 0 0 0 4px #d0e3ff,
    inset 0 -3px 5px rgb(8 31 92 / 8%),
    0 2px 5px rgb(8 31 92 / 8%);
  --tile-solved-fill:
    linear-gradient(160deg, #7096d1 0%, #4563bd 38%, #334eac 70%, #283f91 100%);
  --tile-solved-shadow:
    inset 0 2px 0 rgb(255 255 255 / 50%),
    inset 0 -4px 6px rgb(4 16 58 / 25%),
    inset 0 0 0 4px rgb(255 255 255 / 16%),
    0 3px 8px rgb(8 31 92 / 25%);
  --tile-solved-ink: #fff9f0;

  --band-sealed-grad:
    radial-gradient(70% 85% at 50% 108%, #2a4497 0%, #15307a 38%, #081f5c 64%, #061748 100%);
  --seal-glow: radial-gradient(60% 55% at 50% 100%, rgb(112 150 209 / 38%) 0%, transparent 70%);

  --grain-blend: multiply;
  --grain-opacity: 0.18;

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  color-scheme: light;
}

[data-state="sealed"] {
  --band-grad: var(--band-sealed-grad);
  --band-ink: #fff9f0;
  --band-accent: var(--sky);
  --seal-light: #7096d1;
  --seal-mid: #334eac;
  --seal-deep: #1f357f;
  --seal-line: #22367f;
  --seal-ink: #fff9f0;
  --def-bg: #d0e3ff;
  --def-ink: #081f5c;
}

[data-state="opened"] {
  --band-grad:
    radial-gradient(120% 90% at 50% 100%, #d0e3ff 0%, #bad6eb 50%, #a3c4e0 100%);
  --band-ink: #081f5c;
  --band-accent: #081f5c;
  --seal-light: #334eac;
  --seal-mid: #081f5c;
  --seal-deep: #04103a;
  --seal-line: #334eac;
  --seal-ink: #fff9f0;
  --def-bg: #d0e3ff;
  --def-ink: #081f5c;
}

:root[data-theme="dark"] {
  --bg: #050f2e;
  --card: #0c1a45;
  --card-border: #1d2e66;
  --chip: #162a66;
  --ink: #f7f2eb;
  --muted: #bad6eb;
  --red-ink: #f07a73;
  --fodder: #8fa6ff;
  --field-bg: #0f1f52;

  --card-shadow:
    0 24px 50px -24px rgb(0 0 0 / 80%),
    0 1px 0 rgb(255 255 255 / 6%) inset;

  --tile-border: #1d2e66;
  --tile-fill: linear-gradient(165deg, #0f1f52 0%, #0a163e 100%);
  --tile-shadow: inset 0 2px 3px rgb(0 0 0 / 35%);
  --tile-typed-border: #334eac;
  --tile-typed-fill: linear-gradient(160deg, #1a2d68 0%, #0f1f52 55%, #0b1844 100%);
  --tile-typed-shadow:
    inset 0 2px 0 rgb(255 255 255 / 16%),
    inset 0 0 0 4px #1d2e66,
    inset 0 -3px 5px rgb(0 0 0 / 35%),
    0 2px 5px rgb(0 0 0 / 35%);
  --tile-solved-fill:
    linear-gradient(160deg, #8aa9db 0%, #7096d1 45%, #5c84c6 100%);
  --tile-solved-shadow:
    inset 0 2px 0 rgb(255 255 255 / 45%),
    inset 0 -4px 6px rgb(4 16 58 / 30%),
    inset 0 0 0 4px rgb(255 255 255 / 18%),
    0 3px 8px rgb(0 0 0 / 45%);
  --tile-solved-ink: #081f5c;

  --band-sealed-grad:
    radial-gradient(70% 85% at 50% 108%, #1a3480 0%, #0c1f5a 40%, #061440 70%, #030a26 100%);
  --seal-glow: radial-gradient(60% 55% at 50% 100%, rgb(112 150 209 / 28%) 0%, transparent 70%);

  --grain-blend: screen;
  --grain-opacity: 0.3;

  color-scheme: dark;
}

:root[data-theme="dark"] [data-state="sealed"] {
  --band-ink: #f7f2eb;
  --seal-deep: #1a2c6e;
  --seal-line: #1a2c6e;
  --def-bg: #334eac;
  --def-ink: #fff9f0;
}

:root[data-theme="dark"] [data-state="opened"] {
  --band-grad:
    radial-gradient(120% 90% at 50% 100%, #4a6abf 0%, #334eac 50%, #27407f 100%);
  --band-ink: #f7f2eb;
  --band-accent: #f7f2eb;
  --def-bg: #334eac;
  --def-ink: #fff9f0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* author display rules outrank the browser's own [hidden] rule, which left
   the guess form and the assists on screen after a puzzle was finished */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.75rem;
}

h2 {
  margin: 2rem 0 0.5rem;
  font-size: 1.35rem;
}

h3 {
  margin: 1.5rem 0 0.25rem;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 800;
}

a {
  color: var(--ink);
  text-decoration-color: var(--blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--ink);
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.container {
  position: relative;
  z-index: 2;
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* Band, header and seal */

.band {
  --band-h: 0px;
  --seal-size: min(150vw, 1100px);
  --seal-top-sealed: 96px;
  --seal-top: var(--seal-top-sealed);
  --cap-offset: 0.181;
  position: relative;
  background: var(--band-grad);
  color: var(--band-ink);
}

.band-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--band-sealed-grad);
  opacity: 0;
  pointer-events: none;
}

.band-wash.active {
  opacity: 1;
}

.seal-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.seal-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--seal-glow);
  pointer-events: none;
}

.has-band .band {
  --cap-room: 100px;
  --band-h: calc(var(--seal-top-sealed) + var(--seal-size) * var(--cap-offset) + var(--cap-room));
  min-height: var(--band-h);
}

.site-header {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.brand {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.5rem;
  color: var(--band-ink);
  text-decoration: none;
}

.brand img {
  display: block;
  width: 40px;
  height: 40px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

@media (max-width: 420px) {
  .wordmark {
    display: none;
  }
}

.site-nav {
  display: none;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--band-ink);
  font-weight: 600;
  text-decoration: none;
}

.site-nav a[aria-current="page"]::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.4rem;
  vertical-align: 0.15em;
  background: var(--red);
  border-radius: 50%;
}

.nav-menu {
  position: relative;
}

.nav-menu summary {
  list-style: none;
}

.nav-menu summary::-webkit-details-marker {
  display: none;
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 4;
  display: grid;
  min-width: 11rem;
  padding: 0.5rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 14px 34px rgb(11 31 92 / 18%);
}

.nav-menu-panel a,
.nav-menu-panel button {
  min-height: 0;
  padding: 0.6rem 0.75rem;
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: 12px;
}

.nav-menu-panel a:hover,
.nav-menu-panel button:hover {
  background: var(--chip);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.streak {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.3rem 0.65rem;
  color: var(--band-ink);
  font-size: 0.9rem;
  font-weight: 700;
  background: rgb(255 255 255 / 14%);
  border-radius: 999px;
}

.streak::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
}

[data-state="opened"] .streak {
  background: rgb(11 31 92 / 12%);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--band-ink);
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.icon-button:hover {
  background: rgb(255 255 255 / 14%);
}

[data-state="opened"] .icon-button:hover {
  background: rgb(11 31 92 / 12%);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.band-date {
  position: relative;
  z-index: 1;
  margin: 0.25rem 0 0;
  color: var(--band-accent);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.seal {
  position: absolute;
  top: var(--seal-top);
  left: 50%;
  width: var(--seal-size);
  height: var(--seal-size);
  transform: translateX(-50%);
  filter: drop-shadow(0 -6px 22px rgb(0 0 0 / 30%));
  animation: seal-rise 1.6s ease-out both;
}

/* the wax takes its light from the top left; the stops are driven by the
   theme and the page state, so the gradient follows the palette */
.seal-stop-light {
  stop-color: var(--seal-light);
}

.seal-stop-mid {
  stop-color: var(--seal-mid);
}

.seal-stop-deep {
  stop-color: var(--seal-deep);
}

.seal-whole .seal-body {
  fill: url("#muhur-g");
}

.seal-broken .seal-body {
  fill: url("#muhur-kirik-g");
}

/* a sliver of light just under the rings, as if they were pressed in */
.seal-emboss {
  stroke: rgb(255 255 255 / 30%);
}

.seal-ring {
  stroke: var(--seal-ring);
}

.seal-line {
  stroke: var(--seal-line);
}

/* the wax thickens at the rim */
.seal-edge {
  stroke: rgb(0 0 0 / 14%);
}

[data-state="sealed"] .seal-broken,
[data-state="opened"] .seal-whole {
  display: none;
}

[data-state="opened"] .band {
  --seal-top: 178px;
}

.seal-half {
  transform-box: fill-box;
  transform-origin: center;
}

[data-state="opened"] .seal-half-left {
  animation: seal-crack-left 600ms ease-out both;
}

[data-state="opened"] .seal-half-right {
  animation: seal-crack-right 600ms ease-out both;
}

.seal-cap {
  position: absolute;
  top: calc(var(--seal-top) + var(--seal-size) * var(--cap-offset));
  right: 0;
  left: 0;
  z-index: 1;
  width: calc(var(--seal-size) * 0.46);
  margin-inline: auto;
  color: var(--seal-ink);
  text-align: center;
}

[data-state="opened"] .seal-cap {
  top: calc(var(--seal-top) - 4.5rem);
  width: auto;
  max-width: 32rem;
  padding-inline: 1rem;
  color: var(--band-ink);
}

.seal-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.seal-title {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.seal-note {
  margin: 0.2rem 0 0;
  font-weight: 700;
}

/* Puzzle card */

.has-band .container {
  margin-top: -2.25rem;
  padding-top: 0;
}

.puzzle,
.panel {
  position: relative;
  padding: 1.5rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  box-shadow: var(--card-shadow);
}

.chips {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.chips .timer {
  font-variant-numeric: tabular-nums;
}

.clue {
  margin: 0 0 1.5rem;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 550;
  line-height: 1.25;
  text-align: center;
}

.enumeration {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

.definition {
  padding: 0.05em 0.25em;
  color: var(--def-ink);
  border-radius: 8px;
  /* each line of a wrapped definition is painted on its own, instead of
     one box stretched over the whole inline fragment */
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  background-image: linear-gradient(var(--def-bg), var(--def-bg));
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.definition.ink {
  animation: ink-fill 520ms ease-out both;
}

/* Tiles */

.tiles {
  --tile-max: 54px;
  /* a block, not a flex row: as flex items the word groups collapse to
     their min-content width and drag the tiles down with them */
  display: block;
  /* room for the solved bounce above and the falling letters below */
  padding: 0.6rem 0 1.7rem;
  margin-bottom: 0.3rem;
  text-align: center;
  cursor: text;
  /* the row scrolls rather than the page when even the smallest tiles
     do not fit; the padding keeps the animations out of the clip */
  overflow-x: auto;
}

/* the hint only appears when there is really something to scroll */
.tiles.scrollable {
  text-align: left;
  white-space: nowrap;
  scrollbar-width: thin;
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 2.5rem), transparent 100%);
}

.tile-group {
  display: inline-flex;
  max-width: 100%;
  gap: var(--tile-gap, 0.25rem);
  margin: 0.25rem 0.35rem;
  vertical-align: top;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  /* fixed, because Chrome sizes a shrinkable flex item from its
     min-width when the group asks for its max-content width */
  flex: 0 0 var(--tile-size, var(--tile-max));
  aspect-ratio: 27 / 29;
  font-family: var(--serif);
  font-weight: 600;
  /* a pressed-in glaze until a letter lands on it */
  background: var(--tile-fill);
  border: 2px solid var(--tile-border);
  border-radius: 10px;
  box-shadow: var(--tile-shadow);
}

.tile .letter {
  display: block;
  /* set from the measured tile width in game.js; this is the common case */
  font-size: var(--tile-font, 1.6rem);
  line-height: 1;
}

.tile.filled {
  background: var(--tile-typed-fill);
  border-color: var(--tile-typed-border);
  box-shadow: var(--tile-typed-shadow);
}

.tile.given {
  color: var(--muted);
}

.tile.solved {
  color: var(--tile-solved-ink);
  background: var(--tile-solved-fill);
  border-color: var(--blue-deep);
  box-shadow: var(--tile-solved-shadow);
  animation: tile-bounce 420ms ease-out both;
}

.tile.solved:nth-child(2) {
  animation-delay: 60ms;
}

.tile.solved:nth-child(3) {
  animation-delay: 120ms;
}

.tile.solved:nth-child(4) {
  animation-delay: 180ms;
}

.tile.solved:nth-child(5) {
  animation-delay: 240ms;
}

.tile.solved:nth-child(6) {
  animation-delay: 300ms;
}

.tile.solved:nth-child(7) {
  animation-delay: 360ms;
}

.tile.solved:nth-child(8) {
  animation-delay: 420ms;
}

.tile.pop {
  animation: tile-pop 140ms ease-out;
}

.tiles.shake {
  animation: shake 320ms ease-in-out;
}

.tile::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--red);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
}

.tiles.wrong .tile::after {
  animation: wrong-ring 520ms ease-in-out;
}

/* Wrong guesses */

.wrong-guesses {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.wrong-guesses:empty {
  display: none;
}

.wrong-guesses li {
  padding: 0.2rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--chip);
  border-radius: 999px;
}

/* Guess form, assists and feedback */

.guess-form {
  display: flex;
  gap: 0.5rem;
}

.guess-form input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  background: var(--field-bg);
  border: 2px solid var(--card-border);
  border-radius: 14px;
}

.guess-form input:focus {
  border-color: var(--blue);
}

button {
  min-height: 44px;
  padding: 0.6rem 1rem;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

button.primary {
  color: #ffffff;
  background: var(--navy);
  border-color: var(--navy);
}

button.primary:hover {
  border-color: var(--navy);
  filter: brightness(1.15);
}

:root[data-theme="dark"] button.primary {
  color: var(--navy);
  background: var(--blue-light);
  border-color: var(--blue-light);
}

.helpers {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.helpers button {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 0.5rem;
  white-space: nowrap;
}

.helpers .narrow,
.helpers .glossary-open svg {
  display: none;
}

.helpers .glossary-open svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 560px) {
  .helpers .glossary-open {
    flex: 0 0 44px;
    padding-inline: 0;
  }

  .helpers .glossary-open .wide {
    display: none;
  }

  .helpers .glossary-open svg {
    display: block;
  }
}

@media (max-width: 400px) {
  .helpers button {
    padding-inline: 0.3rem;
    font-size: 0.9rem;
  }

  .helpers .wide {
    display: none;
  }

  .helpers .narrow {
    display: inline;
  }
}

.helpers button[data-action="reveal"] {
  color: var(--red-ink);
  border-color: var(--red-ink);
}

.hints {
  margin: 1.25rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.hints:empty {
  display: none;
}

.feedback {
  min-height: 1.5em;
  margin: 1rem 0 0;
  font-weight: 700;
}

/* Solution */

.solution {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--card-border);
}

.answer {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.explanation {
  margin: 0;
  color: var(--muted);
}

.share-button {
  width: 100%;
  margin-top: 1.25rem;
}

.countdown {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.intro {
  margin: 1.25rem 0 0;
  color: var(--muted);
  text-align: center;
}

/* Archive */

.archive-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--card-border);
}

.archive-list li:last-child {
  border-bottom: 0;
}

.archive-list a {
  flex: 1;
  min-width: 10rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
}

.archive-list a:hover {
  text-decoration: underline;
}

.chip {
  padding: 0.2rem 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--chip);
  border-radius: 999px;
}

.chip-solved {
  color: var(--ink);
  border: 1px solid var(--blue);
}

.puzzle-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  font-weight: 700;
}

.puzzle-nav a {
  text-decoration: none;
}

.puzzle-nav a:hover {
  text-decoration: underline;
}

.disclaimer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Result window */

.result,
.confirm,
.stats-window,
.glossary {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  padding: 1rem;
  background: transparent;
  border: 0;
  display: grid;
  place-items: center;
}

.result:not([open]),
.confirm:not([open]),
.stats-window:not([open]),
.glossary:not([open]) {
  display: none;
}

.result::backdrop,
.confirm::backdrop,
.stats-window::backdrop,
.glossary::backdrop {
  background: rgb(7 18 47 / 60%);
}

.result-panel {
  width: min(22rem, 100%);
  padding: 1.5rem 1.25rem;
  color: var(--ink);
  text-align: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgb(7 18 47 / 35%);
}

.result-logo-wrap {
  position: relative;
  display: block;
  width: 72px;
  margin: 0 auto 0.5rem;
}

.result-logo {
  display: block;
  width: 72px;
  height: 72px;
}

.sparks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.spark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--blue);
  border-radius: 50%;
}

.spark-red {
  width: 8px;
  height: 8px;
  background: var(--red);
}

.result-title {
  margin: 0 0 1rem;
  font-size: 1.3rem;
}

.result-stats {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
  text-align: left;
}

.result-stats > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--card-border);
}

.result-stats > div:last-child {
  border-bottom: 0;
}

.result-stats dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.result-stats dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-community {
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  background: var(--chip);
  border-radius: 14px;
}

.result-note {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.result-action {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 1rem;
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  background: var(--navy);
  border: 2px solid var(--navy);
  border-radius: 14px;
  cursor: pointer;
}

:root[data-theme="dark"] .result-action {
  color: var(--navy);
  background: var(--blue-light);
  border-color: var(--blue-light);
}

.result-close {
  width: 100%;
  margin-top: 0.5rem;
}

.result .countdown {
  margin-top: 0.75rem;
}

.result-open {
  margin-top: 1rem;
}

.confirm-actions {
  display: grid;
  gap: 0.5rem;
}

.confirm-cancel {
  width: 100%;
}

.confirm-reveal {
  width: 100%;
  color: var(--red-ink);
  border-color: var(--red-ink);
}

.confirm-reveal:hover {
  border-color: var(--red-ink);
  background: var(--chip);
}

/* Toast */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 10;
  margin: 0;
  padding: 0.6rem 1.1rem;
  color: #ffffff;
  font-weight: 700;
  background: var(--navy);
  border-radius: 999px;
  box-shadow: 0 14px 34px rgb(7 18 47 / 35%);
  transform: translateX(-50%);
}

:root[data-theme="dark"] .toast {
  color: var(--navy);
  background: var(--blue-light);
}

/* Busy state */

.puzzle[data-busy="1"] .guess-form button,
.puzzle[data-busy="1"] .guess-form input,
.puzzle[data-busy="1"] .helpers button {
  pointer-events: none;
  opacity: 0.65;
}

/* Empty states */

.empty-state {
  text-align: center;
}

.empty-state img {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
}

/* Stats */

.stats-empty {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  margin: 0;
}

.stats dt {
  color: var(--muted);
}

.stats dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
}

/* How to play, privacy */

.howto p,
.howto li {
  max-width: 62ch;
}

.example {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  background: var(--chip);
  border-radius: 16px;
}

.example p {
  margin: 0.25rem 0;
}

.example-clue {
  font-family: var(--serif);
  font-size: 1.2rem;
}

.cta {
  margin-top: 2rem;
  font-size: 1.1rem;
  font-weight: 700;
}

/* Footer */

.site-footer {
  max-width: 680px;
  margin: 2rem auto 0;
  padding: 1.5rem 1rem 2.5rem;
  border-top: 1px solid var(--card-border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.site-footer a {
  color: var(--muted);
}

/* Admin */

/* the admin takes the new colours, but none of the texture or depth */
.admin .band {
  background: var(--navy);
}

.admin .site-header {
  display: flex;
  flex-wrap: wrap;
}

.admin .brand {
  flex: 0 0 auto;
}

.admin .site-nav {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
}

.admin .container {
  max-width: 900px;
}

.admin-form {
  display: grid;
  gap: 0.5rem;
  max-width: 360px;
}

.admin-form.wide {
  max-width: 100%;
}

.admin-form input,
.admin-form textarea,
.admin-form select {
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.admin-form textarea {
  min-height: 4rem;
}

.field {
  display: grid;
  gap: 0.25rem;
}

.flash {
  padding: 0.6rem 0.9rem;
  background: var(--chip);
  border-radius: 12px;
}

.error,
.stock-low,
.empty {
  color: var(--red-ink);
}

.error {
  margin: 0;
}

.calendar,
.puzzle-list {
  width: 100%;
  border-collapse: collapse;
}

.calendar td,
.puzzle-list td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.badge {
  color: var(--muted);
  font-size: 0.8rem;
}

.tabs {
  display: flex;
  gap: 0.75rem;
}

.tabs .active {
  font-weight: 800;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-form {
  display: inline;
}

.delete-form {
  margin-top: 2rem;
}

/* Motion */

@keyframes seal-rise {
  from {
    opacity: 0;
    transform: translate(-50%, 30px);
  }

  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes seal-crack-left {
  to {
    transform: translateX(-8px) rotate(-2deg);
  }
}

@keyframes seal-crack-right {
  to {
    transform: translateX(8px) rotate(2deg);
  }
}

@keyframes tile-pop {
  50% {
    transform: scale(1.08);
  }
}

@keyframes tile-bounce {
  40% {
    transform: translateY(-8px);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

/* the one place a size is animated rather than transform or opacity: a
   transform cannot fill a wrapped line from its own left edge */
@keyframes ink-fill {
  from {
    background-size: 0% 100%;
  }

  to {
    background-size: 100% 100%;
  }
}

@keyframes wrong-ring {
  0%,
  100% {
    opacity: 0;
  }

  25%,
  70% {
    opacity: 1;
  }
}

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

/* Desktop */

@media (min-width: 1024px) {
  .has-band .band {
    --cap-room: 126px;
    --cap-offset: 0.146;
    --seal-size: 900px;
    --seal-top-sealed: 113px;
  }

  [data-state="opened"] .band {
    --seal-top: 250px;
  }

  .site-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    padding: 1.25rem 1.5rem;
  }

  .site-nav {
    display: flex;
  }

  .nav-menu {
    display: none;
  }

  .brand {
    flex: 0;
    justify-content: center;
  }

  .brand img {
    width: 48px;
    height: 48px;
  }

  .header-tools {
    justify-content: flex-end;
  }

  .band-date {
    font-size: 0.95rem;
  }

  .seal-title {
    font-size: 1.6rem;
  }

  .seal-label {
    font-size: 0.75rem;
  }

  .has-band .container {
    max-width: 760px;
    margin-top: -3.75rem;
  }

  .puzzle,
  .panel {
    padding: 2.25rem 2rem;
    border-radius: 36px;
  }

  .clue {
    font-size: 2.6rem;
  }

  .tiles {
    --tile-max: 66px;
  }

  .tile {
    border-radius: 12px;
  }
}

/* Guide and glossary
   These three colours appear only here. In the game itself the clue carries
   the definition highlight and nothing else. */

.part-tanim {
  padding: 0.05em 0.25em;
  color: var(--def-ink);
  background: var(--def-bg);
  border-radius: 8px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.part-gosterge {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  text-decoration: underline;
  text-decoration-color: var(--red-ink);
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
}

.part-malzeme {
  padding: 0.05em 0.2em;
  border: 2px dashed var(--fodder);
  border-radius: 6px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.role {
  padding: 0.1rem 0.45rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--chip);
  border-radius: 999px;
}

.role-tanim {
  color: var(--def-ink);
  background: var(--def-bg);
}

.role-gosterge {
  color: var(--red-ink);
  box-shadow: inset 0 -3px 0 var(--red-ink);
}

.role-malzeme {
  color: var(--ink);
  border: 2px dashed var(--fodder);
}

.guide {
  max-width: 62ch;
  margin-inline: auto;
}

.guide-lead {
  color: var(--muted);
  font-size: 1.15rem;
}

.guide-rule,
.guide-tips {
  padding-left: 1.2rem;
}

.guide-rule li,
.guide-tips li {
  margin-bottom: 0.5rem;
}

.guide-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.guide-table {
  width: 100%;
  margin: 0.75rem 0;
  border-collapse: collapse;
}

.guide-table th,
.guide-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--card-border);
}

/* Anatomy box */

.anatomy {
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 20px;
}

.anatomy-clue {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.6;
}

.anatomy-clue .part {
  min-height: 0;
  padding: 0.05em 0.25em;
  font: inherit;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}

.anatomy-clue .part-tanim {
  background: var(--def-bg);
}

.anatomy-clue .part-malzeme {
  border: 2px dashed var(--fodder);
}

.anatomy-clue .part-gosterge {
  border: 0;
}

.anatomy-clue .part.lit {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.anatomy-rows {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
}

.anatomy-row {
  display: grid;
  grid-template-columns: minmax(8rem, auto) 1fr;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.5rem;
  border-radius: 12px;
}

.anatomy-row.lit {
  background: var(--chip);
}

.anatomy-row dt {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
  font-family: var(--serif);
}

.anatomy-row dd {
  margin: 0;
  color: var(--muted);
}

.anatomy-formula {
  padding: 0.6rem 0.75rem;
  font-family: var(--serif);
  background: var(--chip);
  border-radius: 12px;
}

/* Types */

.tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
}

.tab[aria-selected="true"] {
  color: #ffffff;
  background: var(--navy);
  border-color: var(--navy);
}

:root[data-theme="dark"] .tab[aria-selected="true"] {
  color: var(--navy);
  background: var(--blue-light);
  border-color: var(--blue-light);
}

.type-card {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
}

.type-card summary {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
}

.type-practice {
  margin: 0.75rem 0 0;
}

.type-practice a {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border: 2px solid var(--card-border);
  border-radius: 999px;
}

.type-practice a:hover {
  border-color: var(--blue);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.example-parts {
  margin: 0.5rem 0;
  padding-left: 0;
  list-style: none;
}

.example-parts li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.3rem;
}

.example-solution {
  font-family: var(--serif);
  font-size: 1.1rem;
}

/* Glossary window */

.glossary-panel {
  width: min(28rem, 100%);
  text-align: left;
}

.glossary-search {
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--field-bg);
  border: 2px solid var(--card-border);
  border-radius: 14px;
}

.glossary-body {
  max-height: 50vh;
  margin-bottom: 0.75rem;
  overflow-y: auto;
}

.glossary-group h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.95rem;
}

.glossary-name {
  margin: 0.5rem 0 0.1rem;
  font-family: var(--serif);
  font-weight: 600;
}

.glossary-summary {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.glossary-empty {
  color: var(--muted);
}

.glossary-more {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

/* Muamma nedir? */

.about {
  max-width: 64ch;
  margin-inline: auto;
}

.about-hero h1 {
  margin-bottom: 1.5rem;
  font-size: 2rem;
  font-weight: 650;
}

.about-opening {
  margin: 0 0 1.75rem;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-style: italic;
  font-weight: 550;
  line-height: 1.4;
  text-wrap: balance;
}

.about-closing {
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.4;
  border-top: 1px solid var(--card-border);
  text-wrap: balance;
}

.about-section {
  margin-top: 3rem;
}

.about-cards {
  display: grid;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.about-card {
  padding: 1rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
}

.about-card h3 {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
}

.about-card p {
  margin: 0;
  color: var(--muted);
}

.about-rhythm {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0 0;
}

.about-rhythm dt {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
}

.about-rhythm dd {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.about-cat {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.about-cat img {
  width: 140px;
  height: 140px;
}

.about-cat h2 {
  margin-top: 0;
}

.about-cat div {
  flex: 1;
  min-width: 16rem;
}

.about-end {
  margin-top: 3rem;
  text-align: center;
}

.about-end .about-closing {
  border-top: 0;
}

.about-cta {
  display: inline-block;
  width: auto;
  padding: 0.7rem 1.5rem;
}

@media (min-width: 680px) {
  .about-hero h1 {
    font-size: 2.4rem;
  }

  .about-opening {
    font-size: 1.9rem;
  }

  .about-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Reading pages
   Wider and airier than the game, which keeps its own narrow column. */

.reading .container {
  max-width: 840px;
  padding: 2rem 1rem 4rem;
}

.reading p,
.reading li,
.reading dd {
  line-height: 1.65;
}

.reading h1 {
  margin-bottom: 1.25rem;
  font-size: 2rem;
}

.reading h2 {
  margin: 2.75rem 0 0.75rem;
}

.reading h3 {
  margin: 1.75rem 0 0.35rem;
}

.reading p {
  margin: 0 0 1.1rem;
}

.reading .guide,
.reading .about,
.reading .howto {
  max-width: 100%;
}

.reading .guide > p,
.reading .about p,
.reading .howto > p,
.reading .guide-panel > p,
.reading .guide-tips,
.reading .guide-rule {
  max-width: 68ch;
}

.reading .about-hero p,
.reading .about-end p {
  margin-inline: auto;
}

@media (max-width: 480px) {
  .reading .container {
    padding: 1.5rem 0.75rem 3rem;
  }
}

@media (min-width: 680px) {
  .reading .about-rhythm {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem 2rem;
  }
}

@media (min-width: 900px) {
  .reading .guide-panel .type-card {
    margin: 0;
  }

  .reading .guide-panel > .type-card {
    break-inside: avoid;
  }

  .reading .type-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.9rem;
    align-items: start;
  }
}

/* Grain
   A fixed layer over the page and one over the band. Fixed so scrolling
   never has to repaint a document-tall texture. Never on the admin. */

body::after,
.band::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.04 0 0 0 0 0.12 0 0 0 0 0.36 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  pointer-events: none;
}

body::after {
  position: fixed;
  z-index: 5;
}

.band::after {
  z-index: 1;
}

body.admin::after,
.admin .band::after {
  content: none;
}
