:root {
  color-scheme: light;
  font-family: "HanziPen SC", "Comic Sans MS", "Kaiti SC", STKaiti, KaiTi, cursive;
  --ink: #292622;
  --ink-soft: #5f5a53;
  --paper: #f2efe7;
  --paper-light: #f8f5ed;
  --wall: #aaa8a2;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--wall);
}

body {
  min-height: 100dvh;
  margin: 0;
  padding: 18px 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 16%, transparent 82%, rgba(0, 0, 0, 0.06)),
    linear-gradient(180deg, #b5b3ad 0%, #9f9d97 100%);
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  content: "";
  background:
    repeating-linear-gradient(92deg, transparent 0 83px, rgba(48, 46, 42, 0.025) 84px 85px),
    repeating-linear-gradient(2deg, transparent 0 117px, rgba(255, 255, 255, 0.035) 118px 119px);
  pointer-events: none;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 5px;
}

.game-shell {
  position: relative;
  width: min(calc(100% - 34px), 1120px);
  min-height: calc(100dvh - 36px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 32px) clamp(16px, 4vw, 48px) clamp(22px, 3vw, 34px);
  background:
    repeating-linear-gradient(3deg, transparent 0 7px, rgba(51, 47, 41, 0.016) 8px 9px),
    repeating-linear-gradient(91deg, transparent 0 18px, rgba(255, 255, 255, 0.15) 19px 20px),
    var(--paper);
  border: 1px solid rgba(47, 43, 38, 0.32);
  border-radius: 2px 5px 3px 1px;
  box-shadow: 8px 12px 24px rgba(28, 27, 25, 0.27);
  transform: rotate(-0.08deg);
}

.game-shell::before,
.game-shell::after {
  position: absolute;
  z-index: 10;
  top: 12px;
  width: 8px;
  height: 8px;
  content: "";
  background: #282724;
  border-radius: 50%;
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.35);
}

.game-shell::before {
  left: 13px;
}

.game-shell::after {
  right: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 13px;
  border-bottom: 2px dashed rgba(41, 38, 34, 0.48);
}

.brand,
.topbar-actions,
.language-switch {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  transform: rotate(-1.1deg);
}

.brand-mark {
  display: block;
  width: 43px;
  height: 43px;
  overflow: hidden;
  background: var(--paper-light);
  border: 2px solid var(--ink);
  border-radius: 48% 44% 51% 46%;
  box-shadow: 2px 2px 0 rgba(41, 38, 34, 0.16);
  transform: rotate(2deg);
}

.brand-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

.brand-copy {
  display: grid;
  line-height: 1;
}

.brand-copy strong {
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.16em;
  transform: rotate(-3deg) skewY(-2deg);
}

.brand-copy small {
  margin-top: 5px;
  color: var(--ink-soft);
  font-family: "Comic Sans MS", "HanziPen SC", cursive;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  transform: translateX(5px) rotate(2deg);
}

.topbar-actions {
  gap: 14px;
  transform: rotate(-1.4deg);
}

.language-switch {
  gap: 7px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

.language-option,
.sound-toggle {
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.language-option {
  min-width: 45px;
  min-height: 35px;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 400;
  border: 1.5px solid var(--ink);
  border-radius: 46% 8% 42% 9%;
  transform: rotate(-2deg);
}

.language-option:nth-child(2) {
  border-radius: 8% 44% 11% 39%;
  transform: rotate(2.5deg) translateY(2px);
}

.language-option[aria-pressed="true"] {
  color: var(--ink);
  background: repeating-linear-gradient(-14deg, rgba(41, 38, 34, 0.12) 0 2px, transparent 2px 5px);
  box-shadow: 2px 2px 0 rgba(41, 38, 34, 0.16);
}

.language-option[data-locale="zh-CN"][aria-pressed="true"] {
  transform: rotate(-3.5deg) translateY(1px);
}

.language-option[data-locale="en-US"][aria-pressed="true"] {
  transform: rotate(3deg) translateY(2px);
}

.sound-toggle {
  display: grid;
  width: 44px;
  height: 40px;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 59% 41% 54% 46%;
  box-shadow: 2px 3px 0 rgba(41, 38, 34, 0.13);
  transform: rotate(5deg) translateY(2px);
}

.sound-on-icon,
.sound-off-icon {
  font-family: "Comic Sans MS", "HanziPen SC", cursive;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1;
  transform: translateX(-1px) rotate(-8deg);
}

.sound-off-icon {
  font-size: 19px;
  letter-spacing: 0;
  transform: rotate(7deg);
}

.sound-toggle .sound-off-icon,
.sound-toggle[aria-pressed="true"] .sound-on-icon {
  display: none;
}

.sound-toggle[aria-pressed="true"] .sound-off-icon {
  display: block;
}

.game {
  display: grid;
  justify-items: center;
  padding-top: clamp(13px, 2.6vh, 28px);
  text-align: center;
}

.intro {
  position: relative;
  z-index: 3;
  text-align: left;
  transform: translateX(18px) rotate(-3.2deg);
}

.eyebrow {
  margin: 0 0 4px 32px;
  color: var(--ink-soft);
  font-size: clamp(13px, 1.6vw, 15px);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: rotate(3.5deg);
}

h1 {
  position: relative;
  margin: 0;
  font-family: "HanziPen SC", "Comic Sans MS", "Kaiti SC", cursive;
  font-size: clamp(46px, 6.6vw, 74px);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 0.98;
  text-decoration: none;
}

h1::after {
  position: absolute;
  right: -9%;
  bottom: -5px;
  left: -4%;
  content: "";
  border-top: 2px solid var(--ink);
  transform: rotate(1.8deg);
}

.rough-char {
  display: inline-block;
  min-width: 0.52em;
  transform-origin: 50% 80%;
}

.rough-char-0 {
  transform: translateY(4px) rotate(-7deg);
}

.rough-char-1 {
  transform: translateY(-3px) rotate(5deg);
}

.rough-char-2 {
  transform: translateY(2px) rotate(3deg);
}

.rough-char-3 {
  transform: translateY(-1px) rotate(-4deg);
}

.brand-copy .rough-char {
  min-width: 0.58em;
}

html[lang="en-US"] h1 {
  font-family: "Comic Sans MS", "HanziPen SC", cursive;
  font-size: clamp(36px, 5vw, 59px);
  letter-spacing: 0.01em;
  text-transform: lowercase;
}

.subtitle {
  margin: 15px 0 0 -14px;
  color: var(--ink-soft);
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 400;
  transform: rotate(2deg);
}

.cow-wrap {
  position: relative;
  z-index: 2;
  width: min(90vw, 480px);
  margin-top: clamp(16px, 2.5vh, 25px);
}

.cow-card {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  background: var(--paper-light);
  border: 2px solid var(--ink);
  border-radius: 4px 8px 3px 6px;
  box-shadow: 6px 7px 0 rgba(41, 38, 34, 0.16);
  cursor: pointer;
  isolation: isolate;
  transform: rotate(0.45deg);
  -webkit-tap-highlight-color: transparent;
}

.cow-card::before {
  position: absolute;
  inset: 4px -4px -3px 3px;
  z-index: 4;
  content: "";
  border: 1px solid rgba(41, 38, 34, 0.72);
  border-radius: 6px 3px 7px 2px;
  pointer-events: none;
  transform: rotate(-0.5deg);
}

.cow-photo-crop {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1085 / 1450;
  overflow: hidden;
  border-radius: 3px;
}

.cow-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  transform: scale(0.995);
  transform-origin: center;
}

.cow-card:hover {
  transform: rotate(-0.3deg) translateY(-2px);
}

.cow-card:active {
  box-shadow: 2px 3px 0 rgba(41, 38, 34, 0.15);
  transform: rotate(0.5deg) translate(3px, 3px);
}

.tap-rings {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 17%;
  width: 18%;
  aspect-ratio: 1;
  border: 3px dashed var(--ink);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 50%) scale(0.35);
}

.cow-card.is-calling .cow-photo {
  animation: cow-call 720ms steps(5, end);
}

.cow-card.is-calling .tap-rings {
  animation: ring-pop 700ms ease-out;
}

.speech-bubble {
  position: absolute;
  z-index: 6;
  top: 7%;
  right: -8%;
  min-width: 120px;
  padding: 11px 17px 12px;
  color: var(--ink);
  font-size: clamp(21px, 4vw, 31px);
  font-weight: 700;
  background: var(--paper-light);
  border: 2px solid var(--ink);
  border-radius: 6px 3px 7px 2px;
  box-shadow: 3px 4px 0 rgba(41, 38, 34, 0.17);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) rotate(4deg) scale(0.75);
}

.speech-bubble.is-visible {
  animation: bubble-in 1.15s steps(6, end) both;
}

.controls {
  position: relative;
  z-index: 5;
  display: grid;
  justify-items: center;
  margin-top: -11px;
  transform: translateX(-16px) rotate(2deg);
}

.call-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: min(84vw, 320px);
  min-height: 59px;
  padding: 12px 24px;
  color: var(--ink);
  font-size: clamp(17px, 2.3vw, 20px);
  font-weight: 400;
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 3% 12% 4% 9%;
  box-shadow: 3px 4px 0 rgba(41, 38, 34, 0.15);
  cursor: pointer;
  transition: none;
  transform: rotate(-2.1deg);
  -webkit-tap-highlight-color: transparent;
}

.call-button::after {
  position: absolute;
  inset: 3px -4px -3px 2px;
  content: "";
  border: 1px solid rgba(41, 38, 34, 0.78);
  border-radius: 4% 12% 3% 10%;
  pointer-events: none;
  transform: rotate(0.7deg);
}

.call-button:hover {
  color: var(--ink);
  background: rgba(41, 38, 34, 0.05);
  transform: rotate(0.8deg) translateY(-1px);
}

.call-button:active {
  box-shadow: 1px 2px 0 rgba(41, 38, 34, 0.14);
  transform: translate(3px, 3px) rotate(0.7deg);
}

.button-icon {
  color: var(--ink);
  font-family: "Comic Sans MS", cursive;
  font-size: 24px;
  font-weight: 400;
  transform: rotate(-12deg);
}

.hint,
.call-count {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 400;
}

.hint {
  margin-top: 10px;
  text-decoration: none;
  transform: translateX(12px) rotate(-3deg);
}

.call-count {
  min-height: 18px;
  margin-top: 4px;
}

@keyframes cow-call {
  0% { transform: scale(0.995) rotate(0deg); }
  20% { transform: scale(1.025) rotate(-1.1deg); }
  40% { transform: scale(1.035) rotate(1deg); }
  60% { transform: scale(1.02) rotate(-0.8deg); }
  80% { transform: scale(1.01) rotate(0.5deg); }
  100% { transform: scale(0.995) rotate(0deg); }
}

@keyframes ring-pop {
  0% { opacity: 0; transform: translate(-50%, 50%) scale(0.35); }
  18% { opacity: 0.75; }
  100% { opacity: 0; transform: translate(-50%, 50%) scale(3.3) rotate(12deg); }
}

@keyframes bubble-in {
  0% { opacity: 0; transform: translateY(12px) rotate(4deg) scale(0.75); }
  18%, 72% { opacity: 1; transform: translateY(0) rotate(-2deg) scale(1); }
  100% { opacity: 0; transform: translateY(-9px) rotate(1deg) scale(0.94); }
}

@media (max-width: 560px) {
  body {
    padding: 0;
  }

  .game-shell {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: max(17px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
    border: 0;
    box-shadow: none;
  }

  .game-shell::before,
  .game-shell::after {
    top: 8px;
  }

  .brand-copy {
    display: none;
  }

  .brand-mark {
    width: 39px;
    height: 39px;
  }

  .language-option {
    min-width: 43px;
    padding-inline: 8px;
  }

  .game {
    padding-top: 12px;
  }

  .cow-wrap {
    width: min(87vw, 380px);
    margin-top: 14px;
  }

  .speech-bubble {
    top: 6%;
    right: -1%;
  }

  .call-button {
    min-height: 56px;
  }
}

@media (min-width: 900px), (min-width: 760px) and (max-height: 720px) {
  .game {
    grid-template-columns: minmax(300px, 520px) minmax(250px, 360px);
    grid-template-areas:
      "cow intro"
      "cow controls";
    justify-content: center;
    align-items: center;
    gap: 12px clamp(38px, 6vw, 78px);
    min-height: calc(100dvh - 162px);
    padding-top: 0;
  }

  .intro {
    grid-area: intro;
    align-self: end;
  }

  .cow-wrap {
    grid-area: cow;
    width: min(100%, 520px);
    margin: 0;
  }

  .controls {
    grid-area: controls;
    align-self: start;
    margin-top: 12px;
  }
}

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