:root {
    --bg-dark: #0f172a;
    --bg-darker: #0b1120;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --rank-1: #fbbf24;
    --rank-2: #94a3b8;
    --rank-3: #b45309;
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-darker);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Background elements */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
}
.shape-1 {
    top: -10%; left: -10%;
    width: 400px; height: 400px;
    background: rgba(99, 102, 241, 0.3);
}
.shape-2 {
    bottom: -10%; right: -10%;
    width: 500px; height: 500px;
    background: rgba(168, 85, 247, 0.2);
}

.app-container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.main-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.header {
    text-align: center;
    margin-bottom: 40px;
}
.header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}
.header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

/* User Input Section */
.input-section {
    margin-bottom: 30px;
}
.input-section label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.modern-input {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    outline: none;
}
.modern-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Themes */
.themes-section h4 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.theme-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.theme-btn {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 16px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    width: 100%;
}
.theme-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}
.theme-icon {
    font-size: 2rem;
    margin-right: 16px;
    background: rgba(0, 0, 0, 0.2);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}
.theme-info {
    display: flex;
    flex-direction: column;
}
.theme-name {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 4px;
}
.theme-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    padding: 16px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.5);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-block {
    width: 100%;
}
.start-random-btn {
    width: 100%;
}

/* Leaderboard */
.leaderboard-section {
    display: flex;
    flex-direction: column;
}

.leaderboard-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.leaderboard-header h3 {
    font-weight: 700;
    font-size: 1.2rem;
}
.badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar for Leaderboard */
.leaderboard-list::-webkit-scrollbar {
    width: 6px;
}
.leaderboard-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}
.leaderboard-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
.leaderboard-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    transition: background 0.2s;
}
.rank-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.rank-pos {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    margin-right: 16px;
    color: var(--text-muted);
}
.rank-player {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
}
.rank-score {
    font-weight: 700;
    font-size: 1rem;
}
.pts {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 4px;
}

/* Rank Highlights */
.first .rank-pos { background: rgba(251, 191, 36, 0.2); color: var(--rank-1); }
.first .rank-player { color: var(--rank-1); font-weight: 700; }
.second .rank-pos { background: rgba(148, 163, 184, 0.2); color: var(--rank-2); }
.second .rank-player { color: var(--rank-2); font-weight: 600; }
.third .rank-pos { background: rgba(180, 83, 9, 0.2); color: var(--rank-3); }
.third .rank-player { color: var(--rank-3); font-weight: 600; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 32px;
    border-radius: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.modal-overlay.show .modal-box {
    transform: translateY(0);
}
.modal-title {
    font-size: 1.25rem;
    margin-bottom: 12px;
    color: var(--text-main);
}
.modal-msg {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 24px;
}

@media (max-width: 768px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    .main-card {
        padding: 24px;
    }
    .header h1 {
        font-size: 2rem;
    }
}