* {
    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: 10px;
}

.login-container,
.signup-container,
.dashboard-container,
.story-container,
.rank-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 550px;
    padding: 20px;
}

.logo-section {
    text-align: center;
    margin-bottom: 20px;
}

.logo {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 35px;
    color: white;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
}

.app-subtitle {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.tagline {
    font-size: 11px;
    color: #999;
    font-style: italic;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 12px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 38px;
    cursor: pointer;
    color: #667eea;
    font-size: 16px;
    user-select: none;
}

.remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    cursor: pointer;
}

.forgot-password {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.forgot-password:hover {
    color: #764ba2;
}

.btn-login,
.btn-signup {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-login:hover,
.btn-signup:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-login:active,
.btn-signup:active {
    transform: translateY(0);
}

.signup-section,
.login-section {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.signup-text,
.login-text {
    font-size: 12px;
    color: #666;
}

.signup-link,
.login-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.signup-link:hover,
.login-link:hover {
    color: #764ba2;
}

.error-message {
    display: none;
    background-color: #fff3cd;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 12px;
    border: 1px solid #ffeaa7;
}

.error-message.show {
    display: block;
}

.success-message {
    display: none;
    background-color: #d4edda;
    color: #155724;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 12px;
    border: 1px solid #c3e6cb;
}

.success-message.show {
    display: block;
}

.loading {
    display: none;
    text-align: center;
    margin-bottom: 15px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dashboard Styles */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.welcome-section h1 {
    font-size: 22px;
    color: #333;
    margin-bottom: 5px;
}

.welcome-section p {
    color: #666;
    font-size: 12px;
}

.logout-btn {
    background: #ff6b6b;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.logout-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.stat-card h3 {
    font-size: 11px;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
}

.games-section {
    margin-bottom: 25px;
}

.games-section h2 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.games-section h2::before {
    content: "⚙️";
    margin-right: 8px;
    font-size: 20px;
}

.games-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.game-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
}

.game-card:nth-child(2) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.game-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
}

.game-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.game-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.game-card p {
    font-size: 12px;
    opacity: 0.95;
    margin-bottom: 15px;
    line-height: 1.4;
}

.game-btn {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.game-btn:hover {
    background: white;
    color: #333;
}

.recent-section {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    font-size: 13px;
}

.recent-section h2 {
    font-size: 16px;
    color: #333;
    margin-bottom: 15px;
}

.no-attempts,
.no-data {
    text-align: center;
    color: #999;
    padding: 20px 10px;
    font-style: italic;
    font-size: 13px;
}

/* Story Mode & Rank Game */
.story-header,
.rank-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.story-header h1,
.rank-header h1 {
    font-size: 20px;
    color: #333;
}

.back-btn {
    background: #667eea;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.back-btn:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

.quizzes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 480px) {
    .quizzes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.quiz-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    padding: 18px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.quiz-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.35);
}

.quiz-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}

.quiz-info {
    font-size: 11px;
    opacity: 0.9;
    margin-bottom: 10px;
    line-height: 1.5;
}

.quiz-btn {
    background: white;
    color: #667eea;
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    transition: all 0.3s ease;
    width: 100%;
}

.quiz-btn:hover {
    background: #f0f0f0;
}

/* Leaderboard */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #f9f9f9;
    border-radius: 8px;
    overflow: hidden;
    font-size: 12px;
}

.leaderboard-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.leaderboard-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
}

.leaderboard-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e0e0e0;
}

.leaderboard-table tbody tr:hover {
    background: #f0f0f0;
}

.rank-badge {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    line-height: 28px;
    font-weight: 700;
    font-size: 12px;
}

.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #b8860b 100%);
}

.silver {
    background: linear-gradient(135deg, #c0c0c0 0%, #a8a8a8 100%);
}

.gold {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    color: #333;
}

@media (max-width: 600px) {
    .login-container,
    .signup-container,
    .dashboard-container,
    .story-container,
    .rank-container {
        max-width: 100%;
        padding: 15px;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-section {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .stat-card {
        padding: 15px 10px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .story-header,
    .rank-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .quizzes-grid {
        grid-template-columns: 1fr;
    }
}
