/* 魔法島（assets/island.js）：全螢幕 3D 島嶼＋浮在上面的卡片與標籤。清單模式時整個隱藏。 */
.isle { display: none; }
html.pre-island body:not(.mode-list) .isle, body.mode-island .isle { display: block; }
html.pre-island body:not(.mode-list) main.app, body.mode-island main.app { display: none; }
html.pre-island body:not(.mode-list), body.mode-island { overflow: hidden; overscroll-behavior: none; }

.isle { position: fixed; inset: 0; background: #140E18; color: var(--moon); 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: #140E18; transition: opacity .8s ease; z-index: 30; }
.isle-loading b { font-family: var(--brand); color: var(--gold); font-size: 26px; letter-spacing: .05em; }
.isle-loading span { color: var(--moon-soft); font-size: 14px; }
body.isle-ready .isle-loading { opacity: 0; pointer-events: none; }

/* 浮在場景上的卡片共用樣式：深色毛玻璃＋金邊 */
.isle-hud, .isle-tools button, .isle-sky, .isle-sheet, .isle-hint, .isle-toast, .isle-lang {
  background: rgba(24, 16, 32, .78); border: 1px solid rgba(212, 162, 70, .55); color: var(--moon);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 6px 22px rgba(0, 0, 0, .35);
}

/* 左上：學院名牌 */
.isle-hud { position: absolute; left: 16px; top: max(16px, env(safe-area-inset-top)); z-index: 10; text-align: left; cursor: pointer;
  border-radius: 16px; padding: 12px 16px; min-width: 210px; max-width: calc(100% - 140px); font: inherit; }
.isle-hud .wm b { display: block; font-family: var(--brand); color: var(--gold); font-size: 22px; line-height: 1.05; letter-spacing: .04em; }
.isle-hud .wm b + b { font-size: 24px; }
.isle-hud .yr { margin-top: 8px; font-family: var(--serif); font-size: 14px; }
.isle-hud .bar, .isle-sheet .bar { height: 6px; border-radius: 3px; background: rgba(242, 230, 201, .18); overflow: hidden; margin: 5px 0 3px; }
.isle-hud .bar i, .isle-sheet .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--scarlet), var(--gold)); }
.isle-hud small { display: block; color: var(--moon-soft); font-size: 12px; }
.isle-hud .tt { display: flex; gap: 12px; margin-top: 6px; font-size: 13px; color: var(--moon-soft); }
.isle-hud .tt b { color: var(--gold); font-size: 15px; }
.isle-hud .hint { margin-top: 4px; font-size: 11px; opacity: .8; }

/* 右側：全景／角色／清單／時間 */
.isle-tools { position: absolute; right: 16px; top: max(16px, env(safe-area-inset-top)); z-index: 10; display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.isle-tools > button { display: flex; align-items: center; gap: 8px; border-radius: 14px; padding: 10px 16px; font: 600 15px var(--sans); cursor: pointer; min-width: 96px; }
.isle-tools > button i { font-style: normal; color: var(--gold); width: 18px; text-align: center; }
.isle-tools > button[aria-pressed="false"] { opacity: .55; }
.isle-tools > button:hover, .isle-tools > button:focus-visible { border-color: var(--gold); }
.isle-lang { display: flex; border-radius: 12px; overflow: hidden; align-self: flex-end; }
.isle-lang button { background: none; border: 0; color: var(--moon-soft); font: 600 13px var(--sans); padding: 7px 12px; cursor: pointer; }
.isle-lang button[aria-pressed="true"] { background: var(--gold); color: var(--night); }

/* 天色選單 */
.isle-sky { position: absolute; right: 128px; top: max(16px, env(safe-area-inset-top)); z-index: 12; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.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(242, 230, 201, .06); border: 1px solid transparent; color: var(--moon); border-radius: 10px; padding: 8px 10px; font: 14px var(--sans); cursor: pointer; }
.isle-sky button small { display: block; color: var(--moon-soft); font-size: 11px; }
.isle-sky button[aria-pressed="true"] { border-color: var(--gold); background: rgba(212, 162, 70, .18); }

/* 教室標籤 */
.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: 6px;
  background: rgba(255, 255, 255, .16); color: #fff; border: 1px solid rgba(255, 255, 255, .38); border-radius: 999px;
  -webkit-backdrop-filter: blur(6px) saturate(1.3); backdrop-filter: blur(6px) saturate(1.3);
  padding: 4px 11px 4px 8px; font: 700 13px var(--serif); text-shadow: 0 1px 3px rgba(0, 0, 0, .65); cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); will-change: transform; }
.isle-tag .sw { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .7); flex: 0 0 auto; }
.isle-tag .sw.isl { width: auto; height: auto; box-shadow: none; background: none !important; color: #d9c8ff; font-size: 12px; }
.isle-tag .sw.port { width: auto; height: auto; box-shadow: none; background: none !important; color: #9fe3f0; font-size: 12px; }
.isle-tag .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; font-style: normal; }
.isle-tag .dot.todo { background: #ff6a4a; box-shadow: 0 0 6px #ff6a4a; }
.isle-tag .dot.calm { background: #9fc0ff; }
.isle-tag .dot.done { width: auto; height: auto; background: none; color: #ffd25a; font: 700 12px var(--sans); }
.isle-tag.on { background: rgba(212, 162, 70, .45); border-color: var(--gold); }
.isle-tag.emma { pointer-events: none; padding: 2px 9px; font: 600 11px var(--sans); color: var(--gold-soft); border-color: rgba(212, 162, 70, .6); }
.isle-tag.emma[hidden] { display: none; }

.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; }

/* 下方卡片 */
.isle-sheet { position: absolute; left: 50%; bottom: 0; z-index: 20; width: min(560px, 100%); max-height: 62vh; 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(242, 230, 201, .97); color: var(--ink); border-color: var(--parch-edge); }
.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 var(--line); background: var(--parch); color: var(--ink); font-size: 16px; cursor: pointer; }
.isle-sheet h2 { margin: 0 44px 6px 0; font-family: var(--serif); font-size: 22px; color: var(--scarlet-deep); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.isle-sheet h2 small { flex-basis: 100%; font: 500 13px var(--sans); color: var(--muted); }
.isle-sheet h2 .num { width: 14px; height: 14px; border-radius: 50%; align-self: center; }
.isle-sheet h3 { margin: 14px 0 6px; font: 700 14px var(--sans); color: var(--muted); letter-spacing: .05em; }
.isle-sheet .stats { margin: 4px 0 10px; font-size: 14px; color: var(--muted); }
.isle-sheet .note { font-size: 14px; color: var(--muted); margin: 8px 0; }
.isle-sheet .tt { margin: 10px 0 2px; font-weight: 700; }
.isle-sheet .go { display: inline-block; text-decoration: none; background: var(--scarlet); color: #fff; border-radius: 12px; padding: 10px 18px; font-weight: 700; }
.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-decoration: none; color: var(--ink);
  background: #fffaf0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-family: var(--serif); }
.isle-sheet .row:hover { border-color: var(--gold); }
.isle-sheet .pill { flex: 0 0 auto; font: 700 12px var(--sans); border-radius: 999px; padding: 2px 9px; background: #e8dcc0; color: var(--muted); }
.isle-sheet .pill.todo { background: var(--bad-soft); color: var(--bad); }
.isle-sheet .pill.done { background: var(--good-soft); color: var(--good); }
.isle-sheet .kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.isle-sheet .kv div { background: #fffaf0; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.isle-sheet .kv b { display: block; font-size: 22px; color: var(--scarlet); }
.isle-sheet .kv span { font-size: 12px; color: var(--muted); }

.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); }

/* 寬螢幕（iPad 橫放）：卡片改成左側直欄 */
@media (min-width: 900px) {
  .isle-sheet { left: 16px; top: max(16px, env(safe-area-inset-top)); bottom: 16px; width: 400px; max-height: none;
    border-radius: 20px; transform: translateX(calc(-100% - 24px)); padding: 22px 20px; }
  .isle-sheet.open { transform: translateX(0); }
  .isle-sheet .row { padding: 12px 14px; font-size: 17px; }
  .isle-sheet .go { padding: 12px 22px; font-size: 17px; }
}
/* 手指操作：按鈕至少 44px 高 */
@media (pointer: coarse) {
  .isle-tools > button { min-height: 48px; }
  .isle-tag { min-height: 34px; font-size: 14px; }
  .isle-sky button { min-height: 44px; }
}
/* 清單模式的「回到魔法島」按鈕 */
.to-island { margin-top: 12px; border: 1px solid var(--gold); background: rgba(212, 162, 70, .12); color: var(--gold); border-radius: 999px; padding: 8px 18px; font: 600 15px var(--sans); cursor: pointer; }
.to-island[hidden] { display: none; }

/* 手機直式：工具列改到底部上方一排，名牌縮小 */
@media (max-width: 640px) {
  .isle-hud { left: 10px; top: max(10px, env(safe-area-inset-top)); padding: 8px 12px; min-width: 0; max-width: 64%; border-radius: 12px; }
  .isle-hud .wm b, .isle-hud .wm b + b { font-size: 15px; display: inline; }
  .isle-hud .wm b + b::before { content: " "; }
  .isle-hud .yr { margin-top: 4px; font-size: 12px; }
  .isle-hud .yr small { display: none; }
  .isle-hud .tt { font-size: 11px; gap: 8px; margin-top: 2px; } .isle-hud .tt b { font-size: 13px; }
  .isle-hud .hint { display: none; }
  .isle-tools { top: auto; bottom: calc(56px + env(safe-area-inset-bottom)); left: 12px; right: 12px; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .isle-tools > button { min-width: 0; padding: 8px 11px; font-size: 13px; gap: 5px; }
  .isle-lang { align-self: center; }
  .isle-sky { right: 12px; left: auto; top: auto; bottom: calc(110px + env(safe-area-inset-bottom)); }
  .isle-tag { font-size: 12px; padding: 3px 9px 3px 7px; gap: 5px; }
  .isle-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .isle-sheet { transition: none; } }

/* 題目浮出面板（2026-10-25 Emma：點單元不要整頁跳走，讓錯題本浮在學院上面）
   iframe 載入 review/?…&embed=1（或 xingyinyi/?embed=1），後面的學院變暗、模糊但仍看得到。 */
.isle-practice { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(10, 6, 16, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .35s ease; }
.isle-practice[hidden] { display: none; }
.isle-practice.open { opacity: 1; }
.isle-practice-panel { position: relative; display: flex; flex-direction: column; width: min(760px, 100%); height: 100%;
  border-radius: 22px; overflow: hidden; border: 1px solid rgba(212, 162, 70, .6);
  background: rgba(20, 14, 26, .9); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .3);
  transform: translateY(28px) scale(.97); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.isle-practice.open .isle-practice-panel { transform: none; }
.isle-practice-panel .back { flex: 0 0 auto; align-self: flex-start; margin: 12px 14px 0; border: 1px solid rgba(212, 162, 70, .55);
  background: rgba(212, 162, 70, .12); color: var(--gold); border-radius: 999px; padding: 8px 16px; min-height: 40px;
  font: italic 18px var(--script); cursor: pointer; }
.isle-practice-panel .back::before { content: "← "; font-style: normal; }
.isle-practice-panel .back:hover, .isle-practice-panel .back:focus-visible { border-color: var(--gold); background: rgba(212, 162, 70, .22); }
html:lang(zh) .isle-practice-panel .back { font: 600 16px var(--serif); }
.isle-practice-panel iframe { flex: 1 1 auto; width: 100%; border: 0; background: transparent; color-scheme: dark;
  opacity: 0; transition: opacity .3s ease; }
.isle-practice-panel iframe.ready { opacity: 1; }
@media (max-width: 640px) {
  .isle-practice { padding: 0; }
  .isle-practice-panel { width: 100%; border-radius: 0; border: 0; }
}
@media (prefers-reduced-motion: reduce) { .isle-practice, .isle-practice-panel, .isle-practice-panel iframe { transition: none; } }
