/* Skill Hub 365 Pixel 風：沙色底、墨灰粗外框、硬陰影、直角 */
:root {
  --sand: #F4EBC3;
  --ink: #2D3436;
  --cream: #FFFEF9;
  --teal: #2C7A7B;
  --mustard: #D69E2E;
  --brick: #B85450;
  --accent: #0B7A5E;
  --accent-soft: #CFEFE3;
  --muted: #55584f;
  --dh: 144px; /* 人偶高度；寬度依圖層比例 930:1440 */
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-px: "Pixelify Sans", "Noto Sans TC", monospace;
}
@media (max-height: 700px) { :root { --dh: 120px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--sand);
  background-image: radial-gradient(#E4D69A 1.5px, transparent 1.5px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
}
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
}

/* 頂列 */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.brand { display: block; height: 52px; width: auto; }
.sound {
  font: 700 14px/1 var(--font); color: var(--ink); background: var(--cream);
  border: 3px solid var(--ink); padding: 8px 12px; min-height: 40px; cursor: pointer;
}
.sound[aria-pressed="false"] { background: #e8e1c0; color: var(--muted); }

/* 進度 */
.progress { display: flex; gap: 6px; margin-bottom: 12px; }
.progress span { flex: 1; height: 14px; border: 3px solid var(--ink); background: var(--cream); }
.progress span.done { background: var(--accent); }
.progress span.now { background: var(--mustard); }

/* 人偶與對話框 */
.stage { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.stage[hidden] { display: none; }
.doll {
  position: relative; flex: none;
  height: var(--dh); aspect-ratio: 930 / 1440;
  animation: bob 1.2s steps(2) infinite;
}
.doll img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  user-select: none; -webkit-user-drag: none;
}
.doll img[hidden] { display: none; }
.doll img.drop { animation: drop .5s steps(6) both; }
@keyframes drop { from { transform: translateY(-32px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.bubble {
  position: relative; flex: 1; margin: 0 0 8px;
  background: var(--cream); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  padding: 10px 12px; font-size: 16px; font-weight: 700; line-height: 1.5;
  text-wrap: balance; line-break: strict;
}
.bubble b { font-weight: 900; color: var(--accent); }
.bubble:focus { outline: none; }
.bubble::before {
  content: ""; position: absolute; left: -11px; bottom: 14px; width: 16px; height: 16px;
  background: var(--cream); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  transform: rotate(45deg);
}

/* 題目卡 */
.card {
  background: var(--cream); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink);
  padding: 16px;
}
[tabindex="-1"]:focus { outline: none; }
.subtitle { margin: 0 0 8px; font-size: 16px; font-weight: 700; color: var(--teal); text-wrap: balance; line-break: strict; }
.kicker { font-family: var(--font); font-weight: 900; font-size: 18px; letter-spacing: .5px; color: var(--teal); margin: 0 0 4px; }
h1, h2 { margin: 0 0 6px; font-weight: 900; line-height: 1.35; text-wrap: balance; line-break: strict; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
.hint { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-weight: 700; margin-bottom: 4px; }
.field small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], textarea {
  width: 100%; font: 500 16px/1.5 var(--font); color: var(--ink);
  background: #fff; border: 3px solid var(--ink); padding: 10px 12px; border-radius: 0;
}
textarea { min-height: 120px; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--mustard); outline-offset: 2px;
}
.count { text-align: right; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* 選項（單選與多選） */
.options { display: grid; gap: 10px; margin: 0 0 12px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  font: 700 16px/1.4 var(--font); color: var(--ink);
  background: #fff; border: 3px solid var(--ink); padding: 10px 12px; min-height: 52px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.opt:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.opt > span:last-child { text-wrap: balance; }
.opt .sub { display: block; margin-top: 2px; font-size: 14px; font-weight: 500; color: var(--muted); }
.options.cols2 { grid-template-columns: 1fr 1fr; }
.opt .box {
  flex: none; width: 22px; height: 22px; border: 3px solid var(--ink); background: #fff;
  display: grid; place-items: center; font-size: 14px; line-height: 1; color: #fff;
}
.opt.radio .box { border-radius: 0; }
.opt[aria-pressed="true"] { background: var(--accent-soft); }
.opt[aria-pressed="true"] .box { background: var(--accent); }
.opt[aria-pressed="true"] .box::after { content: "✓"; }
.opt.locked { opacity: .55; }
.counter { font-size: 14px; font-weight: 700; color: var(--teal); margin: 0 0 8px; }
.counter.shake { animation: shake .3s steps(4); color: var(--brick); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* 1 到 5 分 */
.legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.rate { margin: 0 0 12px; }
.rate-label { font-weight: 700; margin-bottom: 6px; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.num {
  font: 900 18px/1 var(--font); color: var(--ink); background: #fff;
  border: 3px solid var(--ink); min-height: 46px; cursor: pointer;
}
.num[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: inset 0 0 0 2px var(--cream); }
.num:active { transform: translateY(2px); }


/* 按鈕列 */
.actions { position: sticky; bottom: 0; z-index: 2; background: var(--cream); margin-top: 8px; padding-top: 4px; }
.nav { display: flex; gap: 10px; padding: 6px 0 2px; }
.btn {
  flex: 1; font: 900 17px/1 var(--font); min-height: 52px; padding: 0 14px;
  border: 3px solid var(--ink); cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
}
.btn.primary { background: var(--accent); color: #fff; flex: 2; }
.btn.ghost { background: #fff; color: var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { background: #E4DDBA; color: #5f5d4f; box-shadow: none; cursor: not-allowed; }

.error {
  background: #F9DDD9; border: 3px solid var(--brick); color: #6b1f1b;
  padding: 8px 12px; margin: 6px 0 4px; font-weight: 700;
}
.error[hidden] { display: none; }
.banner {
  background: #FBF1CF; border: 3px dashed var(--ink); padding: 8px 12px; margin: 0 0 12px;
  font-size: 14px; font-weight: 700;
}

/* 完成頁 */
.cert-wrap { margin: 10px 0 14px; border: 3px solid var(--ink); background: #fff; line-height: 0; }
.cert-wrap img { width: 100%; height: auto; display: block; }
.cert-wrap .loading { line-height: 1.6; padding: 40px 12px; text-align: center; color: var(--muted); }
a.btn { display: grid; place-items: center; text-decoration: none; }
.thanks { margin: 14px 0 0; font-size: 14px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .doll, .doll img.drop, .counter.shake { animation: none; }
}
