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

body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background: linear-gradient(135deg, #FF6B6B 0%, #4ECDC4 50%, #FFE66D 100%);
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    overflow: hidden;
}

.game-container {
    width: 95%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.screen {
    display: none;
    animation: fadeIn 0.5s;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* タイトル画面 */
.game-title {
    text-align: center;
    margin-bottom: 20px;
}

.title-main {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.title-sub {
    display: block;
    font-size: 1em;
    opacity: 0.9;
    margin-top: 5px;
}

.game-description {
    text-align: center;
    font-size: 1.1em;
    margin-bottom: 30px;
    opacity: 0.95;
}

.mode-selection h2 {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    padding: 20px;
    color: #fff;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.mode-btn:hover, .mode-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255, 255, 255, 0.3);
}

.mode-name {
    font-weight: bold;
    font-size: 1.2em;
}

.mode-desc {
    font-size: 0.9em;
    opacity: 0.9;
}

.high-scores {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
}

.high-scores h3 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.high-score-list {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
}

.high-score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    min-width: 80px;
}

.high-score-item span:first-child {
    font-size: 0.9em;
    opacity: 0.9;
}

.high-score-item span:last-child {
    font-size: 1.3em;
    font-weight: bold;
}

/* ゲーム画面 */
.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 10px;
}

.stat {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 10px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
}

.instruction {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 15px;
}

.target-color-label {
    font-size: 1.1em;
    margin-bottom: 10px;
    font-weight: bold;
}

.target-color {
    width: 80px;
    height: 80px;
    margin: 10px auto;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.target-name {
    font-size: 1.3em;
    font-weight: bold;
    margin-top: 10px;
}

.panic-mode-banner {
    background: linear-gradient(90deg, #FF4444, #FF8800, #FF4444);
    color: #fff;
    text-align: center;
    padding: 15px;
    font-size: 1.5em;
    font-weight: bold;
    border-radius: 10px;
    margin-bottom: 15px;
    display: none;
    animation: pulse 0.5s infinite;
}

.panic-mode-banner.active {
    display: block;
}

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

.color-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
}

.color-grid.grid-small {
    grid-template-columns: repeat(3, 1fr);
}

.color-grid.grid-medium {
    grid-template-columns: repeat(4, 1fr);
}

.color-grid.grid-large {
    grid-template-columns: repeat(4, 1fr);
}

.color-block {
    aspect-ratio: 1;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.color-block:hover, .color-block:active {
    transform: scale(0.95);
}

.feedback {
    text-align: center;
    font-size: 1.5em;
    font-weight: bold;
    height: 40px;
    opacity: 0;
    transition: opacity 0.3s;
}

.feedback.show {
    opacity: 1;
}

.feedback.correct {
    color: #4AFF4A;
    text-shadow: 0 0 10px #4AFF4A;
}

.feedback.wrong {
    color: #FF4A4A;
    text-shadow: 0 0 10px #FF4A4A;
}

/* 結果画面 */
.result-title {
    text-align: center;
    font-size: 2em;
    margin-bottom: 20px;
}

.result-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.result-stat {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.result-label {
    font-size: 1.1em;
}

.result-value {
    font-size: 1.3em;
    font-weight: bold;
}

.result-stat.high-score {
    background: rgba(255, 215, 0, 0.3);
}

.result-rank {
    text-align: center;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.rank-label {
    display: block;
    font-size: 1em;
    margin-bottom: 5px;
}

.rank-value {
    display: block;
    font-size: 3em;
    font-weight: bold;
    text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5);
}

.retry-btn, .back-btn {
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    font-size: 1.2em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.retry-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.retry-btn:hover, .retry-btn:active {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5);
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.back-btn:hover, .back-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

/* スマホ対応 */
@media (max-width: 480px) {
    .game-container {
        padding: 15px;
    }

    .title-main {
        font-size: 2em;
    }

    .game-header {
        flex-wrap: wrap;
    }

    .stat {
        min-width: 30%;
    }

    .target-color {
        width: 60px;
        height: 60px;
    }

    .color-grid {
        gap: 8px;
    }

    .panic-mode-banner {
        font-size: 1.2em;
        padding: 10px;
    }
}

/* タッチデバイス用 */
@media (hover: none) {
    .mode-btn:hover {
        transform: none;
    }

    .mode-btn:active {
        transform: scale(0.98);
    }

    .color-block:hover {
        transform: none;
    }

    .retry-btn:hover, .back-btn:hover {
        transform: none;
    }
}