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

body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background: linear-gradient(135deg, #ee9ca7 0%, #ffdde1 50%, #2193b0 100%);
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    padding: 20px;
}

.game-container {
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    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: 48px;
    font-weight: bold;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5),
                 0 0 40px rgba(33, 147, 176, 0.5);
    letter-spacing: 4px;
}

.title-sub {
    display: block;
    font-size: 16px;
    letter-spacing: 8px;
    margin-top: 10px;
    opacity: 0.8;
}

.game-description {
    text-align: center;
    margin-bottom: 40px;
    font-size: 18px;
    opacity: 0.9;
}

.mode-selection h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 24px;
}

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

.mode-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    color: #fff;
    text-align: left;
}

.mode-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.2));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.mode-name {
    display: block;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.mode-desc {
    display: block;
    font-size: 14px;
    opacity: 0.8;
}

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

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

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

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: bold;
}

/* パズル */
.puzzle-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
}

.puzzle-grid {
    display: grid;
    gap: 5px;
    width: fit-content;
    margin: 0 auto;
}

.puzzle-tile {
    aspect-ratio: 1;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    border: 2px solid rgba(33, 147, 176, 0.5);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: #2193b0;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.puzzle-tile:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0.9));
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

.puzzle-tile.empty {
    background: rgba(0, 0, 0, 0.2);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    cursor: default;
}

.puzzle-tile.empty:hover {
    transform: none;
    box-shadow: none;
}

.puzzle-tile.hint {
    animation: hintPulse 1s;
}

@keyframes hintPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(74, 222, 128, 0);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 20px rgba(74, 222, 128, 0.8);
    }
}

/* コントロール */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.control-btn {
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* 結果画面 */
.result-title {
    text-align: center;
    font-size: 36px;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

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

.result-stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-stat:last-child {
    border-bottom: none;
}

.result-stat.high-score {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.2));
    padding: 15px;
    border-radius: 10px;
    margin-top: 10px;
}

.result-stat.high-score .result-value {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.result-label {
    font-size: 18px;
    opacity: 0.8;
}

.result-value {
    font-size: 24px;
    font-weight: bold;
}

.result-rank {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

.rank-label {
    display: block;
    font-size: 18px;
    opacity: 0.8;
    margin-bottom: 10px;
}

.rank-value {
    display: block;
    font-size: 32px;
    font-weight: bold;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

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

.retry-btn {
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
    color: #fff;
}

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

.retry-btn:hover,
.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .title-main {
        font-size: 36px;
    }

    .puzzle-tile {
        font-size: 24px;
    }
}

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

    .puzzle-tile {
        font-size: 20px;
    }

    .controls {
        flex-direction: column;
    }
}
