/* v4 新元件（配合 b.css 航海圖風格） */
#tabs { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
#tabs button { font-size: 13px; padding-inline: 1px; }
.diffrow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.diffrow button { line-height: 1.25; padding: 4px 2px; font-size: 15px; }
.diffrow small { display: block; font-size: 11px; opacity: .85; }
.diffrow button[aria-checked="true"] { outline: 3px solid #8c3b2e; outline-offset: -1px; background: #8c3b2e; color: #fff3d8; }
.diff .note { margin: 5px 0 10px; }
#ask { position: relative; }
#timer { position: absolute; left: 10px; right: 10px; bottom: 2px; height: 5px; border-radius: 3px; background: rgba(70, 45, 20, .22); overflow: hidden; }
#timer i { display: block; height: 100%; background: #4f7d5a; }
#timer.low i { background: #b3362a; }
#askZh.long { font-size: 13px !important; line-height: 1.3 !important; }
.gaptext s { opacity: .75; text-decoration-color: #a02f22; text-decoration-thickness: 2px; }
.ans summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; margin-bottom: 6px; font-size: 15px; }
#levels .isle.t4 img.art { object-fit: contain; }
@media (max-height: 700px) { .gaptext, .gaptext .slot { font-size: 14px !important; line-height: 1.45 !important; } }

/* 首頁第一屏就看得到關卡 */
#home #banner { aspect-ratio: 360 / 96; object-fit: cover; }
#home .menu { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; margin-bottom: 8px; }
#home .menu button, #home .menu button:nth-child(n+4) { grid-column: auto; font-size: 11px; padding: 3px 1px; min-height: 52px; white-space: normal; line-height: 1.2; }
#home #me { padding-block: 6px; margin-bottom: 8px; }
#home .diff .note { margin-bottom: 6px; }
#levels .isle small { font-size: 13px; }
.swap { display: inline-flex; gap: 4px; align-items: baseline; white-space: nowrap; }
#bSkip { white-space: nowrap; }

/* 成長卡 */
#home #me { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
#meSnake { grid-column: 1 / -1; width: 100%; max-width: 300px; height: auto; margin: 0 auto; display: block; }
#me .ttl { font-style: normal; font-size: 12px; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: #8c3b2e; color: #fff3d8; }
#me .stamps { display: flex; gap: 3px; margin-top: 4px; }
#me .stamps i { font-style: normal; font-size: 11px; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; border: 1px dashed currentColor; opacity: .55; }
#me .stamps i.on { opacity: 1; border-style: solid; background: #8c3b2e; color: #fff3d8; }
#me .side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#bReview { font-size: 14px; padding: 0 10px; white-space: nowrap; }
.chip.ach { cursor: default; } .chip.ach.on { font-weight: 700; }
#levels .isle.race .bossart { font-size: 26px; }

/* 成長卡排版：蛇在上排，文字和按鈕在下排 */
#home #me { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "snake snake" "t side"; }
#home #me #meSnake { grid-area: snake; position: static; }
#home #me .t { grid-area: t; }
#home #me .side { grid-area: side; align-self: start; }
#me .ttl { white-space: nowrap; display: inline-block; }
#bReview { line-height: 1.25; }
#bReview:disabled { font-size: 12px; }

/* 海圖：魔王、競速、試航放最上面一列；收起來的島 */
#levels .specials { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
#levels .specials .isle.boss { max-width: none; margin: 0; }
#levels .specials:empty { display: none; }
#levels .more { grid-column: 1 / -1; width: 100%; margin-top: 10px; font-size: 14px; }

/* 未點亮的星期章改用實色字底，提高小字對比，保留原有虛線。 */
#me .stamps i:not(.on) {
  opacity: 1;
  color: #dbceb6;
  background-color: #29484e;
}

/* 成長卡左欄變窄時，星期章可換行並維持圓章的寬度。 */
#me .stamps {
  flex-wrap: wrap;
}

#me .stamps i {
  flex: 0 0 22px;
}

/* 恢復主題覆蓋掉的按鈕最小寬度，320 px 版的欄位仍放得下。 */
@media (min-width: 320px) {
  #home .menu button,
  #tabs button,
  #levels button.isle,
  #story .row button,
  #pad button {
    min-width: 44px;
  }
}

/* v5.2 UI/UX 調校 */
#bContinue { margin-bottom: 10px; font-size: 17px; }
#home #me .evo { grid-area: snake; display: flex; align-items: center; gap: 8px; }
#home #me .evo img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid #e8c98a; flex: none; box-shadow: 0 2px 0 #4a2f1d; }
#home #me .evo canvas { flex: 1; min-width: 0; max-width: 220px; }
#timer { height: 6px; }
.slot.cur { border-bottom-width: 4px; border-bottom-color: #b5562b; }
.rules summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-size: 14px; }
.evos { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.evos figure { margin: 0; text-align: center; font-size: 12px; }
.evos img { width: 100%; aspect-ratio: 1; border-radius: 12px; object-fit: cover; filter: brightness(0) opacity(.35); }
.evos figure.on img { filter: none; }
#story #sArt[src*="evo"], #story #sArt[src*="levelup"] { aspect-ratio: 1; max-height: 42vh; width: auto; margin: 0 auto 8px; }

/* 電腦寬螢幕：首頁左右兩欄，海圖第一屏就看得到 */
@media (min-width: 1024px) {
  #home .wrap { max-width: 1120px; display: grid; grid-template-columns: 340px minmax(0, 1fr); column-gap: 28px; align-items: start; }
  #home .wrap > * { grid-column: 1; }
  #home .wrap > #tabs { grid-column: 2; grid-row: 1; }
  #home .wrap > #tierNote { grid-column: 2; grid-row: 2; }
  #home .wrap > #levels { grid-column: 2; grid-row: 3 / span 8; }
  #home .wrap > #banner { grid-row: 1; } #home .wrap > #bContinue { grid-row: 2; } #home .wrap > #me { grid-row: 3; }
  #home .wrap > .menu { grid-row: 4; } #home .wrap > .diff { grid-row: 5; } #home .wrap > .how { grid-row: 6; } #home .wrap > .rdg-foot { grid-row: 7; }
}

/* 頁首跟著首頁變寬；魔王、競速卡改成精簡橫條 */
@media (min-width: 1024px) { body:not(.playing) header { max-width: 1120px; } }
#levels .specials .isle.boss { display: flex !important; flex-direction: row; align-items: center; gap: 8px; text-align: left; padding: 6px 8px; min-height: 56px; }
#levels .specials .isle.boss::after, #levels .specials .isle.boss::before { display: none; }
#levels .specials .isle.boss .bossart { width: 44px; height: 40px; flex: none; }
#levels .specials .isle.boss .t { flex: 1; min-width: 0; padding: 2px 4px; }
#levels .specials .isle.boss .s { width: auto; background: none; border: 0; margin: 0; }

/* 戰鬥：絕招鈕、裝備工坊 */
#pad #bUlt { background: linear-gradient(90deg, #c98a2b var(--e, 0%), #4a3326 var(--e, 0%)); color: #fff3d8; font-size: 14px; }
#pad #bUlt.full { background: #DE9A45; color: #2a1608; animation: ultpulse 1s infinite; }
@keyframes ultpulse { 50% { filter: brightness(1.15); } }
@media (prefers-reduced-motion: reduce) { #pad #bUlt.full { animation: none; } }
#pad button { min-width: 0 !important; font-size: 14px; }
#forgeArt { display: block; width: 100%; border-radius: 12px; margin-bottom: 8px; aspect-ratio: 3 / 2; object-fit: cover; }
.card.gear { align-items: center; }
.card.gear .gicon { width: 46px; height: 46px; flex: none; }
.card.gear .acts { display: flex; flex-direction: column; gap: 6px; }
.card.gear .acts button { font-size: 13px; padding: 0 8px; white-space: nowrap; }
.card.gear.on { box-shadow: inset 0 0 0 2px #b5562b; }
#shop h3 { margin: 14px 0 8px; }
