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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #fff;
}

/* Dashboard layout */
.site-header {
    text-align: center;
    padding: 60px 20px 30px;
}

.site-header h1 {
    font-size: 3.5rem;
    color: #4ecca3;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 4px;
    margin-bottom: 10px;
}

.site-header p {
    font-size: 1.2rem;
    color: #a0a0c0;
}

.dashboard {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    padding: 40px 20px;
    flex-wrap: wrap;
}

.game-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px 30px;
    width: 320px;
    text-align: center;
    text-decoration: none;
    color: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.game-card:hover {
    transform: translateY(-8px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(78, 204, 163, 0.4);
    box-shadow: 0 15px 40px rgba(78, 204, 163, 0.2);
}

.card-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.game-card h2 {
    font-size: 1.8rem;
    margin-bottom: 12px;
    color: #4ecca3;
}

.game-card p {
    color: #b0b0d0;
    margin-bottom: 25px;
    line-height: 1.5;
}

.play-link {
    display: inline-block;
    color: #4ecca3;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.site-footer {
    text-align: center;
    padding: 30px 20px;
    color: #707090;
    font-size: 0.9rem;
}

/* Game page layout */
.game-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.game-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.2);
}

.game-nav h1 {
    font-size: 1.8rem;
    color: #4ecca3;
    letter-spacing: 2px;
}

.back-link {
    color: #a0a0c0;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.2s;
}

.back-link:hover {
    color: #4ecca3;
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 15px;
}

.score-board {
    display: flex;
    gap: 30px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #4ecca3;
}

.difficulty-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: #a0a0c0;
}

.difficulty-bar select {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #f0f0f5;
    font-size: 1rem;
    cursor: pointer;
}

canvas {
    border: 2px solid #4ecca3;
    border-radius: 12px;
    background: #0f0f23;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.controls {
    text-align: center;
    color: #a0a0c0;
    margin-top: 10px;
}

.controls p {
    margin-bottom: 12px;
    font-size: 0.95rem;
}

button {
    background: #4ecca3;
    color: #1a1a2e;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover {
    background: #3db892;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(78, 204, 163, 0.3);
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #4ecca3;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    z-index: 100;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

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

.game-over p {
    font-size: 1.3rem;
    margin-bottom: 25px;
    color: #f0f0f5;
}

.hidden {
    display: none !important;
}

/* Auth bar */
.auth-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.auth-bar span {
    color: #a0a0c0;
    font-size: 1rem;
}

.auth-btn {
    padding: 8px 18px;
    font-size: 0.9rem;
    text-transform: none;
}

.profile-link {
    color: #4ecca3;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95rem;
}

.profile-link:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1a1a2e;
    border: 2px solid #4ecca3;
    border-radius: 12px;
    padding: 28px;
    width: 90%;
    max-width: 380px;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 18px;
    color: #4ecca3;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #f0f0f5;
    font-size: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: #4ecca3;
}

.modal-content button[type="submit"] {
    width: 100%;
    margin-top: 8px;
}

.modal-content .error {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.modal-content .error.hidden {
    display: none;
}

.toggle-auth {
    text-align: center;
    margin-top: 14px;
    color: #a0a0c0;
}

.toggle-auth a {
    color: #4ecca3;
    cursor: pointer;
}

.link-btn {
    background: transparent;
    border: none;
    color: #4ecca3;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    text-transform: none;
    letter-spacing: 0;
}

.link-btn:hover {
    text-decoration: underline;
    transform: none;
    box-shadow: none;
}

.close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    color: #707090;
    cursor: pointer;
}

.close:hover {
    color: #f0f0f5;
}

/* Leaderboard section */
.leaderboard-section {
    max-width: 900px;
    margin: 0 auto 60px;
    padding: 0 20px;
    width: 100%;
}

.leaderboard-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #4ecca3;
    font-size: 1.8rem;
}

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

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a0a0c0;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tab-btn.active, .tab-btn:hover {
    background: rgba(78, 204, 163, 0.15);
    border-color: #4ecca3;
    color: #4ecca3;
}

.difficulty-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.diff-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a0a0c0;
    padding: 6px 14px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.diff-btn.active, .diff-btn:hover {
    background: rgba(78, 204, 163, 0.15);
    border-color: #4ecca3;
    color: #4ecca3;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table th {
    color: #4ecca3;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.leaderboard-table td {
    color: #d0d0e0;
}

.leaderboard-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Profile page */
.profile-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    flex: 1;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.profile-avatar {
    font-size: 5rem;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    border: 2px solid #4ecca3;
}

.profile-info h2 {
    font-size: 2rem;
    color: #4ecca3;
    margin-bottom: 6px;
}

.profile-handle {
    color: #a0a0c0;
    font-size: 1rem;
    margin-bottom: 10px;
}

.profile-bio {
    color: #d0d0e0;
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.profile-joined {
    color: #707090;
    font-size: 0.85rem;
}

.edit-profile-btn {
    margin-left: auto;
    padding: 10px 20px;
    font-size: 0.9rem;
    text-transform: none;
}

.edit-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 40px;
}

.edit-panel h3 {
    color: #4ecca3;
    margin-bottom: 18px;
}

.edit-panel label {
    display: block;
    color: #a0a0c0;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.edit-panel input, .edit-panel textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #f0f0f5;
    font-size: 1rem;
    font-family: inherit;
}

.edit-panel input:focus, .edit-panel textarea:focus {
    outline: none;
    border-color: #4ecca3;
}

.edit-actions {
    display: flex;
    gap: 12px;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #f0f0f5;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.stats-section, .history-section {
    margin-bottom: 40px;
}

.stats-section h2, .history-section h2 {
    color: #4ecca3;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    color: #4ecca3;
    font-weight: bold;
}

.stat-card .stat-label {
    color: #a0a0c0;
    font-size: 0.9rem;
    margin-top: 6px;
}

.empty-stats {
    color: #707090;
    font-style: italic;
}

/* Auth modal login-pill variant */
.login-pill {
    color: #a0a0c0;
    border-bottom: 1px dashed #a0a0c0;
    cursor: pointer;
    padding-bottom: 1px;
}

.login-pill:hover {
    color: #4ecca3;
    border-bottom-color: #4ecca3;
}

.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1a1a2e;
    border: 2px solid #4ecca3;
    border-radius: 12px;
    padding: 28px;
    width: 90%;
    max-width: 380px;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 18px;
    color: #4ecca3;
}

.modal-content input {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #f0f0f5;
    font-size: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: #4ecca3;
}

.modal-content button[type="submit"] {
    width: 100%;
    margin-top: 8px;
}

.modal-content .error {
    color: #ff6b6b;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.modal-content .error.hidden {
    display: none;
}

.toggle-auth {
    text-align: center;
    margin-top: 14px;
    color: #a0a0c0;
}

.toggle-auth a {
    color: #4ecca3;
    cursor: pointer;
}

.link-btn {
    background: transparent;
    border: none;
    color: #4ecca3;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    text-transform: none;
    letter-spacing: 0;
}

.link-btn:hover {
    text-decoration: underline;
    transform: none;
    box-shadow: none;
}

.close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    color: #707090;
    cursor: pointer;
}

.close:hover {
    color: #f0f0f5;
}

/* Leaderboard section */
.leaderboard-section {
    max-width: 900px;
    margin: 0 auto 60px;
    padding: 0 20px;
    width: 100%;
}

.leaderboard-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #4ecca3;
    font-size: 1.8rem;
}

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

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a0a0c0;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tab-btn.active, .tab-btn:hover {
    background: rgba(78, 204, 163, 0.15);
    border-color: #4ecca3;
    color: #4ecca3;
}

.difficulty-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.diff-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #a0a0c0;
    padding: 6px 14px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.diff-btn.active, .diff-btn:hover {
    background: rgba(78, 204, 163, 0.15);
    border-color: #4ecca3;
    color: #4ecca3;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table th {
    color: #4ecca3;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.leaderboard-table td {
    color: #d0d0e0;
}

.leaderboard-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Responsive */
@media (max-width: 700px) {
    .site-header h1 {
        font-size: 2.2rem;
    }
    .dashboard {
        gap: 20px;
        padding: 20px 10px;
    }
    .game-card {
        width: 90%;
        padding: 30px 20px;
    }
    .game-nav {
        padding: 15px 20px;
    }
    .score-board {
        font-size: 1rem;
    }
    .game-over h2 {
        font-size: 1.8rem;
    }
    .profile-card {
        flex-direction: column;
        text-align: center;
    }
    .edit-profile-btn {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .profile-page {
        padding: 20px 10px;
    }
    .auth-bar {
        flex-direction: column;
        gap: 10px;
    }
    .leaderboard-table th, .leaderboard-table td {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
    .leaderboard-table th:nth-child(4), .leaderboard-table td:nth-child(4),
    .leaderboard-table th:nth-child(5), .leaderboard-table td:nth-child(5) {
        display: none;
    }
    .modal-content {
        padding: 22px;
    }
    .difficulty-bar {
        font-size: 0.9rem;
    }
    .controls p {
        font-size: 0.85rem;
    }
    button {
        padding: 10px 22px;
        font-size: 0.95rem;
    }
    .profile-avatar {
        font-size: 3.5rem;
        width: 80px;
        height: 80px;
    }
    .profile-info h2 {
        font-size: 1.5rem;
    }
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    canvas {
        max-width: 95vw;
    }
}

/* Badges */
.badges-section {
    max-width: 900px;
    margin: 0 auto 60px;
    padding: 0 20px;
    width: 100%;
}

.badges-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #ffd700;
    font-size: 1.6rem;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.badge-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 18px 12px;
    text-align: center;
    transition: all 0.25s ease;
}

.badge-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 215, 0, 0.4);
    box-shadow: 0 8px 24px rgba(255, 215, 0, 0.15);
}

.badge-card.earned {
    border-color: rgba(255, 215, 0, 0.5);
    background: rgba(255, 215, 0, 0.06);
}

.badge-card.locked {
    opacity: 0.4;
    filter: grayscale(0.7);
}

.badge-icon {
    font-size: 2.4rem;
    margin-bottom: 8px;
}

.badge-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f0f0f5;
    margin-bottom: 4px;
}

.badge-desc {
    font-size: 0.75rem;
    color: #a0a0c0;
    line-height: 1.3;
}

.badge-earned-date {
    font-size: 0.7rem;
    color: #ffd700;
    margin-top: 6px;
}
