:root {
  --ink: #5c3044;
  --cream: #fff8ef;
  --candy: #ff7aa2;
  --sun: #ffd15c;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "PingFang HK", "Noto Sans TC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 18%, #ffe1f2 0 18%, transparent 19%),
    radial-gradient(circle at 88% 8%, #fff1b8 0 14%, transparent 15%),
    radial-gradient(circle at 80% 90%, #d9fff3 0 16%, transparent 17%),
    linear-gradient(180deg, #fff4e8, #e7f6ff 70%);
}

button, input { font-family: inherit; }

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 12px 14px 16px;
}

.play-ui { margin-bottom: 10px; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  background: #b7e6ff;
  box-shadow: 0 16px 0 rgba(92, 48, 68, 0.08), 0 18px 40px rgba(92, 48, 68, 0.12);
  border: 4px solid #fff;
}

.shell:has(#play-ui:not(.is-hidden)) .stage {
  width: min(100%, calc((100dvh - 210px) * 16 / 9));
  max-height: calc(100dvh - 210px);
}

@media (max-height: 760px) {
  .ctrl { min-height: 52px; font-size: 1rem; }
  .shell:has(#play-ui:not(.is-hidden)) .stage {
    width: min(100%, calc((100dvh - 176px) * 16 / 9));
    max-height: calc(100dvh - 176px);
  }
}

canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.is-hidden { display: none !important; }

.overlay {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 16px;
  z-index: 5;
}

#screen-quiz,
#screen-map,
#screen-clear,
#screen-bag {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  height: auto;
  bottom: auto;
  right: auto;
  background: #fff8ef;
  border-radius: 28px;
  box-shadow: 0 18px 50px rgba(92, 48, 68, 0.18);
}

.clear-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: -16px -16px 12px;
  padding: 12px 16px;
  background: #fff8ef;
}
.clear-x {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #fff;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}
.level-locked { opacity: 0.55; cursor: not-allowed; }

.card {
  background: rgba(255, 248, 239, 0.96);
  border: 4px solid #fff;
  border-radius: 28px;
  box-shadow: 0 10px 0 rgba(255, 122, 162, 0.25);
}

.ctrl {
  min-height: 64px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--ink);
  background: #ffe08a;
  box-shadow: 0 6px 0 #f0b429;
  touch-action: none;
  user-select: none;
}

.ctrl.jump { background: #ff9ec4; box-shadow: 0 6px 0 #ef5d93; color: white; }

.ctrl:active { transform: translateY(3px); box-shadow: 0 3px 0 #f0b429; }
.ctrl.jump:active { box-shadow: 0 3px 0 #ef5d93; }

.opt {
  width: 100%;
  text-align: left;
  border-radius: 18px;
  border: 4px solid #ffd0e0;
  background: white;
  padding: 10px 14px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 4px 0 #ffd6e4;
}

.opt:hover { border-color: #ff7aa2; }
.opt.wrong { border-color: #fb7185; background: #ffe4e6; }
.opt.right { border-color: #34d399; background: #d1fae5; }
.opt:disabled { cursor: default; }

.shake { animation: shake 0.35s linear; }

@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.toast {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%) translateY(-12px);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  box-shadow: 0 6px 0 rgba(92, 48, 68, 0.08);
  max-width: 90%;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.blank {
  display: inline-block;
  min-width: 4.2em;
  border-bottom: 4px solid #ff7aa2;
  color: #ff7aa2;
  text-align: center;
  margin: 0 4px;
  line-height: 1.1;
}

.hit { color: #0f9f6e; font-weight: 900; }

@media print {
  body * { visibility: hidden; }
  #report, #report * { visibility: visible; }
  #report {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: white;
    color: black;
  }
}
