/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #00060e;
    --surface:    rgba(2, 12, 24, 0.82);
    --border:     rgba(56, 189, 248, 0.12);
    --text:        #c4d8e8;
    --muted:      #3d5a72;
    --accent:      #38bdf8;
    /* 粒子の色・サイズは script.js の PARTICLE_DEF で一元管理 */
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Noto Sans JP', sans-serif;
    overflow: hidden;
    height: 100vh; width: 100vw;
}

/* ===== キャンバス ===== */
#canvas {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    display: block;
}

/* ===== ヘッダー ===== */
#header {
    position: fixed; top: 0; left: 0; right: 0;
    padding: 0 28px;
    height: 56px;
    background: var(--surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 28px;
    z-index: 200;
}

#header::after {
    content: '';
    position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--accent) 30%, var(--accent) 70%, transparent 100%);
    opacity: 0.35;
}

.app-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
}
.app-title-main {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent);
    text-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
}
.app-title-sub {
    font-size: 11px;
    font-weight: 300;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.divider {
    width: 1px; height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

.ctrl-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ctrl-label {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    letter-spacing: 0.04em;
}

input[type="number"],
select {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: var(--text);
    background: rgba(56, 189, 248, 0.05);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 5px;
    padding: 5px 9px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
input[type="number"] { width: 68px; }
input[type="number"]:focus,
select:focus {
    border-color: rgba(56, 189, 248, 0.55);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}
select option { background: #020c18; }

/* ===== 凡例パネル ===== */
#legend {
    position: fixed;
    top: 72px;
    right: 24px;
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    z-index: 200;
    min-width: 196px;
}

.legend-hd {
    font-size: 9px;
    color: var(--muted);
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}
.legend-row:last-child { margin-bottom: 0; }

.legend-dot {
    flex-shrink: 0;
    border-radius: 50%;
}

.legend-name {
    font-size: 12px;
    color: var(--text);
    flex: 1;
    letter-spacing: .02em;
}

.legend-val {
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    color: #64748b;
    text-align: right;
    line-height: 1.4;
}

/* ===== フッター情報 ===== */
#footer {
    position: fixed;
    bottom: 24px; left: 24px;
    z-index: 200;
    font-size: 10px;
    color: var(--muted);
    line-height: 1.8;
    font-family: 'DM Mono', monospace;
}

/* ===== 清浄度クラス表示（左上に配置変更） ===== */
#center-display {
    position: fixed;
    top: 72px;        /* ヘッダーの下に配置 */
    left: 24px;       /* 左端の余白 */
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* 左揃えに変更 */
    gap: 6px;
    pointer-events: none;
    text-align: left;
}

#center-iso {
    font-family: 'DM Mono', monospace;
    font-size: 36px;  /* 画面端のバランスに合わせて少しコンパクトに */
    font-weight: 500;
    letter-spacing: 0.06em;
    color: rgba(196, 216, 232, 1.00);
    line-height: 1;
}

#center-fed {
    font-family: 'DM Mono', monospace;
    font-size: 20px;
    letter-spacing: 0em;
    color: rgba(56, 189, 248, 1.00);
    line-height: 1;
}

/* ===== スケールバー（ものさし） ===== */
#scale-bar {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    height: 40px;
    pointer-events: none;
}

/* 水平ライン */
#scale-line {
    position: absolute;
    top: 0;
    left: 0; right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.75);
}

/* 左右の端キャップ */
#scale-line::before,
#scale-line::after {
    content: '';
    position: absolute;
    top: 0;
    width: 2px;
    height: 10px;
    background: rgba(255, 255, 255, 0.75);
}
#scale-line::before { left: 0; }
#scale-line::after  { right: 0; }

/* 目盛りグループ（tick + ラベル） */
.scale-tick-group {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 目盛り線 */
.scale-tick {
    width: 2px;
    height: 10px;
    background: rgba(255, 255, 255, 0.75);
    margin-top: 2px;
}

/* ラベル */
.scale-label {
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.80);
    margin-top: 5px;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

/* ===== クラスバッジ ===== */
#class-badge {
    position: fixed;
    top: 50%; left: 50%; /* 縦方向も 50%（中央）に変更 */
    transform: translate(-50%, -50%); /* 縦・横ともに中央揃えにする */
    z-index: 150;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .4s;
}
#class-badge.show { opacity: 1; }

.badge-class {
    font-family: 'DM Mono', monospace;
    font-size: 18px; /* 画面中央で見栄えがよくなるよう、13px から少し大きく調整 */
    color: rgba(56, 189, 248, 0.9); /* 少しだけ文字をくっきり */
    letter-spacing: .12em;
    border: 1px solid rgba(56, 189, 248, 0.3); /* 枠線を少し強調 */
    padding: 8px 20px; /* バッジの余白を広げて押し出し感を強化 */
    border-radius: 24px;
    background: rgba(2, 12, 24, 0.85); /* 背景の黒みを少し濃くして粒子と重なっても読めるように */
    box-shadow: 0 0 20px rgba(0, 6, 14, 0.6); /* 軽い影をつけて浮かせる */
}

/* ===== チェックボックス用スタイル ===== */
.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    margin-right: 10px;
}

.switch-label input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 3px;
    background: rgba(2, 12, 24, 0.6);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.switch-label input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.switch-label input[type="checkbox"]:checked::after {
    content: "✓";
    font-size: 10px;
    color: #00060e;
    font-weight: bold;
}

/* ===== 粒子数割合スライダー ===== */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    vertical-align: middle;
}
input[type="range"]::-webkit-slider-runnable-track {
    background: rgba(56, 189, 248, 0.3);
    height: 4px;
    border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    background: var(--accent);
    border-radius: 50%;
    margin-top: -5px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
input[type="range"]:focus {
    outline: none;
}

/* ===== 粒子数割合の数値入力（小幅） ===== */
input#ratioNumber {
    width: 50px;
    text-align: center;
    padding: 5px 4px;
}
input#ratioNumber::-webkit-inner-spin-button,
input#ratioNumber::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}