/* =============================================================
   木質燃焼セル — 燃焼実験室の計器盤
   ============================================================= */

:root {
  --bg: #070605;
  --panel: #100e0c;
  --panel2: #15120f;
  --line: rgba(255, 240, 218, 0.08);
  --line2: rgba(255, 240, 218, 0.18);
  --tx: #ece4d3;
  --tx-dim: #9c9080;
  --tx-faint: #5e564a;
  --amber: #ffa028;
  --fire: #ff6a2a;
  --red: #ff3d23;
  --steam: #cfe2e8;
  --water: #5d93b4;
  --wood: #b07c4f;
  --charc: #57505a;
  --ashc: #a9a49c;
  --font-jp: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-display: "Shippori Mincho", "Hiragino Mincho ProN", serif;
  --font-mono: "Chivo Mono", "Menlo", monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--font-jp);
  font-size: 13px;
}

#app { display: flex; height: 100vh; }

/* ---------------- 3D ビューポート ---------------- */
#viewport {
  position: relative;
  flex: 1;
  min-width: 0;
  background: radial-gradient(ellipse at 50% 60%, #0b0908 0%, #060505 70%);
}
#viewport canvas { display: block; }

/* 銘板 */
.plate {
  position: absolute;
  top: 18px;
  left: 18px;
  padding: 10px 16px 11px;
  border: 1px solid var(--line2);
  background: rgba(10, 8, 6, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}
.plate::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.plate h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.30em;
  color: var(--tx);
}
.plate .plate-en {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.32em;
  color: var(--tx-dim);
}

.hint {
  position: absolute;
  left: 18px;
  bottom: 14px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--tx-faint);
  pointer-events: none;
}

/* フェーズ転換の漢字バナー */
#banner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
#banner span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(64px, 12vw, 130px);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  opacity: 0;
  color: var(--tx);
}
#banner span.show {
  animation: bannerIn 2.0s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
#banner span.hot {
  color: #ff5a22;
  text-shadow: 0 0 28px rgba(255, 90, 20, 0.65), 0 0 90px rgba(255, 120, 30, 0.4);
}
#banner span.cool {
  color: #c8d6dc;
  text-shadow: 0 0 24px rgba(190, 220, 235, 0.35);
}
@keyframes bannerIn {
  0%   { opacity: 0; transform: scale(1.10); filter: blur(7px); }
  14%  { opacity: 1; transform: scale(1.0); filter: blur(0); }
  70%  { opacity: 0.9; }
  100% { opacity: 0; transform: scale(0.97); }
}

/* ---------------- 計器盤 ---------------- */
#panel {
  width: 390px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  background:
    linear-gradient(180deg, var(--panel2), var(--panel) 140px),
    var(--panel);
  border-left: 1px solid var(--line2);
  position: relative;
}
#panel::before {
  /* 紙のようなノイズ */
  content: "";
  position: fixed;
  width: 390px; height: 100vh;
  right: 0; top: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  z-index: 5;
}
#panel::-webkit-scrollbar { width: 5px; }
#panel::-webkit-scrollbar-thumb { background: var(--line2); }

.p-head {
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line2);
}
.p-head-row { display: flex; justify-content: space-between; align-items: flex-start; }
.p-head h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 25px;
  letter-spacing: 0.24em;
}
.p-sub {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.30em;
  color: var(--tx-dim);
}
.p-led {
  width: 9px; height: 9px;
  margin-top: 8px;
  border-radius: 50%;
  background: #4a5e43;
  box-shadow: 0 0 8px rgba(120, 200, 90, 0.4);
  animation: ledPulse 2.4s ease-in-out infinite;
}
.p-led[data-phase="FLAMING"], .p-led[data-phase="IGNITION"] {
  background: var(--fire);
  box-shadow: 0 0 10px rgba(255, 106, 42, 0.8);
  animation-duration: 0.7s;
}
.p-led[data-phase="EMBER"] { background: var(--red); box-shadow: 0 0 8px rgba(255, 61, 35, 0.7); }
.p-led[data-phase="ASH"] { background: #777; box-shadow: none; animation: none; }
@keyframes ledPulse { 50% { opacity: 0.45; } }

.p-clock {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.p-clock span:first-child {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--amber);
}
.p-clock-label {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.25em;
  color: var(--tx-faint);
}

/* セクション */
.p-sec {
  padding: 16px 22px 18px;
  border-bottom: 1px solid var(--line);
}
.p-sec-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--tx-dim);
}
.p-sec-label i {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 9px;
  color: var(--amber);
  letter-spacing: 0.1em;
}
.p-sec-label span {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.3em;
  color: var(--tx-faint);
  margin-left: auto;
}

/* ---------------- 放水・音響ボタン ---------------- */
.btn-douse {
  color: #8fc4ff;
  border-color: rgba(110, 170, 255, 0.45);
}
.btn-douse:hover {
  border-color: #8fc4ff;
  background: rgba(90, 150, 255, 0.10);
  box-shadow: 0 0 10px rgba(110, 170, 255, 0.25);
}
.btn-douse.dousing {
  color: #cfe6ff;
  border-color: #aed3ff;
  background: rgba(110, 170, 255, 0.22);
  box-shadow: 0 0 16px rgba(130, 190, 255, 0.45);
}
#soundBtn[aria-pressed="false"] { opacity: 0.55; }

/* ---------------- 試料セレクタ ---------------- */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg button {
  flex: 1 1 42%;
  font-family: var(--font-jp);
  font-size: 12px;
  letter-spacing: 0.18em;
  padding: 9px 6px 8px;
  color: var(--tx-dim);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line2);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.seg button small {
  font-family: var(--font-mono);
  font-size: 7.5px;
  letter-spacing: 0.22em;
  color: var(--tx-faint);
}
.seg button:hover { border-color: var(--tx-dim); color: var(--tx); }
.seg button.on {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(255, 130, 30, 0.10);
  box-shadow: 0 0 12px rgba(255, 140, 30, 0.18), inset 0 0 8px rgba(255, 140, 30, 0.10);
}
.seg button.on small { color: rgba(255, 160, 40, 0.6); }

/* ---------------- 状態遷移レール ---------------- */
.rail {
  display: flex;
  justify-content: space-between;
  position: relative;
  padding: 4px 2px 0;
}
.rail::before {
  content: "";
  position: absolute;
  top: 21px; left: 12px; right: 12px;
  height: 1px;
  background: var(--line2);
}
.rail-node { position: relative; text-align: center; width: 40px; }
.rail-cnt {
  height: 11px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--amber);
  margin-bottom: 1px;
}
.rail-dot {
  width: 9px; height: 9px;
  margin: 0 auto 7px;
  border: 1px solid var(--tx-faint);
  background: var(--panel);
  transform: rotate(45deg);
  transition: all 0.3s;
}
.rail-jp { font-size: 10px; letter-spacing: 0.08em; color: var(--tx-faint); transition: color 0.3s; }
.rail-note { font-family: var(--font-mono); font-size: 7px; color: var(--tx-faint); opacity: 0.55; margin-top: 2px; }
.rail-node.done .rail-dot { background: var(--tx-faint); border-color: var(--tx-faint); }
.rail-node.done .rail-jp { color: var(--tx-dim); }
.rail-node.active .rail-dot {
  background: var(--amber);
  border-color: var(--amber);
  box-shadow: 0 0 10px rgba(255, 160, 40, 0.75);
  animation: dotPulse 1.1s ease-in-out infinite;
}
.rail-node.active .rail-jp { color: var(--amber); font-weight: 700; }
@keyframes dotPulse { 50% { box-shadow: 0 0 3px rgba(255, 160, 40, 0.3); } }

.phase-now {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.phase-jp {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.18em;
}
.phase-en {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.28em;
  color: var(--amber);
}
.phase-cnt {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--tx-dim);
  margin-left: auto;
}

/* ---------------- 温度 ---------------- */
.temp-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.temp-big {
  font-family: var(--font-mono);
  font-size: 46px;
  font-weight: 300;
  line-height: 1;
  color: var(--tx);
}
.temp-big em {
  font-style: normal;
  font-size: 16px;
  color: var(--tx-dim);
  margin-left: 4px;
}
.temp-marks {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 12px;
  font-size: 9px;
  color: var(--tx-faint);
  letter-spacing: 0.1em;
  text-align: right;
}
.temp-marks b { font-family: var(--font-mono); font-weight: 400; color: var(--tx-dim); margin-right: 4px; }
.temp-graph {
  width: 100%;
  height: 110px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

/* ---------------- 組成バー ---------------- */
.comp-bar {
  display: flex;
  height: 15px;
  border: 1px solid var(--line2);
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.comp-seg { transition: width 0.25s linear; min-width: 0; }
.seg-water { background: var(--water); }
.seg-cell  { background: var(--wood); }
.seg-char  { background: var(--charc); }
.seg-ash   { background: var(--ashc); }
.seg-lost  {
  background: repeating-linear-gradient(135deg, transparent 0 3px, rgba(255, 240, 218, 0.07) 3px 6px);
}
.comp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 9px;
  font-size: 10px;
  color: var(--tx-dim);
  letter-spacing: 0.06em;
}
.comp-legend b {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--tx);
  margin-left: 5px;
  font-size: 9.5px;
}
.sw {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 5px;
  transform: rotate(45deg) scale(0.9);
}
.sw-water { background: var(--water); }
.sw-cell { background: var(--wood); }
.sw-char { background: var(--charc); }
.sw-ash { background: var(--ashc); }
.sw-lost { border: 1px solid var(--tx-faint); }

/* ---------------- 放出メーター ---------------- */
.meter {
  display: grid;
  grid-template-columns: 52px 1fr 64px;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.meter-name { font-size: 11px; letter-spacing: 0.14em; color: var(--tx-dim); }
.meter-segs { display: flex; gap: 2.5px; }
.meter-segs i {
  flex: 1;
  height: 13px;
  background: rgba(255, 240, 218, 0.05);
  transform: skewX(-12deg);
  transition: background 0.12s, box-shadow 0.12s;
}
.meter[data-m="steam"] .meter-segs i.lit { background: var(--steam); box-shadow: 0 0 6px rgba(200, 230, 240, 0.45); }
.meter[data-m="smoke"] .meter-segs i.lit { background: #8d8d8d; box-shadow: 0 0 5px rgba(160, 160, 160, 0.35); }
.meter[data-m="fire"]  .meter-segs i.lit { background: var(--fire); box-shadow: 0 0 7px rgba(255, 106, 42, 0.55); }
.meter[data-m="fire"]  .meter-segs i.lit:nth-child(n+17) { background: var(--red); }
.meter-val {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  color: var(--tx);
}
.meter-val small { font-size: 8px; color: var(--tx-faint); margin-left: 2px; }

/* ---------------- 制御 ---------------- */
.ctl-row {
  display: grid;
  grid-template-columns: 86px 1fr 62px;
  align-items: center;
  gap: 12px;
  margin-bottom: 11px;
}
.ctl-name { font-size: 11px; letter-spacing: 0.12em; color: var(--tx-dim); }
.ctl-val {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}
.ctl-val small { font-size: 8px; color: var(--tx-faint); margin-left: 2px; }

.ctl-burner { margin-bottom: 15px; }
.ctl-state {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-align: right;
  color: var(--tx-faint);
}
.ctl-state.on { color: var(--amber); text-shadow: 0 0 8px rgba(255, 160, 40, 0.5); }

.toggle {
  position: relative;
  width: 52px; height: 24px;
  justify-self: start;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line2);
  cursor: pointer;
  transition: all 0.25s;
}
.toggle .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 17px; height: 16px;
  background: var(--tx-faint);
  transition: all 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.toggle[aria-pressed="true"] {
  border-color: var(--amber);
  background: rgba(255, 130, 30, 0.13);
  box-shadow: 0 0 14px rgba(255, 140, 30, 0.25), inset 0 0 8px rgba(255, 140, 30, 0.15);
}
.toggle[aria-pressed="true"] .knob {
  left: 31px;
  background: var(--amber);
  box-shadow: 0 0 9px rgba(255, 160, 40, 0.8);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line2);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  margin-top: -5.5px;
  background: var(--panel);
  border: 2px solid var(--amber);
  transition: box-shadow 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 9px rgba(255, 160, 40, 0.7);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line2); }
input[type="range"]::-moz-range-thumb {
  width: 11px; height: 11px;
  border-radius: 0;
  background: var(--panel);
  border: 2px solid var(--amber);
}

.ctl-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.btn {
  font-family: var(--font-jp);
  font-size: 11px;
  letter-spacing: 0.2em;
  padding: 8px 18px;
  color: var(--tx);
  background: transparent;
  border: 1px solid var(--line2);
  cursor: pointer;
  transition: all 0.18s;
}
.btn:hover {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1207;
  box-shadow: 0 0 16px rgba(255, 160, 40, 0.4);
}
.ctl-hint { font-size: 9px; color: var(--tx-faint); letter-spacing: 0.08em; }

/* ---------------- ログ ---------------- */
.p-log-sec { border-bottom: none; }
.log { min-height: 90px; }
.log-line {
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: var(--tx-dim);
  padding: 3.5px 0 3.5px 9px;
  border-left: 2px solid transparent;
  animation: logIn 0.4s ease;
}
.log-line span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--tx-faint);
  margin-right: 8px;
}
.log-line:first-child { color: var(--tx); border-left-color: var(--amber); }
.log-line.hot:first-child { border-left-color: var(--red); color: #ffb9a3; }
@keyframes logIn { from { opacity: 0; transform: translateX(-4px); } }

.p-foot {
  padding: 14px 22px 20px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--tx-faint);
  border-top: 1px solid var(--line);
}

/* ---------------- 狭い画面 ---------------- */
@media (max-width: 880px) {
  #app { flex-direction: column; }
  #viewport { min-height: 46vh; }
  #panel {
    width: 100%;
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--line2);
  }
  #panel::before { display: none; }
}
