:root {
  color-scheme: light;
  font-family: "Ma Shan Zheng", "Microsoft YaHei", sans-serif;
  background: #d8d0c0;
  color: #292720;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 920px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 25%, rgb(255 255 255 / 35%), transparent 30%),
    radial-gradient(circle at 85% 70%, rgb(97 76 49 / 10%), transparent 35%),
    repeating-linear-gradient(
      93deg,
      transparent 0,
      transparent 4px,
      rgb(69 52 33 / 2%) 5px
    ),
    #d8d0c0;
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.welcome,
.game {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.welcome-card {
  position: relative;
  width: min(520px, 70vw);
  padding: 64px 68px 58px;
  text-align: center;
  background:
    linear-gradient(rgb(255 255 255 / 38%), rgb(255 255 255 / 8%)),
    #f3eddd;
  border: 1px solid rgb(91 72 43 / 17%);
  box-shadow:
    0 24px 60px rgb(50 39 26 / 20%),
    0 2px 3px rgb(50 39 26 / 12%);
  transform: rotate(-0.35deg);
}

.welcome-card::before,
.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 3px,
      rgb(87 64 35 / 2%) 4px
    ),
    radial-gradient(circle at 20% 30%, rgb(107 78 40 / 6%) 0 1px, transparent 2px);
  background-size: auto, 17px 19px;
}

.eyebrow {
  margin: 0 0 13px;
  color: #83745c;
  font-family: "Kalam", "Segoe Print", cursive;
  font-size: 16px;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 48px;
  font-weight: 400;
  letter-spacing: 0.03em;
}

h1 span {
  white-space: nowrap;
  color: #a22f2a;
}

.instructions {
  margin: 26px 0 22px;
  color: #665f53;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.9;
}

.best-time {
  min-height: 22px;
  margin: 0 0 30px;
  color: #8b382f;
  font-size: 17px;
}

.primary-button {
  position: relative;
  min-width: 150px;
  padding: 12px 30px 10px;
  cursor: pointer;
  color: #fdf9ed;
  background: #9e332e;
  border: 0;
  border-radius: 2px;
  box-shadow: 2px 3px 0 #6f241f;
  font-size: 20px;
  letter-spacing: 0.12em;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.primary-button:hover {
  background: #ad3933;
}

.primary-button:active {
  box-shadow: 1px 1px 0 #6f241f;
  transform: translate(1px, 2px);
}

.primary-button:focus-visible,
.sound-toggle:focus-visible {
  outline: 3px solid rgb(158 51 46 / 38%);
  outline-offset: 4px;
}

.sound-toggle {
  position: fixed;
  z-index: 20;
  top: 24px;
  right: 28px;
  width: 42px;
  height: 42px;
  padding: 0;
  cursor: pointer;
  color: #5a5144;
  background: rgb(244 238 222 / 75%);
  border: 1px solid rgb(80 62 39 / 18%);
  border-radius: 50%;
  box-shadow: 0 3px 12px rgb(49 38 24 / 10%);
  font-family: "Kalam", cursive;
  font-size: 21px;
}

.sound-toggle.is-muted {
  color: #9b9181;
}

.sound-toggle.is-muted::after {
  content: "";
  position: absolute;
  top: 19px;
  left: 9px;
  width: 24px;
  height: 2px;
  background: currentColor;
  transform: rotate(-42deg);
}

.game {
  padding-block: 20px;
}

.paper-shell {
  position: relative;
  height: min(94vh, 877px);
  aspect-ratio: 210 / 297;
  filter: drop-shadow(0 18px 25px rgb(45 34 20 / 22%));
}

.paper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(93deg, rgb(255 255 255 / 36%), transparent 28%),
    #f6f0df;
  border: 1px solid rgb(101 79 49 / 15%);
}

.number {
  --rotation: 0deg;
  --scale-x: 1;
  position: absolute;
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  color: #292824;
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-family: "Kalam", "Segoe Print", cursive;
  font-size: var(--number-size, 23px);
  font-weight: var(--number-weight, 400);
  line-height: 36px;
  text-align: center;
  transform:
    translate(-50%, -50%)
    rotate(var(--rotation))
    scaleX(var(--scale-x));
  -webkit-tap-highlight-color: transparent;
}

.number:focus {
  outline: none;
}

.number::after {
  content: "";
  position: absolute;
  inset: -2px -3px;
  pointer-events: none;
  border: 2px solid transparent;
  border-radius: 48% 53% 46% 55%;
  transform: rotate(-8deg) scale(0.7);
  transition:
    transform 150ms cubic-bezier(0.2, 0.8, 0.3, 1.25),
    border-color 80ms ease;
}

.number.found {
  cursor: default;
  color: #6a302b;
}

.number.found::after {
  border-color: #b3312b;
  transform: rotate(-8deg) scale(1);
}

.number.wrong {
  z-index: 3;
  color: #c2241c;
  animation: wrong-shake 260ms ease;
}

@keyframes wrong-shake {
  0%,
  100% {
    margin-left: 0;
  }
  25% {
    margin-left: -4px;
  }
  50% {
    margin-left: 4px;
  }
  75% {
    margin-left: -2px;
  }
}

.finish-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(64 49 31 / 24%);
  backdrop-filter: blur(1.5px);
}

.finish-overlay[hidden] {
  display: none;
}

.finish-card {
  width: 72%;
  padding: 38px 32px 34px;
  text-align: center;
  background: #f8f1df;
  border: 1px solid rgb(91 69 42 / 20%);
  box-shadow: 0 18px 45px rgb(47 34 20 / 28%);
  transform: rotate(0.5deg);
}

.finish-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  color: #ae342e;
  border: 2px solid #ae342e;
  border-radius: 52% 45% 55% 48%;
  font-family: "Kalam", cursive;
  font-size: 31px;
  line-height: 49px;
  transform: rotate(-7deg);
}

.finish-card h2 {
  margin: 0 0 26px;
  font-size: 32px;
  font-weight: 400;
}

.result-label {
  margin: 0 0 2px;
  color: #756b5b;
  font-family: "Microsoft YaHei", sans-serif;
  font-size: 13px;
}

.result-time {
  margin: 0;
  color: #9e332e;
  font-family: "Kalam", "Segoe Print", cursive;
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.finish-best {
  min-height: 25px;
  margin: 9px 0 24px;
  color: #655d51;
  font-size: 16px;
}

@media (max-height: 760px) {
  .paper-shell {
    height: 94vh;
  }

  .number {
    width: 32px;
    height: 32px;
    line-height: 32px;
  }

  .finish-card {
    padding-block: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
