/* 果蠅大腦 Flappy Bird — 版面 */
:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --fg: #e6edf3;
  --muted: #8b949e;
  --learn: #ffd700;
  --control: #7fdbff;
  --warn: #ff7b72;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* app.js 用 hidden 屬性切換試玩模式的元素；.demo-panel 的 display: flex 不能蓋過它 */
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 -apple-system, "Helvetica Neue", "PingFang TC", "Noto Sans TC", sans-serif;
}

.stage {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: .02em; }
.subtitle { color: var(--muted); max-width: 64ch; }

/* 遊戲畫面 */
.game-area {
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  align-self: center;
  width: 800px;
  max-width: 100%;
}
/* game/renderer.js 為了高 DPI 會在 canvas 上寫 inline 的 width/height（800px/600px）；
   這裡用 !important 讓畫布跟著容器縮放、維持 4:3，窄螢幕才不會出現橫向捲軸。 */
#gameCanvas { display: block; width: 100% !important; height: auto !important; touch-action: none; }
.legend { align-self: center; margin-top: -12px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: baseline; }
.swatch.learn { background: var(--learn); }
.swatch.control { background: var(--control); }

/* 控制列 */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
}
.controls button {
  background: #238636;
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 9px 18px;
  min-height: 40px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.controls button:hover { background: #2ea043; }
.controls #resetExperimentBtn { background: #6e2c2c; }
.controls #resetExperimentBtn:hover { background: #8b3a3a; }
.controls button:disabled { opacity: .45; cursor: not-allowed; }
.slider { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.slider input[type="range"] { width: 180px; accent-color: #2ea043; }
#fpsCapValue { min-width: 62px; color: var(--fg); font-variant-numeric: tabular-nums; }
.readout { color: var(--muted); }
.readout strong { color: var(--fg); font-variant-numeric: tabular-nums; }

.status { color: var(--muted); min-height: 1.6em; }
.status.error { color: var(--warn); }

/* 試玩模式（未通過生物學校準）：橫幅不能關、捲動時停在畫面頂端 */
.demo-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #3d1d00;
  color: #ffd8a8;
  border: 2px solid #f0883e;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  line-height: 1.5;
}
.demo-banner a { color: #ffa657; }
.demo-panel {
  border: 1px dashed #f0883e;
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.demo-panel button {
  background: #9e4a00;
  color: #fff;
  border: 0;
  border-radius: 7px;
  padding: 9px 18px;
  min-height: 40px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.demo-panel button:hover { background: #bd5a00; }
.demo-panel button:disabled { opacity: .45; cursor: not-allowed; }
.demo-note { color: var(--muted); max-width: 72ch; }
.demo-note a, .demo-curve-note { color: #ffa657; }

/* 大腦 2×3 格 */
.brain-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.panel-labels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.panel-label {
  font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid var(--line);
  text-align: center;
  color: var(--learn);
}
.panel-label:nth-child(n + 4) { color: var(--control); }
.panel-label.offline { color: var(--warn); border-color: var(--warn); }
#brainGrid { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; background: #05070a; border-radius: 6px; }

/* 學習曲線 */
.curve-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
#learningCurve { display: block; width: 100%; height: auto; background: #05070a; border-radius: 6px; }
.caption { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* 頁尾：人為接頭與署名 */
footer {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  color: var(--muted);
}
footer h2 { font-size: 1rem; color: var(--fg); margin-bottom: 10px; }
.joints { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.joints li { padding-left: 18px; position: relative; }
.joints li::before { content: "▸"; position: absolute; left: 0; color: var(--warn); }
.attrib { font-size: 12px; margin-bottom: 6px; }
.attrib.warn { color: var(--warn); font-weight: 600; }

@media (max-width: 860px) {
  .stage { padding: 14px 12px 48px; gap: 14px; }
  .game-area { width: 100%; }
  .panel-labels { grid-template-columns: repeat(2, 1fr); }
  .slider input[type="range"] { width: 120px; }
}
