/* 星港任務 App（public/js/star.js）第二季「星際騎士」專用的樣式：道場、光劍、兩個小遊戲的畫布、對決的計時條。
   行動優先：沒有超過 340px 的固定寬度，畫布一律寬 100%（最多 320）。 */

/* 小遊戲畫布：320×360，手機上縮到 modal 的寬 */
.star-canvas {
  display: block; width: 100%; max-width: 320px; height: auto; aspect-ratio: 320 / 360; margin: 0 auto;
  border-radius: 18px; background: #121a3d; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .08);
}
/* 對決的計時條 */
.star-bar-canvas { display: block; width: 100%; max-width: 320px; height: auto; aspect-ratio: 320 / 44; margin: 0 auto; touch-action: none; user-select: none; }

/* 畫布上方的分數列 */
.star-hud { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; flex-wrap: wrap; }

/* 螢幕上的方向鍵／揮劍鍵 */
.star-pad { display: flex; justify-content: center; gap: 8px; }
.star-pad-btn { min-width: 72px; min-height: 48px; font-size: 18px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }

/* 三種架式 */
.star-stances { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.star-stance { min-height: 48px; font-size: 18px; }

/* 對決的對手 */
.star-vs { display: flex; align-items: center; gap: 10px; }
.star-foe { width: 72px; height: 72px; object-fit: contain; flex: none; }
.star-result { min-height: 44px; }

/* 騎士階級卡 */
.star-rank {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, #1d2454, #35407f); box-shadow: 0 2px 0 #141a3a;
}
.star-badge { width: 56px; height: 56px; flex: none; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35)); }
.star-rank-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.star-rank-name { font-weight: 700; font-size: 16px; }
.star-rank-sub { font-size: 12px; opacity: .88; line-height: 1.35; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.star-rank .ach-bar { margin: 2px 0; background: rgba(255, 255, 255, .22); }
.star-rank .ach-fill { background: #ffd66b; }
.star-skills { gap: 4px; }
.star-skills .chip { min-height: 24px; padding: 0 9px; font-size: 12px; background: rgba(255, 255, 255, .16); color: #fff; box-shadow: none; }
.star-skills .chip.on { background: #ffd66b; color: #3a2d10; }
.star-skills .chip.off { opacity: .5; }
.star-skill-text { padding: 0 4px; }

/* ==========================================================================
   星港日誌（全螢幕，像豆苗決鬥一樣蓋在遊戲上）：夜空的底、奶油色的紙卡，跟豆苗島其他畫面同一套軟絨黏土風。
   手機直式 375 寬也排得下：單欄、按鈕至少 44px 高、文字 14px 以上。
   ========================================================================== */
body.in-star #phoneButton, body.in-star .tray, body.in-star .broom-btn, body.in-star .job-chip { visibility: hidden; }
@keyframes sv-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sv-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.sv-view {
  position: fixed; inset: 0; z-index: 24; overflow: hidden; color: var(--ink);
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255, 255, 255, .9), transparent 60%),
    radial-gradient(1.2px 1.2px at 78% 12%, rgba(255, 255, 255, .8), transparent 60%),
    radial-gradient(1.8px 1.8px at 64% 34%, rgba(255, 244, 200, .9), transparent 60%),
    radial-gradient(1.2px 1.2px at 30% 52%, rgba(255, 255, 255, .7), transparent 60%),
    radial-gradient(1.4px 1.4px at 90% 70%, rgba(255, 255, 255, .8), transparent 60%),
    radial-gradient(1.2px 1.2px at 8% 84%, rgba(255, 255, 255, .7), transparent 60%),
    radial-gradient(120% 70% at 50% 0%, #4a54a3 0%, #2f3672 45%, #1f2452 100%);
  padding: var(--safe-t) 0 var(--safe-b);
  animation: sv-in .2s;
}
.sv-hub { position: absolute; inset: var(--safe-t) 0 var(--safe-b); display: flex; flex-direction: column; min-height: 0; }
.sv-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: #fff; }
.sv-top-ic { width: 34px; height: 40px; object-fit: contain; flex: none; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .3)); }
.sv-top-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.sv-top-title b { font-size: 19px; letter-spacing: .5px; }
.sv-top-title span { font-size: 12.5px; opacity: .85; }
.sv-dust { display: flex; align-items: center; gap: 4px; padding: 4px 10px 4px 4px; border-radius: 999px; background: rgba(255, 255, 255, .16); color: #fff; font-variant-numeric: tabular-nums; }
.sv-dust-ic { width: 26px; height: 26px; object-fit: contain; }
.sv-view .cd-x { width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); font-size: 18px; font-weight: 700; color: var(--ink); }
.sv-tabs { display: flex; gap: 6px; padding: 4px 12px 8px; overflow-x: auto; scrollbar-width: none; }
.sv-tabs::-webkit-scrollbar { display: none; }
.sv-tab { flex: 1 0 auto; min-width: 62px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 2px 8px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 14px; font-weight: 700; }
.sv-tab-ic { width: 36px; height: 26px; object-fit: contain; }
.sv-tab.on { background: var(--paper); color: var(--ink); box-shadow: 0 3px 0 #c9b88f; }
.sv-tab.locked { opacity: .55; }
.sv-tab.locked .sv-tab-ic { filter: grayscale(.8); }
.sv-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px 32px; -webkit-overflow-scrolling: touch; }
.sv-col { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* 章節插畫 */
.sv-hero { position: relative; border-radius: 22px; overflow: hidden; aspect-ratio: 1200 / 400; min-height: 150px; background: #2f3672; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.sv-hero-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.sv-hero-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 14px 10px; color: #fff; background: linear-gradient(transparent, rgba(20, 22, 60, .8)); display: flex; flex-direction: column; gap: 2px; }
.sv-hero-text small { font-size: 12.5px; opacity: .9; }
.sv-hero-text h2 { font-size: 24px; margin: 0; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.sv-dots { display: flex; gap: 5px; margin-top: 4px; }
.sv-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .3); }
.sv-dot.done { background: #ffd66b; }
.sv-dot.now { background: #fff; box-shadow: 0 0 0 3px rgba(255, 214, 107, .55); }

/* 角色說話 */
.sv-talk { display: flex; align-items: flex-end; gap: 10px; }
.sv-portrait { width: 80px; height: 112px; object-fit: contain; flex: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); }
.sv-portrait.small { width: 60px; height: 86px; }
.sv-face { width: 44px; height: 44px; object-fit: contain; flex: none; }
.sv-bubble { position: relative; flex: 1; min-width: 0; margin: 0; padding: 10px 14px; border-radius: 18px; background: var(--paper); box-shadow: 0 3px 0 rgba(0, 0, 0, .18); font-size: 15px; line-height: 1.6; }
.sv-bubble::before { content: ''; position: absolute; left: -8px; bottom: 18px; border: 8px solid transparent; border-right-color: var(--paper); border-left: 0; }
.sv-bubble b { display: block; font-size: 13px; color: #c27b2c; }
.sv-bubble p { margin: 2px 0 0; }
.sv-talk.small { align-items: center; }
.sv-talk.small .sv-bubble { font-size: 14px; padding: 8px 12px; }
.sv-talk.small .sv-bubble::before { bottom: auto; top: 50%; transform: translateY(-50%); }

/* 下一步 */
.sv-next { position: relative; display: flex; align-items: center; gap: 12px; margin-top: 6px; padding: 18px 14px 14px; border-radius: 20px; background: #fffbe6; box-shadow: inset 0 0 0 3px var(--sun), 0 4px 0 #b78a22; }
.sv-next.wait { background: #f4efe2; box-shadow: inset 0 0 0 3px #d9cba8, 0 4px 0 rgba(0, 0, 0, .2); }
.sv-next-tag { position: absolute; left: 14px; top: -12px; padding: 2px 12px; border-radius: 999px; background: var(--sun); color: var(--ink); font-size: 13px; font-weight: 700; box-shadow: 0 2px 0 #dfb73f; }
.sv-next.wait .sv-next-tag { background: #e6dcc3; box-shadow: none; }
.sv-next-ic { width: 54px; height: 54px; object-fit: contain; flex: none; }
.sv-next-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sv-next-main b { font-size: 17px; }
.sv-next-main p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.sv-next .sv-go { flex: none; min-height: 48px; min-width: 96px; font-size: 16px; animation: sv-bob 1.4s ease-in-out infinite; }
@media (max-width: 480px) {
  .sv-next { flex-wrap: wrap; }
  .sv-next-main { flex: 1 1 180px; }
  .sv-next .sv-go { flex: 1 1 100%; }
}

/* 一般的紙卡 */
.sv-panel { padding: 12px; border-radius: 20px; background: var(--paper); box-shadow: 0 4px 0 rgba(0, 0, 0, .2); }
.sv-panel > h3 { font-size: 16px; margin: 0 0 8px; }
.sv-step.now { box-shadow: inset 0 0 0 2px var(--sun); }
.sv-step.done { opacity: .72; }
.sv-step .row-ic { object-fit: contain; }
.sv-rewards { display: flex; flex-wrap: wrap; gap: 8px; }
.sv-rw { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--paper-2); font-size: 14px; }
.sv-rw.title { padding: 4px 10px; background: #fbe9b4; font-weight: 700; }
.sv-rw-ic { width: 28px; height: 28px; object-fit: contain; }

/* 故事地圖 */
.sv-map .sv-season { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.sv-map .sv-season > small { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.sv-stops { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.sv-stop { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 8px 10px; border: 0; border-radius: 14px; background: var(--paper-2); color: var(--ink); text-align: left; font: inherit; }
.sv-stop-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: #fff; }
.sv-stop-t { font-size: 14px; font-weight: 700; }
.sv-stop small { font-size: 12px; color: var(--ink-soft); }
.sv-stop.done .sv-stop-n { background: #ffd66b; }
.sv-stop.now { background: #fffbe6; box-shadow: inset 0 0 0 2px var(--sun); }
.sv-stop.now .sv-stop-n { background: var(--sun); }
.sv-stop.later { opacity: .55; }

/* 建築分頁的頭 */
.sv-place { display: flex; align-items: center; gap: 12px; }
.sv-place-art { width: 120px; flex: none; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .35)); }
.sv-place-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sv-place-main h2 { margin: 0; color: #fff; font-size: 21px; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
@media (max-width: 420px) { .sv-place-art { width: 92px; } }
.sv-panel .banner { margin-bottom: 8px; }
.sv-panel h4 { margin: 12px 0 6px; }
.sv-panel .star-rank { margin-bottom: 8px; }

/* 開場：火箭迫降 */
.sv-intro { display: flex; flex-direction: column; gap: 8px; }
.sv-intro-sky { position: relative; height: 170px; border-radius: 18px; overflow: hidden; background: radial-gradient(120% 90% at 50% 0%, #4a54a3, #1f2452); }
.sv-intro-art { display: block; width: 100%; max-height: 300px; object-fit: cover; border-radius: 18px; }
.sv-intro-rocket { position: absolute; left: 50%; top: 14px; height: 130px; transform: translateX(-50%) rotate(-18deg); filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .4)); animation: sv-land 1s ease-out both; }
.sv-intro-a { position: absolute; left: 8%; bottom: -6px; height: 120px; animation: sv-pop .5s .8s both; }
.sv-intro-b { position: absolute; right: 10%; bottom: -4px; height: 96px; animation: sv-pop .5s 1s both; }
.sv-intro h3 { margin: 4px 0 0; }
.sv-intro p { margin: 0; font-size: 15px; line-height: 1.6; }
@keyframes sv-land { from { transform: translate(120%, -120%) rotate(-40deg) scale(.6); opacity: 0; } to { transform: translateX(-50%) rotate(-18deg); opacity: 1; } }
@keyframes sv-pop { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 章節完成 */
.sv-done { display: flex; flex-direction: column; gap: 10px; }
.sv-done-tag { align-self: flex-start; padding: 2px 12px; border-radius: 999px; background: var(--sun); font-weight: 700; }
.sv-done h3 { margin: 0; }
.sv-done .sv-bubble { background: var(--paper-2); box-shadow: none; }
.sv-done .sv-bubble::before { border-right-color: var(--paper-2); }
.sv-done .sv-panel { box-shadow: inset 0 0 0 2px var(--line); }
.sv-done-next { margin: 0; font-weight: 700; color: #6a4fa3; }
.sv-score { font-size: 16px; font-weight: 700; text-align: center; }

/* 畫面左上的「星港任務」小卡 */
.sv-chip {
  position: fixed; left: 10px; top: calc(var(--safe-t) + 132px); z-index: 6; max-width: min(240px, calc(100vw - 120px));
  display: flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border: 0; border-radius: 16px; font: inherit;
  background: linear-gradient(135deg, #3a4385, #2a3168); color: #fff; text-align: left; box-shadow: 0 3px 0 #181d45, 0 6px 14px rgba(0, 0, 0, .2); cursor: pointer;
}
.sv-chip[hidden] { display: none; }
.sv-chip-ic { width: 30px; height: 36px; object-fit: contain; flex: none; }
.sv-chip-main { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sv-chip-main b { font-size: 13px; color: #ffd66b; }
.sv-chip-main small { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-chip.fresh { animation: sv-bob 1.4s ease-in-out infinite; box-shadow: 0 0 0 3px #ffd66b, 0 3px 0 #181d45; }
.sv-chip.wait { opacity: .85; }
body.in-cards .sv-chip, body.in-shop .sv-chip, body.in-star .sv-chip { display: none; }
@media (max-width: 560px) { .sv-chip { left: 6px; top: calc(var(--safe-t) + 60px); } }
/* 溫室：身上的種子 */
.sv-seeds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 10px; padding: 10px 12px; border-radius: 16px; background: rgba(255, 250, 235, .95); color: var(--ink); }
.sv-seeds > b { font-size: 14px; margin-right: 4px; }
.sv-seed { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; }
.sv-seed small { font-weight: 400; color: var(--ink-soft); }
.sv-seed.none { opacity: .45; }
.sv-seed-ic { width: 26px; height: 26px; object-fit: contain; }
