/* カラー変数の定義（デフォルトはライトモード） */
:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #334155;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
    --modal-overlay: rgba(15, 23, 42, 0.3);
    --tab-active-bg: #eff6ff;
    --tab-active-text: var(--accent-color, #3b82f6);
    --btn-secondary: #f1f5f9;
    --btn-secondary-text: #475569;
    --accent-color: #3b82f6; 
}

/* グレー・炭黒系のダークモード */
[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --border-color: #333333;
    --input-bg: #2d2d2d;
    --modal-overlay: rgba(0, 0, 0, 0.6);
    --tab-active-bg: #2d2d2d;
    --tab-active-text: var(--accent-color, #3b82f6);
    --btn-secondary: #2d2d2d;
    --btn-secondary-text: #e0e0e0;
}

body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; box-sizing: border-box; overflow: hidden;
    transition: background-color 0.2s, color 0.2s;
}

.container { text-align: center; width: 100%; max-width: 600px; padding: 20px; }
h1 { margin: 0 0 20px 0; font-size: 1.8rem; color: var(--text-main); font-weight: 700; }

.icon-btn {
    position: fixed; top: 15px; right: 15px;
    background: var(--card-bg); color: var(--text-main);
    border: none; font-size: 22px; width: 44px; height: 44px; border-radius: 50%;
    cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex; justify-content: center; align-items: center; z-index: 90;
}

.main-content { display: flex; flex-direction: column; align-items: center; gap: 20px; }

@media (max-height: 500px) and (orientation: landscape) {
    .container { max-width: 95%; padding: 10px; }
    h1 { font-size: 1.3rem; margin-bottom: 5px; }
    .main-content { flex-direction: row; justify-content: space-evenly; }
    #result { margin: 5px 0 !important; font-size: 1.2rem !important; }
}

.roulette-wrapper { position: relative; }
.arrow {
    position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
    font-size: 24px; color: var(--text-muted); z-index: 10;
}

canvas {
    border-radius: 50%; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background: white; max-width: 70vw; max-height: 55vh;
}

#result { color: var(--text-main); margin: 20px 0; font-size: 1.4rem; font-weight: 600; min-height: 1.5em; }

#spin-btn {
    background-color: var(--accent-color); color: white; border: none;
    padding: 12px 40px; font-size: 16px; font-weight: 600; border-radius: 24px;
    cursor: pointer; transition: background-color 0.2s, filter 0.2s;
}
#spin-btn:active { filter: brightness(0.85); }
#spin-btn:disabled { background-color: #cbd5e1; color: #94a3b8; cursor: not-allowed; }
[data-theme="dark"] #spin-btn:disabled { background-color: #333333; color: #666666; }

/* モーダル基本構造 */
.modal {
    display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%;
    background-color: var(--modal-overlay); backdrop-filter: blur(2px);
    justify-content: center; align-items: center; padding: 12px; box-sizing: border-box;
}

.modal-content {
    background-color: var(--card-bg); border-radius: 16px; width: 100%; max-width: 420px;
    height: 450px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}

.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 10px 20px; flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--text-main); font-weight: 600; }
.close-x-btn { background: none; border: none; font-size: 22px; color: var(--text-muted); cursor: pointer; padding: 0; }

.tab-container { display: flex; padding: 0 16px; gap: 4px; flex-shrink: 0; }
.tab-btn {
    flex: 1; background: none; border: none; padding: 10px 4px;
    font-size: 13px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-radius: 8px;
}
.tab-btn.active { background-color: var(--tab-active-bg); color: var(--tab-active-text); font-weight: 600; }

.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; }
.tab-content { display: none; flex-direction: column; gap: 20px; }
.tab-content.active { display: flex; }

.setting-section { text-align: left; display: flex; flex-direction: column; gap: 8px; }
.setting-section label { font-weight: 600; font-size: 0.85rem; color: var(--text-muted); letter-spacing: 0.05em; }
.setting-section input[type="text"], .setting-section select {
    padding: 10px; font-size: 14px; border: 1px solid var(--border-color);
    border-radius: 8px; background-color: var(--input-bg); color: var(--text-color); outline: none;
}

/* プリセットカラー */
.color-presets { display: flex; gap: 10px; margin-top: 4px; }
.preset-btn {
    width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
    transition: transform 0.15s, outline 0.15s; outline: 2px solid transparent;
}
.preset-btn:active { transform: scale(0.9); }
.preset-btn.selected { outline: 2px solid var(--text-main); outline-offset: 2px; }
.color-blue { background-color: #3b82f6; }
.color-emerald { background-color: #10b981; }
.color-violet { background-color: #8b5cf6; }
.color-rose { background-color: #f43f5e; }
.color-amber { background-color: #f59e0b; }

/* 項目編集 */
.items-list-container { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.item-row { display: flex; gap: 8px; align-items: center; }
.item-row input[type="text"] {
    flex: 1; padding: 8px 10px; font-size: 14px; border: 1px solid var(--border-color);
    border-radius: 6px; background: var(--input-bg); color: var(--text-color);
}
.item-row input[type="color"] { width: 32px; height: 32px; border: 1px solid var(--border-color); border-radius: 6px; background: none; cursor: pointer; padding: 0; }
.delete-btn { background: none; color: var(--text-muted); border: none; padding: 8px; font-size: 13px; cursor: pointer; }
.delete-btn:hover { color: #ef4444; }

.add-btn {
    background-color: var(--btn-secondary); color: var(--btn-secondary-text);
    border: none; padding: 8px; font-size: 13px; border-radius: 6px; font-weight: 500; cursor: pointer;
}

/* 情報タブ */
.app-info-block { text-align: center; padding: 10px 0; border-bottom: 1px dashed var(--border-color); margin-bottom: -5px; }
.app-info-title { margin: 0 0 6px 0; font-size: 1.1rem; color: var(--text-main); font-weight: 700; }
.app-info-credit { margin: 0; font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.03em; }

.csv-controls { display: flex; flex-direction: column; gap: 10px; }
.action-btn, .file-label {
    background-color: var(--btn-secondary); color: var(--btn-secondary-text);
    padding: 10px; font-size: 13px; border-radius: 8px; text-align: center; font-weight: 500; cursor: pointer; border: none;
    transition: background-color 0.15s;
}
.action-btn:active { filter: brightness(0.9); }
input[type="file"] { display: none; }

.danger-btn { background-color: #fee2e2; color: #ef4444; border: none; padding: 10px; font-size: 13px; border-radius: 8px; font-weight: 500; cursor: pointer; text-align: center; }
[data-theme="dark"] .danger-btn { background-color: #442222; color: #fca5a5; }

/* 独自ポップアップ共通スタイル */
.confirm-modal-overlay { z-index: 110; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); }
.confirm-content {
    background-color: var(--card-bg); border-radius: 16px; width: 100%; max-width: 340px; padding: 24px;
    text-align: center; box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3); box-sizing: border-box; animation: confirmPop 0.2s ease-out;
}
@keyframes confirmPop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.confirm-icon { font-size: 40px; margin-bottom: 12px; }
.confirm-content h4 { margin: 0 0 10px 0; font-size: 1.15rem; color: var(--text-main); font-weight: 700; }
.confirm-content p { margin: 0 0 24px 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }

.confirm-buttons { display: flex; gap: 10px; }
.confirm-buttons button { flex: 1; padding: 11px; font-size: 13px; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; transition: filter 0.15s; }
.confirm-buttons button:active { filter: brightness(0.85); }

.confirm-btn-secondary { background-color: var(--btn-secondary); color: var(--btn-secondary-text); }
.confirm-btn-danger { background-color: #ef4444; color: white; }
[data-theme="dark"] .confirm-btn-danger { background-color: #dc2626; }