/* fallback sized like Yusei Magic so the swap does not move the layout */
@font-face {
  font-family: "Yusei Fallback";
  src: local("Arial");
  size-adjust: 105.5%;
}

:root {
  --floor: #9a6a42;
  --wood: #5b3a24;
  --tatami: #cbbf8c;
  --paper: #f6f0e1;
  --cream: #f1dfbf;
  --calico: #e28a3c;
  --black: #1d1b1f;
  --sun: #ffd889;
  --display: "Yusei Magic", "Yusei Fallback", sans-serif;
  --body: "Zen Kaku Gothic New", "Hiragino Sans", Arial, sans-serif;
  --mono: "Overpass Mono", "Courier New", monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--black);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  background: var(--floor) url("/images/floor.webp") repeat;
  background-size: 420px;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a,
button {
  color: inherit;
  cursor: pointer;
}

p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: min(1160px, 100% - 32px);
  margin: 0 auto;
}

/* buttons: soft paper tiles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 24px;
  border: 0;
  border-radius: 14px;
  font-family: var(--display);
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--black);
  background: var(--paper);
  box-shadow: 0 4px 0 var(--wood), 0 8px 14px rgba(40, 20, 8, 0.25);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--wood), 0 12px 18px rgba(40, 20, 8, 0.25);
}

.btn--warm {
  background: var(--calico);
  color: #fff;
}

.title {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  font-weight: 400;
  line-height: 1.1;
  color: var(--paper);
  -webkit-text-stroke: 6px var(--wood);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(40, 20, 8, 0.35);
}

/* header: a low wooden shelf with a framed photo and a paper tag */
.top {
  padding-top: 16px;
}

.shelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 18px 12px;
  border-radius: 6px;
  background: linear-gradient(#6d4a30, var(--wood));
  box-shadow: 0 10px 0 #3e2717, 0 18px 24px rgba(30, 15, 5, 0.35);
}

.shelf-photo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--display);
  font-size: 1.4rem;
  color: var(--paper);
  text-decoration: none;
}

.shelf-photo img {
  padding: 4px;
  background: var(--paper);
  border-radius: 3px;
  transform: rotate(-4deg);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
}

.shelf-tags {
  display: flex;
  gap: 10px;
}

.shelf-tags a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 4px 4px 12px 12px;
  font-family: var(--display);
  font-size: 1rem;
  text-decoration: none;
  background: var(--paper);
  transform: rotate(3deg);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.4s ease;
}

.shelf-tags a:first-child {
  transform: rotate(-2deg);
}

.shelf-tags a:hover {
  transform: rotate(0) translateY(-2px);
}

/* hero: the family row, name sitting above them */
.hero {
  padding: 34px 0 40px;
}

.hero-title {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  height: 1em;
  margin: 0 0 -0.32em;
  padding: 0 4%;
  font-family: var(--display);
  font-size: clamp(4rem, 14vw, 11rem);
  font-weight: 400;
  line-height: 1;
  color: var(--cream);
  -webkit-text-stroke: 0.09em var(--wood);
  paint-order: stroke fill;
  text-shadow: 0 0.06em 0 rgba(40, 20, 8, 0.45);
}

/* the cats sit higher, the puppy a little lower */
.hero-neko {
  transform: translateY(-0.08em) rotate(-3deg);
}

.hero-inu {
  transform: translateY(0.18em) rotate(2deg);
}

.paw-o {
  position: relative;
  display: inline-block;
}

.paw-o svg {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 0.26em;
  height: 0.26em;
  fill: var(--calico);
  transform: translate(-50%, -50%) rotate(-12deg);
  animation: stamp 0.6s 0.4s ease-out both;
}

@keyframes stamp {
  from {
    transform: translate(-50%, -50%) rotate(-12deg) scale(1.8);
  }
  to {
    transform: translate(-50%, -50%) rotate(-12deg) scale(1);
  }
}

.hero-frame {
  border: 12px solid var(--wood);
  border-radius: 8px;
  background: var(--wood);
  box-shadow: inset 0 0 0 3px #3e2717, 0 16px 30px rgba(30, 15, 5, 0.4);
}

.hero-frame img {
  width: 100%;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  border-radius: 2px;
}

.hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
}

.hero-line {
  font-family: var(--display);
  font-size: clamp(1.4rem, 2.8vw, 2.1rem);
  color: var(--paper);
  text-shadow: 0 2px 0 var(--wood), 0 0 12px rgba(40, 20, 8, 0.6);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

/* the family on the paper sliding door */
.family {
  padding: 40px 0;
}

.shoji {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  padding: 26px;
  border: 12px solid var(--wood);
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent calc(50% - 3px), #c9b48f calc(50% - 3px), #c9b48f calc(50% + 3px), transparent calc(50% + 3px)),
    var(--paper);
  box-shadow: 0 16px 30px rgba(30, 15, 5, 0.35);
}

.photo {
  margin: 0;
  padding: 10px 10px 14px;
  background: #fff;
  box-shadow: 0 6px 14px rgba(40, 20, 8, 0.25);
}

.photo:nth-child(odd) {
  transform: rotate(-1.5deg);
}

.photo:nth-child(even) {
  transform: rotate(1.5deg) translateY(10px);
}

.photo p {
  margin-top: 10px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.photo b {
  display: block;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--wood);
}

/* things settle in slowly, like a cat sitting down */
.can-settle .settle {
  translate: 0 22px;
}

.can-settle .settle.is-in {
  translate: 0 0;
  transition: translate 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

/* the quiz, cards laid out on a tatami mat */
.quiz {
  padding: 40px 0;
}

.quiz-intro {
  max-width: 36em;
  margin: -6px 0 22px;
  font-weight: 700;
  color: var(--paper);
  text-shadow: 0 1px 3px rgba(30, 15, 5, 0.8);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  padding: 24px;
  border: 10px solid #3f5a3a;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, #cbbf8c 0 6px, #c2b582 6px 9px);
  box-shadow: 0 16px 30px rgba(30, 15, 5, 0.35);
}

.card {
  perspective: 1200px;
}

.card-inner {
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  padding: 8px 8px 12px;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 6px 12px rgba(40, 20, 8, 0.25);
  backface-visibility: hidden;
}

.card-back {
  transform: rotateY(180deg);
}

.card img {
  border-radius: 6px;
}

.card-q {
  flex: 1;
  margin: 10px 4px;
  font-weight: 700;
  line-height: 1.35;
}

.card-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pick {
  min-height: 44px;
  padding: 6px;
  border: 2px solid var(--wood);
  border-radius: 10px;
  font-family: var(--display);
  font-size: 1rem;
  background: #fff;
  transition: background 0.3s ease;
}

.pick:hover {
  background: var(--sun);
}

.card-way {
  margin: 10px 4px 2px;
  font-family: var(--display);
  font-size: 1.3rem;
  color: var(--wood);
}

.card-way.is-right {
  color: #3f7a34;
}

.card-way.is-wrong {
  color: #b5462a;
}

.card-line {
  margin: 0 4px;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* the dog leaks out: the doorbell result bounces */
.card.is-bouncy.is-flipped .card-back img {
  animation: bounce 0.7s 0.7s ease-out;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-14px);
  }
  55% {
    transform: translateY(0);
  }
  75% {
    transform: translateY(-6px);
  }
}

.score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  margin-top: 22px;
  padding: 16px 22px;
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 6px 14px rgba(40, 20, 8, 0.3);
}

.score-count {
  font-family: var(--mono);
  font-size: 0.95rem;
}

.score-count b {
  color: var(--calico);
}

.score-line {
  flex: 1;
  font-family: var(--display);
  font-size: 1.2rem;
}

/* story strip */
.story {
  padding: 40px 0;
}

.strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.frame {
  margin: 0;
  padding: 12px 12px 16px;
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 10px 20px rgba(30, 15, 5, 0.35);
}

.frame:nth-child(2) {
  margin-top: 36px;
}

.frame:nth-child(3) {
  margin-top: 12px;
}

.frame img {
  border-radius: 2px;
}

.frame p {
  margin-top: 12px;
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.35;
}

/* the coin: a collar far too small for him, with a big brass tag */
.coin {
  padding: 50px 0;
}

.collar {
  max-width: 700px;
  margin: 0 auto;
}

.collar-strap {
  position: relative;
  height: 34px;
  margin: 0 8%;
  border-radius: 17px;
  background: linear-gradient(#e0473a, #b52c22);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2), 0 6px 10px rgba(30, 15, 5, 0.35);
}

.collar-strap::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -26px;
  width: 30px;
  height: 34px;
  margin-left: -15px;
  border: 7px solid #c99a3a;
  border-radius: 50%;
}

.tag {
  margin-top: 22px;
  padding: 30px 32px 28px;
  border-radius: 40px;
  text-align: center;
  background: radial-gradient(circle at 30% 20%, #f7dc8a, #d6a948 70%);
  box-shadow: inset 0 0 0 4px #b78a2e, 0 14px 24px rgba(30, 15, 5, 0.4);
}

.ticker {
  font-family: var(--display);
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  line-height: 1;
  color: var(--wood);
}

.tag-line {
  margin-top: 8px;
  font-weight: 700;
}

.ca-box {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  padding: 12px 16px;
  border: 2px dashed var(--wood);
  border-radius: 16px;
  background: rgba(255, 248, 225, 0.75);
}

.ca-text {
  display: block;
  font-family: var(--mono);
  font-size: clamp(11px, 3.2vw, 18px);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ca-status {
  display: block;
  margin-top: 4px;
  font-family: var(--display);
  color: var(--wood);
}

.tag-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

/* footer */
.end {
  padding: 20px 0 40px;
}

.end-frame {
  position: relative;
  border: 12px solid var(--wood);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 16px 30px rgba(30, 15, 5, 0.4);
}

.end-frame img {
  width: 100%;
  aspect-ratio: 16 / 7;
  object-fit: cover;
}

.end-title {
  position: absolute;
  left: 50%;
  top: 6%;
  font-family: var(--display);
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  line-height: 1;
  color: var(--cream);
  -webkit-text-stroke: 0.09em var(--wood);
  paint-order: stroke fill;
  transform: translateX(-50%);
  white-space: nowrap;
}

.end-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 20px;
}

.end-note {
  max-width: 40em;
  font-size: 0.95rem;
  color: var(--paper);
  text-shadow: 0 1px 3px rgba(30, 15, 5, 0.8);
}

/* 404 */
.lost {
  padding: 40px 0 70px;
}

.lost-card {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 30px;
  align-items: center;
  padding: 26px;
  border: 12px solid var(--wood);
  border-radius: 8px;
  background: var(--paper);
}

.lost-title {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  font-weight: 400;
  line-height: 1;
  color: var(--wood);
}

.lost-card p {
  margin-bottom: 22px;
}

@media (max-width: 900px) {
  .shoji,
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .lost-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .shelf {
    padding: 8px 10px 10px;
  }

  .shelf-photo {
    font-size: 1.15rem;
  }

  .shelf-tags {
    gap: 6px;
  }

  .shelf-tags a {
    padding: 0 8px;
    font-size: 0.9rem;
  }

  .hero-title {
    font-size: clamp(3rem, 18.5vw, 5.2rem);
  }

  .hero-frame {
    border-width: 8px;
  }

  .hero-frame img {
    aspect-ratio: 16 / 9;
  }

  .shoji {
    gap: 14px;
    padding: 14px;
    border-width: 8px;
  }

  .photo p {
    font-size: 0.85rem;
  }

  .cards {
    gap: 12px;
    padding: 12px;
    border-width: 6px;
  }

  .card-q,
  .card-line {
    font-size: 0.85rem;
  }

  .card-pick {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .pick {
    min-height: 40px;
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .strip {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 0 6%;
  }

  .frame:nth-child(n) {
    margin-top: 0;
  }

  .tag {
    padding: 24px 18px;
    border-radius: 28px;
  }

  .end-frame img {
    aspect-ratio: 4 / 3;
  }

  .end-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  /* swap the card faces instead of flipping */
  .card.is-flipped .card-inner {
    transform: none;
  }

  .card.is-flipped .card-front {
    visibility: hidden;
  }

  .card-back {
    transform: none;
    visibility: hidden;
  }

  .card.is-flipped .card-back {
    visibility: visible;
  }
}
