* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #aa835f;
}
body {
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  color: #fff;
  display: grid;
  place-items: center;
}
body::before {
  content: "";
  position: fixed;
  inset: -25px;
  background:
    linear-gradient(#3e302b44, #302e414d),
    url("assets/cover-background.png") center/cover;
  filter: blur(18px);
  pointer-events: none;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}
button:disabled {
  cursor: wait;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#game {
  position: relative;
  isolation: isolate;
  width: min(100vw, 56.28dvh);
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  background: #b59d7a url("assets/room-mobile.png") center/cover;
  box-shadow: 0 0 70px #3a2f3166;
  container-type: inline-size;
}
#world {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}
#cover {
  position: absolute;
  inset: 0;
  background: #b59d7a url("assets/cover-background.png") center/cover;
  z-index: 10;
  transition: opacity 0.28s ease;
}
#coverArt {
  position: absolute;
  width: 100%;
  aspect-ratio: 941/1672;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  max-height: 100%;
  overflow: hidden;
}
#coverOriginal {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  transition: opacity 0.12s;
}
.cover-layer-stack {
  position: absolute;
  inset: 0;
}
.cover-layer-stack img {
  position: absolute;
  display: block;
  object-fit: contain;
  pointer-events: none;
}
.cover-bg {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover !important;
}
.cover-title {
  left: 19%;
  top: 3.8%;
  width: 62%;
  height: 24.5%;
}
.cover-hero {
  left: 21%;
  top: 30.8%;
  width: 57%;
  height: 45.5%;
}
.cover-gold {
  left: 17.8%;
  top: 78.4%;
  width: 64.4%;
  height: 12.1%;
}
.cover-button-text {
  position: absolute;
  top: 80.9%;
  left: 27.5%;
  font-weight: 1000;
  font-size: clamp(20px, 7.4cqw, 39px);
  color: #fff8de;
  -webkit-text-stroke: 1.5px #683718;
  paint-order: stroke fill;
  text-shadow: 0 2px 0 #633615;
}
.cover-tutorial {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  top: 92.2%;
  font-size: clamp(10px, 3.35cqw, 18px);
  font-weight: 900;
  text-shadow: 0 2px 3px #163b4d;
}
.start-hotspot {
  position: absolute;
  left: 18.5%;
  top: 78.5%;
  width: 63%;
  height: 12%;
  border: 0;
  background: transparent;
  border-radius: 999px;
  transition: box-shadow 0.15s;
}
.start-hotspot:not(:disabled):active {
  box-shadow: inset 0 0 0 200px #a46a2222;
}
.start-hotspot:focus-visible {
  outline: 3px solid #fff4bb;
  outline-offset: 2px;
  box-shadow: 0 0 23px #ffd85c;
}
#cover.departing {
  opacity: 0;
  pointer-events: none;
}
#cover.departing #coverOriginal {
  opacity: 0;
}
#loading {
  position: absolute;
  bottom: max(4px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #3c35439c;
  border: 1px solid #fff8;
  padding: 7px 16px;
  border-radius: 30px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 1px #0005;
}
#loading button {
  border: 0;
  background: #ffdb65;
  border-radius: 12px;
  color: #63471f;
  margin-left: 10px;
  padding: 5px 10px;
}
header {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 13px;
  right: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 2;
}
#portrait {
  width: 43px;
  height: 43px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #444775;
  background: #e3e5ff;
}
.hud {
  display: flex;
  gap: 7px;
}
.hud > div {
  height: 42px;
  border: 1.5px solid #fffa;
  border-radius: 16px;
  padding: 4px 11px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: #41405266;
  backdrop-filter: blur(7px);
  text-shadow: 0 2px 2px #25243880;
}
.hud small {
  font-size: 10px;
  font-weight: 800;
}
.hud strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hud strong.number-long {
  font-size: 19px;
  letter-spacing: -0.7px;
}
.hud strong.number-xlong {
  font-size: 16px;
}
.hud span {
  font-size: 12px;
}
.hud .gold {
  font-size: 28px;
  color: #ffdf5e;
  text-shadow: 0 2px #ab7b29;
  -webkit-text-stroke: 0.7px #ce8c21;
}
.round-button {
  height: 40px;
  width: 40px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #49405177;
  color: white;
  font-size: 21px;
  backdrop-filter: blur(5px);
  padding: 0;
  line-height: 1;
}
#powerHud {
  position: absolute;
  z-index: 3;
  top: max(67px, calc(env(safe-area-inset-top) + 53px));
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  width: 82%;
  transform: translateX(-50%);
  pointer-events: none;
}
#powerHud span {
  padding: 5px 10px;
  border: 1.5px solid #fff9;
  border-radius: 999px;
  background: #303b58b8;
  box-shadow: 0 3px 9px #1e293c55;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px #203040;
  backdrop-filter: blur(6px);
}
#comboBadge {
  background: linear-gradient(135deg, #ff7b42d9, #d93a74d9) !important;
}
#powerBadge {
  background: linear-gradient(135deg, #1eb8cbd9, #426bcbd9) !important;
}
#countdown {
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 90px;
  font-weight: 1000;
  color: #ffe89a;
  -webkit-text-stroke: 1.5px #fff5ce;
  text-shadow:
    0 5px #b57e36,
    0 12px 30px #2f283f66;
  pointer-events: none;
  z-index: 3;
}
#touch {
  position: absolute;
  bottom: max(63px, calc(env(safe-area-inset-bottom) + 46px));
  left: 17px;
  right: 17px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}
#touch button {
  pointer-events: auto;
  width: 54px;
  height: 50px;
  border: 1.5px solid #fff9;
  border-radius: 15px;
  background: #29425065;
  color: #fff;
  font-size: 26px;
  box-shadow: 0 3px 6px #22334455;
  backdrop-filter: blur(4px);
  line-height: 1;
  padding: 3px;
}
#touch button:active {
  background: #f9c85a99;
  transform: translateY(2px);
}
#touch #jump {
  width: 61px;
  height: 54px;
  margin-top: -4px;
  background: #b8863a8c;
}
#touch small {
  display: block;
  font-size: 9px;
  margin-top: 2px;
}
footer {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 13px;
  right: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  z-index: 2;
}
footer > span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-shadow: 0 2px 5px #1b354d;
}
#sound {
  position: absolute;
  right: 0;
  width: 28px;
  height: 28px;
  border: 1px solid #fff8;
  border-radius: 50%;
  background: #35465766;
  color: #fff;
  font-size: 17px;
  line-height: 1;
}
#sound small {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 9px;
}
.modal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: #2c273d68;
  backdrop-filter: blur(6px);
}
.dialog {
  position: relative;
  width: 86%;
  max-width: 340px;
  max-height: 94%;
  overflow: auto;
  background: #fff8e9;
  border: 3px solid #fff;
  border-radius: 27px;
  box-shadow: 0 20px 60px #28213855;
  color: #4b4d65;
  text-align: center;
  padding: 18px 22px 12px;
}
.dialog-title {
  width: 125px;
  height: 74px;
  object-fit: contain;
  display: block;
  margin: 0 auto 2px;
}
.dialog-hero {
  width: 78px;
  height: 93px;
  object-fit: contain;
  display: block;
  margin: 2px auto 10px;
}
.dialog > small {
  display: block;
  letter-spacing: 2px;
  font-size: 8px;
  font-weight: 800;
  color: #a29ba8;
}
.dialog h2 {
  font-size: 26px;
  letter-spacing: -0.8px;
  margin: 10px 0;
}
.dialog p {
  font-size: 11px;
  color: #8a8490;
  margin: 8px 0 16px;
  line-height: 1.8;
}
#results {
  display: flex;
  justify-content: center;
  gap: 27px;
  margin: 19px 0;
}
#results small {
  font-size: 10px;
  display: block;
  color: #98909e;
}
#results strong {
  font-size: 23px;
  display: block;
  margin-top: 5px;
}
.record {
  color: #a3989b;
  font-size: 10px;
  margin: 12px 0;
}
.gold-button {
  position: relative;
  display: block;
  border: 0;
  padding: 0;
  background: transparent url("assets/cover-button.png") center/100% 100%
    no-repeat;
  width: 100%;
  height: 78px;
  font-size: 22px;
  font-weight: 900;
  color: #fff9dd;
  -webkit-text-stroke: 1px #714520;
  paint-order: stroke fill;
  text-shadow: 0 1px #764a28;
}
.gold-button > span {
  display: block;
  margin: 0 33px 0 0;
  padding-top: 2px;
}
.gold-button:active {
  transform: translateY(2px);
  filter: brightness(0.97);
}
.secondary {
  display: block;
  border: 0;
  background: none;
  margin: 2px auto 0;
  padding: 10px 20px;
  color: #938795;
  font-size: 11px;
}
#toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border: 1px solid #fff8;
  border-radius: 25px;
  background: #34435888;
  font-size: 12px;
  font-weight: 900;
  color: #ffe6a4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 4;
}
@media (min-width: 700px) {
  #game {
    border-left: 1px solid #fff2;
    border-right: 1px solid #fff2;
  }
}
@media (max-height: 600px) {
  header {
    top: 9px;
    left: 9px;
    right: 9px;
  }
  #portrait {
    width: 31px;
    height: 31px;
  }
  .hud > div {
    height: 31px;
    padding: 3px 6px;
    border-radius: 12px;
  }
  .hud strong {
    font-size: 17px;
  }
  .hud small {
    font-size: 8px;
  }
  .hud .gold {
    font-size: 21px;
  }
  .round-button {
    width: 29px;
    height: 29px;
    font-size: 16px;
  }
  footer > span {
    font-size: 8px;
  }
  #touch {
    bottom: 47px;
    left: 12px;
    right: 12px;
  }
  #touch button {
    width: 40px;
    height: 38px;
    font-size: 20px;
  }
  #touch #jump {
    width: 46px;
    height: 42px;
  }
  .dialog {
    padding: 10px 18px 8px;
  }
  .dialog-title {
    width: 85px;
    height: 47px;
  }
  .dialog-hero {
    width: 50px;
    height: 60px;
    margin: 0 auto 6px;
  }
  .dialog h2 {
    font-size: 20px;
    margin: 8px 0;
  }
  .dialog p {
    font-size: 9px;
    margin: 6px 0;
  }
  .gold-button {
    height: 55px;
    font-size: 18px;
  }
  .gold-button > span {
    margin-right: 23px;
  }
  .record {
    font-size: 8px;
    margin: 8px;
  }
  #results {
    margin: 13px 0;
  }
  #results strong {
    font-size: 18px;
  }
  .secondary {
    font-size: 9px;
    padding: 7px;
  }
  #countdown {
    font-size: 65px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Layered result board: all art stays separate from live score text. */
.modal[data-kind="result"] {
  background: #2c273d75;
  backdrop-filter: blur(9px) saturate(0.9);
}
.modal[data-kind="result"] .dialog {
  width: min(94%, 390px);
  min-width: min(300px, 94%);
  max-width: 390px;
  height: min(74dvh, 660px);
  max-height: 680px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  padding: clamp(116px, 17.5dvh, 156px) 0 4%;
  color: #4a3341;
  font-family:
    "Arial Rounded MT Bold", "Avenir Next Rounded", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  background: transparent url("assets/result-panel.webp") center/100% 100%
    no-repeat;
  box-shadow: none;
  animation: result-pop 0.42s cubic-bezier(0.18, 0.88, 0.32, 1.18) both;
}
.modal[data-kind="result"] .dialog-title {
  position: absolute;
  z-index: 4;
  left: 7%;
  top: 3.8%;
  width: 30%;
  height: 11%;
  object-fit: contain;
  margin: 0;
  filter: drop-shadow(0 3px 2px #163a4f66);
}
.modal[data-kind="result"] .dialog-hero {
  position: absolute;
  z-index: 2;
  left: 29%;
  top: -1.3%;
  width: 45%;
  height: 25%;
  object-fit: contain;
  object-position: center bottom;
  margin: 0;
  filter: drop-shadow(0 8px 8px #50372955);
  pointer-events: none;
}
.modal[data-kind="result"] .dialog > small {
  position: absolute;
  z-index: 4;
  right: 5%;
  top: 6.7%;
  display: none;
  width: 38%;
  padding: 7px 7px 6px 13px;
  border-radius: 5px 2px 2px 5px;
  background: linear-gradient(180deg, #ffd95f, #e9a725 72%, #c57c16);
  box-shadow:
    0 3px 0 #96601c,
    0 6px 10px #18354744;
  color: #69390e;
  font-size: 7px;
  font-weight: 1000;
  line-height: 1.25;
  letter-spacing: 0.4px;
  white-space: nowrap;
  text-shadow: 0 1px #fff0a8;
  transform: rotate(-1deg);
}
.modal[data-kind="result"] .dialog > small::after {
  content: "";
  position: absolute;
  right: -8px;
  top: 0;
  border-top: 14px solid #ffd95f;
  border-bottom: 14px solid #c57c16;
  border-right: 8px solid transparent;
}
.modal[data-kind="result"] .dialog h2 {
  display: block;
  width: 82%;
  margin: 2.5% auto 1.5%;
  color: #4d3140;
  font-size: clamp(23px, 7.4cqw, 31px);
  font-weight: 900;
  letter-spacing: -0.8px;
  line-height: 1.1;
  -webkit-text-stroke: 0.65px #4d3140;
  paint-order: stroke fill;
  text-shadow:
    0 2px #fff,
    0.5px 0 #4d3140,
    -0.5px 0 #4d3140;
  white-space: nowrap;
  word-break: keep-all;
  writing-mode: horizontal-tb;
}
.modal[data-kind="result"] .dialog p {
  display: block;
  width: 82%;
  margin: 0 auto 5%;
  color: #8d7075;
  font-size: clamp(10px, 3cqw, 12px);
  font-weight: 900;
  letter-spacing: 0.15px;
  line-height: 1.5;
  word-break: keep-all;
  writing-mode: horizontal-tb;
}
.modal[data-kind="result"] #results {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 78%;
  gap: 0;
  min-height: 98px;
  margin: 0 auto 4%;
  overflow: hidden;
  border: 3px solid #f7e8c7;
  border-radius: 17px;
  box-shadow:
    0 5px 0 #bb8f5b,
    0 8px 14px #8e673b2f;
}
.modal[data-kind="result"] #results > div {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  padding: 10px 4px 9px 43%;
  color: #fff;
  text-align: left;
}
.modal[data-kind="result"] #results > div:first-child {
  background: linear-gradient(145deg, #19bcca, #08859f);
}
.modal[data-kind="result"] #results > div:last-child {
  background: linear-gradient(145deg, #f8c43f, #d69021);
}
.modal[data-kind="result"] #results > div::before,
.modal[data-kind="result"] .record::before {
  content: "";
  position: absolute;
  background-image: url("assets/result-icons.webp");
  background-repeat: no-repeat;
  background-size: 300% 100%;
}
.modal[data-kind="result"] #results > div::before {
  left: 2%;
  top: 19%;
  width: 39%;
  aspect-ratio: 1;
}
.modal[data-kind="result"] #results > div.has-long-number {
  padding-left: 39%;
}
.modal[data-kind="result"] #results > div.has-long-number::before {
  left: 1%;
  width: 34%;
}
.modal[data-kind="result"] #results > div:first-child::before {
  background-position: left center;
}
.modal[data-kind="result"] #results > div:last-child::before {
  background-position: center center;
}
.modal[data-kind="result"] #results small {
  display: block;
  color: #f7fffd;
  font-size: clamp(8px, 2.6cqw, 11px);
  font-weight: 900;
  -webkit-text-stroke: 0.2px currentColor;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  text-shadow: 0 1px #426b72;
}
.modal[data-kind="result"] #results strong {
  display: block;
  margin-top: 2px;
  color: #fff;
  font-size: clamp(21px, 6.8cqw, 29px);
  font-weight: 900;
  letter-spacing: -1px;
  -webkit-text-stroke: 0.55px #fff;
  paint-order: stroke fill;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  text-shadow: 0 2px #7e5629;
}
.modal[data-kind="result"] #results strong.number-long {
  font-size: clamp(17px, 4.35cqw, 23px);
  letter-spacing: -1.3px;
}
.modal[data-kind="result"] #results strong.number-xlong {
  font-size: clamp(14px, 3.65cqw, 19px);
  letter-spacing: -1.5px;
}
.modal[data-kind="result"] .record {
  position: relative;
  width: 76%;
  min-height: 43px;
  margin: 0 auto 2%;
  padding: 9px 10px 7px 36px;
  border: 2px solid #b77a2f;
  border-radius: 9px;
  background: linear-gradient(180deg, #f7d08a, #dca95c);
  box-shadow:
    inset 0 2px #fff4c5,
    0 3px 0 #8f5c2a;
  color: #6b3c20;
  font-size: clamp(10px, 3.15cqw, 13px);
  font-weight: 900;
  -webkit-text-stroke: 0.25px #6b3c20;
  paint-order: stroke fill;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}
.modal[data-kind="result"] .record b {
  font-size: 1.18em;
}
.modal[data-kind="result"] .record.number-long {
  font-size: clamp(9px, 2.75cqw, 11px);
}
.modal[data-kind="result"] .record.number-xlong {
  font-size: 9px;
}
.modal[data-kind="result"] .record::before {
  left: 8px;
  top: 5px;
  width: 30px;
  height: 30px;
  background-position: right center;
}
.modal[data-kind="result"] .gold-button {
  width: 78%;
  height: clamp(63px, 10dvh, 82px);
  margin: 1% auto -1%;
  font-size: clamp(19px, 6.2cqw, 26px);
  font-family:
    "Arial Rounded MT Bold", "Avenir Next Rounded", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  font-weight: 900;
  letter-spacing: 0.5px;
  -webkit-text-stroke: 1.2px #714520;
  paint-order: stroke fill;
  filter: drop-shadow(0 6px 5px #75542355);
}
.modal[data-kind="result"] .gold-button:focus {
  outline: none;
}
.modal[data-kind="result"] .gold-button:focus-visible {
  filter: drop-shadow(0 0 8px #fff7c9) drop-shadow(0 6px 5px #75542355);
}
.modal[data-kind="result"] .secondary {
  width: 78%;
  margin-left: auto;
  margin-right: auto;
  margin-top: -2%;
  padding: 7px 20px 10px;
  color: #7f6965;
  font-size: clamp(9px, 2.7cqw, 11px);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}
@keyframes result-pop {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@media (max-height: 670px) {
  .modal[data-kind="result"] .dialog {
    height: 88dvh;
    padding-top: 102px;
  }
  .modal[data-kind="result"] #results {
    min-height: 74px;
  }
  .modal[data-kind="result"] .record {
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 5px;
  }
  .modal[data-kind="result"] .gold-button {
    height: 58px;
  }
}
