/* nuclear-fusion-3d — dark-space shell stylesheet
   SCENARIO-002 (AC-01): site dark-space theme, fixed overlay UI, keyboard focus,
   responsive tablet width. SCENARIO-006 (AC-03): tour overlay + physics panel styling. */
  @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');
  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { width: 100%; height: 100%; overflow: hidden; }
  body {
    background: #04060d;
    color: #e2e8f0;
    font-family: 'Outfit', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    user-select: none;
  }
  #stage { position: fixed; inset: 0; cursor: grab; }
  #stage:active { cursor: grabbing; }
  #stage canvas { display: block; }
  #stage::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 52%, rgba(2,4,10,.6) 100%);
  }
  header {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    text-align: center; z-index: 10; pointer-events: none; width: 94vw;
  }
  h1 {
    font-size: 1.25rem; font-weight: 600;
    background: linear-gradient(135deg, #fbbf24, #f472b6, #38bdf8);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; text-shadow: none;
  }
  .subtitle { font-size: .72rem; color: #64748b; margin-top: 2px; }

  /* ── Back-to-home button (shared) ── */
  #homeBtn {
    position: fixed; top: 14px; left: 14px; z-index: 100;
    display: inline-flex; align-items: center; gap: 7px;
    height: 38px; padding: 0 18px 0 14px;
    background: rgba(15, 23, 42, 0.82); backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 19px;
    color: #e2e8f0; font-size: 0.85rem; font-weight: 600; line-height: 1;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
  }
  #homeBtn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(148, 163, 184, 0.45); color: #fff; transform: translateY(-1px);
  }
  #homeBtn:active { transform: translateY(0); }

  /* ── language switcher pill ── */
  .lang-switch {
    position: fixed; top: 14px; left: 136px; z-index: 100;
    display: inline-flex; align-items: center;
    background: rgba(15, 23, 42, 0.82); backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 999px;
    padding: 2px;
  }
  .lang-btn {
    background: transparent; border: none; color: #94a3b8;
    padding: 5px 11px; font-size: 12px; font-family: inherit; font-weight: 500;
    border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center;
    gap: 3px; line-height: 1; transition: all .2s ease;
  }
  .lang-btn:hover { color: #e2e8f0; }
  .lang-btn.active {
    background: rgba(251, 191, 36, 0.18); color: #fbbf24; font-weight: 600;
  }
  .i18n-loading [data-i18n] { visibility: hidden; }

  /* ——— 左侧工具栏（SCENARIO-005） ——— */
  #tools {
    position: fixed; left: 14px; top: 50%; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 8px; z-index: 10;
  }
  .tool-btn {
    width: 42px; height: 42px; border-radius: 13px;
    background: rgba(15,20,32,.72); backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.08);
    color: #cbd5e1; font-size: 16px; cursor: pointer;
    display: grid; place-items: center;
    transition: all .15s; box-shadow: 0 4px 16px rgba(0,0,0,.35);
  }
  .tool-btn:hover { background: rgba(32,44,66,.85); color: #fff; transform: scale(1.05); }
  .tool-btn.active {
    background: rgba(56,189,248,.16); border-color: rgba(56,189,248,.55); color: #7dd3fc;
    box-shadow: 0 0 14px rgba(56,189,248,.2);
  }

  /* ——— 底部控制区（SCENARIO-005） ——— */
  #bottomBar, .ctrl-bar {
    position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
    z-index: 10; display: flex; flex-direction: column; gap: 7px;
    align-items: center; max-width: 96vw;
  }
  .row {
    display: flex; gap: 12px; align-items: center;
    background: rgba(13,18,30,.78); backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,.07); border-radius: 14px;
    padding: 7px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.45);
    flex-wrap: wrap; justify-content: center;
  }
  .ctrl-btn {
    background: #1e293b; color: #e2e8f0; border: 1px solid #334155;
    padding: 6px 14px; border-radius: 9px; cursor: pointer;
    font-family: inherit; font-size: .78rem; transition: all .15s;
  }
  .ctrl-btn:hover { background: #334155; }
  .ctrl-btn.active {
    background: rgba(56,189,248,.16); border-color: rgba(56,189,248,.55); color: #7dd3fc;
  }

  /* ——— 每一幕可点击控制（SCENARIO-025, AC-10）——— */
  #phaseTabs { gap: 7px; }
  .phase-tab {
    background: #16233a; color: #94a3b8; border: 1px solid #26364f;
    padding: 6px 12px; border-radius: 9px; cursor: pointer;
    font-family: inherit; font-size: .74rem; font-weight: 600;
    transition: all .15s; white-space: nowrap;
  }
  .phase-tab:hover { background: #1e3252; color: #e2e8f0; }
  .phase-tab.active {
    background: rgba(56,189,248,.18); border-color: rgba(56,189,248,.6); color: #7dd3fc;
    box-shadow: 0 0 12px rgba(56,189,248,.25);
  }
  .vsep { width: 1px; height: 22px; background: rgba(255,255,255,.12); align-self: center; }

  /* ——— 第二幕实时温度计（SCENARIO-025, AC-10）——— */
  #tempHud {
    position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
    z-index: 9; text-align: center;
    background: rgba(13,17,28,.88); backdrop-filter: blur(14px);
    border: 1px solid rgba(251,191,36,.35); border-radius: 14px;
    padding: 10px 22px 11px; box-shadow: 0 8px 30px rgba(0,0,0,.45);
    pointer-events: auto;
  }
  #tempHud[hidden] { display: none; }
  #tempNow { font-size: 1.1rem; font-weight: 700; color: #fbbf24; font-variant-numeric: tabular-nums; }
  #tempBarWrap {
    width: 230px; height: 4px; background: #1e293b; border-radius: 2px;
    margin: 6px auto 5px; overflow: hidden;
  }
  #tempBar { height: 100%; width: 0%; background: linear-gradient(90deg, #f97316, #fbbf24); border-radius: 2px; transition: width .12s linear; }
  #tempStage { font-size: .72rem; color: #fca5a5; font-weight: 500; }
  #tempGoal { font-size: .64rem; color: #64748b; margin-top: 2px; }

  /* 约束模式切换 */
  #confinementBar {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.08);
  }
  .c-label { font-size: 0.68rem; color: #94a3b8; }
  .c-btn {
    background: #1e293b; border: 1px solid #334155; color: #cbd5e1;
    font-size: 0.68rem; padding: 3px 9px; border-radius: 6px; cursor: pointer;
    font-family: inherit; transition: all 0.15s;
  }
  .c-btn:hover { background: #334155; color: #fff; }
  .c-btn.active {
    background: rgba(56,189,248,0.22); border-color: #38bdf8; color: #38bdf8;
    box-shadow: 0 0 10px rgba(56,189,248,0.3); font-weight: 600;
  }

  /* 劳森判据三乘积仪表 */
  #lawsonGauge {
    margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,0.06);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
  }
  .lawson-title { font-size: 0.64rem; color: #7dd3fc; }
  .lawson-val { font-size: 0.72rem; font-weight: 600; color: #facc15; font-variant-numeric: tabular-nums; }
  .lawson-bar {
    width: 200px; height: 5px; background: #1e293b; border-radius: 3px;
    position: relative; overflow: visible; margin-top: 2px;
  }
  #lawsonFill { height: 100%; width: 0%; background: linear-gradient(90deg, #38bdf8, #a855f7, #ec4899); border-radius: 3px; }
  .lawson-target {
    position: absolute; right: 0; top: -14px; font-size: 0.58rem; color: #f472b6; font-weight: 600;
  }

  /* 第三幕量子隧穿 HUD */
  #tunnelingHud {
    position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
    z-index: 9; text-align: left; pointer-events: none;
    background: rgba(13,17,28,.88); backdrop-filter: blur(14px);
    border: 1px solid rgba(56,189,248,.35); border-radius: 14px;
    padding: 10px 18px 11px; box-shadow: 0 8px 30px rgba(0,0,0,.45);
    display: flex; flex-direction: column; gap: 4px; min-width: 290px;
  }
  #tunnelingHud[hidden] { display: none; }
  .th-title { font-size: 0.76rem; font-weight: 600; color: #38bdf8; margin-bottom: 2px; }
  .th-row { font-size: 0.68rem; color: #94a3b8; display: flex; justify-content: space-between; gap: 10px; }
  .th-row b { color: #f1f5f9; font-weight: 600; }

  /* 反应类型选择浮窗 */
  #rxnPanel {
    position: fixed; left: 66px; top: 50%; transform: translateY(-50%);
    z-index: 100; width: 320px;
    background: rgba(13,18,30,.92); backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,.12); border-radius: 16px;
    padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.55);
  }
  #rxnPanel[hidden] { display: none; }
  .hud-popover__title { font-size: 0.86rem; font-weight: 700; color: #7dd3fc; margin-bottom: 10px; }
  .rxn-options { display: flex; flex-direction: column; gap: 8px; }
  .rxn-btn {
    text-align: left; background: #16233a; border: 1px solid #26364f;
    border-radius: 10px; padding: 8px 12px; color: #cbd5e1; cursor: pointer;
    font-family: inherit; display: flex; flex-direction: column; gap: 3px;
    transition: all 0.2s ease;
  }
  .rxn-btn:hover { background: #1e3252; border-color: rgba(56,189,248,0.4); color: #fff; }
  .rxn-btn.active {
    background: rgba(56,189,248,0.18); border-color: #38bdf8; color: #fff;
    box-shadow: 0 0 14px rgba(56,189,248,0.25);
  }
  .rxn-btn b { font-size: 0.78rem; color: #f8fafc; }
  .rxn-tag {
    font-size: 0.58rem; padding: 1px 6px; border-radius: 4px; font-weight: 700; align-self: flex-start;
  }
  .tag--hot { background: rgba(239,68,68,0.25); color: #f87171; }
  .tag--sea { background: rgba(56,189,248,0.25); color: #38bdf8; }
  .tag--clean { background: rgba(52,211,153,0.25); color: #34d399; }
  .rxn-formula { font-size: 0.66rem; color: #fbbf24; font-family: monospace; }
  .rxn-note { font-size: 0.62rem; color: #94a3b8; line-height: 1.35; }

  #phaseBar { font-size: .74rem; color: #8ea0b5; }
  #phaseBar .phase-tag { color: #64748b; }
  #phaseBar b { color: #38bdf8; font-weight: 600; }

  /* ——— 键盘可达性（SCENARIO-002） ——— */
  .tool-btn:focus-visible,
  .ctrl-btn:focus-visible,
  .phase-tab:focus-visible,
  #homeBtn:focus-visible {
    outline: 2px solid #38bdf8; outline-offset: 2px;
  }

  /* ——— 引导浏览 overlay（SCENARIO-006, AC-03） ——— */
  #tourPanel {
    position: fixed; bottom: 118px; left: 50%; transform: translateX(-50%);
    width: min(580px, 94vw); z-index: 11; display: none;
    background: rgba(13,17,28,.86); backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,.09); border-radius: 16px;
    padding: 14px 18px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
    animation: slideIn .25s ease;
  }
  #tourPanel.open { display: block; }
  #tourTitle { font-size: .95rem; color: #7dd3fc; font-weight: 600; margin-bottom: 5px; }
  #tourText { font-size: .76rem; line-height: 1.7; color: #cbd5e1; min-height: 66px; }
  #tourText strong { color: #facc15; }
  #tourNav { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
  #tourDots { display: flex; gap: 5px; flex: 1; justify-content: center; }
  #tourDots i { width: 7px; height: 7px; border-radius: 50%; background: #334155; cursor: pointer; transition: .2s; }
  #tourDots i.on { background: #38bdf8; box-shadow: 0 0 6px #38bdf8; }

  /* ——— 物理小课堂（SCENARIO-006/014/015/016, AC-06） ——— */
  #physicsPanel {
    position: fixed; right: 14px; top: 64px; width: 320px;
    max-height: calc(100vh - 230px); overflow-y: auto;
    background: rgba(13,17,28,.88); backdrop-filter: blur(18px);
    border: 1px solid rgba(255,255,255,.09); border-radius: 16px;
    padding: 14px 16px 16px; z-index: 9;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
    animation: slideIn .25s ease;
  }
  #physicsPanel h3 { font-size: .92rem; color: #f1f5f9; margin-bottom: 8px; }
  #physicsPanel .rxn {
    font-size: .82rem; color: #fbbf24; font-weight: 600;
    background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.25);
    border-radius: 10px; padding: 6px 10px; margin-bottom: 9px; text-align: center;
  }
  #physicsPanel ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
  #physicsPanel li { font-size: .71rem; line-height: 1.7; color: #cbd5e1; }
  #physicsPanel li b { color: #7dd3fc; font-weight: 600; margin-right: 2px; }
  #physicsPanel .note { font-size: .68rem; color: #64748b; margin-top: 9px; line-height: 1.6; }

  .qa-title { font-size: .74rem; color: #f1f5f9; margin: 12px 0 7px; font-weight: 600; }
  #physicsPanel details.qa {
    border: 1px solid rgba(255,255,255,.07); border-radius: 10px;
    padding: 6px 10px; margin-top: 6px; background: rgba(255,255,255,.02);
  }
  #physicsPanel summary { font-size: .71rem; color: #7dd3fc; font-weight: 600; cursor: pointer; }
  #physicsPanel summary:hover { color: #38bdf8; }
  #physicsPanel details.qa p { font-size: .69rem; color: #cbd5e1; line-height: 1.75; margin-top: 5px; }
  #physicsPanel details.qa p b { color: #fbbf24; font-weight: 600; }

  #hint {
    position: fixed; left: 16px; bottom: 12px; z-index: 9;
    font-size: .66rem; color: #475569; line-height: 1.7; pointer-events: none;
  }

  /* ——— WebGL2 降级提示（SCENARIO-024, AC-09） ——— */
  .webgl2-fallback {
    position: absolute; inset: 0; display: grid; place-items: center;
    text-align: center; padding: 24px; background: #04060d; z-index: 5;
  }
  .webgl2-fallback__icon { font-size: 3rem; margin-bottom: 10px; }
  .webgl2-fallback h2 { font-size: 1.1rem; color: #f8fafc; margin-bottom: 10px; }
  .webgl2-fallback p { font-size: .85rem; color: #94a3b8; line-height: 1.8; max-width: 420px; }

  @keyframes slideIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
  ::-webkit-scrollbar { width: 5px; }
  ::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }

  /* ——— 平板宽度自适应（SCENARIO-002, AC-01） ——— */
  @media (max-width: 820px) {
    h1 { font-size: 1.02rem; }
    .subtitle { font-size: .64rem; }
    #tools { left: 8px; gap: 6px; }
    .tool-btn { width: 38px; height: 38px; font-size: 15px; }
    #tempHud { top: 108px; padding: 6px 14px 7px; }
    #tempBarWrap { width: 150px; }
    .phase-tab { padding: 5px 8px; font-size: .66rem; }
    #physicsPanel {
      right: 8px; left: 8px; width: auto; top: auto; bottom: 128px;
      max-height: 32vh; padding: 10px 12px 12px;
    }
    #tourPanel { bottom: 128px; padding: 11px 14px; }
    #tourText { min-height: 54px; }
    .ctrl-btn { padding: 6px 10px; font-size: .72rem; }
    #hint { display: none; }
  }
