/* letsort.css — LetSort 彩球分類（class 前綴 so-）
   共用語彙（木框／教練／🌼／回家的路／三色）照 LetStack 抄；板面是試管＋彩球。 */
.so { max-width: 560px; margin: 0 auto; }
/* 作者樣式的 display 會蓋過 [hidden] 的 UA display:none（圖例是 flex），所以補這一條 */
.so [hidden] { display: none !important; }

/* toolbar */
.so-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.so-toolbar--2 { margin-top: -6px; }
.so-seg { display: inline-flex; border: 1px solid var(--gd-bd); border-radius: 12px; overflow: hidden; background: #fff; }
.so-seg button {
  appearance: none; border: 0; background: transparent; font: inherit; font-weight: 700;
  padding: 0 14px; min-height: 42px; cursor: pointer; color: #475569; font-size: 14.5px;
  -webkit-tap-highlight-color: transparent;
}
.so-seg button + button { border-left: 1px solid var(--gd-bd); }
.so-seg button[aria-pressed="true"] { background: var(--gd-green); color: #fff; }
.gd-btn--sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }

/* 🌼/🌱 全隱藏鈕（同 LetSlide、同 devlog 的 🐣/🥚）*/
.so-divider { display: flex; align-items: center; gap: 14px; margin: 2px 0 12px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.so-divider::before, .so-divider::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, transparent, #f3dcb5); }
.so-divider::after { background: linear-gradient(to left, transparent, #f3dcb5); }
.so-divider span { width: 40px; height: 40px; border-radius: 50%; background: #fff8ec; border: 1px solid #f3dcb5; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; transition: transform .15s, box-shadow .15s; }
.so-divider:hover span, .so-divider:focus-visible span { transform: scale(1.1); box-shadow: 0 2px 10px rgba(243,220,181,.9); }
.so-divider:focus-visible { outline: none; }
.so--zen .so-top, .so--zen .so-bottom { display: none; }
.so--zen .so-divider { margin-top: 0; }

/* 木框 */
.so-tray {
  position: relative;
  background: linear-gradient(180deg, #f6e3bf, #ecd2a2);
  border: 1px solid #d9b77f; border-radius: 22px;
  box-shadow: 0 8px 26px rgba(120, 80, 20, .16), inset 0 1px 0 rgba(255,255,255,.6);
  padding: 14px;
}
.so-ref { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.so-ref-goal {
  width: 64px; height: 64px; border-radius: 10px; flex-shrink: 0; background: #fff8ea;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; padding: 0 0 9px;
  position: relative;
}
.so-ref-goal::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 34px; height: 3px; margin-left: -17px; border-radius: 2px; background: #c9a36a; }
.so-ref-goal i { height: 8px; border-radius: 999px; background: #8b5cf6; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.so-ref-goal i:nth-child(1) { background: #60a5fa; }
.so-ref-goal i:nth-child(2) { background: #6366f1; }
.so-ref-meta { flex: 1; min-width: 0; }
.so-ref-name { font-weight: 800; font-size: 16px; color: #5b3a12; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-ref-hint { font-size: 12.5px; color: #8a6a3a; margin-top: 2px; }
.so-ref-btns { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.so-undo, .so-teach { background: #fff8ea; border-color: #e5c58c; color: #7a4f14; user-select: none; -webkit-user-select: none; touch-action: manipulation; min-height: 38px; padding: 8px 12px; font-size: 13.5px; justify-content: center; }
.so-teach[aria-pressed="true"] { background: #fde047; border-color: #eab308; color: #422006; }
.so-undo[disabled] { opacity: .45; cursor: default; }

/* 教練（小恐龍）*/
.so-coach { margin: -4px 0 12px; animation: so-pop .22s cubic-bezier(.2,.9,.3,1.2); }
.so-coach-avatar {
  appearance: none; padding: 0; margin: 0 2px 0 -2px; cursor: pointer; flex-shrink: 0;
  width: 48px; height: 48px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.14); overflow: hidden;
  background: url("/assets/img/rexcode-logo.webp") center / cover no-repeat #fff;
  transition: transform .12s, box-shadow .12s; -webkit-tap-highlight-color: transparent;
}
.so-coach-avatar:hover, .so-coach-avatar.is-open { transform: scale(1.08); box-shadow: 0 0 0 3px #fde047, 0 2px 8px rgba(0,0,0,.18); }
.so-coach-bubble { position: relative; background: #fff; border-radius: 14px; padding: 10px 14px; box-shadow: 0 2px 8px rgba(90,55,10,.12); }
.so-coach-bubble::before { content: ''; position: absolute; left: 82px; top: -8px; border: 8px solid transparent; border-bottom-color: #fff; border-top: 0; }
.so-coach-text { font-size: 15px; font-weight: 700; color: #3f2a10; line-height: 1.45; }
.so-coach-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.so-coach-btns:empty { display: none; }

/* 板面：試管架。球的大小 --bs 由 JS 依板面寬度算（試管 5～8 根都要塞得下） */
.so-board {
  position: relative; width: 100%; height: calc(var(--bs) * 5 + 66px);
  background: linear-gradient(180deg, #fdf3e1 0%, #f7e6c8 70%, #e9cf9f 100%);
  border-radius: 14px; overflow: hidden; box-shadow: inset 0 3px 10px rgba(90, 55, 10, .28);
  touch-action: none; outline: none; user-select: none; -webkit-user-select: none;
  --bs: 40px; --base: 30px; --T: 5;
}
.so-board:focus-visible { box-shadow: inset 0 3px 10px rgba(90,55,10,.28), 0 0 0 3px #86efac; }
.so-board::after { content: ''; position: absolute; left: 3%; right: 3%; bottom: 8px; height: 16px; border-radius: 8px; background: linear-gradient(180deg, #d9a96e, #b9813f); }
.so-tube { position: absolute; top: 0; bottom: 0; width: calc(100% / var(--T)); left: calc(var(--t) * 100% / var(--T)); cursor: pointer; }
.so-tube-glass {
  position: absolute; left: 50%; bottom: var(--base); width: calc(var(--bs) + 8px); margin-left: calc(var(--bs) / -2 - 4px);
  height: calc(var(--bs) * 4 + 10px); box-sizing: border-box;
  border: 3px solid rgba(255,255,255,.95); border-top-width: 0; border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, rgba(255,255,255,.55), rgba(255,255,255,.18) 45%, rgba(255,255,255,.4));
  box-shadow: 0 2px 6px rgba(90,55,10,.18);
}
.so-tube-glass::before { content: ''; position: absolute; left: -2px; right: -2px; top: -4px; height: 6px; border-radius: 4px; background: rgba(255,255,255,.95); box-shadow: 0 1px 3px rgba(90,55,10,.2); }
.so-tube-lbl { position: absolute; left: 0; right: 0; bottom: 9px; text-align: center; z-index: 1; font-size: 11.5px; font-weight: 900; color: #fff8ea; text-shadow: 0 1px 2px rgba(0,0,0,.3); }
.so-tube-badge { position: absolute; left: 50%; top: calc(100% - var(--base) - var(--bs) * 4 - 44px); margin-left: -12px; width: 24px; height: 24px; border-radius: 50%; display: none; place-items: center; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.28); z-index: 5; }
.so-tube-badge svg { width: 14px; height: 14px; display: block; }
.so-tube.is-sel .so-tube-glass { border-style: dashed; }
.so-tube.is-done .so-tube-glass { border-color: #86d9a2; background: rgba(134,217,162,.25); }
.so-board--hints .so-tube.is-good .so-tube-glass { border-color: var(--so-good); background: var(--so-good-soft); }
.so-board--hints .so-tube.is-bad  .so-tube-glass { border-color: var(--so-bad); }
.so-board--hints .so-tube.is-same .so-tube-glass { border-color: var(--so-same); }
.so-board--hints .so-tube.is-no   .so-tube-glass { border-color: var(--so-no); border-style: dashed; }
.so-board--hints .so-tube.is-good .so-tube-badge { display: grid; background: var(--so-good); }
.so-board--hints .so-tube.is-bad  .so-tube-badge { display: grid; background: var(--so-bad); }
.so-board--hints .so-tube.is-same .so-tube-badge { display: grid; background: var(--so-same); }
.so-board--hints .so-tube.is-no   .so-tube-badge { display: grid; background: var(--so-no); }

/* 球：顏色之外一定配符號（色盲也分得出來；提示的綠／橘是外圈＋圖示，不和球色搶） */
.so-ball {
  position: absolute; left: calc((var(--t) + .5) * 100% / var(--T)); margin-left: calc(var(--bs) / -2);
  bottom: calc(var(--base) + 5px + var(--i) * var(--bs)); width: var(--bs); height: var(--bs);
  transition: left .19s cubic-bezier(.3,.8,.35,1), bottom .19s cubic-bezier(.3,.8,.35,1);
  z-index: 2; cursor: pointer; will-change: left, bottom;
}
.so-ball.is-lift { bottom: calc(var(--base) + var(--bs) * 4 + 22px); z-index: 4; }
.so-ball-body {
  position: absolute; inset: 2px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.85), rgba(255,255,255,0) 42%), var(--bc);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.16), 0 2px 5px rgba(30,20,60,.28);
  border: 2px solid rgba(255,255,255,.7); box-sizing: border-box;
  color: rgba(255,255,255,.95); font-size: calc(var(--bs) * .42); font-weight: 900; line-height: 1; text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.so-ball-sym { display: none; }
.so-board--syms .so-ball-sym { display: block; }
.so-ball-badge { position: absolute; right: -3px; top: -3px; width: clamp(14px, calc(var(--bs) * .44), 20px); height: clamp(14px, calc(var(--bs) * .44), 20px); border-radius: 50%; display: none; place-items: center; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); z-index: 1; }
.so-ball-badge svg { width: 62%; height: 62%; display: block; }
.so-board--hints .so-ball.is-good .so-ball-badge { display: grid; background: var(--so-good); }
.so-board--hints .so-ball.is-bad  .so-ball-badge { display: grid; background: var(--so-bad); }
.so-board--hints .so-ball.is-same .so-ball-badge { display: grid; background: var(--so-same); }
.so-board--hints .so-ball.is-good .so-ball-body { border-color: var(--so-good); box-shadow: 0 0 0 3px var(--so-good-soft), 0 2px 5px rgba(30,20,60,.28); }
.so-board--hints .so-ball.is-bad  .so-ball-body { border-color: var(--so-bad); }
.so-board--won .so-ball { cursor: default; }
.so-shake { animation: so-shake .24s; }
@keyframes so-shake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }

/* 小手提示 */
.so-glow { z-index: 5; }
.so-ball.so-glow .so-ball-body { animation: so-glow 1s ease-in-out infinite; }
.so-tube.so-glow .so-tube-glass { animation: so-glow-zone 1s ease-in-out infinite; }
@keyframes so-glow {
  0%, 100% { box-shadow: 0 0 0 3px #fde047, 0 0 0 0 rgba(250,204,21,0); }
  50%      { box-shadow: 0 0 0 3px #facc15, 0 0 0 10px rgba(250,204,21,.45); }
}
@keyframes so-glow-zone {
  0%, 100% { border-color: #fde047; }
  50%      { border-color: #facc15; box-shadow: 0 0 0 8px rgba(250,204,21,.3); }
}
.so-hand { position: absolute; left: 50%; top: -6px; margin-left: -14px; font-size: 30px; line-height: 1; pointer-events: none; z-index: 6; animation: so-hand .8s ease-in-out infinite; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.so-ball .so-hand { top: auto; bottom: -8px; }
.so-tube > .so-hand { top: calc(100% - var(--base) - var(--bs) * 4 - 50px); }
@keyframes so-hand { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-8px) scale(1.12); } }

/* 贏了 */
.so-win {
  position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 7;
  background: rgba(255,255,255,.95); border-radius: 14px; padding: 12px 14px;
  text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  display: none; animation: so-pop .28s cubic-bezier(.2,.9,.3,1.3);
}
.so-board--won .so-win { display: block; }
@keyframes so-pop { from { transform: translateY(14px) scale(.94); opacity: 0; } }
.so-win-title { font-size: 20px; font-weight: 900; margin: 0 0 4px; }
.so-win-sub { font-size: 13.5px; color: #475569; margin: 0 0 10px; }
.so-win-best { display: inline-block; background: var(--gd-amber-bg); border: 1px solid var(--gd-amber-bd); color: #92400e; font-weight: 800; font-size: 12px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.so-win-best--perfect { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.so-win-btns { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

/* 統計 / 小知識 / 動作 */
.so-stats { display: flex; justify-content: center; gap: 18px; margin: 14px 0 6px; font-size: 14px; color: #475569; flex-wrap: wrap; }
.so-stat b { color: var(--gd-ink); font-variant-numeric: tabular-nums; font-size: 16px; }
.so-fact { text-align: center; font-size: 13px; color: var(--gd-muted); margin: 0 0 12px; }
.so-fact b { color: var(--gd-ink); font-variant-numeric: tabular-nums; }
.so-fact sup { font-size: .72em; }
.so-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ── 回家的路：綠／橘對比只有 ΔE≈8（色盲），所以一定配圖示 ── */
.so { --so-good: #2f8a50; --so-good-soft: rgba(47, 138, 80, .22); --so-bad: #c4560e; --so-same: #7f897e; --so-no: #94a3b8; }

.so-road { margin-top: 12px; background: #fffaf0; border: 1px solid #e5c58c; border-radius: 16px; padding: 10px 12px 8px; }
.so-road-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 6px; color: #5b3a12; }
.so-road-label, .so-road-unit { font-size: 14px; font-weight: 800; }
.so-road-n { font-size: 30px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; color: #3f2a10; }
.so-road-say { margin-left: auto; font-size: 14px; font-weight: 800; color: #7a4f14; }
.so-road-say.is-good { color: var(--so-good); }
.so-road-say.is-bad { color: var(--so-bad); }
.so-road-track { position: relative; width: 100%; }
.so-road-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.so-road-svg polyline { fill: none; stroke: #f0dfbd; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.so-road-stone {
  position: absolute; border-radius: 50%; background: #fff; border: 2px solid #dcc59a;
  display: grid; place-items: center; font-weight: 800; color: #9a7a4a;
  font-variant-numeric: tabular-nums; transition: opacity .2s; box-sizing: border-box;
}
.so-road-stone.is-past { opacity: .35; }
.so-road-home {
  position: absolute; border-radius: 10px; background: #fff8ea; border: 3px solid var(--so-good);
  box-shadow: 0 2px 6px rgba(0,0,0,.18); box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 3px;
}
.so-road-home i { height: 4px; border-radius: 999px; background: #8b5cf6; }
.so-road-home i:nth-child(1) { background: #60a5fa; }
.so-road-home i:nth-child(2) { background: #6366f1; }
.so-road-home-badge { position: absolute; right: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--so-good); color: #fff; display: grid; place-items: center; }
.so-road-home-badge svg { width: 11px; height: 11px; display: block; }
.so-road-home.is-home { animation: so-home-bounce .8s 2; }
@keyframes so-home-bounce { 40% { transform: translateY(-6px); } }
.so-road-dino { position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 2; pointer-events: none; transition: transform .4s cubic-bezier(.3,.7,.3,1.15); }
.so-road-dino.is-instant { transition: none; }
.so-road-dino-img {
  position: absolute; left: -17px; top: -38px; width: 34px; height: 34px; border-radius: 50%;
  background: url("/assets/img/rexcode-logo.webp") center / cover no-repeat #fff;
  border: 2px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.22);
}
.so-road-dino.is-hop .so-road-dino-img { animation: so-dino-hop .4s; }
@keyframes so-dino-hop { 45% { transform: translateY(-14px); } }
.so-road-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: #7a5a2a; }
.so-lg { display: inline-flex; align-items: center; gap: 5px; }
.so-lg-dot { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.so-lg-dot svg { width: 10px; height: 10px; display: block; }
.so-lg-good { background: var(--so-good); }
.so-lg-bad { background: var(--so-bad); }
.so-lg-same { background: var(--so-same); }
.so-lg-no { background: var(--so-no); }

/* 走過的路 */
.so-journey { margin: 0 0 16px; }
.so-journey-cap { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 8px; font-size: 13px; color: var(--gd-muted); margin-bottom: 2px; }
.so-journey-cap b { color: var(--gd-ink); }
.so-journey-plot { position: relative; max-width: 460px; margin: 0 auto; }
.so-journey-svg { display: block; width: 100%; height: auto; }
.so-j-grid { stroke: #e5e7eb; stroke-width: 1; }
.so-j-base { stroke: var(--so-good); stroke-width: 1.5; stroke-dasharray: 4 4; }
.so-j-axis { fill: #64748b; font-size: 12px; font-variant-numeric: tabular-nums; }
.so-j-home { fill: var(--so-good); font-size: 13px; font-weight: 800; }
.so-j-seg { stroke-width: 3; stroke-linecap: round; }
.so-j-good { stroke: var(--so-good); }
.so-j-bad { stroke: var(--so-bad); }
.so-j-same { stroke: var(--so-same); }
.so-j-pt { fill: #fff; stroke: #475569; stroke-width: 1.5; }
.so-j-ring { fill: none; stroke: #fff; stroke-width: 2; }
.so-j-lbl { fill: #0f172a; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.so-j-lbl--muted { fill: #64748b; font-weight: 700; }
.so-j-guide { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 3 3; }
.so-j-hit { fill: transparent; }
.so-journey-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)); pointer-events: none; z-index: 3;
  background: #fff; border: 1px solid var(--gd-bd); border-radius: 8px; padding: 4px 8px;
  font-size: 12.5px; white-space: nowrap; box-shadow: 0 4px 12px rgba(0,0,0,.1); font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .so-tray { padding: 10px; border-radius: 18px; }
  .so-ref-goal { width: 54px; height: 54px; }
  .so-coach-avatar { width: 42px; height: 42px; }
  .so-coach-bubble::before { left: 66px; }
  .so-coach-text { font-size: 14px; }
  .so-seg button { padding: 0 11px; }
  .so-toolbar .gd-btn { padding: 8px 11px; font-size: 13.5px; min-height: 38px; }
  
  .so-road { padding: 8px 10px 6px; }
  .so-road-n { font-size: 26px; }
  .so-road-say { margin-left: 0; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .so-ball, .so-road-dino, .so-road-stone { transition: none; }
  .so-road-dino.is-hop .so-road-dino-img, .so-road-home.is-home,
  .so-ball.so-glow .so-ball-body, .so-tube.so-glow .so-tube-glass, .so-hand { animation: none; }
}

/* 目標小圖：三支裝好的小試管 */
.so-ref-goal { flex-direction: row; align-items: flex-end; justify-content: center; gap: 5px; padding: 0 0 10px; }
.so-ref-goal::after { display: none; }
.so-ref-goal i { width: 11px !important; height: 34px; border-radius: 0 0 6px 6px; border: 2px solid #d9b77f; border-top: 0; box-shadow: none; }
.so-ref-goal i:nth-child(1) { background: #ef4444; } .so-ref-goal i:nth-child(2) { background: #3b82f6; } .so-ref-goal i:nth-child(3) { background: #facc15; }
.so-road-home { flex-direction: row; align-items: flex-end; gap: 2px; }
.so-road-home i { width: 22% !important; height: 70%; border-radius: 0 0 4px 4px; }
.so-road-home i:nth-child(1) { background: #ef4444; } .so-road-home i:nth-child(2) { background: #3b82f6; } .so-road-home i:nth-child(3) { background: #facc15; }
