<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>マリオカート | 鍵っ子の館</title>
	<atom:link href="https://tt0.link/category/game/mario_kart/feed/" rel="self" type="application/rss+xml" />
	<link>https://tt0.link</link>
	<description>つっちーのつっちーによるつっちーのためのサイト</description>
	<lastBuildDate>Fri, 23 Jan 2026 13:23:57 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://tt0.link/wordpress/wp-content/uploads/2025/02/cropped-980835ffed0b6027944c9941f542bbd5-32x32.png</url>
	<title>マリオカート | 鍵っ子の館</title>
	<link>https://tt0.link</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>マリオカートワールド最適組み合わせ算出ツール</title>
		<link>https://tt0.link/mario_kart_w-pareto/</link>
					<comments>https://tt0.link/mario_kart_w-pareto/#respond</comments>
		
		<dc:creator><![CDATA[つっちー]]></dc:creator>
		<pubDate>Sat, 21 Jun 2025 03:33:29 +0000</pubDate>
				<category><![CDATA[ツール]]></category>
		<category><![CDATA[マリオカート]]></category>
		<guid isPermaLink="false">https://tt0.link/?p=933</guid>

					<description><![CDATA[事前にマリオカートワールドステータス計算ツールで組み合わせを選んでから、同等以上のステータスを表示することもできます 概要 ステータスの比重を決めることで、パレート最適によりキャラクターとマシンの組み合わせを評価し一覧表 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>事前に<a href="https://tt0.link/mario_kart_w-stats/" data-type="post" data-id="924">マリオカートワールドステータス計算ツール</a>で組み合わせを選んでから、同等以上のステータスを表示することもできます</p>



<p></p>



<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>パレート最適組み合わせツール</title>
    <style>
        h1, h2 {
            color: #1a202c;
            text-align: center;
            margin-bottom: 1.5rem;
        }
        .section-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin-top: 1.5rem;
            margin-bottom: 1rem;
            color: #2d3748;
        }
        .slider-group {
            display: flex;
            align-items: center;
            margin-bottom: 1rem;
        }
        .slider-group label {
            width: 180px;
            margin-right: 2rem;
            font-weight: 500;
            color: #4a5568;
            white-space: nowrap;
        }
        .slider-group input[type="range"] {
            flex-grow: 1;
            -webkit-appearance: none;
            height: 8px;
            background: #e2e8f0;
            border-radius: 5px;
            outline: none;
            opacity: 0.7;
            transition: opacity .2s;
        }
        .slider-group input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 20px;
            height: 20px;
            background: #3b82f6;
            border: 2px solid #fff;
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 0 2px rgba(0,0,0,0.2);
        }
        .slider-group input[type="range"]::-moz-range-thumb {
            width: 20px;
            height: 20px;
            background: #3b82f6;
            border: 2px solid #fff;
            border-radius: 50%;
            cursor: pointer;
            box-shadow: 0 0 2px rgba(0,0,0,0.2);
        }
        .slider-group span {
            margin-left: 1rem;
            min-width: 25px;
            text-align: right;
            font-weight: 600;
            color: #3b82f6;
        }
        .button-group {
            display: flex;
            gap: 1rem;
            margin-top: 1.5rem;
        }
        .button-group button {
            flex: 1;
            margin-top: 0;
        }
        button {
            display: block;
            width: 100%;
            padding: 12px 20px;
            background-color: #3b82f6;
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: background-color 0.3s ease, transform 0.2s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        button:hover {
            background-color: #2563eb;
            transform: translateY(-2px);
        }
        button:active {
            background-color: #1d4ed8;
            transform: translateY(0);
        }
        #reset-button {
            background-color: #6c757d;
        }
        #reset-button:hover {
            background-color: #5a6268;
        }
        #reset-button:active {
            background-color: #4e555b;
        }
        #results-container {
            margin-top: 2rem;
            border-top: 1px solid #e2e8f0;
            padding-top: 2rem;
        }
        .no-results {
            text-align: center;
            color: #6b7280;
            padding: 2rem;
            font-size: 1.1rem;
        }

        /* New table styles */
        .results-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1.5rem;
            background-color: #ffffff;
            border-radius: 8px;
            overflow: hidden; /* For rounded corners on table */
        }
        .results-table th, .results-table td {
            border: 1px solid #e2e8f0;
            padding: 10px 12px;
            text-align: left;
            font-size: 0.9rem;
            color: #333;
        }
        .results-table th {
            background-color: #f8f8f8;
            font-weight: 600;
            color: #2d3748;
            position: sticky;
            top: 0;
            z-index: 1;
        }
        .results-table tbody tr {
            background-color: #ffffff;
        }
        .results-table tbody tr:nth-child(even) {
            background-color: #fbfbfc;
        }
        .results-table tbody tr:hover {
            background-color: #e6f7ff;
        }

        /* Filter controls styling */
        .filter-controls {
            margin-top: 1.5rem;
            margin-bottom: 1.5rem;
            padding: 1rem;
            border: 1px solid #e2e8f0;
            border-radius: 8px;
            background-color: #fcfcfc;
            display: flex;
            gap: 0.75rem;
            flex-wrap: wrap;
            justify-content: center;
        }
        .filter-group {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .filter-group label {
            font-weight: 500;
            color: #4a5568;
            white-space: nowrap;
        }
        .filter-group select, .filter-group input[type="number"] {
            padding: 8px 12px;
            border: 1px solid #cbd5e0;
            border-radius: 6px;
            background-color: #fff;
            font-size: 0.95rem;
            cursor: pointer;
            transition: border-color 0.2s ease;
        }
        .filter-group select:hover, .filter-group input[type="number"]:hover {
            border-color: #a7d0fd;
        }
        .filter-group select:focus, .filter-group input[type="number"]:focus {
            outline: none;
            border-color: #3b82f6;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
        }
        /* Break for filter groups */
        .filter-break {
            flex-basis: 100%;
            height: 0;
            margin: 0;
            padding: 0;
        }


        /* Responsive adjustments for table */
        @media (max-width: 768px) {
            .slider-group {
                flex-direction: row;
                align-items: center;
                justify-content: space-between;
                flex-wrap: wrap;
            }
            .slider-group label {
                margin-bottom: 0;
                margin-right: 0.5rem;
                flex-shrink: 0;
            }
            .slider-group input[type="range"] {
                flex-grow: 1;
                width: auto;
            }
            .slider-group span {
                margin-left: 0.5rem;
                min-width: 25px;
                text-align: right;
                flex-shrink: 0;
            }

            .filter-controls {
                flex-direction: column;
                align-items: flex-start;
                gap: 1rem;
            }
            .button-group {
                flex-direction: column;
            }
            .button-group button {
                width: 100%;
            }

            /* Make table stack on small screens */
            .results-table, .results-table thead, .results-table tbody, .results-table th, .results-table td, .results-table tr {
                display: block;
            }
            .results-table thead tr {
                position: absolute;
                top: -9999px;
                left: -9999px;
            }
            .results-table tr {
                margin-bottom: 1rem;
                border: 1px solid #e2e8f0;
                border-radius: 8px;
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            }
            .results-table td {
                border: none;
                border-bottom: 1px solid #eee;
                position: relative;
                padding-left: 50%;
                text-align: right;
            }
            .results-table td:last-child {
                border-bottom: 0;
            }
            .results-table td:before {
                content: attr(data-label);
                position: absolute;
                left: 12px;
                width: 45%;
                padding-right: 10px;
                white-space: nowrap;
                text-align: left;
                font-weight: 600;
                color: #2d3748;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h2 class="section-title">ステータスの比重設定 (0-10)</h2>
        <div id="weights-controls">
            <!-- スライダーはJavaScriptで動的に生成されます -->
        </div>

        <div class="button-group">
            <button id="calculate-button">パレート最適組み合わせを再計算</button>
            <button id="reset-button">リセット</button>
        </div>

        <div id="results-container">
            <h2 class="section-title">パレート最適組み合わせ一覧</h2>
            <!-- Filter controls are moved here -->
            <div class="filter-controls" id="filter-controls">
                <div class="filter-group" id="character-filter-group">
                    <label for="character-filter">キャラクター:</label>
                    <select id="character-filter"></select>
                </div>
                <div class="filter-group" id="kart-filter-group">
                    <label for="kart-filter">マシン:</label>
                    <select id="kart-filter"></select>
                </div>
                <!-- 改行を強制するための要素を追加 -->
                <div class="filter-break"></div>
                <!-- 数値フィルターはJavaScriptで動的に追加されます -->
            </div>
            <div id="pareto-combinations">
                <!-- 結果はここに動的に表示されます -->
                <p class="no-results">「パレート最適組み合わせを再計算」ボタンを押して結果を表示します。</p>
            </div>
        </div>
    </div>

    <script>
        console.log("Script execution started."); // デバッグログ

        // PHPから渡されたデータをJavaScript変数に代入
        const charactersData = [{"name":"マリオ","stats":{"speed_onroad":1.2,"speed_dirt":1,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":1.2,"handling_dirt":0.8,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/マリオ.png"},{"name":"ルイージ","stats":{"speed_onroad":1,"speed_dirt":1.2,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":1.2,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/ルイージ.png"},{"name":"ピーチ","stats":{"speed_onroad":1,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1.4,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ピーチ.png"},{"name":"デイジー","stats":{"speed_onroad":1,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1.4,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/デイジー.png"},{"name":"ヨッシー","stats":{"speed_onroad":0.8,"speed_dirt":1,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1.4,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ヨッシー.png"},{"name":"キノピオ","stats":{"speed_onroad":0.6,"speed_dirt":0.8,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.6,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/キノピオ.png"},{"name":"ノコノコ","stats":{"speed_onroad":0.6,"speed_dirt":0.6,"speed_underwater":0.8,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ノコノコ.png"},{"name":"クッパ","stats":{"speed_onroad":1.6,"speed_dirt":1.6,"speed_underwater":1.6,"acceleration":0.6,"weight":2,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/クッパ.png"},{"name":"ワリオ","stats":{"speed_onroad":1.6,"speed_dirt":1.4,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.8,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ワリオ.png"},{"name":"ワルイージ","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":1.6,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/ワルイージ.png"},{"name":"ロゼッタ","stats":{"speed_onroad":1.2,"speed_dirt":1.2,"speed_underwater":1.4,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ロゼッタ.png"},{"name":"ポリーン","stats":{"speed_onroad":1.4,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":1,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/ポリーン.png"},{"name":"ベビィマリオ","stats":{"speed_onroad":0.6,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.8,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/ベビィマリオ.png"},{"name":"ベビィルイージ","stats":{"speed_onroad":0.4,"speed_dirt":0.6,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.8,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/ベビィルイージ.png"},{"name":"ベビィピーチ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ベビィピーチ.png"},{"name":"ベビィデイジー","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ベビィデイジー.png"},{"name":"ジュゲム","stats":{"speed_onroad":0.6,"speed_dirt":0.6,"speed_underwater":0.8,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ジュゲム.png"},{"name":"キノピコ","stats":{"speed_onroad":0.8,"speed_dirt":0.6,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.6,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/キノピコ.png"},{"name":"クッパJr.","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/クッパJr..png"},{"name":"ベビィロゼッタ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.6,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.8},"imageUrl":"/myApps/img/marioKart/characters/ベビィロゼッタ.png"},{"name":"キャサリン","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1.2,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":0.8,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/キャサリン.png"},{"name":"キングテレサ","stats":{"speed_onroad":1.2,"speed_dirt":1.4,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":1,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/キングテレサ.png"},{"name":"ヘイホー","stats":{"speed_onroad":0.6,"speed_dirt":0.8,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.6,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/ヘイホー.png"},{"name":"ドンキーコング","stats":{"speed_onroad":1.4,"speed_dirt":1.6,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.8,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ドンキーコング.png"},{"name":"トッテン","stats":{"speed_onroad":0.8,"speed_dirt":0.6,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.6,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/トッテン.png"},{"name":"ハナチャン","stats":{"speed_onroad":1.6,"speed_dirt":1.4,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.8,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ハナチャン.png"},{"name":"クリボー","stats":{"speed_onroad":0.6,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.8,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/クリボー.png"},{"name":"ウシ","stats":{"speed_onroad":1.4,"speed_dirt":1.6,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.8,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ウシ.png"},{"name":"カロン","stats":{"speed_onroad":0.4,"speed_dirt":0.6,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.8,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/カロン.png"},{"name":"ハンマーブロス","stats":{"speed_onroad":1,"speed_dirt":1.2,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":1.2,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/ハンマーブロス.png"},{"name":"カニ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.6,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.8},"imageUrl":"/myApps/img/marioKart/characters/カニ.png"},{"name":"ガマネー","stats":{"speed_onroad":1,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1.4,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ガマネー.png"},{"name":"プクプク","stats":{"speed_onroad":0.6,"speed_dirt":0.6,"speed_underwater":0.8,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/プクプク.png"},{"name":"ガボン","stats":{"speed_onroad":0.6,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.8,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/ガボン.png"},{"name":"ペンギン","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1.2,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":0.8,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/ペンギン.png"},{"name":"ブル","stats":{"speed_onroad":1.4,"speed_dirt":1.6,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.8,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ブル.png"},{"name":"ハッチン","stats":{"speed_onroad":0.6,"speed_dirt":0.8,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.6,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/ハッチン.png"},{"name":"モンテ","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":1.6,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/モンテ.png"},{"name":"ポイハナ","stats":{"speed_onroad":1.2,"speed_dirt":1.2,"speed_underwater":1.4,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ポイハナ.png"},{"name":"パタテンテン","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/パタテンテン.png"},{"name":"バサバサ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/バサバサ.png"},{"name":"パックンフラワー","stats":{"speed_onroad":1.4,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":1,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/パックンフラワー.png"},{"name":"プー","stats":{"speed_onroad":1.2,"speed_dirt":1,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":1.2,"handling_dirt":0.8,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/プー.png"},{"name":"チョロプー","stats":{"speed_onroad":0.8,"speed_dirt":1,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1.4,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/チョロプー.png"},{"name":"サンボ","stats":{"speed_onroad":1,"speed_dirt":1.2,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":1.2,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/サンボ.png"},{"name":"フィッシュボーン","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.6,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.8},"imageUrl":"/myApps/img/marioKart/characters/フィッシュボーン.png"},{"name":"テレン","stats":{"speed_onroad":0.4,"speed_dirt":0.6,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.8,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/テレン.png"},{"name":"リフトン","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/リフトン.png"},{"name":"ゆきだるま","stats":{"speed_onroad":1.4,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":1,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/ゆきだるま.png"},{"name":"ツッコンドル","stats":{"speed_onroad":1.2,"speed_dirt":1.4,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":1,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/ツッコンドル.png"}];
        const kartsData = [{"name":"スタンダードカート","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1,"acceleration":1,"weight":0.4,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/スタンダードカート.png"},{"name":"リボンクラシカル","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1,"acceleration":1,"weight":0.4,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/リボンクラシカル.png"},{"name":"ファイアチャージャー","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/ファイアチャージャー.png"},{"name":"ロイヤルターボ","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/ロイヤルターボ.png"},{"name":"Bダッシュ","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/Bダッシュ.png"},{"name":"マッハクイーン","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/マッハクイーン.png"},{"name":"タートルバギー","stats":{"speed_onroad":0.8,"speed_dirt":1.6,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":1.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/タートルバギー.png"},{"name":"ラリーカート","stats":{"speed_onroad":0.8,"speed_dirt":1.6,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":1.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/ラリーカート.png"},{"name":"ケロケロード","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/ケロケロード.png"},{"name":"スーパーカーペット","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/スーパーカーペット.png"},{"name":"H₂O","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/H₂O.png"},{"name":"コゲッソー","stats":{"speed_onroad":1.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.2,"weight":0.2,"handling_onroad":1.8,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/コゲッソー.png"},{"name":"スチームバイク","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.2,"weight":0.2,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/スチームバイク.png"},{"name":"ビッグブル","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/ビッグブル.png"},{"name":"ホットラリー","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/ホットラリー.png"},{"name":"トイダンプ","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/トイダンプ.png"},{"name":"バウザーバギー","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/バウザーバギー.png"},{"name":"メカクッパ","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":2,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":0.2,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/メカクッパ.png"},{"name":"スタンダードバイク","stats":{"speed_onroad":0.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.8,"weight":0,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/スタンダードバイク.png"},{"name":"カラフルスクーター","stats":{"speed_onroad":0.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.8,"weight":0,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/カラフルスクーター.png"},{"name":"レディオライド","stats":{"speed_onroad":0.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.8,"weight":0,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/レディオライド.png"},{"name":"ドカンバイク","stats":{"speed_onroad":0,"speed_dirt":1,"speed_underwater":0,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ドカンバイク.png"},{"name":"ラリーバイク","stats":{"speed_onroad":0,"speed_dirt":1,"speed_underwater":0,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ラリーバイク.png"},{"name":"こいのぼり","stats":{"speed_onroad":0,"speed_dirt":0,"speed_underwater":1,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":2},"imageUrl":"/myApps/img/marioKart/karts/こいのぼり.png"},{"name":"ドルフィンキック","stats":{"speed_onroad":0,"speed_dirt":0,"speed_underwater":1,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":2},"imageUrl":"/myApps/img/marioKart/karts/ドルフィンキック.png"},{"name":"マッハレーサー","stats":{"speed_onroad":1.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.4,"weight":0,"handling_onroad":2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/マッハレーサー.png"},{"name":"FCロボットバイク","stats":{"speed_onroad":1.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.4,"weight":0,"handling_onroad":2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/FCロボットバイク.png"},{"name":"ドッシーウェーブ","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.2,"handling_dirt":0.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ドッシーウェーブ.png"},{"name":"パタテンテン","stats":{"speed_onroad":0.2,"speed_dirt":1.2,"speed_underwater":0.2,"acceleration":1.4,"weight":0.2,"handling_onroad":1,"handling_dirt":1.8,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/パタテンテン.png"},{"name":"Wチョッパー","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":1.4,"acceleration":0.6,"weight":0.4,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/Wチョッパー.png"},{"name":"ファイアモービル","stats":{"speed_onroad":0.6,"speed_dirt":1.8,"speed_underwater":1,"acceleration":0.6,"weight":0.6,"handling_onroad":0.6,"handling_dirt":1.8,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ファイアモービル.png"},{"name":"ベルトライク","stats":{"speed_onroad":1.6,"speed_dirt":1.6,"speed_underwater":1.6,"acceleration":0.6,"weight":0.8,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/karts/ベルトライク.png"},{"name":"ローブスター","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":2,"acceleration":0.2,"weight":1,"handling_onroad":0,"handling_dirt":0,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/ローブスター.png"},{"name":"スターモービル","stats":{"speed_onroad":1.2,"speed_dirt":1.6,"speed_underwater":2.2,"acceleration":0,"weight":1,"handling_onroad":0.2,"handling_dirt":0.4,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/スターモービル.png"},{"name":"ムービースター","stats":{"speed_onroad":1.6,"speed_dirt":1.6,"speed_underwater":1.6,"acceleration":0.4,"weight":0.6,"handling_onroad":0.8,"handling_dirt":0.8,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/karts/ムービースター.png"},{"name":"サファリカーゴ","stats":{"speed_onroad":1.8,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":0.4,"weight":1,"handling_onroad":1.4,"handling_dirt":0.2,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/サファリカーゴ.png"},{"name":"キラーヘッド","stats":{"speed_onroad":1.8,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":0.4,"weight":1,"handling_onroad":1.4,"handling_dirt":0.2,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/キラーヘッド.png"},{"name":"イグニッション","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1,"acceleration":1.2,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/イグニッション.png"},{"name":"スケルトン","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.6,"weight":0.2,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/スケルトン.png"},{"name":"ラリーゲイター","stats":{"speed_onroad":1.8,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":0.6,"weight":1.2,"handling_onroad":1,"handling_dirt":0,"handling_underwater":0},"imageUrl":"/myApps/img/marioKart/karts/ラリーゲイター.png"}];
        console.log('charactersData loaded:', charactersData);
        console.log('kartsData loaded:', kartsData);


        // 新しいステータスラベルを定義 (これは計算とスライダー用なので変更なし)
        const statLabels = {
            'speed_onroad': 'スピード（舗装路）',
            'speed_dirt': 'スピード（悪路）',
            'speed_underwater': 'スピード（水上）',
            'acceleration': 'かそく',
            'weight': 'おもさ',
            'handling_onroad': 'まがりやすさ（舗装路）',
            'handling_dirt': 'まがりやすさ（悪路）',
            'handling_underwater': 'まがりやすさ（水上）'
        };
        const statsToOptimize = Object.keys(statLabels); // 最適化対象のステータスキーのリスト

        // 表示用のステータスラベルと順序を定義
        const displayStatLabels = {
            'speed': 'スピード',
            'acceleration': 'かそく',
            'weight': 'おもさ',
            'handling': 'まがりやすさ'
        };

        const displayStatOrder = [
            'speed', 'acceleration', 'weight', 'handling'
        ];

        let weights = {}; // 各ステータスの比重を保持するオブジェクト
        let selectedFilterCharacter = 'すべて';
        let selectedFilterKart = 'すべて';
        
        // statFilters を window オブジェクトのプロパティとして明示的に定義
        window.statFilters = {}; // 各ステータスの最小値・最大値を保持するオブジェクト
        console.log('window.statFilters initialized:', window.statFilters); // デバッグログ


        // 初期比重をすべて1に設定し、スライダーを生成
        function initializeWeightsAndSliders() {
            const weightsControls = document.getElementById('weights-controls');
            weightsControls.innerHTML = ''; // 既存のスライダーをクリア

            statsToOptimize.forEach(statKey => {
                weights[statKey] = 1; // 初期値はすべて1

                const sliderGroup = document.createElement('div');
                sliderGroup.classList.add('slider-group');

                const label = document.createElement('label');
                label.textContent = statLabels[statKey];
                sliderGroup.appendChild(label);

                const slider = document.createElement('input');
                slider.type = 'range';
                slider.min = '0';
                slider.max = '10';
                slider.value = weights[statKey];
                slider.id = `slider-${statKey}`;
                sliderGroup.appendChild(slider);

                const valueSpan = document.createElement('span');
                valueSpan.textContent = weights[statKey];
                valueSpan.id = `value-${statKey}`;
                sliderGroup.appendChild(valueSpan);

                slider.addEventListener('input', (event) => {
                    weights[statKey] = parseInt(event.target.value);
                    valueSpan.textContent = weights[statKey];
                });

                weightsControls.appendChild(sliderGroup);
            });
        }

        /**
         * キャラクターとマシンのフィルタードロップダウン、および数値フィルターを生成します。
         */
        function createFilterDropdowns() {
            console.log('Inside createFilterDropdowns. window.statFilters before forEach:', window.statFilters); // デバッグログ

            const characterFilter = document.getElementById('character-filter');
            const kartFilter = document.getElementById('kart-filter');
            const filterControls = document.getElementById('filter-controls');

            // 数値フィルターのみをクリアするように変更
            const existingStatFilters = filterControls.querySelectorAll('.filter-group:not(#character-filter-group):not(#kart-filter-group)');
            existingStatFilters.forEach(group => group.remove());

            // キャラクターフィルターのオプションを生成
            // 初回ロード時のみ生成し、それ以外は既存の要素を使用
            if (characterFilter.options.length === 0) {
                let allCharOption = document.createElement('option');
                allCharOption.value = 'すべて';
                allCharOption.textContent = 'すべて';
                characterFilter.appendChild(allCharOption);
                charactersData.forEach(char => {
                    let option = document.createElement('option');
                    option.value = char.name;
                    option.textContent = char.name;
                    characterFilter.appendChild(option);
                });
            }

            // マシンフィルターのオプションを生成
            // 初回ロード時のみ生成し、それ以外は既存の要素を使用
            if (kartFilter.options.length === 0) {
                let allKartOption = document.createElement('option');
                allKartOption.value = 'すべて';
                allKartOption.textContent = 'すべて';
                kartFilter.appendChild(allKartOption);
                kartsData.forEach(kart => {
                    let option = document.createElement('option');
                    option.value = kart.name;
                    option.textContent = kart.name;
                    kartFilter.appendChild(option);
                });
            }

            // フィルター変更時のイベントリスナー
            // イベントリスナーが重複して設定されないように注意
            if (!characterFilter.dataset.listenerAttached) {
                characterFilter.addEventListener('change', (event) => {
                    selectedFilterCharacter = event.target.value;
                    calculateAndRenderResults(); // フィルター変更時に結果を再計算・再描画
                });
                characterFilter.dataset.listenerAttached = 'true';
            }

            if (!kartFilter.dataset.listenerAttached) {
                kartFilter.addEventListener('change', (event) => {
                    selectedFilterKart = event.target.value;
                    calculateAndRenderResults(); // フィルター変更時に結果を再計算・再描画
                });
                kartFilter.dataset.listenerAttached = 'true';
            }

            // 数値フィルターの初期化と生成
            statsToOptimize.forEach((statKey, index) => {
                window.statFilters[statKey] = { min: '', max: '' }; // 初期値は空

                const filterGroup = document.createElement('div');
                filterGroup.classList.add('filter-group');
                filterGroup.innerHTML = `
                    <label>${statLabels[statKey]}:</label>
                    <input type="number" id="min-${statKey}" placeholder="最小" style="width: 70px;" step="0.1">
                    <span>〜</span>
                    <input type="number" id="max-${statKey}" placeholder="最大" style="width: 70px;" step="0.1">
                `;
                // 改行要素の直後に挿入するように変更
                filterControls.appendChild(filterGroup);

                // 特定のフィルターの後に改行を追加してレイアウトを調整
                if (statKey === 'speed_underwater' || statKey === 'weight') {
                    const filterBreak = document.createElement('div');
                    filterBreak.classList.add('filter-break');
                    filterControls.appendChild(filterBreak);
                }

                // イベントリスナーを設定
                document.getElementById(`min-${statKey}`).addEventListener('input', (event) => {
                    window.statFilters[statKey].min = event.target.value !== '' ? parseFloat(event.target.value) : '';
                    calculateAndRenderResults();
                });
                document.getElementById(`max-${statKey}`).addEventListener('input', (event) => {
                    window.statFilters[statKey].max = event.target.value !== '' ? parseFloat(event.target.value) : '';
                    calculateAndRenderResults();
                });
            });
        }

        /**
         * フィルタードロップダウンと数値フィルターの選択をリセットします。
         */
        function resetFilterDropdowns() {
            document.getElementById('character-filter').value = 'すべて';
            document.getElementById('kart-filter').value = 'すべて';
            selectedFilterCharacter = 'すべて';
            selectedFilterKart = 'すべて';

            // 数値フィルターをリセット
            statsToOptimize.forEach(statKey => {
                document.getElementById(`min-${statKey}`).value = '';
                document.getElementById(`max-${statKey}`).value = '';
                window.statFilters[statKey].min = '';
                window.statFilters[statKey].max = '';
            });
        }

        /**
         * 2つの組み合わせを比較し、combAがcombBを支配するかどうかを判断します。
         * 支配とは、すべてのステータスでcombAがcombBと同等以上であり、かつ少なくとも1つのステータスでcombAがcombBより優れていることを意味します。
         *
         * @param {Object} combA - 最初の組み合わせ（キャラクターとマシンの合計ステータス）
         * @param {Object} combB - 2番目の組み合わせ（キャラクターとマシンの合計ステータス）
         * @returns {boolean} combAがcombBを支配する場合はtrue、そうでない場合はfalse
         */
        function dominates(combA, combB) {
            let isBetterInAtLeastOne = false;
            for (const stat of statsToOptimize) {
                // 重み付けされたステータスを比較
                const weightedStatA = combA.totalStats[stat] * weights[stat];
                const weightedStatB = combB.totalStats[stat] * weights[stat];

                if (weightedStatA < weightedStatB) {
                    // combAがcombBより少なくとも1つのステータスで劣っていれば支配しない
                    return false;
                }
                if (weightedStatA > weightedStatB) {
                    // combAがcombBより少なくとも1つのステータスで優れていればフラグを立てる
                    isBetterInAtLeastOne = true;
                }
            }
            // すべてのステータスで同等以上であり、少なくとも1つのステータスで優れている場合に支配する
            return isBetterInAtLeastOne;
        }

        /**
         * パレート最適組み合わせを計算します。
         * @param {Array} combinations - すべてのキャラクターとマシンの組み合わせ配列
         * @returns {Array} パレート最適組み合わせの配列
         */
        function findParetoOptimal(combinations) {
            const paretoFront = [];

            combinations.forEach(currentComb => {
                let isDominated = false;
                // 現在の組み合わせが既存のパレート集合のいずれかの組み合わせに支配されているかチェック
                for (let i = 0; i < paretoFront.length; i++) {
                    const existingParetoComb = paretoFront[i];
                    if (dominates(existingParetoComb, currentComb)) {
                        isDominated = true;
                        break;
                    }
                }

                if (!isDominated) {
                    // 現在の組み合わせが支配されていなければ、それをパレート集合に追加
                    // そして、現在の組み合わせによって支配される既存のパレート集合の組み合わせを削除
                    const newParetoFront = [];
                    paretoFront.forEach(existingParetoComb => {
                        if (!dominates(currentComb, existingParetoComb)) {
                            newParetoFront.push(existingParetoComb);
                        }
                    });
                    newParetoFront.push(currentComb);
                    // paretoFrontを更新
                    paretoFront.splice(0, paretoFront.length, ...newParetoFront);
                }
            });

            return paretoFront;
        }

        /**
         * すべてのキャラクターとマシンの組み合わせを生成し、合計ステータスを計算します。
         * フィルタリングが適用されている場合は、その条件に従います。
         * @returns {Array} すべての組み合わせの配列
         */
        function generateAllCombinations() {
            let allCombinations = [];
            
            // フィルターに基づいてキャラクターを絞り込み
            const charactersToProcess = selectedFilterCharacter === 'すべて'
                ? charactersData
                : charactersData.filter(char => char.name === selectedFilterCharacter);

            // フィルターに基づいてマシンを絞り込み
            const kartsToProcess = selectedFilterKart === 'すべて'
                ? kartsData
                : kartsData.filter(kart => kart.name === selectedFilterKart);

            charactersToProcess.forEach(character => {
                kartsToProcess.forEach(kart => {
                    const totalStats = {};
                    let totalWeightedScore = 0; // 新しい加重合計スコア
                    let passesStatFilters = true; // 数値フィルターの通過フラグ

                    for (const stat of statsToOptimize) {
                        // キャラクターとマシンのステータスを合算
                        totalStats[stat] = (character.stats[stat] || 0.0) + (kart.stats[stat] || 0.0);

                        // 数値フィルターを適用
                        const min = window.statFilters[stat].min; // window.statFilters を使用
                        const max = window.statFilters[stat].max; // window.statFilters を使用
                        if ((min !== '' && totalStats[stat] < min) || (max !== '' && totalStats[stat] > max)) {
                            passesStatFilters = false;
                            break; // 1つでも条件を満たさない場合はループを終了
                        }

                        // 加重スコアを計算に加える
                        totalWeightedScore += totalStats[stat] * (weights[stat] || 1);
                    }

                    if (passesStatFilters) {
                        allCombinations.push({
                            character: character,
                            kart: kart,
                            totalStats: totalStats,
                            totalWeightedScore: totalWeightedScore // 加重合計スコアを保存
                        });
                    }
                });
            });
            return allCombinations;
        }

        /**
         * 結果を表示コンテナにレンダリングします。
         * @param {Array} combinations - 表示する組み合わせの配列
         */
        function renderResults(combinations) {
            const resultsContainer = document.getElementById('pareto-combinations');
            resultsContainer.innerHTML = ''; // 既存の結果をクリア

            if (combinations.length === 0) {
                resultsContainer.innerHTML = '<p class="no-results">選択された比重とフィルター条件ではパレート最適解が見つかりませんでした。比重やフィルターを変更してお試しください。</p>';
                return;
            }

            // 加重合計スコアで降順ソート
            combinations.sort((a, b) => b.totalWeightedScore - a.totalWeightedScore);

            // 上位100件に限定
            const top100Combinations = combinations.slice(0, 100);

            const table = document.createElement('table');
            table.classList.add('results-table'); // スタイリング用のクラスを追加

            // テーブルヘッダーの作成
            const thead = document.createElement('thead');
            // 1行目のヘッダー
            const headerRow1 = document.createElement('tr');
            headerRow1.innerHTML = `
                <th rowspan="2">順位</th>
                <th rowspan="2">キャラクター</th>
                <th rowspan="2">マシン</th>
                <th rowspan="2">評価値</th>
                <th colspan="3">スピード</th>
                <th rowspan="2">かそく</th>
                <th rowspan="2">おもさ</th>
                <th colspan="3">まがりやすさ</th>
            `;
            thead.appendChild(headerRow1);

            // 2行目のヘッダー（スピードとまがりやすさのサブ項目）
            const headerRow2 = document.createElement('tr');
            headerRow2.innerHTML = `
                <th>舗装路</th>
                <th>悪路</th>
                <th>水上</th>
                <th>舗装路</th>
                <th>悪路</th>
                <th>水上</th>
            `;
            thead.appendChild(headerRow2);
            table.appendChild(thead);

            // テーブルボディの作成
            const tbody = document.createElement('tbody');
            top100Combinations.forEach((combination, index) => { // indexを追加
                const row = document.createElement('tr');

                // 順位のセルを追加
                const tdRank = document.createElement('td');
                tdRank.textContent = index + 1; // 0始まりなので+1
                tdRank.setAttribute('data-label', '順位'); // モバイル表示用
                row.appendChild(tdRank);

                const tdChar = document.createElement('td');
                tdChar.textContent = combination.character.name;
                tdChar.setAttribute('data-label', 'キャラクター'); // モバイル表示用
                row.appendChild(tdChar);

                const tdKart = document.createElement('td');
                tdKart.textContent = combination.kart.name;
                tdKart.setAttribute('data-label', 'マシン'); // モバイル表示用
                row.appendChild(tdKart);

                // 評価値のセルを追加 (小数点以下2桁まで表示)
                const tdScore = document.createElement('td');
                tdScore.textContent = combination.totalWeightedScore.toFixed(2);
                tdScore.setAttribute('data-label', '評価値'); // モバイル表示用
                row.appendChild(tdScore);

                // スピードのサブ項目
                const tdSpeedOnroad = document.createElement('td');
                tdSpeedOnroad.textContent = combination.totalStats['speed_onroad'].toFixed(1);
                tdSpeedOnroad.setAttribute('data-label', 'スピード（舗装路）');
                row.appendChild(tdSpeedOnroad);

                const tdSpeedDirt = document.createElement('td');
                tdSpeedDirt.textContent = combination.totalStats['speed_dirt'].toFixed(1);
                tdSpeedDirt.setAttribute('data-label', 'スピード（悪路）');
                row.appendChild(tdSpeedDirt);

                const tdSpeedUnderwater = document.createElement('td');
                tdSpeedUnderwater.textContent = combination.totalStats['speed_underwater'].toFixed(1);
                tdSpeedUnderwater.setAttribute('data-label', 'スピード（水上）');
                row.appendChild(tdSpeedUnderwater);

                // かそく
                const tdAcceleration = document.createElement('td');
                tdAcceleration.textContent = combination.totalStats['acceleration'].toFixed(1);
                tdAcceleration.setAttribute('data-label', 'かそく');
                row.appendChild(tdAcceleration);

                // おもさ
                const tdWeight = document.createElement('td');
                tdWeight.textContent = combination.totalStats['weight'].toFixed(1);
                tdWeight.setAttribute('data-label', 'おもさ');
                row.appendChild(tdWeight);

                // まがりやすさのサブ項目
                const tdHandlingOnroad = document.createElement('td');
                tdHandlingOnroad.textContent = combination.totalStats['handling_onroad'].toFixed(1);
                tdHandlingOnroad.setAttribute('data-label', 'まがりやすさ（舗装路）');
                row.appendChild(tdHandlingOnroad);

                const tdHandlingDirt = document.createElement('td');
                tdHandlingDirt.textContent = combination.totalStats['handling_dirt'].toFixed(1);
                tdHandlingDirt.setAttribute('data-label', 'まがりやすさ（悪路）');
                row.appendChild(tdHandlingDirt);

                const tdHandlingUnderwater = document.createElement('td');
                tdHandlingUnderwater.textContent = combination.totalStats['handling_underwater'].toFixed(1);
                tdHandlingUnderwater.setAttribute('data-label', 'まがりやすさ（水上）');
                row.appendChild(tdHandlingUnderwater);

                tbody.appendChild(row);
            });
            table.appendChild(tbody);
            resultsContainer.appendChild(table);
        }

        /**
         * パレート最適組み合わせの計算と結果のレンダリングを統合した関数。
         * スライダーやフィルター変更時に呼び出されます。
         */
        function calculateAndRenderResults() {
            console.log('Calculating and rendering results...');
            const allCombinations = generateAllCombinations();
            console.log('Generated all combinations:', allCombinations);
            const paretoOptimalCombinations = findParetoOptimal(allCombinations);
            console.log('Found pareto optimal combinations:', paretoOptimalCombinations);
            renderResults(paretoOptimalCombinations);
        }

        // イベントリスナーの設定
        document.addEventListener('DOMContentLoaded', () => {
            initializeWeightsAndSliders(); // スライダーの初期化
            createFilterDropdowns(); // フィルタードロップダウンの生成とイベントリスナー設定

            // sessionStorageからprefilledMinStatsを読み込み、フィルターに反映
            const prefilledMinStats = sessionStorage.getItem('prefilledMinStats');
            if (prefilledMinStats) {
                const stats = JSON.parse(prefilledMinStats);
                statsToOptimize.forEach(statKey => {
                    const minInput = document.getElementById(`min-${statKey}`);
                    if (minInput && stats[statKey] !== undefined) {
                        minInput.value = stats[statKey];
                        window.statFilters[statKey].min = stats[statKey]; // window.statFilters を使用
                    }
                });
                sessionStorage.removeItem('prefilledMinStats'); // 使用後クリア
            }

            // ページロード時の初期計算とレンダリング
            calculateAndRenderResults();
            
            // 計算ボタンクリック時のイベントリスナー
            document.getElementById('calculate-button').addEventListener('click', calculateAndRenderResults);

            // リセットボタンクリック時のイベントリスナー
            document.getElementById('reset-button').addEventListener('click', () => {
                // スライダーを初期値にリセット
                statsToOptimize.forEach(statKey => {
                    weights[statKey] = 1;
                    document.getElementById(`slider-${statKey}`).value = 1;
                    document.getElementById(`value-${statKey}`).textContent = 1;
                });

                // フィルターを初期値にリセット
                resetFilterDropdowns();

                // 結果を再計算・再描画
                calculateAndRenderResults();
            });
        });
    </script>
</body>
</html>




<p></p>



<h2 class="wp-block-heading">概要</h2>



<p>ステータスの比重を決めることで、パレート最適によりキャラクターとマシンの組み合わせを評価し一覧表示します</p>



<p>にじさんじシェリンさんが動画で使っていたツールのパクリです</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="【マリカワールド】どのカスタムが強いんじゃ【シェリン/にじさんじ】" width="1256" height="707" src="https://www.youtube.com/embed/Lm4nCxdvT4A?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<h2 class="wp-block-heading">更新履歴</h2>



<p><strong><strong>2025/8/</strong>15</strong></p>



<ul class="wp-block-list">
<li>ラリーバイクとドカンバイクのまがりやすさ(舗装路)の値を修正</li>
</ul>



<p><strong>2025/8/2</strong></p>



<ul class="wp-block-list">
<li>データソースを以下に変更<br><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1BtHeFAEwL1MLND-l7KZz_Zg4wZWC2YIikbyweocqwSs/edit?gid=555944039#gid=555944039">https://docs.google.com/spreadsheets/d/1BtHeFAEwL1MLND-l7KZz_Zg4wZWC2YIikbyweocqwSs/edit?gid=555944039#gid=555944039<span class="fa fa-external-link external-icon anchor-icon"></span></a></li>
</ul>



<p><strong>2025/7/16</strong></p>



<ul class="wp-block-list">
<li>キャラクターのまがりやすさを最新の値に更新</li>
</ul>



<p><strong>2025/7/10</strong></p>



<ul class="wp-block-list">
<li>データソースを<a rel="noopener" target="_blank" href="https://japan-mk.blog.jp/mkworld.st-c">https://japan-mk.blog.jp/mkworld.st-c<span class="fa fa-external-link external-icon anchor-icon"></span></a>に変更</li>



<li>まがりやすさについても道路別のステータスを表示するように変更</li>
</ul>



<p><strong>2025/6/21</strong></p>



<ul class="wp-block-list">
<li>初版</li>



<li>データソースは<a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1t3BeXH3shj6Rh7x0ROFD81ZBxyumQFs9pebbnYcfWi4/edit?pli=1&amp;gid=735843013#gid=735843013">https://docs.google.com/spreadsheets/d/1t3BeXH3shj6Rh7x0ROFD81ZBxyumQFs9pebbnYcfWi4/edit?pli=1&amp;gid=735843013#gid=735843013<span class="fa fa-external-link external-icon anchor-icon"></span></a></li>
</ul>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://tt0.link/mario_kart_w-pareto/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>マリオカートワールドステータス計算ツール</title>
		<link>https://tt0.link/mario_kart_w-stats/</link>
					<comments>https://tt0.link/mario_kart_w-stats/#respond</comments>
		
		<dc:creator><![CDATA[つっちー]]></dc:creator>
		<pubDate>Fri, 20 Jun 2025 11:45:15 +0000</pubDate>
				<category><![CDATA[ツール]]></category>
		<category><![CDATA[マリオカート]]></category>
		<guid isPermaLink="false">https://tt0.link/?p=924</guid>

					<description><![CDATA[概要 にじさんじシェリンさんが動画で使っていたツールのパクリです 更新履歴 2025/8/15 2025/8/2 2025/7/24 2025/7/16 2025/7/10 2025/6/20]]></description>
										<content:encoded><![CDATA[
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>マリオカート - 組み合わせ比較ツール</title>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link rel="stylesheet" href="/myApps/css/marioKart/status.css">
    <style>

    </style>
</head>
<body>
    <div class="main-container">
        <div class="comparison-controls">
            <div id="comparison-slots-container" class="comparison-slots">
                <!-- Comparison slots will be dynamically inserted here -->
            </div>
        </div>

        <div class="chart-area">
            <h2 class="section-title">合計ステータス比較</h2>
            <div class="chart-container">
                <canvas id="statsChart"></canvas>
            </div>
        </div>
    </div>

    <!-- Popup Modal -->
    <div id="selection-popup" class="popup-overlay" style="display: none;">
        <div class="popup-content">
            <h3 id="popup-title"></h3>
            <div id="popup-grid" class="popup-grid"></div>
            <button id="close-popup" class="popup-close-button">閉じる</button>
        </div>
    </div>

    <script>
        // PHPから渡されたデータをJavaScript変数に代入
        const charactersData = [{"name":"マリオ","stats":{"speed_onroad":1.2,"speed_dirt":1,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":1.2,"handling_dirt":0.8,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/マリオ.png"},{"name":"ルイージ","stats":{"speed_onroad":1,"speed_dirt":1.2,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":1.2,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/ルイージ.png"},{"name":"ピーチ","stats":{"speed_onroad":1,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1.4,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ピーチ.png"},{"name":"デイジー","stats":{"speed_onroad":1,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1.4,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/デイジー.png"},{"name":"ヨッシー","stats":{"speed_onroad":0.8,"speed_dirt":1,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1.4,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ヨッシー.png"},{"name":"キノピオ","stats":{"speed_onroad":0.6,"speed_dirt":0.8,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.6,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/キノピオ.png"},{"name":"ノコノコ","stats":{"speed_onroad":0.6,"speed_dirt":0.6,"speed_underwater":0.8,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ノコノコ.png"},{"name":"クッパ","stats":{"speed_onroad":1.6,"speed_dirt":1.6,"speed_underwater":1.6,"acceleration":0.6,"weight":2,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/クッパ.png"},{"name":"ワリオ","stats":{"speed_onroad":1.6,"speed_dirt":1.4,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.8,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ワリオ.png"},{"name":"ワルイージ","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":1.6,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/ワルイージ.png"},{"name":"ロゼッタ","stats":{"speed_onroad":1.2,"speed_dirt":1.2,"speed_underwater":1.4,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ロゼッタ.png"},{"name":"ポリーン","stats":{"speed_onroad":1.4,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":1,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/ポリーン.png"},{"name":"ベビィマリオ","stats":{"speed_onroad":0.6,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.8,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/ベビィマリオ.png"},{"name":"ベビィルイージ","stats":{"speed_onroad":0.4,"speed_dirt":0.6,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.8,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/ベビィルイージ.png"},{"name":"ベビィピーチ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ベビィピーチ.png"},{"name":"ベビィデイジー","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ベビィデイジー.png"},{"name":"ジュゲム","stats":{"speed_onroad":0.6,"speed_dirt":0.6,"speed_underwater":0.8,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/ジュゲム.png"},{"name":"キノピコ","stats":{"speed_onroad":0.8,"speed_dirt":0.6,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.6,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/キノピコ.png"},{"name":"クッパJr.","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/クッパJr..png"},{"name":"ベビィロゼッタ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.6,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.8},"imageUrl":"/myApps/img/marioKart/characters/ベビィロゼッタ.png"},{"name":"キャサリン","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1.2,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":0.8,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/キャサリン.png"},{"name":"キングテレサ","stats":{"speed_onroad":1.2,"speed_dirt":1.4,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":1,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/キングテレサ.png"},{"name":"ヘイホー","stats":{"speed_onroad":0.6,"speed_dirt":0.8,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.6,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/ヘイホー.png"},{"name":"ドンキーコング","stats":{"speed_onroad":1.4,"speed_dirt":1.6,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.8,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ドンキーコング.png"},{"name":"トッテン","stats":{"speed_onroad":0.8,"speed_dirt":0.6,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.6,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/トッテン.png"},{"name":"ハナチャン","stats":{"speed_onroad":1.6,"speed_dirt":1.4,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.8,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ハナチャン.png"},{"name":"クリボー","stats":{"speed_onroad":0.6,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.8,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/クリボー.png"},{"name":"ウシ","stats":{"speed_onroad":1.4,"speed_dirt":1.6,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.8,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ウシ.png"},{"name":"カロン","stats":{"speed_onroad":0.4,"speed_dirt":0.6,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.8,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/カロン.png"},{"name":"ハンマーブロス","stats":{"speed_onroad":1,"speed_dirt":1.2,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":1.2,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/ハンマーブロス.png"},{"name":"カニ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.6,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.8},"imageUrl":"/myApps/img/marioKart/characters/カニ.png"},{"name":"ガマネー","stats":{"speed_onroad":1,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1.4,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ガマネー.png"},{"name":"プクプク","stats":{"speed_onroad":0.6,"speed_dirt":0.6,"speed_underwater":0.8,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/プクプク.png"},{"name":"ガボン","stats":{"speed_onroad":0.6,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.8,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/ガボン.png"},{"name":"ペンギン","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1.2,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":0.8,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/ペンギン.png"},{"name":"ブル","stats":{"speed_onroad":1.4,"speed_dirt":1.6,"speed_underwater":1.4,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.8,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/characters/ブル.png"},{"name":"ハッチン","stats":{"speed_onroad":0.6,"speed_dirt":0.8,"speed_underwater":0.6,"acceleration":1.6,"weight":1,"handling_onroad":1.2,"handling_dirt":1.6,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/characters/ハッチン.png"},{"name":"モンテ","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":1.6,"acceleration":0.8,"weight":1.8,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/モンテ.png"},{"name":"ポイハナ","stats":{"speed_onroad":1.2,"speed_dirt":1.2,"speed_underwater":1.4,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/ポイハナ.png"},{"name":"パタテンテン","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/パタテンテン.png"},{"name":"バサバサ","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":2,"weight":0.6,"handling_onroad":1.6,"handling_dirt":1.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/characters/バサバサ.png"},{"name":"パックンフラワー","stats":{"speed_onroad":1.4,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":1,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/パックンフラワー.png"},{"name":"プー","stats":{"speed_onroad":1.2,"speed_dirt":1,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":1.2,"handling_dirt":0.8,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/プー.png"},{"name":"チョロプー","stats":{"speed_onroad":0.8,"speed_dirt":1,"speed_underwater":0.8,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1.4,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/characters/チョロプー.png"},{"name":"サンボ","stats":{"speed_onroad":1,"speed_dirt":1.2,"speed_underwater":1,"acceleration":1.2,"weight":1.4,"handling_onroad":0.8,"handling_dirt":1.2,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/characters/サンボ.png"},{"name":"フィッシュボーン","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.6,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.8},"imageUrl":"/myApps/img/marioKart/characters/フィッシュボーン.png"},{"name":"テレン","stats":{"speed_onroad":0.4,"speed_dirt":0.6,"speed_underwater":0.4,"acceleration":1.8,"weight":0.8,"handling_onroad":1.4,"handling_dirt":1.8,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/テレン.png"},{"name":"リフトン","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1,"acceleration":1.4,"weight":1.2,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/characters/リフトン.png"},{"name":"ゆきだるま","stats":{"speed_onroad":1.4,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":1,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/ゆきだるま.png"},{"name":"ツッコンドル","stats":{"speed_onroad":1.2,"speed_dirt":1.4,"speed_underwater":1.2,"acceleration":1,"weight":1.6,"handling_onroad":0.6,"handling_dirt":1,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/characters/ツッコンドル.png"}];
        const kartsData = [{"name":"スタンダードカート","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1,"acceleration":1,"weight":0.4,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/スタンダードカート.png"},{"name":"リボンクラシカル","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1,"acceleration":1,"weight":0.4,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/リボンクラシカル.png"},{"name":"ファイアチャージャー","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/ファイアチャージャー.png"},{"name":"ロイヤルターボ","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/ロイヤルターボ.png"},{"name":"Bダッシュ","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/Bダッシュ.png"},{"name":"マッハクイーン","stats":{"speed_onroad":1.6,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":1.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/マッハクイーン.png"},{"name":"タートルバギー","stats":{"speed_onroad":0.8,"speed_dirt":1.6,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":1.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/タートルバギー.png"},{"name":"ラリーカート","stats":{"speed_onroad":0.8,"speed_dirt":1.6,"speed_underwater":0.8,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":1.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/ラリーカート.png"},{"name":"ケロケロード","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/ケロケロード.png"},{"name":"スーパーカーペット","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/スーパーカーペット.png"},{"name":"H₂O","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/H₂O.png"},{"name":"コゲッソー","stats":{"speed_onroad":1.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.2,"weight":0.2,"handling_onroad":1.8,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/コゲッソー.png"},{"name":"スチームバイク","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":0.8,"acceleration":1.2,"weight":0.2,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/スチームバイク.png"},{"name":"ビッグブル","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/ビッグブル.png"},{"name":"ホットラリー","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/ホットラリー.png"},{"name":"トイダンプ","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/トイダンプ.png"},{"name":"バウザーバギー","stats":{"speed_onroad":1.4,"speed_dirt":2,"speed_underwater":1.4,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":1.4,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/バウザーバギー.png"},{"name":"メカクッパ","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":2,"acceleration":0.2,"weight":1,"handling_onroad":0.2,"handling_dirt":0.2,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/メカクッパ.png"},{"name":"スタンダードバイク","stats":{"speed_onroad":0.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.8,"weight":0,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/スタンダードバイク.png"},{"name":"カラフルスクーター","stats":{"speed_onroad":0.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.8,"weight":0,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/カラフルスクーター.png"},{"name":"レディオライド","stats":{"speed_onroad":0.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.8,"weight":0,"handling_onroad":1.4,"handling_dirt":1.4,"handling_underwater":1.4},"imageUrl":"/myApps/img/marioKart/karts/レディオライド.png"},{"name":"ドカンバイク","stats":{"speed_onroad":0,"speed_dirt":1,"speed_underwater":0,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ドカンバイク.png"},{"name":"ラリーバイク","stats":{"speed_onroad":0,"speed_dirt":1,"speed_underwater":0,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ラリーバイク.png"},{"name":"こいのぼり","stats":{"speed_onroad":0,"speed_dirt":0,"speed_underwater":1,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":2},"imageUrl":"/myApps/img/marioKart/karts/こいのぼり.png"},{"name":"ドルフィンキック","stats":{"speed_onroad":0,"speed_dirt":0,"speed_underwater":1,"acceleration":1.6,"weight":0,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":2},"imageUrl":"/myApps/img/marioKart/karts/ドルフィンキック.png"},{"name":"マッハレーサー","stats":{"speed_onroad":1.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.4,"weight":0,"handling_onroad":2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/マッハレーサー.png"},{"name":"FCロボットバイク","stats":{"speed_onroad":1.2,"speed_dirt":0.2,"speed_underwater":0.2,"acceleration":1.4,"weight":0,"handling_onroad":2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/FCロボットバイク.png"},{"name":"ドッシーウェーブ","stats":{"speed_onroad":0.8,"speed_dirt":0.8,"speed_underwater":1.6,"acceleration":0.8,"weight":0.6,"handling_onroad":0.2,"handling_dirt":0.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ドッシーウェーブ.png"},{"name":"パタテンテン","stats":{"speed_onroad":0.2,"speed_dirt":1.2,"speed_underwater":0.2,"acceleration":1.4,"weight":0.2,"handling_onroad":1,"handling_dirt":1.8,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/パタテンテン.png"},{"name":"Wチョッパー","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":1.4,"acceleration":0.6,"weight":0.4,"handling_onroad":1,"handling_dirt":1,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/Wチョッパー.png"},{"name":"ファイアモービル","stats":{"speed_onroad":0.6,"speed_dirt":1.8,"speed_underwater":1,"acceleration":0.6,"weight":0.6,"handling_onroad":0.6,"handling_dirt":1.8,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/ファイアモービル.png"},{"name":"ベルトライク","stats":{"speed_onroad":1.6,"speed_dirt":1.6,"speed_underwater":1.6,"acceleration":0.6,"weight":0.8,"handling_onroad":0.4,"handling_dirt":0.4,"handling_underwater":0.4},"imageUrl":"/myApps/img/marioKart/karts/ベルトライク.png"},{"name":"ローブスター","stats":{"speed_onroad":1.4,"speed_dirt":1.4,"speed_underwater":2,"acceleration":0.2,"weight":1,"handling_onroad":0,"handling_dirt":0,"handling_underwater":1},"imageUrl":"/myApps/img/marioKart/karts/ローブスター.png"},{"name":"スターモービル","stats":{"speed_onroad":1.2,"speed_dirt":1.6,"speed_underwater":2.2,"acceleration":0,"weight":1,"handling_onroad":0.2,"handling_dirt":0.4,"handling_underwater":1.6},"imageUrl":"/myApps/img/marioKart/karts/スターモービル.png"},{"name":"ムービースター","stats":{"speed_onroad":1.6,"speed_dirt":1.6,"speed_underwater":1.6,"acceleration":0.4,"weight":0.6,"handling_onroad":0.8,"handling_dirt":0.8,"handling_underwater":0.8},"imageUrl":"/myApps/img/marioKart/karts/ムービースター.png"},{"name":"サファリカーゴ","stats":{"speed_onroad":1.8,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":0.4,"weight":1,"handling_onroad":1.4,"handling_dirt":0.2,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/サファリカーゴ.png"},{"name":"キラーヘッド","stats":{"speed_onroad":1.8,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":0.4,"weight":1,"handling_onroad":1.4,"handling_dirt":0.2,"handling_underwater":0.2},"imageUrl":"/myApps/img/marioKart/karts/キラーヘッド.png"},{"name":"イグニッション","stats":{"speed_onroad":1,"speed_dirt":1,"speed_underwater":1,"acceleration":1.2,"weight":0.6,"handling_onroad":0.6,"handling_dirt":0.6,"handling_underwater":0.6},"imageUrl":"/myApps/img/marioKart/karts/イグニッション.png"},{"name":"スケルトン","stats":{"speed_onroad":0.4,"speed_dirt":0.4,"speed_underwater":0.4,"acceleration":1.6,"weight":0.2,"handling_onroad":1.2,"handling_dirt":1.2,"handling_underwater":1.2},"imageUrl":"/myApps/img/marioKart/karts/スケルトン.png"},{"name":"ラリーゲイター","stats":{"speed_onroad":1.8,"speed_dirt":1.2,"speed_underwater":1.2,"acceleration":0.6,"weight":1.2,"handling_onroad":1,"handling_dirt":0,"handling_underwater":0},"imageUrl":"/myApps/img/marioKart/karts/ラリーゲイター.png"}];
        const numberOfSlots = 3; // PHPからスロット数を取得

        // --- State Management ---
        let comparisonSlots = [];
        let myChart = null;
        let activeSlotIndex = -1; // The slot currently being edited

        // --- DOM Elements ---
        const slotsContainer = document.getElementById('comparison-slots-container');
        const popup = document.getElementById('selection-popup');
        const popupTitle = document.getElementById('popup-title');
        const popupGrid = document.getElementById('popup-grid');
        const closePopupButton = document.getElementById('close-popup');

        const statKeys = [
            'speed_onroad', 'speed_dirt', 'speed_underwater',
            'acceleration', 'weight',
            'handling_onroad', 'handling_dirt', 'handling_underwater'
        ];
        const statLabels = [
            'スピード(舗装路)', 'スピード(悪路)', 'スピード(水上)',
            'かそく', 'おもさ',
            'まがりやすさ(舗装路)', 'まがりやすさ(悪路)', 'まがりやすさ(水上)'
        ];
        const chartColors = [
            'rgba(59, 130, 246, 0.7)', 'rgba(249, 115, 22, 0.7)', 'rgba(22, 163, 74, 0.7)',
            'rgba(139, 92, 246, 0.7)', 'rgba(239, 68, 68, 0.7)'
        ];
         const chartBorderColors = [
            'rgb(59, 130, 246)', 'rgb(249, 115, 22)', 'rgb(22, 163, 74)',
            'rgb(139, 92, 246)', 'rgb(239, 68, 68)'
        ];

        // --- Core Functions ---

        /**
         * Renders all comparison slots in the UI based on the current state.
         */
        function renderSlots() {
            slotsContainer.innerHTML = '';
            comparisonSlots.forEach((slot, index) => {
                const slotEl = document.createElement('div');
                slotEl.className = 'comparison-slot';
                slotEl.dataset.id = slot.id;

                let charHtml = `
                    <div class="selection-box" data-type="character" data-index="${index}">
                        <div class="placeholder">+</div>
                        <span>キャラクターを選択</span>
                    </div>`;
                if (slot.character) {
                    charHtml = `
                    <div class="selection-box" data-type="character" data-index="${index}">
                        <img decoding="async" src="${slot.character.imageUrl}" alt="${slot.character.name}">
                        <span>${slot.character.name}</span>
                    </div>`;
                }

                let kartHtml = `
                    <div class="selection-box" data-type="kart" data-index="${index}">
                        <div class="placeholder">+</div>
                        <span>マシンを選択</span>
                    </div>`;
                if (slot.kart) {
                    kartHtml = `
                    <div class="selection-box" data-type="kart" data-index="${index}">
                        <img decoding="async" src="${slot.kart.imageUrl}" alt="${slot.kart.name}">
                        <span>${slot.kart.name}</span>
                    </div>`;
                }
                
                // Determine if the button should be disabled
                const isButtonDisabled = !(slot.character && slot.kart);
                const buttonHtml = `
                    <button class="action-button" data-index="${index}" ${isButtonDisabled ? 'disabled' : ''}>同一ステータス以上の組み合わせを確認</button>
                `;

                slotEl.innerHTML = `
                    <div class="slot-header">
                        <span class="slot-title">組み合わせ #${index + 1}</span>
                    </div>
                    ${charHtml}
                    ${kartHtml}
                    ${buttonHtml}
                `;
                slotsContainer.appendChild(slotEl);
            });
        }

        /**
         * Opens the selection popup.
         * @param {string} type - 'character' or 'kart'.
         * @param {number} index - The index of the slot being edited.
         */
        function openPopup(type, index) {
            activeSlotIndex = index;
            popupTitle.textContent = type === 'character' ? 'キャラクターを選択' : 'マシンを選択';
            const data = type === 'character' ? charactersData : kartsData;
            populatePopup(data, type);
            popup.style.display = 'flex';
        }

        /**
         * Closes the selection popup.
         */
        function closePopup() {
            popup.style.display = 'none';
            popupGrid.innerHTML = '';
            activeSlotIndex = -1;
        }

        /**
         * Populates the popup grid with selectable items.
         * @param {Array} data - The data to display (characters or karts).
         * @param {string} type - 'character' or 'kart'.
         */
        function populatePopup(data, type) {
            popupGrid.innerHTML = '';
            data.forEach(item => {
                const div = document.createElement('div');
                div.className = 'popup-item';
                div.innerHTML = `
                    <img decoding="async" src="${item.imageUrl}" alt="${item.name}">
                    <span>${item.name}</span>
                `;
                div.addEventListener('click', () => {
                    if (activeSlotIndex !== -1) {
                        comparisonSlots[activeSlotIndex][type] = item;
                        renderSlots();
                        updateChart();
                    }
                    closePopup();
                });
                popupGrid.appendChild(div);
            });
        }

        /**
         * Updates the chart with the current comparison data.
         */
        function updateChart() {
            const datasets = comparisonSlots.map((slot, index) => {
                const totalStats = {};
                statKeys.forEach(key => {
                    const charStat = slot.character ? slot.character.stats[key] : 0;
                    const kartStat = slot.kart ? slot.kart.stats[key] : 0;
                    totalStats[key] = charStat + kartStat;
                });
                const data = statKeys.map(key => totalStats[key]);
                let label = `組み合わせ #${index + 1}`;
                if (slot.character && slot.kart) {
                    label = `${slot.character.name} & ${slot.kart.name}`;
                } else if (slot.character) {
                    label = slot.character.name;
                } else if (slot.kart) {
                    label = slot.kart.name;
                }
                
                return {
                    label: label,
                    data: data,
                    backgroundColor: chartColors[index % chartColors.length],
                    borderColor: chartBorderColors[index % chartBorderColors.length],
                    borderWidth: 1,
                };
            }).filter(ds => ds.data.some(d => d > 0)); // Only show datasets with some data

            if (myChart) {
                myChart.data.datasets = datasets;
                myChart.update();
            } else {
                initializeChart(datasets);
            }
        }

        /**
         * Initializes the Chart.js bar chart.
         * @param {Array} datasets - The initial datasets for the chart.
         */
        function initializeChart(datasets) {
            const ctx = document.getElementById('statsChart').getContext('2d');
            myChart = new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: statLabels,
                    datasets: datasets
                },
                options: {
                    indexAxis: 'y', // 横向きの棒グラフに設定
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        x: { // X軸（値）の設定
                            beginAtZero: true,
                            max: 4,
                            ticks: {
                                stepSize: 1
                            }
                        },
                        y: { // Y軸（ラベル）の設定
                            // 特に設定は不要
                        }
                    },
                    plugins: {
                        legend: {
                            position: 'top',
                        },
                        title: {
                            display: true,
                            text: '組み合わせステータス比較'
                        }
                    }
                }
            });
        }

        // --- Event Listeners ---
        closePopupButton.addEventListener('click', closePopup);
        popup.addEventListener('click', (e) => {
            if (e.target === popup) closePopup();
        });
        slotsContainer.addEventListener('click', (e) => {
            const selectionBox = e.target.closest('.selection-box');
            if (selectionBox) {
                const type = selectionBox.dataset.type;
                const index = parseInt(selectionBox.dataset.index, 10);
                openPopup(type, index);
            }
            const button = e.target.closest('.action-button');
            if (button) {
                const index = parseInt(button.dataset.index, 10);
                const slot = comparisonSlots[index];
                if (slot.character && slot.kart) {
                    const combinedStats = {};
                    statKeys.forEach(stat => {
                        combinedStats[stat] = (slot.character.stats[stat] || 0.0) + (slot.kart.stats[stat] || 0.0);
                    });
                    sessionStorage.setItem('prefilledMinStats', JSON.stringify(combinedStats));
                    window.open('/mario_kart_w-pareto/#results-container', '_blank'); // Open in new tab
                }
            }
        });

        // --- Initial Load ---
        window.onload = function() {
            // 設定されたスロット数に基づいて初期スロットを生成
            for (let i = 0; i < numberOfSlots; i++) {
                 const newSlot = {
                    id: i, // IDをシンプルにインデックスにする
                    character: null,
                    kart: null
                };
                comparisonSlots.push(newSlot);
            }
            renderSlots();
            updateChart();
        };
    </script>
</body>
</html>




<p></p>



<h2 class="wp-block-heading">概要</h2>



<p>にじさんじシェリンさんが動画で使っていたツールのパクリです</p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="【マリカワールド】どのカスタムが強いんじゃ【シェリン/にじさんじ】" width="1256" height="707" src="https://www.youtube.com/embed/Lm4nCxdvT4A?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p></p>



<h2 class="wp-block-heading">更新履歴</h2>



<p><strong><strong>2025/8/</strong>15</strong></p>



<ul class="wp-block-list">
<li>ラリーバイクとドカンバイクのまがりやすさ(舗装路)の値を修正</li>
</ul>



<p><strong>2025/8/2</strong></p>



<ul class="wp-block-list">
<li>キャラクターとマシンを3種類選択して比較できるように変更</li>



<li>データソースを以下に変更<br><a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1BtHeFAEwL1MLND-l7KZz_Zg4wZWC2YIikbyweocqwSs/edit?gid=555944039#gid=555944039">https://docs.google.com/spreadsheets/d/1BtHeFAEwL1MLND-l7KZz_Zg4wZWC2YIikbyweocqwSs/edit?gid=555944039#gid=555944039<span class="fa fa-external-link external-icon anchor-icon"></span></a></li>
</ul>



<p><strong>2025/7/24</strong></p>



<ul class="wp-block-list">
<li>キャラクターとマシンの選択方法をポップアップに変更</li>
</ul>



<p><strong>2025/7/16</strong></p>



<ul class="wp-block-list">
<li>キャラクターのまがりやすさを最新の値に更新</li>
</ul>



<p><strong>2025/7/10</strong></p>



<ul class="wp-block-list">
<li>データソースを<a rel="noopener" target="_blank" href="https://japan-mk.blog.jp/mkworld.st-c">https://japan-mk.blog.jp/mkworld.st-c<span class="fa fa-external-link external-icon anchor-icon"></span></a>に変更</li>



<li>まがりやすさについても道路別のステータスを表示するように変更</li>
</ul>



<p><strong>2025/6/20</strong></p>



<ul class="wp-block-list">
<li>初版</li>



<li>データソースは<a rel="noopener" target="_blank" href="https://docs.google.com/spreadsheets/d/1t3BeXH3shj6Rh7x0ROFD81ZBxyumQFs9pebbnYcfWi4/edit?pli=1&amp;gid=735843013#gid=735843013">https://docs.google.com/spreadsheets/d/1t3BeXH3shj6Rh7x0ROFD81ZBxyumQFs9pebbnYcfWi4/edit?pli=1&amp;gid=735843013#gid=735843013<span class="fa fa-external-link external-icon anchor-icon"></span></a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://tt0.link/mario_kart_w-stats/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
