/* 鍛造村（island.js）：大廳的全螢幕 3D 村落＋浮在上面的名牌、索引、卡片與標籤。
   清單模式時整個隱藏；鍛造、讀筆記、完成畫面則浮在村子上面（2026-10-25 使用者要求，不要切回舊畫面）。 */
.isle { display: none; }
html.pre-island body:not(.mode-list) .isle, body.mode-island .isle { display: block; }
html.pre-island body:not(.mode-list).on-hall main.app, body.mode-island.on-hall main.app { display: none; }
html.pre-island body:not(.mode-list), body.mode-island { overflow: hidden; overscroll-behavior: none; }

/* 浮在村子上的畫面：背後的村子變暗、繼續動，面板置中、可以捲動 */
body.mode-island:not(.on-hall) .isle > :not(canvas) { display: none !important; }
body.mode-island:not(.on-hall) main.app { position: fixed; inset: 0; z-index: 40; max-width: none; margin: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: max(20px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 40%, rgba(10, 8, 10, .35), rgba(10, 8, 10, .72)); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
body.mode-island:not(.on-hall) main.app > .screen { max-width: 680px; margin: clamp(12px, 7vh, 80px) auto 0; animation: isle-rise .35s cubic-bezier(.2, .8, .2, 1); }
body.mode-island:not(.on-hall) .topbar { background: rgba(18, 16, 20, .84); border: 1px solid rgba(201, 164, 92, .45); border-radius: 14px; padding: 8px 12px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 8px 26px rgba(0, 0, 0, .4); }
body.mode-island:not(.on-hall) .anvil-card, body.mode-island:not(.on-hall) .note-sheet, body.mode-island:not(.on-hall) .done {
  background: rgba(24, 21, 26, .9); border-color: rgba(201, 164, 92, .4); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
body.mode-island:not(.on-hall) .heat { margin: 10px 4px; }
body.mode-island:not(.on-hall) .done { margin-top: 12vh; }
@keyframes isle-rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { body.mode-island:not(.on-hall) main.app > .screen { animation: none; } }

.isle { position: fixed; inset: 0; background: #120e10; color: var(--bone); font-family: var(--sans); -webkit-tap-highlight-color: transparent; }
.isle canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* 載入畫面 */
.isle-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: #120e10; transition: opacity .8s ease; z-index: 30; }
.isle-loading b { font-family: "Almendra", var(--display); color: var(--ember-hot); font-size: 30px; }
.isle-loading span { color: var(--ash); font-size: 14px; }
body.isle-ready .isle-loading { opacity: 0; pointer-events: none; }

/* 浮在場景上的面板共用：炭黑毛玻璃＋暗金邊 */
.isle-hud, .isle-tools > button, .isle-tools .lang-toggle, .isle-sky, .isle-index, .isle-hint, .isle-toast {
  background: rgba(18, 16, 20, .8); border: 1px solid rgba(201, 164, 92, .5); color: var(--bone);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 6px 22px rgba(0, 0, 0, .4);
}

/* 左上：名牌＋今天的鍛造 */
.isle-hud { position: absolute; left: 16px; top: max(16px, env(safe-area-inset-top)); z-index: 10; cursor: pointer;
  border-radius: 18px; padding: 14px 18px 16px; width: 290px; max-width: calc(100% - 32px); }
.isle-hud .wm .kanji { display: block; font-family: "Yuji Boku", var(--serif); color: var(--ember); font-size: 30px; line-height: 1.1; letter-spacing: .04em; }
.isle-hud .wm b { display: block; font-family: "Almendra", var(--display); color: var(--gold); font-size: 21px; line-height: 1.15; }
.isle-hud .kv { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 12px; font-size: 13px; color: var(--ash); }
.isle-hud .kv b { color: var(--ember-hot); font: 600 16px var(--mono); }
.isle-hud .go, .isle-sheet .go { display: block; width: 100%; text-align: center; text-decoration: none; border: 0; cursor: pointer;
  background: linear-gradient(180deg, var(--ember-hot), var(--ember)); color: #1a0d05; border-radius: 12px; padding: 11px 14px; font: 700 15px var(--sans); }
.isle-hud .go:disabled, .isle-sheet .go:disabled { background: var(--steel); color: var(--ash); cursor: default; }
.isle-sheet .go.ghost { background: transparent; border: 1px solid var(--gold); color: var(--gold); }

/* 右上：工具列（橫排） */
.isle-tools { position: absolute; right: 16px; top: max(16px, env(safe-area-inset-top)); z-index: 11; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; max-width: 62%; }
.isle-tools > button { display: flex; align-items: center; gap: 7px; border-radius: 12px; padding: 9px 14px; font: 600 14px var(--sans); cursor: pointer; }
.isle-tools > button i { font-style: normal; color: var(--gold); }
.isle-tools > button[aria-pressed="false"] { opacity: .6; }
.isle-tools > button:hover, .isle-tools > button:focus-visible { border-color: var(--ember-hot); }
.isle-tools .lang-toggle { display: flex; border-radius: 12px; overflow: hidden; margin: 0; }
.isle-tools .lang-toggle button { background: none; border: 0; color: var(--ash); font: 600 13px var(--sans); padding: 9px 11px; cursor: pointer; }
.isle-tools .lang-toggle button[aria-pressed="true"] { background: var(--gold); color: var(--coal); }

/* 天色選單 */
.isle-sky { position: absolute; right: 16px; top: calc(max(16px, env(safe-area-inset-top)) + 54px); z-index: 13; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.isle-sky[hidden] { display: none; }
.isle-sky > b { font-family: var(--serif); color: var(--gold); font-size: 14px; padding: 0 4px; }
.isle-sky button { text-align: left; background: rgba(237, 229, 218, .06); border: 1px solid transparent; color: var(--bone); border-radius: 10px; padding: 8px 10px; font: 14px var(--sans); cursor: pointer; }
.isle-sky button small { display: block; color: var(--ash); font-size: 11px; }
.isle-sky button[aria-pressed="true"] { border-color: var(--gold); background: rgba(201, 164, 92, .18); }

/* 右側：島嶼索引（寬螢幕常駐，可收起） */
.isle-index { position: absolute; right: 16px; top: calc(max(16px, env(safe-area-inset-top)) + 60px); bottom: 16px; z-index: 9; width: 300px;
  border-radius: 18px; padding: 16px 14px; overflow: auto; background: rgba(237, 229, 218, .95); color: #231d1c; border-color: rgba(120, 90, 50, .35); }
body.isle-index-off .isle-index, body.isle-sheet-open .isle-index { display: none; }
.isle-index .kicker { margin: 0; font: 600 11px var(--mono); letter-spacing: .14em; color: var(--ember); }
.isle-index h2 { margin: 2px 0 2px; font: 900 22px var(--serif); }
.isle-index .sub { margin: 0 0 10px; font-size: 13px; color: #6b5f57; }
.isle-index .ix-list { display: flex; flex-direction: column; border-top: 1px solid rgba(60, 40, 30, .15); }
.isle-index .ix-list.more { margin-top: 12px; }
.isle-index .ix-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; background: none; border: 0; border-bottom: 1px solid rgba(60, 40, 30, .12);
  text-align: left; padding: 9px 4px; cursor: pointer; color: inherit; font: inherit; }
.isle-index .ix-row:hover { background: rgba(228, 113, 42, .08); }
.isle-index .ix-row .no { font: italic 600 20px Georgia, serif; }
.isle-index .ix-row.sub .no { font-size: 14px; color: var(--gold); text-align: center; }
.isle-index .ix-row .nm b { display: block; font: 700 15px var(--serif); }
.isle-index .ix-row .nm small { display: block; font-size: 11.5px; color: #7a6d63; line-height: 1.35; }
.isle-index .ix-row .ct { font: 600 12px var(--mono); color: #6b5f57; text-align: right; white-space: nowrap; }
.isle-index .ix-row .ct i { display: block; font-style: normal; color: #c2541c; }
.isle-index .legend { margin: 12px 2px 0; font-size: 12px; color: #6b5f57; }

/* 島上的標籤 */
.isle-labels { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.isle-tag { position: absolute; left: 0; top: 0; pointer-events: auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px;
  background: rgba(237, 229, 218, .95); color: #231d1c; border: 1.5px solid rgba(60, 40, 30, .25); border-radius: 999px;
  padding: 5px 12px 5px 5px; font: 700 14px var(--serif); cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); will-change: transform; }
.isle-tag .n { display: inline-block; min-width: 26px; padding: 2px 6px; border-radius: 999px; color: #fff; font: 700 12px var(--sans); text-align: center; }
.isle-tag .n.core { background: #3a2a22; color: var(--ember-hot); font-family: var(--serif); }
.isle-tag i { font-style: normal; font: 700 12px var(--mono); border-radius: 999px; padding: 1px 7px; }
.isle-tag i.due { background: var(--ember); color: #fff; }
.isle-tag i.ok { background: var(--knew); color: #fff; }
.isle-tag.on { background: var(--coal); color: var(--ember-hot); border-color: var(--ember-hot); }
.isle-tag.core { font-size: 15px; }
/* 一家人的名牌：小一點、深色，和街區標籤分得開 */
.isle-tag.char { padding: 3px 10px; font: 600 12px var(--sans); background: rgba(18, 16, 20, .82); color: var(--ember-hot); border-color: rgba(255, 178, 87, .6); z-index: 1; }

.isle-hint { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; margin: 0;
  border-radius: 999px; padding: 7px 16px; font-size: 13px; white-space: nowrap; pointer-events: none; }
body.isle-sheet-open .isle-hint { display: none; }

/* 卡片：窄螢幕從下方升起，寬螢幕在左側 */
.isle-sheet { position: absolute; left: 50%; bottom: 0; z-index: 20; width: min(560px, 100%); max-height: 64vh; overflow: auto;
  transform: translate(-50%, 105%); transition: transform .45s cubic-bezier(.2, .8, .2, 1); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); background: rgba(237, 229, 218, .97); color: #231d1c;
  border: 1px solid rgba(120, 90, 50, .35); box-shadow: 0 8px 30px rgba(0, 0, 0, .45); }
.isle-sheet.open { transform: translate(-50%, 0); }
.isle-sheet .x { position: absolute; right: 12px; top: 10px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(60, 40, 30, .2); background: #fff8ee; color: #231d1c; font-size: 16px; cursor: pointer; }
.isle-sheet h2 { margin: 0 44px 8px 0; font: 900 22px var(--serif); color: #3a1d10; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.isle-sheet h2 small { flex-basis: 100%; font: 500 13px var(--sans); color: #7a6d63; }
.isle-sheet h2 .num { font: 700 13px var(--sans); color: #fff; border-radius: 999px; padding: 2px 8px; align-self: center; }
.isle-sheet h2 .num.core { background: #3a2a22; color: var(--ember-hot); font-family: var(--serif); }
.isle-sheet h3 { margin: 16px 0 6px; font: 700 13px var(--sans); color: #7a6d63; letter-spacing: .06em; }
.isle-sheet .stats { margin: 2px 0 6px; font-size: 14px; color: #6b5f57; }
.isle-sheet .note { font-size: 13.5px; color: #6b5f57; margin: 10px 0 0; }
.isle-sheet .meter { height: 6px; border-radius: 3px; background: rgba(60, 40, 30, .14); overflow: hidden; margin: 4px 0 12px; }
.isle-sheet .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--ember), var(--gold)); }
.isle-sheet .rows { display: flex; flex-direction: column; gap: 6px; }
.isle-sheet .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; color: #231d1c; cursor: pointer;
  background: #fffaf2; border: 1px solid rgba(60, 40, 30, .15); border-radius: 10px; padding: 9px 12px; font: inherit; width: 100%; }
.isle-sheet .row.tp { cursor: default; }
.isle-sheet .row > span:first-child { flex: 1; min-width: 0; }
.isle-sheet .row b { display: block; font: 700 15px var(--serif); }
.isle-sheet .row small { display: block; font-size: 12px; color: #7a6d63; }
.isle-sheet .row .meter { margin: 5px 0 0; height: 4px; }
.isle-sheet button.row:hover { border-color: var(--ember); }
.isle-sheet .pill { flex: 0 0 auto; font: 700 12px var(--sans); border-radius: 999px; padding: 2px 9px; background: #efe2cc; color: #6b5f57; }
.isle-sheet .mini { flex: 0 0 auto; border: 1px solid var(--gold); background: transparent; color: #8a6420; border-radius: 999px; padding: 6px 12px; font: 700 13px var(--sans); cursor: pointer; }
.isle-sheet .mini.hot { background: var(--ember); border-color: var(--ember); color: #fff; }
.isle-sheet .mini:disabled { opacity: .45; cursor: default; }
.isle-sheet .kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 6px 0 12px; }
.isle-sheet .kv div { background: #fffaf2; border: 1px solid rgba(60, 40, 30, .15); border-radius: 10px; padding: 8px; text-align: center; }
.isle-sheet .kv b { display: block; font: 600 22px var(--mono); color: #c2541c; }
.isle-sheet .kv span { font-size: 12px; color: #7a6d63; }

.isle-toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.96); z-index: 25; border-radius: 12px; padding: 10px 18px; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; }
.isle-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* 寬螢幕（平板橫放、電腦）：卡片改成左側直欄，蓋住名牌 */
@media (min-width: 900px) {
  .isle-sheet { left: 16px; top: max(16px, env(safe-area-inset-top)); bottom: 16px; width: 390px; max-height: none;
    border-radius: 20px; transform: translateX(calc(-100% - 24px)); padding: 22px 20px; }
  .isle-sheet.open { transform: translateX(0); }
  body.isle-sheet-open .isle-hud { opacity: 0; pointer-events: none; }
}
/* 手指操作：按鈕至少 44px 高 */
@media (pointer: coarse) {
  .isle-tools > button { min-height: 46px; }
  .isle-tag { min-height: 36px; font-size: 15px; }
  .isle-sky button, .isle-sheet .mini { min-height: 44px; }
  .isle-index .ix-row { padding: 12px 4px; }
}
/* 清單畫面的「回到鍛造群島」按鈕 */
.to-island { display: block; margin: 14px auto 0; border: 1px solid var(--gold); background: rgba(201, 164, 92, .12); color: var(--gold); border-radius: 999px; padding: 8px 18px; font: 600 15px var(--sans); cursor: pointer; position: relative; z-index: 2; }
.to-island[hidden] { display: none; }

/* 平板直放（iPad mini 直拿，約 744×1133）：工具列移到下方好按、卡片從下方升起 */
@media (min-width: 641px) and (max-width: 899px) and (orientation: portrait) {
  .isle-tools { top: auto; bottom: max(16px, env(safe-area-inset-bottom)); left: 16px; right: 16px; max-width: none; justify-content: center; }
  .isle-tools > button { padding: 10px 14px; }
  .isle-sky { top: auto; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 62px); }
  .isle-index { top: max(16px, env(safe-area-inset-top)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px); width: 330px; }
  body:not(.isle-index-off) .isle-hud { display: none; }
  .isle-hint { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 66px); }
  .isle-sheet { width: calc(100% - 24px); max-height: 56vh; border-radius: 22px 22px 0 0; padding: 20px 22px calc(20px + env(safe-area-inset-bottom)); }
  body.isle-sheet-open .isle-tools, body.isle-sheet-open .isle-hint { display: none; }
  .isle-sheet .row { padding: 12px 14px; }
  .isle-sheet .go { padding: 13px 16px; font-size: 16px; }
}
/* 手機直式：工具列移到下方、名牌縮小 */
@media (max-width: 640px) {
  .isle-hud { left: 10px; right: 10px; width: auto; padding: 10px 12px; border-radius: 14px; }
  .isle-hud .wm .kanji { font-size: 22px; display: inline; }
  .isle-hud .wm b { font-size: 16px; display: inline; margin-left: 8px; }
  .isle-hud .kv { margin: 6px 0 8px; font-size: 12px; }
  .isle-hud .go { padding: 8px; font-size: 14px; }
  .isle-tools { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); left: 10px; right: 10px; max-width: none; justify-content: center; gap: 6px; }
  .isle-tools > button { padding: 8px 10px; font-size: 13px; gap: 5px; }
  .isle-sky { top: auto; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .isle-tag { font-size: 12px; padding: 3px 9px 3px 3px; gap: 5px; }
  .isle-tag .n { min-width: 22px; font-size: 11px; }
  .isle-index { left: 10px; right: 10px; width: auto; top: 150px; bottom: 76px; }
  .isle-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .isle-sheet { transition: none; } }
