/* Notebook-doodle theme: graph paper, felt-pen outlines, pencil heads in the background. */

:root {
  --paper: #fbfaf3;
  --grid: #d3e3ef;
  --margin: #f0aaaa;
  --ink: #262626;
  --ink-soft: #5a5a5a;
  --pencil: #9a9a9a;
  --green: #8cc63e;
  --green-light: #b8e06e;
  --green-dark: #6a9e26;
  --red: #d9473a;
  --correct: #9fd356;
  --wrong: #f07a6a;
  --partial: #f8c64a;
  --sticky: #fff3a8;
  --card: rgba(255, 255, 253, 0.9);
  --sketch: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --sketch-alt: 18px 225px 18px 255px / 255px 18px 225px 18px;
  --sketch-small: 14px 5px 12px 6px / 6px 12px 5px 14px;
  --sketch-small-alt: 6px 13px 5px 12px / 12px 5px 14px 6px;
  --pop: 3px 4px 0 var(--ink);
  --pop-small: 2px 3px 0 var(--ink);
  --hatch: repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.22) 0 3px, transparent 3px 8px);
  --hand: "Ink Free", "Marker Felt", "Segoe Print", "Chalkboard SE", "Comic Sans MS", cursive;
  color-scheme: light;
}

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

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  font-family: var(--hand);
  font-size: 1.05rem;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 2.75rem, var(--margin) 2.75rem, var(--margin) calc(2.75rem + 2px), transparent calc(2.75rem + 2px)),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 22px 22px, 22px 22px;
}

body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("/img/doodles.svg") center top / 960px auto repeat;
  opacity: 0.42;
}

h1,
h2 {
  font-family: var(--hand);
  font-weight: 700;
  margin: 0;
}

button,
input {
  font-family: var(--hand);
}

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

/* ——— Masthead ——— */

.masthead {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
}

/* A patch of clean paper so the pencil heads never run behind the title. */
.brand {
  padding: 0.5rem 1.5rem;
  text-align: center;
  background: radial-gradient(closest-side, var(--paper) 70%, rgba(251, 250, 243, 0));
}

.brand-mark {
  display: block;
  margin: 0 auto 0.25rem;
  transform: rotate(-8deg);
}

/* Outlined felt-pen letters with a hard drop, like the Doodle Jump logo. */
.brand h1 {
  display: inline-block;
  font-size: clamp(2.8rem, 9vw, 4.4rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--green);
  transform: rotate(-2deg);
  text-shadow:
    -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
    0 -2px 0 var(--ink), 0 2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
    4px 5px 0 var(--ink);
}

.tagline {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.icon-button {
  width: 2.75rem;
  height: 2.75rem;
  border: 2.5px solid var(--ink);
  border-radius: 50% 45% 52% 48% / 48% 52% 45% 50%;
  background: #fff;
  color: var(--ink);
  font: 700 1.3rem var(--hand);
  cursor: pointer;
  box-shadow: var(--pop-small);
  transition: transform 0.12s ease;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--green-light);
  transform: translateY(-2px) rotate(-6deg);
}

/* ——— Modes ——— */

.modes {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem auto 0;
  padding: 0 1rem;
}

.mode {
  padding: 0.3rem 1rem;
  border: 2px solid var(--ink);
  border-radius: var(--sketch-small);
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--pop-small);
}

.mode:nth-child(even) {
  border-radius: var(--sketch-small-alt);
}

.mode.is-active {
  font-weight: 700;
  background: var(--green);
  transform: rotate(-2deg);
}

.mode.is-soon {
  color: var(--ink-soft);
  background: transparent;
  border-style: dashed;
  box-shadow: none;
  cursor: not-allowed;
}

/* ——— Cards ——— */

.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
}

.scroll {
  position: relative;
  max-width: 36rem;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  text-align: center;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch);
  box-shadow: 4px 5px 0 rgba(38, 38, 38, 0.85);
  transform: rotate(-0.4deg);
}

/* A second, fainter pencil outline slightly off the first one. */
.scroll::before {
  content: "";
  position: absolute;
  inset: -6px -4px -3px -7px;
  border: 1.5px solid var(--ink);
  border-radius: var(--sketch-alt);
  opacity: 0.3;
  transform: rotate(0.7deg);
  pointer-events: none;
}

.lede {
  margin: 0.75rem 0 0;
  color: var(--ink-soft);
}

.yesterday {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

/* ——— Guess form ——— */

.guess-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.combo {
  position: relative;
  flex: 1;
  min-width: 0;
}

.combo input {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 1.15rem;
  color: var(--ink);
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small);
}

.combo input:focus {
  outline: 3px solid var(--green-light);
  outline-offset: 1px;
}

.suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 16rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  text-align: left;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small-alt);
  box-shadow: var(--pop);
}

.suggestions li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.suggestions li[aria-selected="true"],
.suggestions li:hover {
  background: #eef7dd;
}

.suggestions mark {
  background: none;
  color: var(--red);
  font-weight: 700;
}

.hints {
  display: grid;
  gap: 0.6rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.hints[hidden] {
  display: none;
}

/* Unlocked hints are sticky notes; locked ones are dashed pencil outlines. */
.hint {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.55rem 0.9rem;
  text-align: left;
  background: var(--sticky);
  border: 2px solid var(--ink);
  border-radius: var(--sketch-small);
  box-shadow: var(--pop-small);
  transform: rotate(-0.6deg);
}

.hint:nth-child(even) {
  border-radius: var(--sketch-small-alt);
  transform: rotate(0.5deg);
}

.hint-label {
  flex: none;
  font-weight: 700;
}

.hint.is-locked {
  color: var(--ink-soft);
  background: transparent;
  border: 2px dashed var(--pencil);
  box-shadow: none;
  transform: none;
}

.status {
  min-height: 1.4em;
  margin: 0.75rem 0 0;
  color: var(--red);
}

/* The green platform the doodler jumps on. */
.seal-button {
  padding: 0.6rem 1.4rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, var(--green-light) 0 35%, var(--green) 35% 80%, var(--green-dark) 80%);
  border: 2.5px solid var(--ink);
  border-radius: 18px 24px 16px 22px / 22px 16px 24px 18px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.seal-button:hover:not(:disabled),
.seal-button:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 7px 0 var(--ink);
}

.seal-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}

.seal-button:disabled {
  filter: grayscale(1);
  opacity: 0.5;
  cursor: not-allowed;
}

/* ——— Board ——— */

.board-scroll {
  overflow-x: auto;
  padding: 0 0.25rem 0.5rem;
}

.grid {
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 7px;
}

.grid th {
  padding: 0 0.25rem 0.3rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  border-bottom: 2.5px solid var(--ink);
}

.grid td {
  padding: 0;
  perspective: 600px;
}

.cell {
  display: grid;
  place-content: center;
  min-width: 7.25rem;
  min-height: 4.5rem;
  padding: 0.4rem 0.45rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  background-image: var(--hatch);
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small);
  box-shadow: var(--pop-small);
  animation: flip-in 0.55s ease both;
  animation-delay: var(--delay, 0s);
}

.grid td:nth-child(even) .cell {
  border-radius: var(--sketch-small-alt);
}

.cell.is-correct {
  background-color: var(--correct);
}

.cell.is-wrong {
  background-color: var(--wrong);
}

.cell.is-partial {
  background-color: var(--partial);
}

.cell .year-suffix {
  font-size: 0.8em;
  white-space: nowrap;
}

.cell .arrow {
  display: block;
  font-size: 1.3rem;
  line-height: 1;
}

.figure-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 11rem;
  min-height: 4.5rem;
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-weight: 700;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small-alt);
  box-shadow: var(--pop-small);
  animation: flip-in 0.4s ease both;
}

@keyframes flip-in {
  from {
    transform: rotateY(90deg);
    opacity: 0;
  }
  to {
    transform: rotateY(0);
    opacity: 1;
  }
}

/* ——— Medallion: initials in a hand-drawn circle ——— */

.medallion {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--sticky);
  border: 2.5px solid var(--ink);
  border-radius: 50% 45% 52% 48% / 48% 52% 45% 50%;
  box-shadow: 2px 2px 0 var(--ink);
}

.medallion-large {
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 1rem;
  font-size: 2rem;
  background: var(--green-light);
  box-shadow: var(--pop);
}

.board-title {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
  text-align: center;
}

.board-empty {
  max-width: 30rem;
  margin: 0.5rem auto;
  padding: 0.9rem 1rem;
  text-align: center;
  color: var(--ink-soft);
  border: 2.5px dashed var(--pencil);
  border-radius: var(--sketch-small);
}

.grid tr.is-new .figure-cell {
  animation: flip-in 0.4s ease both, new-guess 2.4s ease 0.4s;
}

@keyframes new-guess {
  0%, 50% { background: var(--sticky); }
  100% { background: #fff; }
}

.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
}

.chip {
  padding: 0.15rem 0.65rem;
  font-size: 0.95rem;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--sketch-small);
}

.chip.is-correct {
  background: var(--correct);
}

.chip.is-wrong {
  background: var(--wrong);
}

.chip.is-partial {
  background: var(--partial);
}

/* ——— Victory ——— */

.victory {
  transform: rotate(0.5deg);
}

.victory h2 {
  font-size: 2rem;
}

.victory p {
  margin: 0.5rem 0 1.25rem;
  color: var(--ink-soft);
}

.victory .countdown {
  margin: 1.25rem 0 0;
}

.countdown strong {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ——— Dialogs: a page torn from the notebook ——— */

.sheet {
  max-width: 30rem;
  padding: 1.75rem;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  border: 3px solid var(--ink);
  border-radius: var(--sketch);
  box-shadow: 6px 7px 0 var(--ink);
}

.sheet::backdrop {
  background: rgba(38, 38, 38, 0.45);
}

.sheet h2 {
  font-size: 1.8rem;
}

.sheet ul {
  padding-left: 1.2rem;
}

.sheet li {
  margin: 0.4rem 0;
}

.sheet form {
  text-align: center;
  margin-top: 1.25rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 1.25rem 0 0;
  text-align: center;
}

.stat-row dd {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.stat-row dt {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ——— Footer and text pages ——— */

.site-footer {
  padding: 0 1rem 2rem;
  text-align: center;
  font-size: 0.95rem;
}

.site-footer .about {
  max-width: 36rem;
  margin: 0 auto 1rem;
  color: var(--ink-soft);
}

.site-footer a,
.quote-source a,
.prose a {
  color: var(--ink);
  text-decoration-color: var(--green-dark);
  text-decoration-thickness: 2px;
}

/* Long pages stay straight: a tilt of a fraction of a degree shifts their bottom sideways. */
.prose,
.prose::before {
  transform: none;
}

.prose {
  max-width: 44rem;
  text-align: left;
  line-height: 1.5;
}

.prose h2 {
  margin-top: 1.5rem;
  font-size: 1.45rem;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose .seal-button {
  display: block;
  margin: 0 auto;
}

.prose .status {
  text-align: center;
  color: var(--green-dark);
}

.credits {
  padding-left: 1.2rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.credits li {
  margin: 0.25rem 0;
  overflow-wrap: anywhere;
}

.legal-address {
  font-style: normal;
}

.updated {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ——— Quote mode ——— */

.quote-card {
  position: relative;
  margin: 1rem 0 0;
  padding: 1.1rem 1.4rem 1.2rem 2.6rem;
  background: var(--sticky);
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-alt);
  box-shadow: var(--pop);
  transform: rotate(0.6deg);
}

.quote-card::before {
  content: "“";
  position: absolute;
  top: -0.35rem;
  left: 0.55rem;
  font-family: Georgia, serif;
  font-size: 3.6rem;
  line-height: 1;
  color: var(--green-dark);
}

.quote-card blockquote {
  margin: 0;
  font-family: var(--hand);
  font-size: 1.3rem;
  line-height: 1.45;
}

.attempts-panel {
  max-width: 36rem;
  width: 100%;
  margin: 0 auto;
}

.attempts-panel:has(.attempts:empty) {
  display: none;
}

.attempts {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attempt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.8rem;
  font-weight: 700;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small);
  box-shadow: var(--pop-small);
}

.attempt:nth-child(even) {
  border-radius: var(--sketch-small-alt);
}

.attempt.is-wrong {
  background: var(--hatch), var(--wrong);
}

.attempt.is-correct {
  background: var(--hatch), var(--correct);
}

.attempt.is-new {
  animation: attempt-in 0.35s ease-out;
}

@keyframes attempt-in {
  from {
    opacity: 0;
    transform: translateY(-0.5rem) rotate(-2deg);
  }
}

.quote-source,
.quote-original {
  margin: 0.5rem auto 0;
  max-width: 34rem;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* ——— Portrait mode: a photo taped into the notebook ——— */

.portrait-frame {
  position: relative;
  width: min(100%, 17rem);
  margin: 1.25rem auto 0;
  padding: 0.6rem 0.6rem 0.5rem;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small);
  box-shadow: var(--pop);
  transform: rotate(-1.2deg);
}

.portrait-frame::before {
  content: "";
  position: absolute;
  top: -0.8rem;
  left: 50%;
  width: 5.5rem;
  height: 1.5rem;
  background: rgba(255, 243, 168, 0.85);
  border: 1.5px solid rgba(38, 38, 38, 0.35);
  transform: translateX(-50%) rotate(3deg);
}

.portrait-frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  background: var(--grid);
  border: 2px solid var(--ink);
}

.portrait-level {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* ——— Chronology mode ——— */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  text-align: left;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0.6rem;
  font-weight: 700;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--sketch-small);
  box-shadow: var(--pop-small);
  counter-increment: rank;
}

.timeline-row::before {
  content: counter(rank);
  flex: none;
  width: 1.2rem;
  text-align: center;
  font-size: 1.2rem;
  color: var(--ink-soft);
}

.timeline-row:nth-child(even) {
  border-radius: var(--sketch-small-alt);
}

.timeline-row.is-movable {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.timeline-row.is-movable:hover {
  background: var(--sticky);
}

.timeline-row.is-movable:focus-visible {
  outline: 3px solid var(--green-dark);
  outline-offset: 2px;
}

.timeline.is-sorting .timeline-row {
  transition: transform 0.15s ease;
}

.timeline.is-sorting .timeline-row.is-dragging {
  position: relative;
  z-index: 1;
  cursor: grabbing;
  background: var(--sticky);
  box-shadow: 4px 8px 0 var(--ink);
  transition: none;
}

.timeline-row.is-correct {
  background: var(--hatch), var(--correct);
}

.timeline-row.is-wrong {
  background: var(--hatch), var(--wrong);
}

.row-name {
  flex: 1;
  min-width: 0;
}

.row-grip {
  flex: none;
  padding: 0 0.2rem;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--pencil);
}

.timeline-end {
  margin: 0.35rem 0 1rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.timeline-start {
  margin: 1rem 0 0;
}

.timeline-start + .timeline {
  margin-top: 0.35rem;
}

.timeline.is-solution {
  margin-bottom: 1.25rem;
}

.history {
  display: grid;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.history-row > span:first-child {
  margin-right: 0.4rem;
}

.square {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--ink);
  border-radius: var(--sketch-small);
}

.square.is-correct {
  background: var(--correct);
}

.square.is-wrong {
  background: var(--wrong);
}

@media (max-width: 40rem) {
  body {
    background-image:
      linear-gradient(var(--grid) 1px, transparent 1px),
      linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 22px 22px;
  }

  body::before {
    background-size: 640px auto;
  }

  .cell {
    min-width: 5rem;
    min-height: 3.8rem;
    padding: 0.3rem;
    font-size: 0.78rem;
  }

  .figure-cell {
    width: 8rem;
    font-size: 0.85rem;
  }

  .quote-card blockquote {
    font-size: 1.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cell,
  .figure-cell,
  .grid tr.is-new .figure-cell,
  .attempt.is-new {
    animation: none;
  }

  .seal-button,
  .icon-button,
  .timeline.is-sorting .timeline-row {
    transition: none;
  }
}
