:root {
  color-scheme: light;
  --lavender: #c9c6e8;
  --lavender-deep: #a99ed0;
  --panel: #fffefe;
  --ink: #766f9c;
  --ink-soft: #9a93ba;
  --shadow: rgba(83, 74, 132, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Arial Rounded MT Bold", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  background: #ece8fa;
  color: var(--ink);
  touch-action: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

.phone-shell {
  width: min(100vw, 444px);
  height: 100dvh;
  min-height: 720px;
  margin: 0 auto;
  background: var(--lavender);
  position: relative;
  overflow: hidden;
}

.game-panel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #c8c6ea;
}

.scene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.18;
  filter: saturate(1.08) blur(0.3px);
}

.lavender-wash {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(200, 198, 234, 0.82), rgba(200, 198, 234, 0.92) 58%, rgba(200, 198, 234, 0.98)),
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 36%);
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(18px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  height: 84px;
  display: grid;
  grid-template-columns: 58px 1fr 86px;
  align-items: start;
}

.icon-button,
.wechat-pill {
  border: 0;
  height: 48px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 0 rgba(138, 130, 178, 0.32), 0 8px 14px rgba(105, 96, 154, 0.12);
}

.settings {
  width: 48px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.settings span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle, #8f83bd 0 25%, transparent 27%),
    conic-gradient(from 0deg, #8f83bd 0 10%, transparent 10% 20%, #8f83bd 20% 30%, transparent 30% 40%, #8f83bd 40% 50%, transparent 50% 60%, #8f83bd 60% 70%, transparent 70% 80%, #8f83bd 80% 90%, transparent 90%);
}

.level-block {
  display: grid;
  place-items: center;
  gap: 4px;
  font-weight: 900;
  font-size: 24px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
}

.timer-pill {
  height: 34px;
  min-width: 120px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid rgba(132, 121, 174, 0.45);
  box-shadow: inset 0 -2px 0 rgba(171, 164, 202, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 17px;
  color: #7c74a8;
}

.clock-face {
  width: 30px;
  height: 30px;
  margin-left: -8px;
  border-radius: 50%;
  background:
    linear-gradient(120deg, transparent 47%, #746fb2 48% 52%, transparent 53%),
    radial-gradient(circle at 50% 50%, #fff7e4 0 41%, #ffd54f 42% 64%, #ee9b23 65% 100%);
  box-shadow: 0 2px 0 #c67612, 0 2px 7px rgba(138, 97, 27, 0.32);
}

.wechat-pill {
  justify-self: end;
  width: 84px;
  margin-top: 4px;
  border-radius: 22px;
  background: rgba(146, 144, 180, 0.48);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 10px;
}

.wechat-pill span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
}

.wechat-pill b {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.82);
  display: block;
}

.coin-pop {
  position: absolute;
  z-index: 7;
  top: 108px;
  left: 50%;
  translate: -50% 0;
  min-height: 20px;
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  text-shadow: 0 2px 5px rgba(93, 82, 137, 0.4);
  pointer-events: none;
}

.play-space {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 112px;
  bottom: 252px;
}

#boardCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.zoom-rail {
  position: absolute;
  left: 12px;
  bottom: 12px;
  width: 28px;
  height: 178px;
  display: grid;
  grid-template-rows: 30px 1fr;
  gap: 10px;
  opacity: 0.78;
}

#centerBtn {
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 5px;
  background:
    radial-gradient(circle, #fff 0 22%, transparent 24%),
    linear-gradient(#6f6f86, #6f6f86) 50% 0 / 3px 100% no-repeat,
    linear-gradient(90deg, #6f6f86, #6f6f86) 0 50% / 100% 3px no-repeat,
    rgba(102, 103, 126, 0.82);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.4) inset;
  cursor: pointer;
}

#zoomSlider {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 24px;
  height: 136px;
  accent-color: #f7f7f7;
}

.tray-area {
  position: absolute;
  z-index: 3;
  left: 40px;
  right: 40px;
  bottom: 132px;
  height: 146px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 4px 0 rgba(164, 156, 199, 0.45),
    0 10px 18px rgba(86, 76, 133, 0.2),
    inset 0 0 0 4px rgba(230, 227, 240, 0.82);
}

#trayCanvas {
  width: 100%;
  height: 100%;
  cursor: grab;
}

.tool-row {
  position: absolute;
  z-index: 4;
  left: 58px;
  right: 58px;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(3, 72px);
  justify-content: space-between;
  align-items: center;
}

.tool {
  position: relative;
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #f4d3ff, #b875f0 74%, #8d57cf 100%);
  box-shadow: 0 5px 0 #7748b4, 0 8px 13px rgba(79, 54, 121, 0.3);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tool b {
  position: absolute;
  top: -4px;
  right: -2px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(#6be74b, #2abf36);
  color: #fff;
  font-size: 23px;
  line-height: 1;
  box-shadow: 0 2px 0 #16851e, 0 2px 6px rgba(56, 120, 32, 0.35);
}

.tool i {
  display: block;
  position: relative;
}

.magnet i {
  width: 42px;
  height: 42px;
  border-radius: 8px 8px 24px 24px;
  border: 12px solid #10a8e8;
  border-top-color: transparent;
  rotate: -30deg;
}

.magnet i::before,
.magnet i::after {
  content: "";
  position: absolute;
  top: -13px;
  width: 12px;
  height: 14px;
  background: #ffd259;
  border-radius: 2px;
}

.magnet i::before {
  left: -12px;
}

.magnet i::after {
  right: -12px;
}

.brush i {
  width: 16px;
  height: 45px;
  border-radius: 10px;
  background: linear-gradient(90deg, #e88625, #ffc254 45%, #c76b12);
  rotate: 14deg;
}

.brush i::after {
  content: "";
  position: absolute;
  left: -12px;
  bottom: -14px;
  width: 42px;
  height: 25px;
  border-radius: 6px 6px 18px 18px;
  background: linear-gradient(90deg, #f7f1df, #d8cdb5);
}

.hourglass i {
  width: 42px;
  height: 48px;
  background:
    radial-gradient(ellipse at 50% 28%, #e5f3ff 0 34%, transparent 36%),
    radial-gradient(ellipse at 50% 70%, #76d3ff 0 33%, transparent 35%),
    linear-gradient(#e83b34, #f9655e) top / 100% 9px no-repeat,
    linear-gradient(#2887d7, #4db8f7) bottom / 100% 9px no-repeat;
  border-radius: 12px;
}

.toast {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 294px;
  translate: -50% 10px;
  opacity: 0;
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(80, 74, 120, 0.78);
  color: #fff;
  text-align: center;
  font-weight: 800;
  pointer-events: none;
  transition: opacity 180ms ease, translate 180ms ease;
}

.toast.show {
  opacity: 1;
  translate: -50% 0;
}

.modal {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(90, 82, 138, 0.34);
  backdrop-filter: blur(2px);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(82%, 320px);
  border-radius: 18px;
  padding: 24px 22px 20px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(174, 166, 204, 0.75), 0 18px 30px rgba(80, 74, 120, 0.3);
  text-align: center;
}

.modal-card h1 {
  margin: 0 0 10px;
  font-size: 26px;
  color: #776bb0;
}

.modal-card p {
  margin: 0 0 18px;
  line-height: 1.55;
  color: #8d86ad;
}

.modal-card button {
  border: 0;
  height: 46px;
  min-width: 138px;
  border-radius: 24px;
  background: linear-gradient(#ffdf5f, #ffac2c);
  color: #7a4a09;
  font-weight: 900;
  box-shadow: 0 4px 0 #d77d17, 0 8px 12px rgba(146, 87, 23, 0.22);
  cursor: pointer;
}

@media (max-height: 760px) {
  .phone-shell {
    min-height: 640px;
  }

  .play-space {
    top: 98px;
    bottom: 224px;
  }

  .tray-area {
    bottom: 108px;
    height: 128px;
  }

  .tool-row {
    bottom: 16px;
  }
}
