<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>BAHAMA式長さ「答え一発」 v3.1 基準完全整合版</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body { font-family: sans-serif; background: #f0f2f5; padding: 15px; line-height: 1.5; color: #333; }
.card { background: #fff; padding: 25px; border-radius: 16px; box-shadow: 0 8px 20px rgba(0,0,0,0.15); max-width: 480px; margin: auto; }
h1 { font-size: 1.3em; text-align: center; color: #1a73e8; margin-bottom: 20px; border-bottom: 3px solid #1a73e8; padding-bottom: 10px; }
.input-group { margin-bottom: 18px; }
label { display: block; margin-bottom: 6px; font-weight: bold; font-size: 0.9em; color: #555; }
select, input { width: 100%; padding: 14px; border: 2px solid #ddd; border-radius: 10px; box-sizing: border-box; font-size: 1.1em; background: #fff; outline: none; }
select:focus, input:focus { border-color: #1a73e8; }
.result-container { background: #1a73e8; color: white; padding: 25px; border-radius: 12px; text-align: center; margin-top: 25px; transition: 0.3s; }
.result-container.warning { background: #d93025; }
.result-label { font-size: 0.9em; opacity: 0.9; margin-bottom: 5px; }
.result-val { font-size: 2.8em; font-weight: bold; }
.unit { font-size: 0.4em; margin-left: 8px; }
.msg { font-size: 1em; margin-top: 12px; font-weight: bold; min-height: 1.2em; }
.spec-table { width: 100%; font-size: 0.75em; color: #777; margin-top: 20px; border-top: 1px solid #eee; padding-top: 10px; line-height: 1.6; }
.footer { font-size: 0.7em; color: #999; text-align: center; margin-top: 15px; }
</style>
</head>
<body>
<div class="card">
<h1>ビール配管計算機「答え一発」</h1>
<div class="input-group">
<label>🌡️ ビール温度 (℃)</label>
<input type="number" id="temp" value="5" step="0.5">
</div>
<div class="input-group">
<label>💨 設定ガス圧 (MPa)</label>
<input type="number" id="gasPressure" value="0.100" step="0.005">
</div>
<div class="input-group">
<label>🧬 使用ホースの材質と内径</label>
<select id="hoseSpecs">
<optgroup label="■ポリオレフィン・EVA・塩ビ">
<option value="0.0060">4mm (標準)</option>
<option value="0.0025" selected>5mm (基準・4m整合モデル)</option>
<option value="0.0012">6mm (標準)</option>
<option value="0.0006">7mm (標準)</option>
<option value="0.0004">8mm (標準)</option>
<option value="0.0002">9mm (標準)</option>
</optgroup>
<optgroup label="■シリコン系(肉厚・高抵抗)">
<option value="0.0045">5mm (シリコン)</option>
<option value="0.0022">6mm (シリコン)</option>
<option value="0.0011">7mm (シリコン)</option>
</optgroup>
</select>
</div>
<div id="resultBox" class="result-container">
<div class="result-label">必要なホースの長さ</div>
<div><span id="resultLength" class="result-val">--</span><span class="unit">m</span></div>
<div id="resultMsg" class="msg"></div>
</div>
<div class="spec-table">
<strong>【設定根拠】</strong><br>
・均衡圧:(温度 × 0.015) + 0.015 MPa<br>
・検証1:8℃で均衡圧 0.135 MPa (整合)<br>
・検証2:5℃(均衡圧0.09) + 5mm(0.0025)×4m = 0.10 MPa (整合)
</div>
<div class="footer">
© Beer Physics Lab - v3.1
</div>
</div>
<script>
function calculate() {
const temp = parseFloat(document.getElementById('temp').value) || 0;
const Pgas = parseFloat(document.getElementById('gasPressure').value) || 0;
const R = parseFloat(document.getElementById('hoseSpecs').value);
// 【修正後ロジック】 8度で0.135、5度で0.09になる数式
const Pequil = (temp * 0.015) + 0.015;
// 有効圧(設定圧と均衡圧の差)
let effectiveP = Pgas - Pequil;
let length = effectiveP / R;
const resultBox = document.getElementById('resultBox');
const resultLength = document.getElementById('resultLength');
const resultMsg = document.getElementById('resultMsg');
if (effectiveP <= 0) {
resultBox.classList.add('warning');
resultLength.innerText = "0.00";
resultMsg.innerText = "圧不足!設定圧が均衡圧(" + Pequil.toFixed(3) + ")以下です";
} else {
resultBox.classList.remove('warning');
resultLength.innerText = length.toFixed(2);
resultMsg.innerText = "この長さで「答え一発」!";
}
}
document.querySelectorAll('input, select').forEach(el => {
el.addEventListener('change', calculate);
el.addEventListener('input', calculate);
});
calculate();
</script>
</body>
</html>