/* :rootでカラーパレットや基本サイズを定義し、一貫性のあるデザインを容易にします */
:root {
    --bg-color: #1a1a1a;
    --panel-bg-color: #282c34;
    --text-color: #e6e6e6;
    --primary-color: #61dafb;
    --secondary-color: #98c379;
    --border-color: #444b58;
    --input-bg-color: #3a3f4b;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* --- 基本設定 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* ページ全体のスクロールを禁止 */
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* --- 3Dビュー用キャンバス --- */
#webgl-canvas {
    position: fixed;
    top: 0;
    left: 0;
    outline: none;
    width: 100%;
    height: 100%;
}

/* --- UIパネル --- */
#ui-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 380px;
    max-height: calc(100vh - 30px); /* 画面からはみ出ないように高さを制限 */
    overflow-y: auto; /* 内容が多い場合はスクロール可能に */
    background-color: var(--panel-bg-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    padding: 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 25px; /* 各セクション間の隙間 */
}

/* --- UIパネル内ヘッダー --- */
#ui-panel header h1 {
    font-size: 1.5em;
    color: var(--primary-color);
    margin-bottom: 5px;
}

#ui-panel header p {
    font-size: 0.9em;
    color: #aab3c3;
}

/* --- UIセクション共通スタイル --- */
.ui-section {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.ui-section:first-of-type {
    border-top: none;
    padding-top: 0;
}

.ui-section h2 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: var(--secondary-color);
}

/* --- 入力要素グループ --- */
.input-group, .slider-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.slider-group {
    display: grid;
    grid-template-columns: 20px 1fr 55px; /* ラベル | スライダー | 数値入力 */
    gap: 10px;
    align-items: center;
}

label {
    font-size: 0.9em;
    white-space: nowrap;
}

/* --- フォーム要素（input, select, button） --- */
input[type="number"],
input[type="file"],
select {
    background-color: var(--input-bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    font-size: 0.9em;
}

input[type="number"] {
    width: 70px;
}

input[type="file"] {
    width: 100%;
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    background-color: var(--primary-color);
    color: var(--bg-color);
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    transition: background-color 0.2s;
}
input[type="file"]::file-selector-button:hover {
    background-color: #88eaff;
}

select {
    width: 60%;
    cursor: pointer;
}

fieldset {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 15px;
    margin-top: 10px;
}
fieldset legend {
    padding: 0 5px;
    font-size: 0.9em;
    color: #aab3c3;
}

/* スライダーのスタイル */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 5px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

input[type="range"]:hover {
    opacity: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* --- ボタン --- */
button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button:hover {
    background-color: #88eaff;
}
button:active {
    transform: scale(0.98);
}


/* --- 画像プレビュー --- */
#image-preview-container {
    margin-top: 15px;
}
#image-preview {
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

/* --- ヘルプオーバーレイ --- */
#help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none; /* JavaScriptで表示を切り替える */
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#help-overlay.visible {
    display: flex;
}

.help-content {
    background-color: var(--panel-bg-color);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
}

.help-content h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.help-content ul {
    list-style: none;
    padding-left: 0;
}

.help-content li {
    margin-bottom: 12px;
    line-height: 1.5;
}

.help-content li strong {
    color: var(--secondary-color);
    margin-right: 8px;
    display: inline-block;
    width: 90px;
}

#close-help {
    margin-top: 20px;
}