/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Quicksand, sans-serif;
    margin: 40px;
    background: linear-gradient(135deg, #AEC8FD 0%, #EBADD9 100%);
    min-height: 100vh;
    color: #333;
}

/* Main container */
.container {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    margin: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Top 10 Container - Separate from main container */
.top10-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.top10-container:empty {
    display: none;
}

/* Header styling */
h2 {
    text-align: center;
    margin-bottom: 25px;
    color: #2c3e50;
    font-size: 1.5em;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Form elements */
input, select {
    padding: 12px 15px;
    width: 100%;
    margin-bottom: 15px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #fff;
    color: #333;
}

input:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    transform: translateY(-1px);
}

input::placeholder {
    color: #999;
    font-style: italic;
}

/* Button styling */
button {
    padding: 12px 20px;
    width: 100%;
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

button:hover {
    background: linear-gradient(45deg, #0056b3, #003d82);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

/* Results section */
#ketqua {
    margin-top: 20px;
    font-size: 14px;
    line-height: 1.6;
    animation: fadeIn 0.5s ease-out;
}

#ketqua:empty {
    display: none;
}

/* Result card styling */
.result-card {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 25px;
    border-radius: 12px;
    border-left: 4px solid #007bff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.result-card h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3em;
    text-align: center;
    border-bottom: 2px solid #007bff;
    padding-bottom: 10px;
}

/* Score section */
.score-section {
    margin-bottom: 25px;
    text-align: center;
}

.total-score {
    font-size: 1.2em;
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.total-score .score {
    font-size: 1.3em;
    font-weight: bold;
}

/* Ranking section */
.ranking-section {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ranking-section h4 {
    color: #495057;
    margin-bottom: 12px;
    font-size: 1.1em;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}

.rank-details p {
    margin-bottom: 8px;
    font-size: 0.95em;
}

.rank-details strong {
    color: #2c3e50;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    border-radius: 10px;
    transition: width 0.8s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.2) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.2) 75%,
        transparent 75%,
        transparent
    );
    background-size: 20px 20px;
    animation: move 2s linear infinite;
}

@keyframes move {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 20px;
    }
}

/* Stats section */
.stats-section {
    margin-top: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border-radius: 8px;
    border: 1px solid #2196f3;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.stat-item:last-child {
    margin-bottom: 0;
}

.stat-label {
    color: #1976d2;
    font-weight: 500;
}

.stat-value {
    color: #0d47a1;
    font-weight: bold;
}

/* Scores grid for individual subjects */
.scores-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-radius: 8px;
    font-weight: 500;
    transition: transform 0.2s ease;
    white-space: nowrap;
}

.score-item:hover {
    transform: translateY(-2px);
}

.score-item.excellent {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-left: 4px solid #28a745;
    color: #155724;
}

.score-item.outstanding {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border-left: 4px solid #ff9800;
    color: #e65100;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
}

.score-item.good {
    background: linear-gradient(135deg, #cce5ff, #b3d9ff);
    border-left: 4px solid #007bff;
    color: #004085;
}

.score-item.average {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-left: 4px solid #ffc107;
    color: #856404;
}

.score-item.poor {
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.score-item .subject {
    font-weight: 600;
    flex: 1;
    margin-right: 15px;
}

.score-item .score {
    font-size: 1.1em;
    font-weight: bold;
    min-width: 60px;
    text-align: right;
}

/* Note section */
.note {
    background: linear-gradient(135deg, #e1f5fe, #b3e5fc);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #03a9f4;
    margin-top: 20px;
}

.note p {
    margin: 0;
    color: #01579b;
    font-size: 0.9em;
}

/* Loading, success, and error states */
.loading {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    border-left: 4px solid #6c757d;
}

.success {
    color: #155724;
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-left: 4px solid #28a745;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.error {
    color: #721c24;
    background: linear-gradient(135deg, #f8d7da, #f5c6cb);
    border-left: 4px solid #dc3545;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
}

/* Responsive design */
@media (max-width: 600px) {
    body {
        margin: 20px;
    }
    
    .container {
        padding: 20px;
        border-radius: 10px;
    }
    
    h2 {
        font-size: 1.3em;
    }
    
    input, select, button {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .result-card {
        padding: 20px;
    }
    
    .result-card h3 {
        font-size: 1.2em;
    }
    
    .scores-grid {
        gap: 6px;
    }
    .score-item {
        padding: 10px 12px;
        font-size: 0.9em;
    }
    .score-item .subject {
        margin-right: 10px;
    }
    .score-item .score {
        min-width: 50px;
        font-size: 1em;
    }
    
    .stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    /* Adjust sound toggle for mobile */
    .sound-toggle {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    /* Adjust top 10 container for mobile */
    .top10-container {
        padding: 0 10px;
        margin: 20px auto;
    }
}

/* Animation for smooth transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#ketqua {
    animation: fadeIn 0.5s ease-out;
}

/* Hover effects for interactive elements */
input:hover, select:hover {
    border-color: #007bff;
}

/* Custom select arrow */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    color: #333;
}

/* Focus visible for accessibility */
button:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Sound toggle button */
.sound-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(45deg, #007bff, #0056b3);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    text-transform: none;
    letter-spacing: normal;
    padding: 0;
}

.sound-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
}

.sound-toggle:active {
    transform: scale(0.95);
}

.sound-toggle.muted {
    background: linear-gradient(45deg, #6c757d, #495057);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.sound-toggle.muted:hover {
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

/* Footer styles */
.footer {
    width: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 25px 0 15px 0;
    text-align: center;
    margin-top: 40px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.footer-content {
    max-width: 600px;
    margin: 0 auto;
    font-size: 1em;
    line-height: 1.7;
}
.footer a {
    color: #ffd700;
    text-decoration: underline;
    transition: color 0.2s;
}
.footer a:hover {
    color: #fff;
}

@media (max-width: 600px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer {
        padding: 15px;
    }
}

/* Top 10 Section Styles */
.top10-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid #dee2e6;
}

.top10-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
}

.top10-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.top10-box {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.top10-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.top10-box h4 {
    color: #495057;
    margin-bottom: 12px;
    font-size: 1.1em;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 2px solid #007bff;
    font-weight: 600;
}

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

.top10-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 6px;
    border-left: 3px solid #007bff;
    transition: all 0.3s ease;
}

.top10-item:hover {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.top10-item:first-child {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-left-color: #ffc107;
    font-weight: bold;
}

.top10-item:nth-child(2) {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-left-color: #6c757d;
    font-weight: bold;
}

.top10-item:nth-child(3) {
    background: linear-gradient(135deg, #fff5f5, #fed7d7);
    border-left-color: #e53e3e;
    font-weight: bold;
}

.top10-item .rank {
    font-weight: bold;
    color: #2c3e50;
    min-width: 60px;
}

.top10-item .sbd {
    color: #495057;
    font-family: monospace;
    font-size: 0.9em;
    flex: 1;
    text-align: center;
}

.top10-item .score {
    font-weight: bold;
    color: #007bff;
    min-width: 80px;
    text-align: right;
}

.no-data {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #dee2e6;
}

/* Responsive design for top 10 */
@media (max-width: 600px) {
    .top10-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .top10-box {
        padding: 12px;
    }

    .top10-item {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }

    .top10-item .rank,
    .top10-item .sbd,
    .top10-item .score {
        min-width: auto;
        text-align: center;
    }

    .top10-list {
        max-height: 250px;
    }
}
.total-score:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}
