Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro-preview-05-06· GoogleHugging Face LMArena Human Preference 140K

HTMLで簡単なスネークゲームを作成してください。 ただしUIには最もこだわり、そしてバグはマイナスの評価になります。…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash-lite-preview-06-17-thinking’s answer.
  1. User

    HTMLで簡単なスネークゲームを作成してください。 ただしUIには最もこだわり、そしてバグはマイナスの評価になります。 あなたはデザイナーとして最もプレイしやすく、最も魅了されるようなデザインを作成します。 例えばクリア報酬でスキンが解放されるなどはプレイヤーが長期的にプレイする魅力になります。 他にもどの環境からでもプレイできるようにレスポンシブなデザインを意識することも非常に大切でしょう。 他にも獲得したポイントの表示を一定ポイントごとに見た目を変更したりすることで高揚心を煽るのもいいかもしれません。 一つのコードブロックにまとめて提出してください。

  2. Gemini Assistant

    はい、承知いたしました。UIに最もこだわり、プレイしやすく魅力的なスネークゲームを作成します。スキン解放システム、レスポンシブデザイン、スコアに応じた表示変化などを盛り込み、バグのない完成度の高いゲームを目指します。

    以下に、HTML、CSS、JavaScriptを一つにまとめたコードを提出します。

    <!DOCTYPE html>
    <html lang="ja">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>スネークゲーム EVO</title>
        <style>
            @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');
    
            :root {
                --bg-color: #1a1a2e;
                --primary-color: #16213e;
                --secondary-color: #0f3460;
                --accent-color: #e94560;
                --text-color: #dcdcdc;
                --highlight-color: #537895;
                --font-family: 'Poppins', sans-serif;
                --neon-green: #39FF14;
                --neon-blue: #00FFFF;
                --neon-pink: #FF00FF;
                --neon-orange: #FFA500;
            }
    
            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }
    
            body {
                font-family: var(--font-family);
                background-color: var(--bg-color);
                color: var(--text-color);
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                min-height: 100vh;
                padding: 10px;
                overflow-x: hidden;
            }
    
            .game-container {
                background-color: var(--primary-color);
                border-radius: 15px;
                box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
                padding: 20px;
                display: flex;
                flex-direction: column;
                align-items: center;
                width: 100%;
                max-width: 640px; /* Max width for larger screens */
            }
    
            h1 {
                font-size: 2.5rem;
                color: var(--accent-color);
                margin-bottom: 10px;
                text-shadow: 0 0 10px var(--accent-color);
                font-weight: 700;
            }
    
            .score-board {
                display: flex;
                justify-content: space-between;
                width: 100%;
                max-width: 400px; /* Consistent width for score display */
                margin-bottom: 15px;
                font-size: 1.2rem;
                font-weight: 600;
            }
    
            .score-item {
                background-color: var(--secondary-color);
                padding: 8px 15px;
                border-radius: 8px;
                box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
            }
            
            #score-value.tier-1 { color: var(--neon-green); text-shadow: 0 0 5px var(--neon-green); }
            #score-value.tier-2 { color: var(--neon-blue); text-shadow: 0 0 8px var(--neon-blue); font-size: 1.1em; }
            #score-value.tier-3 { color: var(--neon-pink); text-shadow: 0 0 10px var(--neon-pink); font-size: 1.2em; }
            #score-value.tier-4 { color: var(--neon-orange); text-shadow: 0 0 12px var(--neon-orange); font-size: 1.3em; animation: pulse 1s infinite; }
    
            @keyframes pulse {
                0% { transform: scale(1); }
                50% { transform: scale(1.05); }
                100% { transform: scale(1); }
            }
    
            .canvas-wrapper {
                position: relative;
                width: 100%; /* Make wrapper responsive */
                max-width: 400px; /* Max width for canvas */
                aspect-ratio: 1 / 1; /* Maintain square shape */
                margin-bottom: 20px;
                border: 3px solid var(--secondary-color);
                border-radius: 10px;
                overflow: hidden; /* Ensures canvas stays within border */
                background-color: #000; /* Fallback for canvas background */
            }
            
            #gameCanvas {
                display: block;
                width: 100%;
                height: 100%;
                background-color: rgba(10,10,20,0.8); /* Dark, slightly transparent canvas */
                image-rendering: pixelated; /* For crisp pixels if using pixel art */
                image-rendering: -moz-crisp-edges;
                image-rendering: crisp-edges;
            }
    
            .controls-panel {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 10px;
                width: 100%;
                max-width: 400px;
            }
    
            .game-button {
                background-color: var(--accent-color);
                color: var(--text-color);
                border: none;
                padding: 12px 25px;
                border-radius: 8px;
                font-size: 1rem;
                font-weight: 600;
                cursor: pointer;
                transition: background-color 0.3s ease, transform 0.1s ease;
                box-shadow: 0 4px 10px rgba(0,0,0,0.2);
                width: 100%;
                max-width: 250px;
            }
    
            .game-button:hover {
                background-color: #ff6384; /* Lighter accent */
                transform: translateY(-2px);
            }
            .game-button:active {
                transform: translateY(0px);
            }
            .game-button:disabled {
                background-color: #888;
                cursor: not-allowed;
            }
    
            .instructions {
                margin-top: 15px;
                font-size: 0.9rem;
                color: var(--highlight-color);
                text-align: center;
                width: 100%;
                max-width: 400px;
            }
    
            /* Modal Styles */
            .modal {
                display: none;
                position: fixed;
                z-index: 1000;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                overflow: auto;
                background-color: rgba(0,0,0,0.6);
                align-items: center;
                justify-content: center;
            }
    
            .modal-content {
                background-color: var(--primary-color);
                margin: auto;
                padding: 25px;
                border: 1px solid var(--secondary-color);
                border-radius: 15px;
                width: 90%;
                max-width: 500px;
                box-shadow: 0 10px 30px rgba(0,0,0,0.4);
                text-align: center;
                animation: fadeInModal 0.3s ease-out;
            }
    
            @keyframes fadeInModal {
                from { opacity: 0; transform: scale(0.9); }
                to { opacity: 1; transform: scale(1); }
            }
    
            .modal h2 {
                color: var(--accent-color);
                margin-bottom: 20px;
                font-size: 1.8rem;
            }
            
            .modal p {
                margin-bottom: 15px;
                font-size: 1.1rem;
            }
    
            .skin-selection-container {
                display: grid;
                grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
                gap: 15px;
                margin-bottom: 20px;
            }
    
            .skin-option {
                background-color: var(--secondary-color);
                padding: 10px;
                border-radius: 8px;
                cursor: pointer;
                transition: transform 0.2s ease, box-shadow 0.2s ease;
                border: 2px solid transparent;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
            }
            
            .skin-option:hover {
                transform: translateY(-3px);
                box-shadow: 0 5px 15px rgba(0,0,0,0.2);
            }
            
            .skin-option.selected {
                border-color: var(--accent-color);
                box-shadow: 0 0 10px var(--accent-color);
            }
    
            .skin-option.locked {
                opacity: 0.6;
                cursor: not-allowed;
                position: relative;
            }
            
            .skin-option.locked::after {
                content: '🔒';
                position: absolute;
                top: 5px;
                right: 5px;
                font-size: 1.2em;
            }
    
            .skin-preview {
                width: 40px;
                height: 20px;
                border-radius: 4px;
                margin-bottom: 8px;
                border: 1px solid var(--text-color);
            }
    
            .skin-name {
                font-size: 0.9rem;
                font-weight: 500;
            }
            
            .unlock-info {
                font-size: 0.75rem;
                color: var(--highlight-color);
                margin-top: 4px;
            }
    
            .new-skin-unlocked {
                color: var(--neon-green);
                font-weight: bold;
                animation: glow 1.5s infinite alternate;
            }
    
            @keyframes glow {
                from { text-shadow: 0 0 5px var(--neon-green), 0 0 10px var(--neon-green); }
                to { text-shadow: 0 0 10px var(--neon-green), 0 0 20px var(--neon-green); }
            }
    
            /* Responsive adjustments */
            @media (max-width: 480px) {
                h1 { font-size: 2rem; }
                .score-board { font-size: 1rem; }
                .game-button { padding: 10px 20px; font-size: 0.9rem; }
                .instructions { font-size: 0.8rem; }
                .modal-content { padding: 20px; }
                .modal h2 { font-size: 1.5rem; }
            }
    
        </style>
    </head>
    <body>
        <div class="game-container">
            <h1>SNAKE EVO</h1>
            <div class="score-board">
                <div class="score-item">スコア: <span id="score-value">0</span></div>
                <div class="score-item">ハイスコア: <span id="high-score-value">0</span></div>
            </div>
            <div class="canvas-wrapper">
                <canvas id="gameCanvas"></canvas>
            </div>
            <div class="controls-panel">
                <button id="start-button" class="game-button">スタート</button>
                <button id="change-skin-button" class="game-button">スキン変更</button>
            </div>
            <p class="instructions">操作: 矢印キー (PC) / スワイプ (モバイル)</p>
        </div>
    
        <!-- Game Over Modal -->
        <div id="gameOverModal" class="modal">
            <div class="modal-content">
                <h2 id="gameOverTitle">ゲームオーバー</h2>
                <p>最終スコア: <span id="finalScore">0</span></p>
                <p id="newHighScoreMessage" style="display:none; color: var(--neon-orange); font-weight: bold;">ハイスコア更新!</p>
                <p id="newSkinUnlockMessage" class="new-skin-unlocked" style="display:none;">新しいスキンが解放されました!</p>
                <button id="restart-button" class="game-button">もう一度プレイ</button>
                <button id="gameOverSkinButton" class="game-button" style="margin-top:10px;">スキン選択へ</button>
            </div>
        </div>
    
        <!-- Skin Selection Modal -->
        <div id="skinModal" class="modal">
            <div class="modal-content">
                <h2>スキンを選択</h2>
                <div id="skin-selection-container" class="skin-selection-container">
                    <!-- Skin options will be populated by JavaScript -->
                </div>
                <button id="closeSkinModal" class="game-button">閉じる</button>
            </div>
        </div>
    
        <script>
            const canvas = document.getElementById('gameCanvas');
            const ctx = canvas.getContext('2d');
            const canvasWrapper = document.querySelector('.canvas-wrapper');
    
            const scoreValueEl = document.getElementById('score-value');
            const highScoreValueEl = document.getElementById('high-score-value');
            const startButton = document.getElementById('start-button');
            const changeSkinButton = document.getElementById('change-skin-button');
            
            const gameOverModal = document.getElementById('gameOverModal');
            const finalScoreEl = document.getElementById('finalScore');
            const restartButton = document.getElementById('restart-button');
            const newHighScoreMessageEl = document.getElementById('newHighScoreMessage');
            const newSkinUnlockMessageEl = document.getElementById('newSkinUnlockMessage');
            const gameOverSkinButton = document.getElementById('gameOverSkinButton');
            const gameOverTitleEl = document.getElementById('gameOverTitle');
    
            const skinModal = document.getElementById('skinModal');
            const skinSelectionContainer = document.getElementById('skin-selection-container');
            const closeSkinModalButton = document.getElementById('closeSkinModal');
    
            const GRID_SIZE = 20; // Number of cells in a row/column
            let cellSize;
            let snake, food, score, highScore, direction, gameLoopInterval, gameRunning, currentSpeed;
            let baseSpeed = 150; // ms per update
    
            const skins = [
                { id: 'classic', name: 'クラシック', headColor: '#32CD32', bodyColor: '#28a428', foodColor: '#FF4500', unlocked: true, unlockScore: 0 },
                { id: 'ocean', name: 'オーシャン', headColor: '#1E90FF', bodyColor: '#187bcd', foodColor: '#FFD700', unlocked: false, unlockScore: 30 },
                { id: 'sunset', name: 'サンセット', headColor: '#FFA500', bodyColor: '#cc8400', foodColor: '#8A2BE2', unlocked: false, unlockScore: 60 },
                { id: 'neon', name: 'ネオンピンク', headColor: '#FF00FF', bodyColor: '#cc00cc', foodColor: '#00FFFF', unlocked: false, unlockScore: 100 },
                { id: 'shadow', name: 'シャドウ', headColor: '#A9A9A9', bodyColor: '#808080', foodColor: '#FFFFFF', unlocked: false, unlockScore: 150 },
                { id: 'crimson', name: 'クリムゾン', headColor: '#DC143C', bodyColor: '#b01030', foodColor: '#F0E68C', unlocked: false, unlockScore: 200 }
            ];
            let unlockedSkins = [];
            let currentSkin;
    
            function resizeCanvas() {
                const wrapperWidth = canvasWrapper.clientWidth;
                const wrapperHeight = canvasWrapper.clientHeight; // Use this if aspect ratio is not 1:1
                
                // For a square canvas, use the smaller dimension of the wrapper
                const size = Math.min(wrapperWidth, wrapperHeight);
    
                cellSize = Math.floor(size / GRID_SIZE);
                canvas.width = cellSize * GRID_SIZE;
                canvas.height = cellSize * GRID_SIZE;
    
                // Recenter canvas if wrapper is larger
                canvas.style.marginLeft = `${(wrapperWidth - canvas.width) / 2}px`;
                canvas.style.marginTop = `${(wrapperHeight - canvas.height) / 2}px`;
    
                if (gameRunning) draw(); // Redraw if game is running
                else if (snake) drawInitialState(); // Redraw initial state if game not started but initialized
            }
    
            function drawInitialState() {
                clearCanvas();
                if (snake && snake.length > 0) drawSnake();
                if (food) drawFood();
            }
    
            function loadGameData() {
                highScore = parseInt(localStorage.getItem('snakeEvoHighScore')) || 0;
                highScoreValueEl.textContent = highScore;
    
                const savedUnlockedSkins = JSON.parse(localStorage.getItem('snakeEvoUnlockedSkins'));
                if (savedUnlockedSkins) {
                    unlockedSkins = savedUnlockedSkins;
                } else {
                    unlockedSkins = skins.filter(s => s.unlocked).map(s => s.id);
                    localStorage.setItem('snakeEvoUnlockedSkins', JSON.stringify(unlockedSkins));
                }
                skins.forEach(s => {
                    if (unlockedSkins.includes(s.id)) s.unlocked = true;
                });
    
                const savedSkinId = localStorage.getItem('snakeEvoCurrentSkinId') || 'classic';
                currentSkin = skins.find(s => s.id === savedSkinId) || skins[0];
            }
    
            function saveGameData() {
                localStorage.setItem('snakeEvoHighScore', highScore);
                localStorage.setItem('snakeEvoUnlockedSkins', JSON.stringify(unlockedSkins));
                localStorage.setItem('snakeEvoCurrentSkinId', currentSkin.id);
            }
    
            function initGame() {
                snake = [{ x: Math.floor(GRID_SIZE / 2), y: Math.floor(GRID_SIZE / 2) }];
                direction = { x: 0, y: 0 }; // No movement until first input
                score = 0;
                currentSpeed = baseSpeed;
                updateScoreDisplay();
                generateFood();
                drawInitialState();
                startButton.textContent = 'スタート';
                startButton.disabled = false;
            }
    
            function startGame() {
                if (gameRunning) return;
                // Require a direction to be set before starting, or default to right
                if (direction.x === 0 && direction.y === 0) {
                     direction = { x: 1, y: 0 }; // Default to right if no direction set
                }
                gameRunning = true;
                startButton.textContent = 'プレイ中...';
                startButton.disabled = true;
                changeSkinButton.disabled = true;
                gameLoop();
            }
    
            function gameLoop() {
                if (!gameRunning) return;
    
                update();
                draw();
    
                gameLoopInterval = setTimeout(gameLoop, currentSpeed);
            }
    
            function update() {
                const head = { ...snake[0] };
                head.x += direction.x;
                head.y += direction.y;
    
                // Wall collision
                if (head.x < 0 || head.x >= GRID_SIZE || head.y < 0 || head.y >= GRID_SIZE) {
                    gameOver();
                    return;
                }
    
                // Self collision
                for (let i = 1; i < snake.length; i++) {
                    if (head.x === snake[i].x && head.y === snake[i].y) {
                        gameOver();
                        return;
                    }
                }
    
                snake.unshift(head);
    
                // Food collision
                if (head.x === food.x && head.y === food.y) {
                    score++;
                    updateScoreDisplay();
                    generateFood();
                    // Speed up
                    currentSpeed = Math.max(50, baseSpeed - Math.floor(score / 5) * 10);
                } else {
                    snake.pop();
                }
            }
    
            function draw() {
                clearCanvas();
                drawFood();
                drawSnake();
            }
    
            function clearCanvas() {
                ctx.fillStyle = getComputedStyle(canvas).backgroundColor; // Use CSS defined bg
                ctx.fillRect(0, 0, canvas.width, canvas.height);
            }
    
            function drawSnake() {
                snake.forEach((segment, index) => {
                    ctx.fillStyle = index === 0 ? currentSkin.headColor : currentSkin.bodyColor;
                    ctx.fillRect(segment.x * cellSize, segment.y * cellSize, cellSize, cellSize);
                    // Add a slight border for better segment visibility
                    ctx.strokeStyle = varType(currentSkin.bodyColor, "darker", 20); // Make darker outline
                    ctx.strokeRect(segment.x * cellSize, segment.y * cellSize, cellSize, cellSize);
                });
            }
            
            // Helper function to darken/lighten colors (for borders etc.)
            function varType(hex, type, percent) {
                hex = hex.replace(/^\s*#|\s*$/g, '');
                if(hex.length == 3){
                    hex = hex.replace(/(.)/g, '$1$1');
                }
                var r = parseInt(hex.substr(0, 2), 16),
                    g = parseInt(hex.substr(2, 2), 16),
                    b = parseInt(hex.substr(4, 2), 16);
    
                if (type === "lighter") {
                    r = Math.min(255, r + Math.floor(r * (percent/100)));
                    g = Math.min(255, g + Math.floor(g * (percent/100)));
                    b = Math.min(255, b + Math.floor(b * (percent/100)));
                } else if (type === "darker") {
                    r = Math.max(0, r - Math.floor(r * (percent/100)));
                    g = Math.max(0, g - Math.floor(g * (percent/100)));
                    b = Math.max(0, b - Math.floor(b * (percent/100)));
                }
                return '#' + (0x1000000 + r * 0x10000 + g * 0x100 + b).toString(16).slice(1);
            }
    
    
            function drawFood() {
                ctx.fillStyle = currentSkin.foodColor;
                ctx.fillRect(food.x * cellSize, food.y * cellSize, cellSize, cellSize);
                // Add a "glowing" effect to food
                ctx.shadowColor = currentSkin.foodColor;
                ctx.shadowBlur = 8;
                ctx.fillRect(food.x * cellSize, food.y * cellSize, cellSize, cellSize);
                ctx.shadowBlur = 0; // Reset shadow
            }
    
            function generateFood() {
                let newFoodPosition;
                do {
                    newFoodPosition = {
                        x: Math.floor(Math.random() * GRID_SIZE),
                        y: Math.floor(Math.random() * GRID_SIZE)
                    };
                } while (snake.some(segment => segment.x === newFoodPosition.x && segment.y === newFoodPosition.y));
                food = newFoodPosition;
            }
    
            function updateScoreDisplay() {
                scoreValueEl.textContent = score;
                scoreValueEl.className = ''; // Reset classes
                if (score >= 100) scoreValueEl.classList.add('tier-4');
                else if (score >= 75) scoreValueEl.classList.add('tier-3');
                else if (score >= 50) scoreValueEl.classList.add('tier-2');
                else if (score >= 25) scoreValueEl.classList.add('tier-1');
    
                if (score > highScore) {
                    highScore = score;
                    highScoreValueEl.textContent = highScore;
                }
            }
            
            function handleKeydown(e) {
                if (!gameRunning && (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight")) {
                     // If game not running, first arrow key press sets initial direction and starts game
                    setDirectionFromKey(e.key);
                    if (direction.x !== 0 || direction.y !== 0) { // Check if direction was actually set
                        startGame();
                    }
                    return;
                }
                
                if (!gameRunning) return; // Ignore input if game hasn't started by other means
                setDirectionFromKey(e.key);
            }
    
            function setDirectionFromKey(key) {
                switch (key) {
                    case 'ArrowUp':
                        if (direction.y === 0) direction = { x: 0, y: -1 };
                        break;
                    case 'ArrowDown':
                        if (direction.y === 0) direction = { x: 0, y: 1 };
                        break;
                    case 'ArrowLeft':
                        if (direction.x === 0) direction = { x: -1, y: 0 };
                        break;
                    case 'ArrowRight':
                        if (direction.x === 0) direction = { x: 1, y: 0 };
                        break;
                }
            }
    
            // Touch controls
            let touchStartX = 0;
            let touchStartY = 0;
            let touchEndX = 0;
            let touchEndY = 0;
    
            canvas.addEventListener('touchstart', function(e) {
                e.preventDefault(); // Prevent scrolling
                touchStartX = e.changedTouches[0].screenX;
                touchStartY = e.changedTouches[0].screenY;
            }, { passive: false });
    
            canvas.addEventListener('touchend', function(e) {
                e.preventDefault();
                touchEndX = e.changedTouches[0].screenX;
                touchEndY = e.changedTouches[0].screenY;
                handleSwipe();
            }, { passive: false });
    
            function handleSwipe() {
                const deltaX = touchEndX - touchStartX;
                const deltaY = touchEndY - touchStartY;
                const absDeltaX = Math.abs(deltaX);
                const absDeltaY = Math.abs(deltaY);
    
                // Minimum swipe distance
                if (Math.max(absDeltaX, absDeltaY) < 30) return;
    
                let newDirection;
                if (absDeltaX > absDeltaY) { // Horizontal swipe
                    newDirection = deltaX > 0 ? 'ArrowRight' : 'ArrowLeft';
                } else { // Vertical swipe
                    newDirection = deltaY > 0 ? 'ArrowDown' : 'ArrowUp';
                }
                
                if (!gameRunning) {
                    setDirectionFromKey(newDirection);
                     if (direction.x !== 0 || direction.y !== 0) {
                        startGame();
                    }
                    return;
                }
                setDirectionFromKey(newDirection);
            }
    
    
            function gameOver() {
                gameRunning = false;
                clearTimeout(gameLoopInterval);
                startButton.textContent = 'スタート';
                startButton.disabled = false;
                changeSkinButton.disabled = false;
    
                finalScoreEl.textContent = score;
                gameOverTitleEl.textContent = "ゲームオーバー";
                newHighScoreMessageEl.style.display = score === highScore && score > 0 ? 'block' : 'none';
                
                let unlockedNewSkin = false;
                skins.forEach(s => {
                    if (!s.unlocked && score >= s.unlockScore) {
                        s.unlocked = true;
                        if (!unlockedSkins.includes(s.id)) {
                             unlockedSkins.push(s.id);
                        }
                        unlockedNewSkin = true;
                    }
                });
                newSkinUnlockMessageEl.style.display = unlockedNewSkin ? 'block' : 'none';
                
                saveGameData();
                gameOverModal.style.display = 'flex';
            }
    
            function populateSkinSelection() {
                skinSelectionContainer.innerHTML = ''; // Clear existing options
                skins.forEach(skin => {
                    const option = document.createElement('div');
                    option.classList.add('skin-option');
                    if (skin.id === currentSkin.id) {
                        option.classList.add('selected');
                    }
                    if (!skin.unlocked) {
                        option.classList.add('locked');
                    }
    
                    const preview = document.createElement('div');
                    preview.classList.add('skin-preview');
                    preview.style.background = `linear-gradient(45deg, ${skin.headColor} 50%, ${skin.bodyColor} 50%)`;
                    
                    const name = document.createElement('span');
                    name.classList.add('skin-name');
                    name.textContent = skin.name;
    
                    option.appendChild(preview);
                    option.appendChild(name);
    
                    if (!skin.unlocked) {
                        const unlockInfo = document.createElement('span');
                        unlockInfo.classList.add('unlock-info');
                        unlockInfo.textContent = `スコア ${skin.unlockScore} で解放`;
                        option.appendChild(unlockInfo);
                    }
    
                    option.addEventListener('click', () => {
                        if (skin.unlocked) {
                            currentSkin = skin;
                            saveGameData();
                            // Update selected visual
                            document.querySelectorAll('.skin-option').forEach(opt => opt.classList.remove('selected'));
                            option.classList.add('selected');
                            if (!gameRunning) drawInitialState(); // Update preview on canvas if game not running
                        }
                    });
                    skinSelectionContainer.appendChild(option);
                });
            }
    
            // Event Listeners
            startButton.addEventListener('click', () => {
                if (!gameRunning) {
                     // If direction is not set (e.g., after page load, before any key press)
                    if (direction.x === 0 && direction.y === 0) {
                        direction = { x: 1, y: 0 }; // Default to right
                    }
                    startGame();
                }
            });
            
            restartButton.addEventListener('click', () => {
                gameOverModal.style.display = 'none';
                initGame();
                // startGame(); // Optionally auto-start, or wait for user to click start/press key
            });
    
            gameOverSkinButton.addEventListener('click', () => {
                gameOverModal.style.display = 'none';
                skinModal.style.display = 'flex';
                populateSkinSelection();
            });
    
            changeSkinButton.addEventListener('click', () => {
                skinModal.style.display = 'flex';
                populateSkinSelection();
            });
    
            closeSkinModalButton.addEventListener('click', () => {
                skinModal.style.display = 'none';
                 if (!gameRunning) drawInitialState();
            });
    
            window.addEventListener('keydown', handleKeydown);
            window.addEventListener('resize', resizeCanvas);
    
    
            // Initial setup
            loadGameData();
            resizeCanvas(); // Initial canvas sizing
            initGame(); // Initialize game state but don't start
            
        </script>
    </body>
    </html>
    
    

    主な機能とデザインのポイント:

    1. 洗練されたUIデザイン:

      • ダークテーマを基調とし、ネオンカラーのアクセントで見やすく魅力的な外観。
      • フォントにはPoppinsを使用し、モダンで読みやすいテキスト。
      • ボタンやモーダルウィンドウは角丸で統一感のあるデザイン。
      • ホバーエフェクトやクリック時のフィードバック。
    2. レスポンシブデザイン:

      • ゲームコンテナ、キャンバス、UI要素が画面サイズに応じて適切に調整されます。
      • PCでは矢印キー、モバイルではスワイプ操作に対応。
    3. スコア表示の演出:

      • 現在のスコアが一定の閾値を超えるごとに、文字色やサイズ、テキストシャドウが変化し、高揚感を煽ります。
      • 特定のスコア以上でアニメーション(パルスエフェクト)も追加。
    4. スキンシステム:

      • 複数のスキンを用意し、それぞれ異なる配色(頭、体、エサ)。
      • スキンは特定のスコアを達成することで解放されます。
      • 解放状況と現在選択中のスキンはlocalStorageに保存され、次回プレイ時にも引き継がれます。
      • スキン選択モーダルで、解放済み/未解放のスキンを視覚的に確認・選択できます。
      • 新しいスキンが解放された際には、ゲームオーバー画面でお知らせします。
    5. ゲームプレイの向上:

      • スネークがエサを食べるごとに、少しずつゲームスピードが上昇し、難易度が上がります。
      • スネークのセグメントがわかりやすいように、わずかな境界線を追加。
      • エサには発光エフェクトを加え、視認性を向上。
    6. バグ対策と安定性:

      • スネークが即座に反対方向へ移動できないように制御。
      • エサがスネークの体の上に生成されないように配慮。
      • ゲームリセット時の状態初期化を確実に行います。
      • localStorageの読み書き時のエラーを考慮(今回は基本的な実装)。
    7. 操作性:

      • PCでは矢印キー、モバイル端末ではキャンバス上でのスワイプ操作で直感的にスネークをコントロールできます。
      • ゲーム開始はスタートボタンクリック、または最初の方向キー/スワイプ入力でも可能です。

    プレイ方法:

    1. 上記のコードを.htmlファイルとして保存し、ブラウザで開きます。
    2. 「スタート」ボタンを押すか、矢印キー(PC)またはスワイプ(モバイル)でゲームを開始します。
    3. スネークを操作してエサを食べ、スコアを伸ばしてください。
    4. 壁や自分自身に衝突するとゲームオーバーです。
    5. 「スキン変更」ボタンから、獲得したスキンを選んで見た目を変えることができます。

    このゲームは、UIの美しさ、プレイの楽しさ、そして長期的に遊んでもらうためのモチベーション維持に重点を置いてデザインされています。お楽しみいただければ幸いです。

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.