:root {
  color-scheme: dark;
  --sky: #1986d2;
  --soil: #5f3920;
  --soil-dark: #2b1a13;
  --amber: #f6b830;
  --orange: #f26522;
  --cream: #fff3cf;
  --teal: #38d6be;
  --danger: #ff4d2e;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 10%, rgba(255, 221, 96, 0.22), transparent 28rem),
    linear-gradient(135deg, #0d375f 0%, #15202b 48%, #19140f 100%);
  color: var(--cream);
  font-family: "Trebuchet MS", Verdana, sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(#ffd45d, var(--amber) 58%, #dc7e14);
  color: #1d140a;
  cursor: pointer;
  font: 900 1rem/1 "Trebuchet MS", Verdana, sans-serif;
  padding: 0.9rem 1.15rem;
  text-transform: uppercase;
  box-shadow: 0 5px 0 #7b4010, 0 12px 24px rgba(0, 0, 0, 0.28);
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #7b4010, 0 8px 18px rgba(0, 0, 0, 0.25);
}

.game-shell {
  width: min(100vw, 960px);
  min-height: min(100vh, 780px);
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(230px, 290px);
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.stage-wrap {
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: 2 / 3;
  border: 5px solid #19110b;
  border-radius: 8px;
  overflow: hidden;
  background: var(--soil-dark);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: crisp-edges;
}

.hud {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  justify-content: center;
  min-width: 0;
}

.hud-title,
.brand {
  color: #ffcb21;
  font-weight: 1000;
  letter-spacing: 0;
  text-shadow: 4px 4px 0 #111, 0 0 18px rgba(255, 115, 0, 0.7);
  text-transform: uppercase;
}

.hud-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 0.92;
}

.brand {
  font-size: clamp(2.35rem, 10vw, 5.25rem);
  line-height: 0.78;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: var(--orange);
}

.brand.small {
  font-size: clamp(2rem, 8vw, 3.6rem);
}

.stat,
.meter {
  border: 3px solid #27170c;
  border-radius: 8px;
  background: rgba(54, 32, 19, 0.9);
  padding: 0.75rem;
  box-shadow: inset 0 0 0 2px rgba(255, 224, 136, 0.08);
}

.stat span,
.meter span {
  display: block;
  color: #e3c188;
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 0.2rem;
  color: white;
  font-size: clamp(1.25rem, 3vw, 1.55rem);
  line-height: 1.05;
}

.bar {
  height: 1.2rem;
  margin-top: 0.45rem;
  border-radius: 999px;
  overflow: hidden;
  background: #1b100b;
  border: 2px solid #120b07;
}

.bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--danger), #ffe66d, var(--teal));
  transition: width 120ms linear;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem;
  text-align: center;
  background:
    linear-gradient(rgba(6, 13, 20, 0.3), rgba(6, 13, 20, 0.72)),
    radial-gradient(circle at center 18%, rgba(22, 156, 221, 0.82), rgba(63, 34, 18, 0.94) 72%);
}

.overlay p {
  max-width: 24rem;
  margin: 0;
  color: white;
  font-size: clamp(1rem, 2.7vw, 1.22rem);
  font-weight: 800;
  line-height: 1.35;
  text-shadow: 2px 2px 0 #15100c;
}

.hidden {
  display: none;
}

.menu-portrait {
  position: relative;
  width: min(52vw, 210px);
  aspect-ratio: 0.78;
  margin: -0.35rem 0 -0.1rem;
  filter: drop-shadow(8px 10px 0 rgba(0, 0, 0, 0.38));
}

.sean-face {
  position: absolute;
  left: 50%;
  top: 11%;
  width: 34%;
  height: 23%;
  transform: translateX(-50%) rotate(-5deg);
  border: 4px solid #26170f;
  border-radius: 49% 44% 52% 46%;
  background: #f0c08a;
  z-index: 4;
}

.sean-face::before {
  content: "";
  position: absolute;
  left: 38%;
  top: 37%;
  width: 20%;
  height: 23%;
  border-radius: 45%;
  border-right: 4px solid #8c4d2c;
}

.sean-face i {
  position: absolute;
  top: 29%;
  width: 18%;
  height: 17%;
  border-radius: 50%;
  background: white;
  border: 2px solid #26170f;
}

.sean-face i:first-child {
  left: 22%;
}

.sean-face i:nth-child(2) {
  right: 21%;
}

.sean-face i::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 45%;
  height: 45%;
  border-radius: 50%;
  background: #1b1510;
}

.sean-face b {
  position: absolute;
  left: 34%;
  bottom: 17%;
  width: 31%;
  height: 11%;
  border-radius: 0 0 999px 999px;
  background: #3a1c16;
}

.sean-hair {
  position: absolute;
  left: 31.5%;
  top: 6.5%;
  width: 37%;
  height: 12%;
  transform: rotate(-9deg);
  border: 4px solid #26170f;
  border-bottom: 0;
  border-radius: 52% 48% 18% 18%;
  background: #2b1a13;
  z-index: 5;
}

.sean-hair::before,
.sean-hair::after {
  content: "";
  position: absolute;
  top: -22%;
  width: 48%;
  height: 70%;
  background: #2b1a13;
  border-top: 4px solid #26170f;
  border-radius: 60% 50% 0 0;
}

.sean-hair::before {
  left: -4%;
  transform: rotate(-18deg);
}

.sean-hair::after {
  right: -3%;
  transform: rotate(20deg);
}

.sean-shirt {
  position: absolute;
  left: 37%;
  top: 34%;
  width: 27%;
  height: 31%;
  border: 4px solid #26170f;
  border-radius: 14px 14px 8px 8px;
  background: #eee8d8;
  transform: rotate(4deg);
  z-index: 3;
}

.sean-shirt::after {
  content: "";
  position: absolute;
  right: 18%;
  top: 42%;
  width: 30%;
  height: 17%;
  border-radius: 50%;
  background: rgba(93, 57, 32, 0.42);
}

.sean-shirt::before {
  content: "";
  position: absolute;
  left: -24%;
  top: 80%;
  width: 145%;
  height: 95%;
  background:
    linear-gradient(90deg, #245da4 0 31%, transparent 32% 55%, #245da4 56% 100%);
  border-radius: 0 0 8px 8px;
  z-index: -1;
}

.shovel-stick {
  position: absolute;
  left: 18%;
  top: 8%;
  width: 6%;
  height: 78%;
  border: 3px solid #26170f;
  border-radius: 999px;
  background: #8b5b2f;
  transform: rotate(-23deg);
  z-index: 1;
}

.shovel-stick::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -21%;
  width: 420%;
  height: 27%;
  transform: translateX(-50%);
  border: 4px solid #26170f;
  border-radius: 18px 18px 55% 55%;
  background:
    radial-gradient(circle at 34% 24%, #f8f8f8 0 18%, transparent 19%),
    linear-gradient(#dedede, #8d8d8d);
}

.shovel-head {
  display: none;
}

.mode-select {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  width: min(100%, 22rem);
}

.intro-scene {
  width: min(86%, 22rem);
  aspect-ratio: 1.45;
  border: 4px solid #21150d;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(#3aa7ee 0 45%, #78c85d 46% 100%);
  box-shadow: 0 12px 0 rgba(0, 0, 0, 0.28);
}

.intro-yard {
  position: relative;
  width: 100%;
  height: 100%;
}

.intro-yard::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#26a3ef 0 45%, #c7aa72 46% 100%);
  opacity: 0;
  animation: china-arrival 7.5s linear infinite;
  z-index: 0;
}

.intro-post {
  position: absolute;
  left: 66%;
  bottom: 18%;
  width: 7%;
  height: 45%;
  background: #8a592d;
  border: 3px solid #26170f;
  transform-origin: bottom center;
  animation: post-wobble 7.5s linear infinite;
  z-index: 1;
}

.intro-shovel {
  position: absolute;
  left: 34%;
  bottom: 16%;
  width: 4%;
  height: 46%;
  border-radius: 999px;
  background: #7b4a2b;
  border: 2px solid #26170f;
  transform-origin: 50% 80%;
  animation: shovel-hit 7.5s linear infinite;
  z-index: 5;
}

.intro-shovel::after {
  content: "";
  position: absolute;
  left: -120%;
  bottom: -13%;
  width: 330%;
  height: 20%;
  border-radius: 0 0 999px 999px;
  background: #9b9b9b;
  border: 2px solid #26170f;
}

.intro-sean {
  position: absolute;
  left: 22%;
  bottom: 16%;
  width: 19%;
  height: 42%;
  animation: sean-pop 7.5s linear infinite;
  z-index: 6;
}

.intro-sean::before {
  content: "";
  position: absolute;
  left: 24%;
  top: 0;
  width: 44%;
  height: 34%;
  border-radius: 50%;
  background: #f0c08a;
  border: 3px solid #26170f;
  box-shadow: 0 -7px 0 #2b1a13;
}

.intro-sean::after {
  content: "";
  position: absolute;
  left: 14%;
  top: 34%;
  width: 62%;
  height: 47%;
  border-radius: 8px;
  background: #eee8d8;
  border: 3px solid #26170f;
}

.intro-stone {
  position: absolute;
  left: 47%;
  bottom: 19%;
  width: 10%;
  aspect-ratio: 1;
  border-radius: 46%;
  background: radial-gradient(circle at 35% 30%, #f3e8ff, #7c48b7 52%, #2b1748);
  border: 3px solid #26170f;
  animation: stone-magic 7.5s linear infinite;
  z-index: 4;
}

.intro-burst {
  position: absolute;
  left: 51.5%;
  bottom: 25%;
  width: 8%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(207, 118, 255, 0.72);
  box-shadow: 0 0 28px 16px rgba(207, 118, 255, 0.45);
  transform: translate(-50%, 50%) scale(0);
  animation: teleport-flash 7.5s linear infinite;
  z-index: 7;
}

.intro-china-shop,
.intro-china-roof,
.intro-china-lantern,
.intro-china-sign {
  position: absolute;
  opacity: 0;
  animation: china-arrival 7.5s linear infinite;
  z-index: 2;
}

.intro-china-shop {
  bottom: 23%;
  width: 31%;
  height: 39%;
  border: 3px solid #26170f;
  background: #a9362b;
}

.intro-china-shop.shop-one {
  left: 3%;
}

.intro-china-shop.shop-two {
  right: 4%;
  width: 35%;
  background: #c58a2f;
}

.intro-china-roof {
  bottom: 59%;
  width: 39%;
  height: 15%;
  background: #1e2c35;
  clip-path: polygon(0 70%, 50% 5%, 100% 70%, 88% 100%, 12% 100%);
}

.intro-china-roof.roof-one {
  left: -1%;
}

.intro-china-roof.roof-two {
  right: 1%;
  width: 43%;
}

.intro-china-lantern {
  bottom: 54%;
  width: 7%;
  aspect-ratio: 0.8;
  border-radius: 50%;
  border: 2px solid #7a2417;
  background: #c92f22;
  z-index: 3;
}

.intro-china-lantern.lantern-one {
  left: 38%;
}

.intro-china-lantern.lantern-two {
  right: 37%;
}

.intro-china-sign {
  right: 17%;
  bottom: 42%;
  width: 11%;
  height: 18%;
  display: grid;
  place-items: center;
  border: 3px solid #26170f;
  background: #1f4e92;
  color: white;
  font-weight: 1000;
  font-size: 1.7rem;
  z-index: 3;
}

@keyframes shovel-hit {
  0%, 16% { transform: rotate(-22deg); }
  22%, 32% { transform: rotate(24deg); }
  40%, 100% { transform: rotate(-22deg); }
}

@keyframes post-wobble {
  0%, 15% { transform: rotate(0deg); }
  25%, 38% { transform: rotate(-7deg); }
  44%, 100% { transform: rotate(0deg); }
}

@keyframes stone-magic {
  0%, 28% { transform: scale(0.45); opacity: 0; }
  35%, 68% { transform: scale(1); opacity: 1; }
  72%, 100% { transform: scale(0.45); opacity: 0; }
}

@keyframes teleport-flash {
  0%, 44% { transform: translate(-50%, 50%) scale(0); opacity: 0; }
  55% { transform: translate(-50%, 50%) scale(2.2); opacity: 1; }
  74%, 100% { transform: translate(-50%, 50%) scale(0); opacity: 0; }
}

@keyframes sean-pop {
  0%, 54% { transform: translate(0, 0); opacity: 1; }
  64%, 76% { transform: translate(58%, -33%) rotate(12deg); opacity: 0; }
  77%, 100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes china-arrival {
  0%, 68% { opacity: 0; }
  74%, 100% { opacity: 1; }
}

.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  color: #f8dfad;
  font-size: 0.9rem;
  font-weight: 800;
}

kbd {
  min-width: 2rem;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
  background: rgba(0, 0, 0, 0.35);
}

.mobile-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.mobile-controls button {
  aspect-ratio: 1;
  padding: 0;
  font-size: 2.2rem;
}

.mobile-controls .wide-control {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  min-height: 3rem;
  font-size: 0.95rem;
}

@media (max-width: 760px) {
  body {
    place-items: start center;
  }

  .game-shell {
    min-height: 100vh;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 0.6rem;
  }

  .stage-wrap {
    width: min(100%, 440px);
    justify-self: center;
  }

  .hud {
    width: min(100%, 440px);
    justify-self: center;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-title {
    display: none;
  }

  .mobile-controls {
    grid-column: 1 / -1;
  }
}
