/* ============================================================
   apps/boat-harbor.html 样式（P0-4-T17 <style> 块外联）
   - 页面 style="..." 与 on* 仍在本页（P0-4-T18 整改）
   ============================================================ */

/* Design Token：项目级 Glassmorphism 规范（与 topbar.8d4aa38f.css 一致） */
:root {
  --glass-bg-light:           rgba(255, 255, 255, 0.55);
  --glass-border-light:        rgba(15, 23, 42, 0.06);
  --glass-highlight-light:     rgba(255, 255, 255, 0.6);
  --glass-shadow-light:        rgba(15, 23, 42, 0.06);
  --glass-bg-dark:             rgba(10, 14, 39, 0.72);
  --glass-border-dark:         rgba(255, 255, 255, 0.06);
  --glass-highlight-dark:      rgba(255, 255, 255, 0.08);
  --glass-shadow-dark:         rgba(0, 0, 0, 0.32);
  --glass-blur:                blur(20px) saturate(180%);
}

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  /* ==== 基础与背景 ==== */
  html, body { height: 100%; }
  body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: #e0f2fe;
    background: #06121f;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
  }
  /* 海洋背景层（多层渐变模拟水深 + 远光） */
  .ocean {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
      radial-gradient(ellipse 100% 60% at 50% 0%,  rgba(14,165,233,0.18) 0%, transparent 55%),
      radial-gradient(ellipse 80% 50% at 80% 100%, rgba(56,189,248,0.10) 0%, transparent 60%),
      radial-gradient(ellipse 60% 40% at 0% 90%,  rgba(14,165,233,0.08) 0%, transparent 60%),
      linear-gradient(180deg, #0a2540 0%, #06121f 60%, #03091a 100%);
    pointer-events: none;
  }
  /* 漂浮气泡 */
  .bubble {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(186,230,253,0.45), rgba(125,211,252,0.05) 70%);
    pointer-events: none;
    z-index: 0;
    animation: rise linear infinite;
  }
  @keyframes rise {
    0%   { transform: translateY(0)     scale(0.8); opacity: 0; }
    10%  { opacity: 0.8; }
    90%  { opacity: 0.6; }
    100% { transform: translateY(-110vh) scale(1.1); opacity: 0; }
  }

  /* ==== 游戏工具条（原自定义顶栏下移；共享顶栏 fixed 悬浮于上方 z-90） ==== */
  .game-toolbar {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 18px 28px;
    /* Glassmorphism（统一引用 design token · 深色玻璃） */
    background: var(--glass-bg-dark);
    border-bottom: 1px solid var(--glass-border-dark);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow:
      inset 0 1px 0 var(--glass-highlight-dark),
      0 8px 32px var(--glass-shadow-dark);
  }
  .btn-exit {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid #facc15;
    border-radius: 6px;
    color: #facc15;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s, color 0.18s, transform 0.12s;
    font-family: inherit;
  }
  .btn-exit:hover { background: #facc15; color: #0c1929; }
  .btn-exit:active { transform: translateY(1px); }
  .topbar-title {
    font-size: 15px;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: 0.12em;
    text-shadow: 0 0 18px rgba(56,189,248,0.4);
  }
  .timer {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 22px;
    font-weight: 800;
    color: #fef08a;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 14px rgba(254,240,138,0.4);
    transition: color 0.3s, text-shadow 0.3s;
  }
  .timer .clock { font-size: 18px; }
  .timer.urgent { color: #f87171; text-shadow: 0 0 18px rgba(248,113,113,0.7); animation: pulse-red 0.6s infinite alternate; }
  @keyframes pulse-red {
    to { transform: scale(1.08); text-shadow: 0 0 28px rgba(248,113,113,0.95); }
  }

  /* ==== 状态栏（常驻） ==== */
  .stats-bar {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 48px;
    padding: 14px 24px;
    background: rgba(6,18,31,0.6);
    border-bottom: 1px solid rgba(14,165,233,0.10);
  }
  .stat {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #bae6fd;
  }
  .stat-icon { width: 22px; height: 22px; flex-shrink: 0; }
  .stat-val { font-size: 17px; font-weight: 800; color: #f0f9ff; min-width: 22px; text-align: left; }
  .stat-target .slash { color: #475569; margin: 0 4px; }

  /* ==== 主游戏区 ==== */
  .game-area {
    position: relative;
    z-index: 5;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 24px 16px;
  }

  /* ==== 棋盘 ==== */
  .board-wrap {
    position: relative;
    padding: 0;
  }
  .board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 112px);
    grid-template-rows: repeat(3, 112px);
    gap: 6px;
    padding: 10px;
    background: rgba(10,37,64,0.55);
    border: 1.5px solid rgba(14,165,233,0.25);
    border-radius: 18px;
    box-shadow:
      0 0 50px rgba(14,165,233,0.12),
      inset 0 0 30px rgba(14,165,233,0.04);
    user-select: none;
    -webkit-user-select: none;
  }
  /* SVG 连线覆盖层（绝对定位在 board 内） */
  .line-layer {
    position: absolute;
    top: 10px; left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    pointer-events: none;
    z-index: 2;
  }

  /* 单元格 */
  .cell {
    position: relative;
    background: rgba(14,60,110,0.55);
    border: 1px solid rgba(14,165,233,0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.2s, transform 0.12s;
    overflow: visible;
  }
  .cell.interact { cursor: pointer; }
  .cell.interact:hover { background: rgba(14,90,160,0.6); border-color: rgba(14,165,233,0.3); }
  /* 路径底色（浅蓝） */
  .cell.path { background: rgba(125,211,252,0.25); border-color: rgba(125,211,252,0.5); }
  /* 起点 / 终点软提示 */
  .cell.start-cell { background: rgba(14,165,233,0.18); }
  .cell.end-cell   { background: rgba(14,165,233,0.18); }
  /* 危险高亮（白色虚线外框） */
  .cell.reef-highlight {
    background: rgba(239,68,68,0.12);
    border: 2px dashed rgba(255,255,255,0.85);
    box-shadow: 0 0 0 2px rgba(239,68,68,0.35), 0 0 24px rgba(239,68,68,0.35);
  }
  /* 触礁 */
  .cell.hit-reef {
    background: rgba(239,68,68,0.32);
    border-color: rgba(239,68,68,0.7);
    animation: shake 0.35s ease-in-out;
  }
  @keyframes shake {
    0%,100% { transform: translateX(0); }
    20%     { transform: translateX(-5px); }
    40%     { transform: translateX(5px); }
    60%     { transform: translateX(-3px); }
    80%     { transform: translateX(3px); }
  }
  .cell-icon { width: 58px; height: 58px; pointer-events: none; }
  .reef-pulse { animation: reef-pulse 1.6s ease-in-out infinite; }
  @keyframes reef-pulse {
    0%,100% { transform: scale(1); }
    50%     { transform: scale(1.08); }
  }

  /* 白色圆点路径 */
  .dot-line { fill: none; stroke: rgba(255,255,255,0.9); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
  .dot-line.demo {
    stroke: rgba(255,255,255,0.75);
    stroke-dasharray: 2 12;
    animation: dot-flow 0.8s linear infinite;
  }
  @keyframes dot-flow { to { stroke-dashoffset: -28; } }

  /* 手势引导（指向港湾） */
  .gesture {
    position: absolute;
    top: -28px;
    right: -10px;
    font-size: 36px;
    color: #f1f5f9;
    text-shadow: 0 0 12px rgba(255,255,255,0.7);
    pointer-events: none;
    z-index: 4;
    animation: gesture-bounce 1.4s ease-in-out infinite;
  }
  @keyframes gesture-bounce {
    0%,100% { transform: translate(0, 0)   rotate(-15deg); }
    50%     { transform: translate(10px,-10px) rotate(-25deg); }
  }

  /* ==== 教学提示区 ==== */
  .tutorial-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-height: 110px;
  }
  .hint {
    background: rgba(6,18,31,0.9);
    border: 1px solid rgba(14,165,233,0.25);
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 14.5px;
    line-height: 1.6;
    color: #bae6fd;
    text-align: center;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  }
  .step-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    border-radius: 4px;
    background: rgba(14,165,233,0.18);
    color: #7dd3fc;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    vertical-align: 1px;
  }
  .btn-continue {
    padding: 10px 32px;
    background: linear-gradient(135deg, #0ea5e9, #0369a1);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.12em;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 18px rgba(14,165,233,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  }
  .btn-continue:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(14,165,233,0.55); filter: brightness(1.08); }
  .btn-continue:active { transform: translateY(0); }

  /* ==== 弹窗 ==== */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .modal-overlay.show { opacity: 1; pointer-events: all; }
  .modal {
    background: linear-gradient(180deg, #0f2744 0%, #0a1c33 100%);
    border: 1px solid rgba(14,165,233,0.35);
    border-radius: 20px;
    padding: 32px 36px 28px;
    text-align: center;
    max-width: 360px;
    width: 88%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 30px rgba(14,165,233,0.15);
    transform: scale(0.9);
    transition: transform 0.3s;
  }
  .modal-overlay.show .modal { transform: scale(1); }
  .modal-icon { font-size: 56px; margin-bottom: 8px; line-height: 1; }
  .modal-title { font-size: 22px; font-weight: 800; margin-bottom: 10px; color: #f0f9ff; }
  .modal-desc { font-size: 14px; color: #7dd3fc; margin-bottom: 22px; line-height: 1.6; }
  .modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
  .btn-modal {
    padding: 10px 22px;
    border: none;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s, filter 0.15s, background 0.18s;
  }
  .btn-modal:hover { transform: translateY(-2px); filter: brightness(1.08); }
  .btn-modal:active { transform: translateY(0); }
  .btn-primary { background: linear-gradient(135deg, #0ea5e9, #0369a1); color: #fff; box-shadow: 0 4px 14px rgba(14,165,233,0.4); }
  .btn-secondary { background: rgba(14,165,233,0.12); color: #7dd3fc; border: 1px solid rgba(14,165,233,0.3); }
  .btn-secondary:hover { background: rgba(14,165,233,0.2); }

  /* 隐藏（用于游戏阶段收起提示与按钮） */
  .hidden { display: none !important; }
