:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --gold: #ffd528;
  --ink: #5b2d13;
  --green: #03c36e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, #40352e 0 9%, transparent 38%),
    #141210;
  touch-action: none;
  user-select: none;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

#game {
  position: relative;
  width: min(100vw, calc(100dvh * 430 / 956));
  height: min(100dvh, calc(100vw * 956 / 430));
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: #6c351a;
  box-shadow: 0 0 42px rgba(0, 0, 0, 0.75);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.pause-button {
  position: absolute;
  z-index: 8;
  top: 2.4%;
  left: 2.6%;
  width: 11.8%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13%;
  border: 3px solid #f7c793;
  border-radius: 29%;
  background: linear-gradient(#dc9c62, #bd6a34);
  box-shadow:
    0 5px 0 #80431e,
    0 8px 16px rgba(35, 10, 0, 0.35),
    inset 0 2px 4px rgba(255, 255, 255, 0.45);
}

.pause-button span {
  width: 19%;
  height: 53%;
  border: 2px solid #a85d34;
  border-radius: 4px;
  background: #fff4db;
  box-shadow: inset 0 1px 2px #fff;
}

.pause-button:active,
.booster:active,
.green-button:active {
  transform: translateY(3px);
}

.timer {
  position: absolute;
  z-index: 7;
  top: 7.7%;
  left: 50%;
  min-width: 37%;
  height: 6.3%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border: 3px solid rgba(233, 235, 230, 0.75);
  border-radius: 999px;
  color: white;
  background: rgba(15, 15, 14, 0.74);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  font-size: clamp(24px, 7.1vw, 35px);
  font-weight: 1000;
  letter-spacing: -2px;
  -webkit-text-stroke: 1.5px #111;
}

.clock-icon {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 5px solid #ffb000;
  border-radius: 50%;
  background: #fff8d4;
  box-shadow:
    0 0 0 2px #ff7b00,
    inset 0 0 5px #ffc927;
}

.clock-icon::before,
.clock-icon::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 10px;
  height: 8px;
  border-radius: 8px 8px 2px 2px;
  background: #ff8a00;
}

.clock-icon::before {
  left: -7px;
  transform: rotate(-38deg);
}

.clock-icon::after {
  right: -7px;
  transform: rotate(38deg);
}

.clock-icon i,
.clock-icon i::after {
  position: absolute;
  content: "";
  left: 50%;
  top: 50%;
  width: 2px;
  height: 8px;
  border-radius: 2px;
  background: #ff6a00;
  transform-origin: 50% 0;
  transform: translate(-50%, 0) rotate(180deg);
}

.clock-icon i::after {
  height: 6px;
  transform: translate(0, 0) rotate(120deg);
}

.stage-label {
  position: absolute;
  z-index: 4;
  top: 18.2%;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 15px 6px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(45, 22, 12, 0.45);
  font-weight: 800;
  font-size: clamp(11px, 3.2vw, 15px);
  letter-spacing: 2px;
  transition: opacity 0.25s;
}

.motion-badge {
  position: absolute;
  z-index: 9;
  top: 2.7%;
  right: 2.8%;
  height: 4.4%;
  min-width: 18%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 999px;
  color: #fff7df;
  background: rgba(37,29,24,.56);
  box-shadow: 0 3px 8px rgba(0,0,0,.28);
  font-size: clamp(11px,3vw,14px);
  font-weight: 900;
}

.motion-badge.ready {
  color: white;
  background: rgba(0,166,96,.78);
}

.motion-badge.warn {
  background: rgba(222,117,12,.82);
}

.motion-phone {
  width: 13px;
  height: 21px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 3px;
  box-shadow: -5px 0 0 -4px currentColor, 5px 0 0 -4px currentColor;
  transform: rotate(-8deg);
}

.slot-tray {
  position: absolute;
  z-index: 8;
  left: 2%;
  top: 76.8%;
  width: 96%;
  height: 8.1%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1.2%;
  padding: 2.1% 2.1% 2.4%;
  border: 4px solid #f7f7f5;
  border-radius: 16px 16px 12px 12px;
  background: linear-gradient(#f4f4f2, #bdbdbb);
  box-shadow:
    0 5px 0 #81817f,
    0 11px 19px rgba(0, 0, 0, 0.3),
    inset 0 2px 2px white;
}

.slot {
  position: relative;
  min-width: 0;
  border-radius: 11px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.35), transparent 45%),
    #9fa09f;
  box-shadow:
    inset 0 3px 7px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.8);
}

.slot-token {
  position: absolute;
  inset: -9% -9%;
  z-index: 2;
  background: center / contain no-repeat;
  filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.22));
  animation: slot-in 0.22s cubic-bezier(.2,1.45,.45,1);
}

.slot-token.matching {
  animation: slot-match 0.36s ease-in forwards;
}

@keyframes slot-in {
  from { opacity: 0; transform: translateY(-24px) scale(1.4) rotate(-8deg); }
  to { opacity: 1; transform: none; }
}

@keyframes slot-match {
  0% { transform: scale(1); filter: brightness(1) drop-shadow(0 4px 2px rgba(0,0,0,.2)); }
  45% { transform: scale(1.24); filter: brightness(1.5) drop-shadow(0 0 9px #fff8a7); }
  100% { opacity: 0; transform: scale(.1) rotate(22deg); }
}

.boosters {
  position: absolute;
  z-index: 8;
  left: 0;
  top: 85.7%;
  width: 100%;
  height: 14.3%;
  display: flex;
  align-items: flex-start;
  justify-content: space-evenly;
  padding-top: 2.6%;
  border-top: 4px solid #f9d0a7;
  border-radius: 28px 28px 0 0;
  background:
    linear-gradient(180deg, rgba(255, 201, 157, 0.96), rgba(198, 103, 63, 0.98)),
    #cf714a;
  box-shadow:
    0 -4px 0 rgba(105, 43, 18, 0.55),
    inset 0 3px 4px rgba(255,255,255,.4);
}

.booster {
  position: relative;
  width: 26%;
  height: 79%;
  padding: 1px 3px 5px;
  border: 3px solid #d18f00;
  border-radius: 16px;
  color: #753b18;
  background: linear-gradient(180deg, #fff622 0%, #ffc816 66%, #ef9f00 100%);
  box-shadow:
    0 6px 0 #8f481c,
    0 9px 12px rgba(90, 34, 9, 0.34),
    inset 0 2px 2px rgba(255,255,255,.8);
  transition: filter .2s, transform .08s;
}

.booster.used {
  filter: grayscale(0.75) brightness(0.72);
  pointer-events: none;
}

.booster-icon {
  display: block;
  width: 63%;
  height: 53%;
  margin: -2px auto -4px;
}

.booster strong {
  display: block;
  font-size: clamp(18px, 5.9vw, 28px);
  line-height: 1;
  font-weight: 1000;
  letter-spacing: 1px;
  text-shadow: 0 2px rgba(255,255,255,.52);
}

.booster-count {
  position: absolute;
  z-index: 3;
  right: -7px;
  top: -10px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 3px solid white;
  border-radius: 50%;
  color: white;
  background: #7b7f82;
  box-shadow: 0 2px 3px rgba(0,0,0,.25);
  font-size: 14px;
  font-weight: 900;
}

.gesture-hint {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 25.7%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff8dd;
  background: rgba(30, 17, 10, 0.72);
  box-shadow: 0 4px 8px rgba(0,0,0,.28);
  font-size: clamp(12px,3.5vw,16px);
  font-weight: 800;
  white-space: nowrap;
  animation: hint-bob 1.3s ease-in-out infinite alternate;
  transition: opacity .3s;
}

.shake-prompt {
  display: none !important;
  position: absolute;
  z-index: 16;
  left: 50%;
  top: 61%;
  width: 74%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 50px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 10px;
  padding: 11px 16px;
  border: 3px solid #ffe772;
  border-radius: 18px;
  color: #fff7dd;
  background: rgba(45,24,12,.9);
  box-shadow:
    0 7px 0 rgba(70,30,6,.72),
    0 12px 22px rgba(0,0,0,.34),
    inset 0 1px 0 rgba(255,255,255,.22);
  pointer-events: none;
  animation: shake-callout .7s ease-in-out infinite alternate;
}

.shake-prompt strong {
  align-self: end;
  font-size: clamp(17px,4.8vw,23px);
  line-height: 1;
}

.shake-prompt small {
  align-self: start;
  margin-top: 4px;
  color: #ffd993;
  font-size: clamp(10px,2.8vw,13px);
  line-height: 1.25;
}

.shake-phone {
  grid-row: 1 / span 2;
  justify-self: center;
  width: 27px;
  height: 44px;
  display: block;
  border: 4px solid #ffdb2c;
  border-radius: 7px;
  position: relative;
  transform: rotate(-12deg);
}

.shake-phone::before,
.shake-phone::after {
  content: "";
  position: absolute;
  top: 8px;
  width: 12px;
  height: 23px;
  border: 3px solid #ffdb2c;
  border-top-color: transparent;
  border-bottom-color: transparent;
}

.shake-phone::before { left: -19px; border-right: 0; border-radius: 50% 0 0 50%; }
.shake-phone::after { right: -19px; border-left: 0; border-radius: 0 50% 50% 0; }

@keyframes shake-callout {
  from { transform: translateX(-50%) rotate(-1deg) scale(.98); }
  to { transform: translateX(-50%) rotate(1deg) scale(1.02); }
}

.finger {
  display: inline-block;
  width: 11px;
  height: 17px;
  margin-right: 5px;
  vertical-align: -4px;
  border: 2px solid #fff7da;
  border-radius: 7px 7px 5px 5px;
  position: relative;
}

.finger::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: -4px;
  top: -5px;
  border: 2px solid rgba(255,255,255,.45);
  border-radius: 50%;
  animation: tap-ring 1.3s infinite;
}

@keyframes hint-bob {
  to { transform: translate(-50%, -4px); }
}

@keyframes tap-ring {
  from { opacity: .8; transform: scale(.5); }
  to { opacity: 0; transform: scale(1.5); }
}

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 19%;
  max-width: 84%;
  transform: translate(-50%, -8px);
  padding: 8px 15px;
  border-radius: 8px;
  color: white;
  background: rgba(28, 21, 16, .86);
  font-size: clamp(12px, 3.4vw, 16px);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(9, 10, 10, .72);
  backdrop-filter: blur(1px);
  animation: veil-in .2s ease-out;
}

.hidden {
  display: none !important;
}

@keyframes veil-in {
  from { opacity: 0; }
}

.paper-panel {
  position: relative;
  width: 64%;
  padding: 39px 22px 22px;
  border: 3px solid #e9d8b2;
  border-radius: 8px;
  color: #663216;
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,.7), transparent 32%),
    #fff8dc;
  box-shadow:
    0 8px 0 #b79058,
    0 16px 30px rgba(0,0,0,.46),
    inset 0 0 18px rgba(198,143,59,.16);
  text-align: center;
  transform-origin: center;
  animation: panel-pop .28s cubic-bezier(.2,1.2,.42,1);
}

@keyframes panel-pop {
  from { transform: scale(.72); opacity: 0; }
}

.panel-title {
  position: absolute;
  left: -4%;
  top: -21px;
  width: 108%;
  height: 45px;
  display: grid;
  place-items: center;
  border: 3px solid #0089b4;
  border-radius: 7px 7px 3px 3px;
  color: white;
  background: linear-gradient(#23c4ec, #099dd1);
  box-shadow: 0 4px 0 #087394;
  font-size: clamp(20px, 5.9vw, 29px);
  font-weight: 1000;
  letter-spacing: 3px;
  text-shadow: 0 2px #087392;
}

.panel-close {
  position: absolute;
  z-index: 4;
  right: -13px;
  top: -15px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  border: 3px solid #8c4929;
  border-radius: 8px;
  color: #fff6d8;
  background: #e45f3a;
  box-shadow: 0 2px 0 #853619;
  font-size: 23px;
  line-height: 1;
  font-weight: 1000;
}

#stageArt {
  width: 62%;
  height: auto;
  margin: 5px auto -5px;
}

.stage-panel h2 {
  margin: 0;
  color: #f04428;
  font-size: clamp(19px, 5.3vw, 26px);
  font-weight: 1000;
}

.stage-panel p {
  margin: 6px 0 14px;
  color: #7a4c28;
  font-size: clamp(11px, 3.1vw, 14px);
  line-height: 1.45;
}

.green-button,
.gray-button {
  width: 76%;
  min-height: 45px;
  margin: 4px auto;
  border: 3px solid #039c57;
  border-radius: 8px;
  color: white;
  background: linear-gradient(#12d67a, #00b763);
  box-shadow:
    0 4px 0 #087d49,
    inset 0 2px 2px rgba(255,255,255,.38);
  font-size: clamp(17px, 4.8vw, 23px);
  font-weight: 1000;
  text-shadow: 0 2px #087d49;
}

.gray-button {
  border-color: #999;
  background: linear-gradient(#babdc1, #8e9296);
  box-shadow: 0 4px 0 #65686b;
  text-shadow: 0 2px #626568;
}

.pause-panel {
  width: 58%;
  padding-top: 54px;
}

.toggle-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 0 0 14px;
}

.setting-toggle {
  position: relative;
  width: 50px;
  height: 75px;
  padding: 2px;
  color: #9a663d;
  background: transparent;
}

.setting-toggle > span {
  display: grid;
  place-items: center;
  height: 37px;
  color: #dc8f54;
  font-size: 31px;
  font-weight: 1000;
}

.setting-toggle small {
  display: block;
  font-size: 11px;
  font-weight: 800;
}

.setting-toggle i {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: 2px auto 0;
  border-radius: 5px;
  color: white;
  background: #1dc875;
  font-style: normal;
  font-size: 14px;
}

.setting-toggle:not(.active) {
  filter: grayscale(1);
  opacity: .55;
}

.sound-symbol::before {
  content: "";
  width: 18px;
  height: 24px;
  display: block;
  clip-path: polygon(0 34%, 35% 34%, 85% 0, 85% 100%, 35% 66%, 0 66%);
  background: currentColor;
}

.vibrate-symbol::before {
  content: "";
  width: 16px;
  height: 29px;
  display: block;
  border: 3px solid currentColor;
  border-radius: 3px;
  box-shadow: -7px 0 0 -5px currentColor, 7px 0 0 -5px currentColor;
}

.result-panel {
  position: relative;
  width: 72%;
  padding: 55px 23px 23px;
  border: 4px solid #d8c9a5;
  border-radius: 7px;
  color: #5c2e17;
  background: #fff9e5;
  box-shadow:
    0 8px 0 #997342,
    0 18px 34px rgba(0,0,0,.5);
  text-align: center;
  animation: panel-pop .28s cubic-bezier(.2,1.2,.42,1);
}

.result-ribbon {
  position: absolute;
  left: -8%;
  top: -29px;
  width: 116%;
  height: 58px;
  display: grid;
  place-items: center;
  clip-path: polygon(0 19%, 12% 19%, 12% 0, 88% 0, 88% 19%, 100% 19%, 92% 100%, 74% 82%, 26% 82%, 8% 100%);
  color: white;
  background: linear-gradient(#8f969d, #555a61 55%, #767d83);
  filter: drop-shadow(0 4px 0 #34373a);
  font-size: clamp(26px, 7.5vw, 36px);
  font-weight: 1000;
  letter-spacing: 8px;
  text-shadow: 0 3px #383b3f;
}

.result-ribbon.win {
  background: linear-gradient(#ffdc35, #ef9c09 60%, #ffb312);
  filter: drop-shadow(0 4px 0 #9e5b08);
  text-shadow: 0 3px #9e5b08;
}

#resultArt {
  width: 82%;
  height: auto;
  margin: -5px auto -3px;
}

.result-panel h2 {
  margin: 0 0 4px;
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 1000;
}

.result-panel p {
  min-height: 20px;
  margin: 0 0 9px;
  color: #916644;
  font-size: clamp(11px, 3.2vw, 15px);
}

.text-button {
  display: block;
  margin: 13px auto 0;
  padding: 5px 10px;
  color: #715845;
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
}

.safe-bottom {
  position: absolute;
  z-index: 9;
  bottom: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-bottom);
  pointer-events: none;
  background: #bd633f;
}

.loading-overlay {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #fff4d6;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,181,59,.24), transparent 36%),
    linear-gradient(155deg,#2c160d,#6c2f16);
  font-size: clamp(15px,4vw,19px);
  letter-spacing: 1px;
  transition: opacity .3s;
}

.loading-overlay.done {
  opacity: 0;
  pointer-events: none;
}

.loading-goose {
  position: relative;
  width: 88px;
  height: 72px;
  border-radius: 52% 48% 45% 48%;
  background: #fffdf2;
  box-shadow: 0 7px 0 rgba(0,0,0,.14);
  animation: loading-waddle .55s ease-in-out infinite alternate;
}

.loading-goose::before {
  content: "";
  position: absolute;
  left: 7px;
  top: -39px;
  width: 30px;
  height: 54px;
  border-radius: 50% 50% 35% 35%;
  background: #fffdf2;
  transform: rotate(-18deg);
}

.loading-goose::after {
  content: "";
  position: absolute;
  left: -10px;
  top: -28px;
  width: 23px;
  height: 12px;
  clip-path: polygon(0 50%,100% 0,100% 100%);
  background: #f28a13;
}

.loading-goose span::before,
.loading-goose span::after {
  content: "";
  position: absolute;
  bottom: -12px;
  width: 28px;
  height: 8px;
  border-radius: 80%;
  background: #f28a13;
}

.loading-goose span::before { left: 12px; }
.loading-goose span::after { right: 10px; }

@keyframes loading-waddle {
  from { transform: translateX(-5px) rotate(-3deg); }
  to { transform: translateX(5px) rotate(3deg); }
}

@media (max-height: 680px) and (orientation: landscape) {
  #game {
    width: min(46vw, calc(100dvh * 430 / 956));
  }
}

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