* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    height: 100%;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.main-wrapper {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20px;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    border-radius: 10px;
    color: white;
    font-size: 18px;
    font-weight: bold;
    flex-wrap: wrap;
    gap: 15px;
}

.score-container, .distance-container, .coins-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#score, #distance, #coins {
    font-size: 24px;
    min-width: 50px;
    text-align: right;
}

#gameCanvas {
    display: block;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    max-width: 100%;
    height: auto;
    touch-action: none;
    background: white;
}

/* パニックモード表示 */
.panic-mode-display {
    background: linear-gradient(135deg, #ff6b6b, #ff0000);
    color: white;
    padding: 15px 30px;
    margin: 15px 0;
    border-radius: 15px;
    text-align: center;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.5);
    animation: panic-pulse 0.5s ease-in-out infinite;
}

.panic-mode-title {
    font-size: 24px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.panic-mode-timer {
    font-size: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.panic-mode-bonus {
    font-size: 18px;
    color: #ffeb3b;
    margin-top: 5px;
}

@keyframes panic-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* パワーアップ表示 */
.powerup-display {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    justify-content: center;
}

.powerup-item {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: powerup-glow 1s ease-in-out infinite;
}

.powerup-icon {
    font-size: 30px;
}

.powerup-count, .powerup-timer {
    font-size: 20px;
    font-weight: bold;
    color: #4CAF50;
}

@keyframes powerup-glow {
    0%, 100% {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 2px 20px rgba(76, 175, 80, 0.4);
    }
}

/* ゲームオーバー画面 */
.game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 1000;
    min-width: 300px;
}

.game-over-screen h2 {
    color: #4CAF50;
    font-size: 28px;
    margin-bottom: 20px;
}

.final-stats {
    margin: 20px 0;
}

.stat-item {
    margin: 10px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 10px;
}

.stat-label {
    color: #666;
    font-size: 14px;
}

.stat-value {
    color: #4CAF50;
    font-size: 24px;
    font-weight: bold;
    display: block;
    margin-top: 5px;
}

.name-input-container {
    margin: 20px 0;
}

#playerName {
    padding: 10px;
    font-size: 16px;
    border: 2px solid #4CAF50;
    border-radius: 5px;
    width: 150px;
    margin-right: 10px;
}

#saveScoreBtn {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

#saveScoreBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(67, 233, 123, 0.4);
}

#saveScoreBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.restart-button {
    background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.restart-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

/* コントロールボタン */
.game-controls {
    margin-top: 20px;
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

#startBtn, #helpBtn {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
}

#helpBtn {
    background: linear-gradient(135deg, #f39c12 0%, #e74c3c 100%);
}

#startBtn:hover, #helpBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(67, 233, 123, 0.4);
}

#helpBtn:hover {
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

.install-button {
    background: linear-gradient(135deg, #51cf66 0%, #2ecc71 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s;
}

.install-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(81, 207, 102, 0.4);
}

/* ヘルプパネル */
.help-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.help-panel h2 {
    color: #4CAF50;
    text-align: center;
    font-size: 24px;
    margin: 0 0 20px 0;
    padding: 10px;
    background: linear-gradient(135deg, #c3f0ca 0%, #8fde9b 100%);
    border-radius: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.help-section {
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border-left: 4px solid #4CAF50;
}

.help-section h3 {
    color: #495057;
    font-size: 18px;
    margin: 0 0 10px 0;
    font-weight: bold;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    padding: 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.help-section strong {
    color: #4CAF50;
    font-size: 15px;
}

/* ハイスコアパネル */
.highscore-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.highscore-panel h2 {
    color: #4CAF50;
    text-align: center;
    font-size: 24px;
    margin: 0 0 20px 0;
    padding: 10px;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border-radius: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.highscore-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.highscore-item {
    padding: 15px 15px 15px 45px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border-left: 4px solid #4CAF50;
    position: relative;
}

.highscore-item.rank-1 {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe08a 100%);
    border-left-color: #ffd700;
}

.highscore-item.rank-2 {
    background: linear-gradient(135deg, #e7eaf6 0%, #d6dbe5 100%);
    border-left-color: #c0c0c0;
}

.highscore-item.rank-3 {
    background: linear-gradient(135deg, #ffebd1 0%, #ffd4a3 100%);
    border-left-color: #cd7f32;
}

.highscore-rank {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    font-weight: bold;
}

.highscore-name {
    font-weight: bold;
    color: #495057;
    font-size: 16px;
    margin-bottom: 5px;
}

.highscore-score {
    color: #4CAF50;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
}

.highscore-distance {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 3px;
}

.highscore-date {
    color: #868e96;
    font-size: 12px;
}

.no-scores {
    text-align: center;
    padding: 30px;
    color: #868e96;
    font-size: 14px;
}

/* スクロールバーのスタイル */
.help-panel::-webkit-scrollbar,
.highscore-panel::-webkit-scrollbar {
    width: 8px;
}

.help-panel::-webkit-scrollbar-track,
.highscore-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.help-panel::-webkit-scrollbar-thumb,
.highscore-panel::-webkit-scrollbar-thumb {
    background: #4CAF50;
    border-radius: 10px;
}

.help-panel::-webkit-scrollbar-thumb:hover,
.highscore-panel::-webkit-scrollbar-thumb:hover {
    background: #45a049;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .main-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .help-panel {
        width: 100%;
        max-width: 500px;
        order: 2;
    }

    .game-container {
        order: 1;
    }

    .highscore-panel {
        width: 100%;
        max-width: 500px;
        order: 3;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .main-wrapper {
        padding-top: 10px;
    }

    .game-container {
        padding: 15px;
        width: 100%;
        max-width: 100%;
    }

    .help-panel {
        width: 100%;
        max-width: none;
        padding: 15px;
        margin-top: 20px;
    }

    .highscore-panel {
        width: 100%;
        max-width: none;
        padding: 15px;
        margin-top: 20px;
    }

    #gameCanvas {
        width: 100% !important;
        height: auto !important;
        max-width: 800px;
        margin: 0 auto;
    }

    .game-controls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    #startBtn, #helpBtn {
        width: 100%;
        padding: 15px 20px;
    }

    .powerup-display {
        flex-wrap: wrap;
    }

    .game-header {
        font-size: 16px;
    }

    #score, #distance, #coins {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }

    .help-panel h2,
    .highscore-panel h2 {
        font-size: 18px;
    }

    .help-section h3 {
        font-size: 15px;
    }

    .help-section li {
        font-size: 12px;
    }

    .panic-mode-title {
        font-size: 20px;
    }

    .panic-mode-timer {
        font-size: 18px;
    }

    .game-over-screen {
        width: 90%;
        padding: 20px;
    }
}