/* ===================== GENERAL STYLES ===================== */
* {
    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;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

/* ===================== HEADER ===================== */
header.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.95;
}

/* ===================== GAME WRAPPER ===================== */
.game-wrapper {
    padding: 30px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    font-size: 1em;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================== GAME SECTIONS ===================== */
.game-section {
    margin-bottom: 30px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Problem Container */
.problem-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    border: 2px solid #667eea;
}

.problem-container h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.problem-display {
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    border: 2px solid #667eea;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#problemText {
    font-size: 1.3em;
    font-weight: 600;
    color: #333;
}

/* Problem Input Area */
.problem-input-area {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.answer-input {
    flex: 1;
    padding: 12px 15px;
    font-size: 1em;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Timer Display */
.timer-display {
    text-align: center;
    font-size: 1.1em;
    color: #e74c3c;
    font-weight: 600;
    margin-bottom: 15px;
}

/* Feedback */
.feedback {
    min-height: 40px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    display: none;
}

.feedback.show {
    display: block;
}

.feedback.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.feedback.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Name Container */
.name-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.name-container h2 {
    margin-bottom: 15px;
    font-size: 1.5em;
}

.name-container p {
    margin-bottom: 20px;
    font-size: 1.1em;
}

.name-input {
    width: 100%;
    max-width: 400px;
    padding: 12px 15px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.name-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Spinner Container */
.spinner-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.spinner-container h2 {
    color: #667eea;
    margin-bottom: 30px;
    font-size: 1.5em;
}

.spinner-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto 30px;
}

canvas#spinnerCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 50%;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
    transition: transform 0.1s linear;
}

.spinner-pointer {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 15px solid #FF6B6B;
    z-index: 10;
}

/* Result Container */
.result-container {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.result-container h2 {
    margin-bottom: 25px;
    font-size: 1.5em;
}

.result-display {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.result-item {
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-item:last-of-type {
    border-bottom: none;
}

.result-label {
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
    font-size: 1.1em;
}

.result-value {
    display: block;
    font-size: 1.2em;
    letter-spacing: 0.5px;
}

.result-image-item {
    padding: 20px 0;
}

.result-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* ===================== LEADERBOARD ===================== */
.leaderboard-container {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
}

.leaderboard-container h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.leaderboard-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.leaderboard-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

.leaderboard-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.leaderboard-table tbody tr:hover {
    background: #f5f5f5;
}

.leaderboard-table tbody tr img {
    max-width: 60px;
    max-height: 60px;
    border-radius: 5px;
}

.leaderboard-table .loading {
    text-align: center;
    color: #999;
    padding: 30px !important;
}

/* ===================== BUTTONS ===================== */
.btn {
    padding: 12px 25px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-success {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* ===================== FOOTER ===================== */
footer.footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    border-top: 1px solid #eee;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .game-wrapper {
        padding: 15px;
    }

    .problem-display {
        min-height: 80px;
    }

    #problemText {
        font-size: 1em;
    }

    .problem-input-area {
        flex-direction: column;
    }

    .answer-input {
        width: 100%;
    }

    .spinner-wrapper {
        width: 100%;
    }

    canvas#spinnerCanvas {
        max-width: 90vw;
    }

    .leaderboard-table {
        font-size: 0.9em;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px;
    }

    .tab-navigation {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
    }
}

/* ===================== ANIMATIONS ===================== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spinning {
    animation: spin var(--spin-duration, 4s) var(--spin-timing, cubic-bezier(0.33, 0.66, 0.66, 1)) forwards;
}

/* ===================== LOADING ===================== */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 1.5s infinite;
}
