/* ── Island Page Scoped Styles ── */
#island-page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #06090f;
  font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', sans-serif;
  color: #e0e8f0;
  touch-action: none;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
#island-page #islandTopBar {
  flex-shrink: 0;
  height: 48px;
  background: linear-gradient(to bottom, #0d1a2e, #081220);
  border-bottom: 1px solid #1a2d48;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px;
  z-index: 100;
}
#island-page #islandResBar { display: flex; gap: 5px; flex-wrap: nowrap; }
#island-page .i-res {
  display: flex; align-items: center; gap: 3px;
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 3px 8px;
  color: #a8bcd4; white-space: nowrap;
}
#island-page .i-res b { color: #e8f4ff; font-size: 12px; }
#island-page #islandTitle {
  font-size: 13px; font-weight: 700;
  color: #22d3ee; letter-spacing: 0.5px;
  white-space: nowrap;
}
#island-page #btnMenu {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; color: #8aa4c4; width: 32px; height: 32px;
  font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#island-page #btnMenu:active { background: rgba(34,211,238,0.2); }

/* ── XP Banner ── */
#island-page #islandXpBanner {
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(13,148,136,0.25), rgba(34,211,238,0.15));
  border-bottom: 1px solid rgba(34,211,238,0.2);
  padding: 6px 14px;
  font-size: 12px; color: #22d3ee;
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
#island-page #islandXpBtn {
  background: linear-gradient(135deg,#0d9488,#22d3ee);
  color: #fff; border-radius: 10px; padding: 3px 10px;
  font-size: 11px; font-weight: 700;
}

/* ── Map ── */
#island-page #mapContainer {
  flex: 1 1 0; min-height: 0;
  position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #0e1d34 0%, #040810 100%);
  cursor: grab;
}
#island-page #mapContainer:active { cursor: grabbing; }
#island-page #mapCanvas {
  position: absolute; top: 0; left: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /* canvas 自身处理点击由 JS 监听，绝对定位的悬浮按钮在其上层 */
  z-index: 1;
  pointer-events: none;
}

/* ── Bottom bar ── */
#island-page #bottomBar {
  flex-shrink: 0;
  background: #070d18;
  border-top: 1px solid #152030;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#island-page #activeTool {
  font-size: 10px; color: #3a5070;
  text-align: center; padding: 3px 0 4px;
  letter-spacing: 0.5px;
}
#island-page #activeToolName { color: #22d3ee; font-weight: 600; }

/* ── Tab bar ── */
#island-page #tabBar {
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  border-bottom: 1px solid #112030;
}
#island-page #tabBar::-webkit-scrollbar { display: none; }
#island-page .i-tab {
  flex-shrink: 0;
  background: none; border: none;
  color: #3a5070; font-size: 11px; font-weight: 600;
  padding: 8px 12px; cursor: pointer; letter-spacing: 0.3px;
  transition: color 0.15s; white-space: nowrap;
}
#island-page .i-tab.active {
  color: #22d3ee;
  border-bottom: 2px solid #22d3ee;
}

/* ── Tool scroll ── */
#island-page #toolScroll { height: 160px; overflow: hidden; }
#island-page .i-tool-panel { display: none; flex-direction: column; height: 160px; }
#island-page .i-tool-panel.active { display: flex; }

/* ── Chip row ── */
#island-page .chip-row {
  flex-shrink: 0; display: flex; flex-direction: row; align-items: center;
  gap: 5px; padding: 5px 10px 4px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none; height: 32px;
}
#island-page .chip-row::-webkit-scrollbar { display: none; }
#island-page .chip {
  flex-shrink: 0; padding: 2px 10px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: #5a7898; font-size: 10px; cursor: pointer;
  white-space: nowrap; transition: all 0.12s;
}
#island-page .chip.active {
  background: rgba(34,211,238,0.18);
  border-color: #22d3ee; color: #22d3ee;
}

/* ── Button row ── */
#island-page .btn-row {
  flex: 1; min-height: 0;
  display: flex; flex-direction: row; align-items: stretch;
  gap: 8px; padding: 0 10px 6px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none; width: 100%;
}
#island-page .btn-row::-webkit-scrollbar { display: none; }
#island-page .i-tool-panel:not(#terrainPanel) .btn-row,
#island-page .i-tool-panel:not(#terrainPanel) { height: 160px; }
#island-page .i-tool-panel:not(#terrainPanel) > .tbtn { flex-shrink: 0; }

/* ── Tool buttons ── */
#island-page .tbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 4px; min-width: 88px; width: 88px; height: 118px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: 12px; cursor: pointer;
  font-size: 10px; color: #8aa4c4;
  flex-shrink: 0; transition: all 0.12s; padding: 6px 5px 4px; overflow: hidden;
}
#island-page .tbtn:active { transform: scale(0.94); }
#island-page .tbtn.active {
  background: rgba(34,211,238,0.15); border-color: #22d3ee;
  color: #a8f0f8; box-shadow: 0 0 12px rgba(34,211,238,0.3);
}
#island-page .btn-preview {
  width: 72px; height: 56px; border-radius: 6px; flex-shrink: 0;
  overflow: hidden; background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.06);
}
#island-page .tbtn canvas { width: 72px; height: 56px; border-radius: 6px; display: block; flex-shrink: 0; }
#island-page .btn-label { font-size: 10px; color: #9ab4cc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; text-align: center; line-height: 1.3; }
#island-page .cost-tag { font-size: 8.5px; color: #f0c050; white-space: nowrap; background: rgba(240,192,80,0.1); border-radius: 5px; padding: 1px 4px; }

/* ── Sheet ── */
#island-page .i-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #0c1628; border-top: 2px solid #1a3050;
  border-radius: 18px 18px 0 0; z-index: 300;
  max-height: 65vh; overflow-y: auto;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
}
#island-page .i-sheet.hidden { transform: translateY(110%); pointer-events: none; }
#island-page .sheet-handle { width: 36px; height: 4px; background: #1e3550; border-radius: 2px; margin: 10px auto 8px; }
#island-page #sheetBg { position: absolute; inset: 0; background: rgba(0,0,0,0.5); z-index: 290; }
#island-page #sheetBg.hidden { display: none; }

/* ── Info sheet content ── */
#island-page #infoContent { padding: 0 14px 6px; font-size: 13px; color: #8aa4c4; line-height: 1.7; }
#island-page .info-title { font-size: 16px; font-weight: 700; color: #d0e8ff; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
#island-page .lv-badge { font-size: 11px; background: linear-gradient(135deg, #f6c90e, #c08000); color: #2a1800; border-radius: 10px; padding: 1px 8px; }
#island-page .info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
#island-page .info-card { background: rgba(255,255,255,0.04); border-radius: 8px; padding: 7px 10px; }
#island-page .info-card .lbl { font-size: 10px; color: #3a5070; }
#island-page .info-card .val { font-size: 13px; color: #c0d8f0; font-weight: 600; }
#island-page .upgrade-hint { font-size: 11px; color: #f6c90e; margin-top: 4px; }
#island-page .maxlv-hint { font-size: 11px; color: #22d3ee; margin-top: 4px; }
#island-page .unlock-desc { font-size: 12px; color: #5a7898; margin: 4px 0 6px; }
#island-page .unlock-cost-label { font-size: 13px; color: #f6c90e; }
#island-page #infoActions { display: flex; gap: 8px; padding: 8px 14px 14px; }
#island-page .act-btn { flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.05); color: #a0b8d0; font-size: 13px; cursor: pointer; transition: all 0.15s; }
#island-page .act-btn:active { background: rgba(34,211,238,0.2); border-color: #22d3ee; color: #fff; }
#island-page .act-btn.danger:active { background: rgba(220,60,60,0.2); border-color: #dc3545; color: #ff8888; }
#island-page .act-btn:disabled { opacity: 0.3; pointer-events: none; }

/* ── Menu sheet ── */
#island-page .menu-title { font-size: 15px; font-weight: 700; color: #22d3ee; margin-bottom: 12px; }
#island-page .menu-btn { display: block; width: 100%; padding: 12px 14px; margin-bottom: 8px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; color: #ccd8e8; font-size: 14px; text-align: left; cursor: pointer; }
#island-page .menu-btn:active { background: rgba(34,211,238,0.15); border-color: #22d3ee; }
#island-page .section-title { font-size: 11px; font-weight: 700; color: #3a5070; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 1px; }
#island-page .unlock-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px; }
#island-page .unlock-cost { font-size: 11px; color: #f6c90e; margin-top: 2px; }
#island-page .done-lbl { color: #22d3ee; font-size: 12px; }
#island-page .unlock-btn { background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.35); border-radius: 8px; color: #22d3ee; font-size: 11px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
#island-page .unlock-btn:disabled { opacity: 0.35; pointer-events: none; }

/* ── Toast ── */
#island-page #toast {
  position: absolute; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(6,12,24,0.96);
  border: 1px solid rgba(34,211,238,0.45);
  color: #22d3ee; padding: 8px 18px; border-radius: 20px;
  font-size: 13px; opacity: 0; pointer-events: none; z-index: 500;
  transition: opacity 0.22s, transform 0.22s; white-space: nowrap;
}
#island-page #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Loading ── */
#island-page #loadingTip {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #06090f; z-index: 999; color: #22d3ee;
  font-size: 14px; gap: 12px;
}
#island-page .spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(34,211,238,0.18);
  border-top-color: #22d3ee;
  border-radius: 50%; animation: islandSpin 0.8s linear infinite;
}
@keyframes islandSpin { to { transform: rotate(360deg); } }

/* ── 隐藏旧底部工具栏（已迁移到左侧）── */
#island-page #bottomBar { display: none; }

/* ── 左侧悬浮工具栏 ── */
#island-page #leftToolbar {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  z-index: 200;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  pointer-events: auto;
}
#island-page #leftToolbar.readonly-hidden { display: none !important; }

/* 展开/收起按钮（整合进 tab 列顶部） */
#island-page #lftToggle {
  background: rgba(7,13,24,0.92) !important;
  border-bottom: 2px solid rgba(34,211,238,0.25) !important;
  color: #22d3ee !important;
  font-size: 14px !important;
  letter-spacing: 1px;
}
#island-page #lftToggle.active {
  background: rgba(34,211,238,0.18) !important;
  color: #fff !important;
}

/* 纵向 tab 列 */
#island-page #lftTabs {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  background: rgba(7,13,24,0.92);
  border: 1.5px solid rgba(255,255,255,0.1);
  border-left: none;
  border-radius: 0 10px 10px 0;
  overflow: hidden;
  gap: 0;
}
#island-page #lftTabs .i-tab {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
}
#island-page #lftTabs .i-tab:last-child { border-bottom: none; }
#island-page #lftTabs .i-tab.active {
  background: rgba(34,211,238,0.18);
  color: #22d3ee;
  border-bottom: 1px solid rgba(34,211,238,0.2);
}

/* 抽屉（向右展开） */
#island-page #lftDrawer {
  pointer-events: all;
  width: 0;
  overflow: hidden;
  transition: width 0.25s cubic-bezier(.4,0,.2,1);
  background: rgba(7,13,24,0.95);
  border: 1.5px solid rgba(34,211,238,0.25);
  border-left: none;
  border-radius: 0 12px 12px 0;
  position: relative;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
#island-page #lftDrawer.open { width: 220px; overflow: hidden; }

#island-page #lftDrawerInner {
  width: 220px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* 面板标题栏 */
#island-page .lft-panel-title {
  flex-shrink: 0;
  padding: 8px 12px 6px;
  font-size: 12px;
  font-weight: 700;
  color: #22d3ee;
  border-bottom: 1px solid rgba(34,211,238,0.15);
  letter-spacing: 0.5px;
}

/* 可滚动区域 */
#island-page #lftScroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
#island-page #lftScroll::-webkit-scrollbar { display: none; }

/* 地形面板在左侧抽屉里 */
#island-page #lftScroll .i-tool-panel { display: none; flex-direction: column; }
#island-page #lftScroll .i-tool-panel.active { display: flex; }
#island-page #lftScroll .chip-row {
  flex-shrink: 0; display: flex; flex-wrap: nowrap; gap: 4px;
  padding: 6px 8px 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#island-page #lftScroll .chip-row::-webkit-scrollbar { display: none; }
#island-page #lftScroll .btn-row,
#island-page #lftScroll .lft-btn-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 8px 8px;
  justify-content: flex-start;
}

/* 左侧抽屉的 tbtn 稍微窄一点 */
#island-page #lftScroll .tbtn {
  min-width: 80px; width: 80px; height: 110px;
}

/* 当前工具标签 */
#island-page .lft-active-tool {
  flex-shrink: 0;
  font-size: 10px; color: #3a5070;
  text-align: center; padding: 4px 0 6px;
  border-top: 1px solid rgba(255,255,255,0.05);
  letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding-left: 4px; padding-right: 4px;
}

/* ── 右上角好友悬浮按钮 ── */
#island-page .friends-fab {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px; height: 40px;
  background: rgba(7,13,24,0.92);
  border: 1.5px solid rgba(34,211,238,0.4);
  border-radius: 12px;
  color: #22d3ee;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  pointer-events: auto;
  transition: background 0.15s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
#island-page .friends-fab:active { background: rgba(34,211,238,0.22); transform: scale(0.92); }

/* ── 好友列表 sheet ── */
#island-page .friend-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; transition: background 0.12s; border-radius: 8px;
  padding-left: 4px; padding-right: 4px;
}
#island-page .friend-item:last-child { border-bottom: none; }
#island-page .friend-item:active { background: rgba(34,211,238,0.1); }
#island-page .friend-emoji { font-size: 28px; flex-shrink: 0; width: 40px; text-align: center; }
#island-page .friend-info { flex: 1; min-width: 0; }
#island-page .friend-name { font-size: 14px; font-weight: 700; color: #d0e8ff; }
#island-page .friend-island { font-size: 11px; color: #5a7898; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#island-page .friend-visit { font-size: 12px; color: #22d3ee; flex-shrink: 0; white-space: nowrap; }

/* ── 返回自己的岛按钮 ── */
#island-page .back-btn {
  background: rgba(34,211,238,0.12);
  border: 1px solid rgba(34,211,238,0.4);
  border-radius: 8px; color: #22d3ee;
  font-size: 11px; padding: 4px 10px; cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center;
}
#island-page .back-btn:active { background: rgba(34,211,238,0.25); }

/* ── 右下角撤销按钮 ── */
#island-page .undo-fab {
  position: absolute;
  bottom: 14px;
  right: 10px;
  width: 40px; height: 40px;
  background: rgba(7,13,24,0.88);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 12px;
  color: #cfe8ff;
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  pointer-events: auto;
  transition: background 0.15s, opacity 0.2s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
#island-page .undo-fab:not(:disabled):active { background: rgba(34,211,238,0.2); transform: scale(0.92); }
#island-page .undo-fab:disabled { cursor: not-allowed; }

/* ── 放置确认 bar ── */
#island-page .confirm-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(7,13,24,0.97);
  border-top: 1.5px solid rgba(34,211,238,0.35);
  padding: 10px 14px 12px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  z-index: 300;
  pointer-events: auto;
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1);
  safe-area-inset-bottom: env(safe-area-inset-bottom);
}
#island-page .confirm-bar.show { transform: translateY(0); }

#island-page .confirm-info {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1;
}
#island-page #confirmBarLabel {
  font-size: 13px; font-weight: 700; color: #d0e8ff; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
#island-page .confirm-cost {
  font-size: 11px; color: #22d3ee; white-space: nowrap;
}
#island-page .confirm-actions {
  display: flex; gap: 8px; flex-shrink: 0;
}
#island-page .confirm-cancel-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px; color: #7a9abc;
  font-size: 13px; padding: 7px 14px; cursor: pointer;
  transition: background 0.12s;
}
#island-page .confirm-cancel-btn:active { background: rgba(255,255,255,0.14); }
#island-page .confirm-ok-btn {
  background: rgba(34,211,238,0.18);
  border: 1.5px solid rgba(34,211,238,0.55);
  border-radius: 10px; color: #22d3ee;
  font-size: 13px; font-weight: 700; padding: 7px 18px; cursor: pointer;
  transition: background 0.12s;
}
#island-page .confirm-ok-btn:active { background: rgba(34,211,238,0.35); }
