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

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

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.header {
    margin-bottom: 30px;
}

.start-screen {
    text-align: center;
    padding: 20px 0;
}

.start-content h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.start-content p {
    font-size: 1rem;
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
}

.nickname-input {
    margin-bottom: 25px;
}

.nickname-input input {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    font-size: 1.1rem;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', sans-serif;
    text-align: center;
}

.nickname-input input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    text-align: left;
    padding-left: 20px;
}

.nickname-input input::placeholder {
    color: #999;
    font-weight: 400;
    opacity: 1;
}

.nickname-input input:focus::placeholder {
    opacity: 0;
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.start-content .nickname-input {
    margin-bottom: 0;
}

.start-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 500;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', sans-serif;
    min-width: 200px;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.start-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.leaderboard-btn {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 500;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', sans-serif;
    min-width: 200px;
}

.leaderboard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.back-btn {
    background: linear-gradient(45deg, #95A5A6, #7F8C8D);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', sans-serif;
    margin-top: 20px;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.leaderboard-screen {
    text-align: center;
    padding: 20px 0;
}

.leaderboard-screen .header {
    display: none;
}

.leaderboard-content h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 25px;
}

.leaderboard-list {
    max-height: 350px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding-right: 5px;
}

.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 12px;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.leaderboard-item:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.leaderboard-item.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    border-left-color: #FF8C00;
}

.leaderboard-item.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A9A9A9);
    color: white;
    border-left-color: #808080;
}

.leaderboard-item.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #B8860B);
    color: white;
    border-left-color: #A0522D;
}

.rank {
    font-weight: 700;
    font-size: 1.1rem;
    min-width: 30px;
}

.player-info {
    flex: 1;
    text-align: left;
    margin-left: 15px;
}

.player-info .name {
    font-weight: 500;
    font-size: 1rem;
}

.player-info .date {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 2px;
}

.level {
    font-weight: 700;
    font-size: 1.1rem;
    color: #667eea;
}

.leaderboard-item.rank-1 .level,
.leaderboard-item.rank-2 .level,
.leaderboard-item.rank-3 .level {
    color: white;
}

.loading {
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.error {
    padding: 20px;
    color: #e74c3c;
    background: #fdf2f2;
    border-radius: 8px;
    margin: 20px 0;
}

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.timer-container {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
    margin-bottom: 10px;
}

.timer-bar {
    width: 200px;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.timer-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #FFC107, #FF5722);
    transition: width 0.1s linear;
    border-radius: 4px;
}

.timer-text {
    font-weight: 500;
    color: #666;
    min-width: 40px;
}

.countdown {
    font-size: 5rem;
    font-weight: 700;
    color: #667eea;
    margin: 50px 0;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s ease;
}

.countdown.show {
    opacity: 1;
    transform: scale(1);
}

.score {
    font-size: 1.2rem;
    font-weight: 500;
    color: #666;
    margin-bottom: 20px;
}

.game-grid {
    display: grid;
    gap: 8px;
    margin: 30px auto;
    max-width: 400px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.game-grid.show {
    opacity: 1;
    transform: translateY(0);
}

.grid-2x2 { grid-template-columns: repeat(2, 1fr); }
.grid-3x3 { grid-template-columns: repeat(3, 1fr); }
.grid-4x4 { grid-template-columns: repeat(4, 1fr); }
.grid-5x5 { grid-template-columns: repeat(5, 1fr); }

.tile {
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.tile.correct {
    border-color: #4CAF50;
    animation: correct 0.3s ease;
}

.tile.wrong {
    border-color: #FF5722;
    animation: wrong 0.3s ease;
}

@keyframes correct {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes wrong {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
    100% { transform: translateX(0); }
}

.message {
    font-size: 1.1rem;
    font-weight: 500;
    min-height: 30px;
    margin-top: 20px;
    color: #666;
}

.message.error {
    color: #FF5722;
    animation: shake 0.3s ease;
}

.message.success {
    color: #4CAF50;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 1000;
}

.game-over h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #fff;
}

.game-over .player-name {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #fff;
    font-weight: 500;
}

.game-over .final-score {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: #ccc;
}

.restart-btn {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 500;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', sans-serif;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    .title {
        font-size: 2rem;
    }
    
    .countdown {
        font-size: 4rem;
        margin: 30px 0;
    }
    
    .timer-bar {
        width: 150px;
    }
    
    .game-grid {
        max-width: 300px;
        gap: 6px;
    }
    
    .tile {
        border-radius: 6px;
    }
}

@media (max-width: 400px) {
    .title {
        font-size: 1.8rem;
    }
    
    .countdown {
        font-size: 3rem;
    }
    
    .timer-bar {
        width: 120px;
    }
    
    .game-grid {
        max-width: 250px;
        gap: 4px;
    }
}