/* ============================================================
   億萬寶藏島 — 元件樣式
   ============================================================ */

/* ---------- 按鈕 ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border: 0; border-radius: 16px;
  font-size: 1.02rem; font-weight: 800; letter-spacing: .02em;
  color: var(--text); background: rgba(255, 255, 255, .14);
  cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
  touch-action: manipulation;
}
.btn:hover { background: rgba(255, 255, 255, .22); }
.btn:active { transform: translateY(2px) scale(.98); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--primary { color: #3a2300; background: linear-gradient(180deg, #ffe08a, var(--gold-2)); box-shadow: 0 4px 0 #b45309, 0 8px 18px rgba(0, 0, 0, .35); }
.btn--primary:hover { background: linear-gradient(180deg, #fff0b8, #ffc233); }
.btn--primary:active { box-shadow: 0 1px 0 #b45309; }
.btn--soft { background: rgba(255, 255, 255, .18); border: 1px solid var(--panel-line); }
.btn--ghost { background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .28); }
.btn--danger { background: #e11d48; color: #fff; box-shadow: 0 4px 0 #9f1239; }
.btn--danger:hover { background: #f43f5e; }
.btn--xl { min-height: 58px; padding: 12px 34px; font-size: 1.25rem; border-radius: 20px; }
.btn--sm { min-height: 44px; padding: 6px 14px; font-size: .92rem; border-radius: 12px; }
.btn--icon { min-width: 48px; padding: 8px 12px; font-size: 1.2rem; }
.btn--glow { animation: glow 2.2s ease-in-out infinite; }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border-radius: 14px; border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, .12); color: var(--text);
  cursor: pointer; position: relative; overflow: hidden;
  transition: background .2s, transform .12s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .24); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.is-on { background: var(--gold); color: #3a2300; }
.icon-btn.is-off { opacity: .6; }
.icon-btn.is-off svg { opacity: .5; }

.ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .45); transform: scale(0); animation: ripple .6s ease-out forwards; pointer-events: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--panel-line); padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .95rem; min-height: 32px; }
.pill--score { color: var(--gold); }
.pill--combo { color: #fff; background: linear-gradient(90deg, #f97316, #ef4444); border: 0; animation: pop .35s ease; }
.badge { display: inline-block; align-self: flex-start; background: var(--gold); color: #3a2300; padding: 2px 12px; border-radius: 999px; font-weight: 800; font-size: .85rem; }

/* ---------- 星星 ---------- */
.star { color: #8da2bb; }
.star--on { color: var(--gold); text-shadow: 0 0 8px rgba(255, 201, 60, .7); }

/* ---------- 關卡卡片 ---------- */
.level-card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  min-height: 150px; padding: 12px 14px; border: 2px solid transparent; border-radius: 18px;
  color: var(--ink); background: linear-gradient(180deg, var(--parchment), var(--parchment-2));
  cursor: pointer; box-shadow: 0 6px 14px rgba(0, 0, 0, .3); transition: transform .15s ease, box-shadow .2s ease;
  overflow: hidden; font-size: 1rem;
}
.level-card:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0, 0, 0, .4); }
.level-card:active { transform: translateY(1px); }
.level-card__num { position: absolute; top: 8px; right: 12px; font-weight: 900; font-size: 1.25rem; color: rgba(91, 74, 51, .55); }
.level-card__icon { font-size: 2rem; line-height: 1; }
.level-card__title { font-weight: 900; font-size: 1.02rem; line-height: 1.25; padding-right: 26px; }
.level-card__concept { font-size: .85rem; color: var(--ink-2); line-height: 1.3; }
.level-card__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; font-size: .82rem; font-weight: 800; }
.level-card__stars { font-size: 1.1rem; letter-spacing: 1px; }
.level-card .star { color: #c9b98f; }
.level-card .star--on { color: #f59e0b; text-shadow: none; }
.level-card__best { color: var(--ink-2); }
.level-card--done { border-color: #34d399; }
.level-card--current { border-color: var(--gold); animation: glow 2s ease-in-out infinite; }
.level-card--boss { background: linear-gradient(180deg, #fde68a, #f59e0b); }
.level-card--locked { cursor: not-allowed; background: linear-gradient(180deg, #8a97a8, #6b7a8e); color: #1f2a37; opacity: .85; box-shadow: none; }
.level-card--locked:hover { transform: none; }
.level-card--locked .level-card__concept, .level-card--locked .level-card__num { color: #243244; }
.level-card--locked .level-card__lock { color: #1f2a37; }

/* ---------- 答題畫面 ---------- */
.playbar { display: flex; align-items: center; gap: 10px; padding: 4px 0 8px; }
.playbar__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.playbar__level { font-weight: 800; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.playbar__tools { display: flex; align-items: center; gap: 6px; }
.dots { display: flex; flex-wrap: wrap; gap: 5px; }
.dots__dot { width: 14px; height: 14px; border-radius: 50%; background: rgba(255, 255, 255, .22); border: 2px solid rgba(255, 255, 255, .35); }
.dots__dot.is-current { border-color: var(--gold); background: rgba(255, 201, 60, .35); animation: pulse 1.4s ease-in-out infinite; }
.dots__dot.is-correct { background: var(--mint); border-color: var(--mint); }
.dots__dot.is-second { background: #fbbf24; border-color: #fbbf24; }
.dots__dot.is-helped { background: var(--violet); border-color: var(--violet); }

.timerbar { display: flex; align-items: center; gap: 10px; padding: 4px 4px 8px; }
.timerbar__icon { font-size: 1.4rem; }
.timerbar__track { flex: 1; height: 16px; border-radius: 999px; background: rgba(255, 255, 255, .18); overflow: hidden; border: 1px solid var(--panel-line); }
.timerbar__fill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #34d399, #a3e635); transition: width .12s linear; }
.timerbar__text { min-width: 2.2em; text-align: right; font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.timerbar.is-warn .timerbar__fill { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.timerbar.is-danger .timerbar__fill { background: linear-gradient(90deg, #fb7185, #ef4444); animation: pulse-bar .6s ease-in-out infinite; }
.timerbar.is-danger .timerbar__text { color: #ffb4b4; animation: pulse .6s ease-in-out infinite; }
.timerbar.is-over .timerbar__fill { background: #64748b; }

.bossbar { display: flex; align-items: center; gap: 10px; padding: 0 4px 8px; }
.bossbar__img { width: 52px; height: 52px; object-fit: contain; }
.bossbar__img.is-hit { animation: shake .5s ease; }
.bossbar__main { flex: 1; }
.bossbar__name { font-weight: 900; color: #ffd0d0; font-size: .9rem; }
.bossbar__track { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, .4); overflow: hidden; border: 1px solid var(--panel-line); }
.bossbar__fill { height: 100%; width: 100%; background: linear-gradient(90deg, #f43f5e, #fb923c); transition: width .5s ease; }

.play-stage { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.play-visual-wrap { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 20px; padding: 10px; display: grid; place-items: center; min-height: 120px; backdrop-filter: blur(4px); }
.play-visual { width: 100%; display: grid; place-items: center; transition: box-shadow .3s; border-radius: 14px; }
.play-visual.is-highlighted { box-shadow: 0 0 0 4px var(--gold), 0 0 24px rgba(255, 201, 60, .6); background: rgba(255, 201, 60, .08); }
.play-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.question-card { background: linear-gradient(180deg, var(--parchment), var(--parchment-2)); color: var(--ink); border-radius: 20px; padding: 14px 18px; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.question-card__tag { display: inline-block; background: #7c2d12; color: #fff; padding: 1px 12px; border-radius: 999px; font-size: .8rem; font-weight: 800; margin-bottom: 6px; }
.question-card__prompt { font-size: clamp(1.15rem, 3.4vw, 1.5rem); font-weight: 800; line-height: 1.5; overflow-wrap: anywhere; }
.question-card__note { margin-top: 6px; color: var(--ink-2); font-size: .95rem; }
.answer-area { min-height: 60px; }
.play-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (min-width: 900px) {
  .play-stage { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .play-visual-wrap { position: sticky; top: calc(var(--appbar-h) + 12px); min-height: 260px; }
}
@media (max-width: 640px) {
  .play-actions { order: 1; }
  .answer-area { order: 2; }
  .playbar__level { font-size: .88rem; }
  .play-visual-wrap { min-height: 100px; padding: 6px; }
  .play-visual { max-height: 200px; overflow: hidden; }
  .question-card { padding: 12px 14px; }
}

/* ---------- 選擇題 ---------- */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choices--symbols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-btn { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 14px; border-radius: 16px; border: 3px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .14); color: var(--text); font-size: 1.12rem; font-weight: 800; text-align: left; cursor: pointer; transition: transform .12s, background .2s, border-color .2s; touch-action: manipulation; }
.choice-btn:hover:not([disabled]) { background: rgba(255, 255, 255, .26); transform: translateY(-2px); }
.choice-btn__key { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(0, 0, 0, .35); font-size: .85rem; }
.choice-btn__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.choices--symbols .choice-btn { justify-content: center; font-size: 1.8rem; }
.choices--symbols .choice-btn__text { text-align: center; flex: none; }
.choice-btn.is-correct { background: #059669; border-color: #6ee7b7; animation: pop .4s ease; }
.choice-btn.is-wrong { background: #9f1239; border-color: #fda4af; opacity: .75; }
.choice-btn[disabled]:not(.is-correct):not(.is-wrong) { opacity: .55; cursor: default; }
@media (max-width: 420px) { .choices:not(.choices--symbols) { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 排序題 ---------- */
.order { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.order__slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.order__slot { min-height: 52px; display: grid; place-items: center; border-radius: 12px; border: 2px dashed rgba(255, 255, 255, .4); font-weight: 800; color: var(--muted); font-size: 1rem; padding: 4px 6px; overflow-wrap: anywhere; }
.order__slot.is-filled { border-style: solid; border-color: var(--gold); background: rgba(255, 201, 60, .2); color: #fff; }
.order__slot.is-wrong { border-color: #fb7185; background: rgba(251, 113, 133, .3); animation: shake .5s ease; }
.order__tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.order__tile { min-height: 56px; border-radius: 14px; border: 3px solid rgba(255, 255, 255, .3); background: linear-gradient(180deg, var(--parchment), var(--parchment-2)); color: var(--ink); font-weight: 900; font-size: 1.1rem; cursor: pointer; padding: 6px 8px; touch-action: manipulation; }
.order__tile[disabled] { opacity: .3; cursor: default; }
.order > .btn { align-self: flex-start; }

/* ---------- 直式 ---------- */
.vertical-math { background: rgba(255, 255, 255, .1); border: 1px dashed rgba(255, 255, 255, .35); border-radius: 16px; padding: 10px 16px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: clamp(1.5rem, 6vw, 2.1rem); font-weight: 800; }
.vm-row { display: grid; grid-template-columns: 1.4em auto; justify-content: end; gap: 8px; text-align: right; }
.vm-op { color: var(--gold); }
.vm-line { height: 3px; background: var(--text); margin: 4px 0; border-radius: 2px; }
.vertical-math__division { display: inline-flex; align-items: baseline; gap: 6px; }
.vm-bracket { font-size: 1.3em; color: var(--gold); }
.vm-dividend { border-top: 3px solid var(--text); padding: 0 8px; }
.vertical-math__hint { font-family: var(--font); font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: 6px; }

/* ---------- 數字鍵盤 ---------- */
.numpad { display: flex; flex-direction: column; gap: 10px; }
.numpad__fields { display: flex; flex-wrap: wrap; gap: 10px; }
.numpad__field { flex: 1 1 140px; min-height: 60px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 6px 14px; border-radius: 16px; border: 3px solid rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .32); color: var(--text); cursor: pointer; text-align: left; }
.numpad__field.is-active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 201, 60, .25); }
.numpad__field-label { font-size: .78rem; color: var(--muted); font-weight: 700; }
.numpad__value { font-size: 1.7rem; font-weight: 900; min-height: 1.3em; font-variant-numeric: tabular-nums; letter-spacing: .02em; overflow-wrap: anywhere; }
.numpad__keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.numpad__key { min-height: 52px; border-radius: 14px; border: 0; font-size: 1.4rem; font-weight: 900; color: var(--ink); background: linear-gradient(180deg, var(--parchment), var(--parchment-2)); box-shadow: 0 3px 0 #b8964f; cursor: pointer; touch-action: manipulation; }
.numpad__key:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8964f; }
.numpad__backspace, .numpad__clear { background: linear-gradient(180deg, #fecaca, #fca5a5); box-shadow: 0 3px 0 #b45353; font-size: 1.1rem; }
.numpad__submit { grid-column: span 2; background: linear-gradient(180deg, #86efac, #34d399); box-shadow: 0 3px 0 #15803d; font-size: 1.2rem; }
.numpad__decimal[hidden] { display: none; }

/* ---------- 回饋面板 ---------- */
.feedback { display: none; gap: 12px; align-items: flex-start; border-radius: 18px; padding: 12px 14px; color: var(--ink); background: var(--parchment); border: 3px solid #fbbf24; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.feedback.is-visible { display: flex; animation: slide-up .3s ease both; }
.feedback--correct { border-color: #34d399; background: #ecfdf5; }
.feedback--hint { border-color: #fbbf24; background: #fffbeb; }
.feedback__icon { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #34d399; color: #064e3b; font-weight: 900; font-size: 1.1rem; }
.feedback--hint .feedback__icon { background: #fde68a; }
.feedback__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.feedback__body strong { font-size: 1.05rem; }
.feedback__body p { font-size: .95rem; overflow-wrap: anywhere; }
.feedback__small { color: var(--ink-2); font-size: .85rem !important; }
.feedback__streak { color: #c2410c; font-weight: 800; }
.feedback__next { flex: none; align-self: center; }
@media (max-width: 520px) { .feedback.is-visible { flex-wrap: wrap; } .feedback__next { width: 100%; } }

/* ---------- 分步引導 ---------- */
.steps-panel { position: fixed; inset: 0; z-index: 75; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .25s; }
.steps-panel.is-open { opacity: 1; }
.steps__sheet { width: min(100%, 560px); max-height: calc(100dvh - var(--appbar-h) - 8px); overflow-y: auto; background: linear-gradient(180deg, #fff9e6, #f5e6b8); color: var(--ink); border-radius: 24px 24px 0 0; padding: 16px 16px calc(var(--footer-h) + 18px); box-shadow: 0 -10px 30px rgba(0, 0, 0, .5); }
.steps__head h2 { font-size: 1.25rem; }
.steps__kicker { font-weight: 800; color: #9a3412; font-size: .9rem; }
.steps__progress { margin: 6px 0; color: var(--ink-2); font-weight: 800; }
.steps__body { display: flex; flex-direction: column; gap: 10px; }
.step__prompt { font-size: 1.15rem; font-weight: 800; }
.step__feedback { min-height: 1.4em; font-weight: 800; }
.step__feedback.is-correct { color: #047857; }
.step__feedback.is-wrong { color: #be123c; }
.steps__foot { margin-top: 10px; display: flex; justify-content: flex-end; }
.steps__sheet .btn--ghost { color: var(--ink); border-color: rgba(43, 33, 24, .4); }
.steps__sheet .numpad__field { background: #fff; color: var(--ink); border-color: #d6b97b; }
.steps__sheet .numpad__field-label { color: var(--ink-2); }
.steps__done { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 8px 0; }
.steps__done-icon { font-size: 3rem; }

/* ---------- 教具 ---------- */
.mp { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px; }
.mp__label { color: var(--muted); font-size: .85rem; font-weight: 700; text-align: center; }
.pv { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.pv__group { background: rgba(255, 255, 255, .1); border-radius: 14px; padding: 6px 8px 8px; border: 1px solid var(--panel-line); }
.pv__gname { text-align: center; font-weight: 800; color: var(--gold); font-size: .85rem; margin-bottom: 4px; }
.pv__cells { display: flex; gap: 4px; }
.pv__cell { width: clamp(36px, 8.4vw, 54px); display: flex; flex-direction: column; align-items: center; border-radius: 10px; background: var(--parchment); color: var(--ink); overflow: hidden; }
.pv__cell.is-empty { background: rgba(255, 255, 255, .12); color: rgba(255, 255, 255, .4); }
.pv__d { font-size: clamp(1.2rem, 4.4vw, 1.8rem); font-weight: 900; line-height: 1.5; min-height: 1.5em; }
.pv__p { width: 100%; text-align: center; font-size: .7rem; font-weight: 800; background: rgba(0, 0, 0, .18); padding: 1px 0; }
.pv__cell.is-hl { box-shadow: 0 0 0 3px var(--gold); background: #fde68a; }
.cmp { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: 10px; width: 100%; }
.cmp--list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cmp__card { position: relative; flex: 1 1 130px; background: var(--parchment); color: var(--ink); border-radius: 14px; padding: 10px 8px; text-align: center; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cmp__card strong { font-size: clamp(1.1rem, 4.2vw, 1.6rem); overflow-wrap: anywhere; }
.cmp__card small { color: var(--ink-2); font-weight: 700; }
.cmp__tag { position: absolute; top: 4px; left: 6px; background: #7c2d12; color: #fff; border-radius: 6px; padding: 0 6px; font-size: .75rem; font-weight: 800; }
.cmp__vs { align-self: center; font-weight: 900; color: var(--gold); }
.nl, .am { width: 100%; max-width: 440px; height: auto; }
.nl__line { stroke: #e8f1ff; stroke-width: 4; stroke-linecap: round; }
.nl__tick { stroke: #e8f1ff; stroke-width: 3; }
.nl__mid { stroke: var(--gold); stroke-width: 3; stroke-dasharray: 4 3; }
.nl__pin { stroke: var(--coral); stroke-width: 3; }
.nl__dot { fill: var(--coral); stroke: #fff; stroke-width: 3; }
.nl__text { fill: #e8f1ff; font-size: 12px; font-weight: 700; }
.nl__text--point { fill: #ffd0c8; font-size: 14px; font-weight: 900; }
.nl__text--mid { fill: var(--gold); }
.am__a { fill: #38bdf8; opacity: .85; }
.am__b { fill: #34d399; opacity: .85; }
.am__t { fill: #04263f; font-size: 18px; font-weight: 900; }
.am__t--sm { font-size: 15px; }
.am__s { fill: #04263f; font-size: 12px; font-weight: 700; }
.am__k { fill: #e8f1ff; font-size: 14px; font-weight: 800; }
.bal { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.bal__pan { flex: 1; min-width: 0; text-align: center; padding: 14px 6px; border-radius: 14px; background: var(--parchment); color: var(--ink); font-weight: 900; font-size: clamp(1.1rem, 4vw, 1.5rem); overflow-wrap: anywhere; box-shadow: 0 6px 0 rgba(0, 0, 0, .25); }
.bal__mid { font-size: 2.2rem; }
.pat { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.pat__item { min-width: 48px; height: 48px; padding: 0 8px; display: grid; place-items: center; border-radius: 50%; background: var(--parchment); color: var(--ink); font-weight: 900; font-size: 1.1rem; }
.pat__item.is-unknown { background: var(--coral); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.pat__arrow { color: var(--gold); font-style: normal; font-weight: 900; font-size: 1.4rem; }
.expr { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 900; text-align: center; background: rgba(255, 255, 255, .12); border-radius: 16px; padding: 14px 12px; width: 100%; overflow-wrap: anywhere; }
.expr__paren { color: var(--gold); font-size: 1.15em; }
.mascot { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.mascot img { width: clamp(100px, 24vw, 170px); height: auto; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)); animation: bob 3s ease-in-out infinite; }
.mascot--boss img { width: clamp(120px, 30vw, 210px); }
.mascot__bubble { background: var(--parchment); color: var(--ink); padding: 8px 14px; border-radius: 14px; font-weight: 800; font-size: .95rem; max-width: 18em; }
@media (max-width: 640px) { .mascot { flex-direction: row; } .mascot img { width: 84px; } .mascot--boss img { width: 96px; } }

/* ---------- 結算 ---------- */
.result__stars { display: flex; gap: 12px; font-size: 3.4rem; }
.result__star { color: #8da2bb; opacity: 0; transform: scale(.3) rotate(-30deg); animation: star-in .6s cubic-bezier(.2, 1.4, .4, 1) forwards; animation-delay: calc(var(--i) * .38s + .3s); }
.result__star.star--on { color: var(--gold); text-shadow: 0 0 16px rgba(255, 201, 60, .8); }
.result__score { display: flex; flex-direction: column; align-items: center; }
.result__score-label { color: var(--muted); font-weight: 700; }
.result__score-value { font-size: 3rem; font-weight: 900; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.result__new { color: #86efac; font-weight: 800; }
.result__prev { color: var(--muted); font-size: .9rem; }
.result__badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.badge-chip { background: rgba(255, 255, 255, .14); padding: 4px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; }
.badge-chip--gold { background: linear-gradient(90deg, #fde68a, #fbbf24); color: #3a2300; }
.result__treasure { width: 100%; }

/* ---------- 寶物卡 ---------- */
.treasure-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 14px; border-radius: 18px; border: 0; color: var(--ink); background: linear-gradient(180deg, var(--parchment), var(--parchment-2)); box-shadow: 0 6px 14px rgba(0, 0, 0, .3); font-size: 1rem; }
button.treasure-card { cursor: pointer; }
button.treasure-card:hover { transform: translateY(-3px); }
.treasure-card__level { font-size: .8rem; font-weight: 800; color: var(--ink-2); }
.treasure-card__emoji { font-size: 2.4rem; line-height: 1; }
.treasure-card__name { font-size: 1.1rem; }
.treasure-card__fact { font-size: .9rem; color: var(--ink-2); }
.treasure-card--locked { background: linear-gradient(180deg, #8a97a8, #6b7a8e); color: #1f2a37; box-shadow: none; }
.treasure-card--locked .treasure-card__fact, .treasure-card--locked .treasure-card__level { color: #1f2a37; }
.treasure-card--result { flex-direction: row; align-items: center; gap: 14px; }
.treasure-card--result img { width: 96px; height: 96px; object-fit: contain; flex: none; animation: bob 2.6s ease-in-out infinite; }
.treasure-card__body { display: flex; flex-direction: column; gap: 4px; }
.treasure-card__body h3 { font-size: 1.15rem; }
.treasure-card__body p { font-size: .92rem; color: var(--ink-2); }

/* ---------- 對話框 ---------- */
.dialog { --dialog-max: min(88dvh, calc(100dvh - 2 * (var(--footer-h) + env(safe-area-inset-bottom, 0px) + 12px))); width: min(92vw, 520px); max-height: var(--dialog-max); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: linear-gradient(180deg, #fff9e6, #f5e6b8); box-shadow: 0 20px 50px rgba(0, 0, 0, .6); overflow: hidden; }
.dialog--small { width: min(92vw, 420px); }
/* 對話框在 top layer，z-index 蓋不過；讓遮罩停在頁尾上方、對話框高度也避開頁尾，版權頁尾才會一直清楚可見 */
.dialog::backdrop { bottom: 52px; bottom: calc(var(--footer-h, 52px) + env(safe-area-inset-bottom, 0px)); background: rgba(3, 12, 24, .72); backdrop-filter: blur(3px); }
.dialog__form { display: flex; flex-direction: column; max-height: var(--dialog-max); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 6px; }
.dialog__head h2 { font-size: 1.25rem; }
.dialog__head .btn--icon { color: var(--ink); background: rgba(43, 33, 24, .1); }
.dialog__body { padding: 8px 18px 12px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.dialog__foot { padding: 8px 16px 16px; display: flex; justify-content: flex-end; gap: 10px; }
.dialog__foot--two { justify-content: space-between; }
.dialog__hr { border: 0; border-top: 1px solid rgba(43, 33, 24, .2); width: 100%; margin: 2px 0; }
.dialog__note { font-size: .85rem; color: var(--ink-2); }
.dialog__version { font-size: .8rem; color: var(--ink-2); text-align: right; }
.dialog .btn--ghost { color: var(--ink); border-color: rgba(43, 33, 24, .4); }
.setting-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px dashed rgba(43, 33, 24, .2); }
.setting-row--single { border-bottom: 0; }
.setting-row input[type="range"] { width: 100%; height: 44px; accent-color: #d97706; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 800; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__ui { position: relative; width: 52px; height: 30px; flex: none; border-radius: 999px; background: #a8a29e; transition: background .2s; }
.switch__ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.switch input:checked + .switch__ui { background: #059669; }
.switch input:checked + .switch__ui::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__ui { outline: 3px solid #d97706; outline-offset: 2px; }
.reset-confirm { background: #fee2e2; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.reset-confirm__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.install__platform { font-weight: 800; color: #9a3412; }
.install__steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; }

/* ---------- 計算紙 ---------- */
.scratchpad-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(3, 12, 24, .7); padding: 12px 12px calc(var(--footer-h) + env(safe-area-inset-bottom, 0px) + 12px); }
.scratchpad { width: min(100%, 860px); height: min(78dvh, 620px); display: flex; flex-direction: column; background: #fff8e8; color: var(--ink); border-radius: 18px; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, .6); }
.scratchpad__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; background: #f4e3b5; }
.scratchpad__tip { flex: 1; color: var(--ink-2); font-size: .85rem; }
.scratchpad__tools { display: flex; gap: 6px; }
.scratchpad .btn--soft { color: var(--ink); background: rgba(43, 33, 24, .1); }
.scratchpad .btn--soft.is-active, .scratchpad .btn--soft[aria-pressed="true"] { background: #fbbf24; }
.scratchpad__canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; background: #fff8e8 repeating-linear-gradient(0deg, transparent 0 31px, rgba(120, 90, 40, .12) 31px 32px); }

/* ---------- 提示、彩帶、浮動字 ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--footer-h) + 16px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); z-index: 90; max-width: min(92vw, 520px); padding: 10px 18px; border-radius: 14px; background: #0b2540; color: #fff; border: 2px solid var(--gold); font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; text-align: center; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast--warn { border-color: #fb923c; }
.toast--success { border-color: var(--mint); }
.confetti-layer { position: fixed; inset: 0; z-index: 95; pointer-events: none; overflow: hidden; }
.confetti__piece { position: absolute; top: 30%; border-radius: 2px; animation: confetti var(--d, 2s) ease-out forwards; }
.float-text { position: fixed; left: 50%; top: 38%; z-index: 60; font-weight: 900; font-size: 2.6rem; pointer-events: none; animation: float-up 1.2s ease-out forwards; text-shadow: 0 4px 12px rgba(0, 0, 0, .6); }
.float-text--good { color: var(--gold); }
.float-text--help { color: #c4b5fd; }
.konami-banner { position: fixed; left: 50%; top: 28%; transform: translateX(-50%); z-index: 98; padding: 16px 28px; border-radius: 20px; background: linear-gradient(90deg, #7c3aed, #db2777, #f59e0b); color: #fff; font-weight: 900; font-size: clamp(1.2rem, 5vw, 2rem); text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); width: max-content; max-width: 92vw; }
.konami-banner.is-show { animation: konami 3.6s ease both; }
.noscript { position: fixed; inset: auto 16px 80px; z-index: 99; background: #fff; color: #111; padding: 16px; border-radius: 12px; }
