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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.scores {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.score-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    background: #e0e0e0;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 30px;
    aspect-ratio: 1;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.cell {
    background: white;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.cell.filled {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell:hover {
    transform: scale(1.05);
}

.cell.destroyed {
    animation: destroy 0.5s ease-out;
}

@keyframes destroy {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.controls {
    text-align: center;
}

.turn-counter {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.color-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.color-btn {
    padding: 15px 25px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.color-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.color-btn:active:not(:disabled) {
    transform: translateY(0);
}

.color-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.restart-btn {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.restart-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    font-size: 1.3em;
    margin-bottom: 25px;
    color: #333;
}

#final-score {
    color: #764ba2;
    font-weight: bold;
}

/* 하이스코어 입력 폼 */
.highscore-form {
    margin: 15px 0;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.highscore-form.hidden {
    display: none;
}

#player-name {
    flex: 1;
    max-width: 200px;
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #667eea;
    border-radius: 8px;
    text-align: center;
    text-transform: uppercase;
    font-family: 'Segoe UI', monospace;
}

#player-name:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.submit-btn {
    padding: 10px 25px;
    background: #2ECC71;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.submit-btn:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.submit-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
}

/* 리더보드 */
.leaderboard {
    margin: 20px 0;
}

.leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.leaderboard-item.top-1 {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: white;
    font-weight: bold;
}

.leaderboard-item.top-2 {
    background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
    color: white;
}

.leaderboard-item.top-3 {
    background: linear-gradient(135deg, #CD7F32 0%, #B8860B 100%);
    color: white;
}

.rank {
    font-weight: bold;
    font-size: 1.2em;
    min-width: 40px;
}

.player-name {
    flex: 1;
    text-align: left;
    font-weight: bold;
    font-family: monospace;
    font-size: 1.1em;
}

.player-score {
    font-weight: bold;
    font-size: 1.1em;
}

.loading {
    color: #95a5a6;
    font-style: italic;
}

.error-message {
    color: #e74c3c;
    padding: 10px;
    background: #fadbd8;
    border-radius: 5px;
    margin: 10px 0;
}

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

    h1 {
        font-size: 2em;
    }

    .scores {
        gap: 20px;
    }

    .color-btn {
        padding: 12px 20px;
        font-size: 0.9em;
    }
}
