@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

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

body {
    font-family: 'Space Grotesk', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 25%, #7e22ce 50%, #c026d3 75%, #1e3c72 100%);
    background-size: 400% 400%;
    animation: techFlow 18s ease infinite;
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

@keyframes techFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-container {
    max-width: 950px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(192, 38, 211, 0.8);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { text-shadow: 0 0 20px rgba(192, 38, 211, 0.8); }
    50% { text-shadow: 0 0 30px rgba(192, 38, 211, 1); }
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.score, .accuracy {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid rgba(192, 38, 211, 0.5);
}

.screen {
    display: block;
    animation: fadeIn 0.5s ease;
}

.screen.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.setup-panel, .results-panel {
    background: rgba(30, 60, 114, 0.8);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(192, 38, 211, 0.5);
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.setup-panel h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

.operation-selector, .difficulty-selector {
    margin: 30px 0;
}

.operation-selector h3, .difficulty-selector h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.operation-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.operation-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(192, 38, 211, 0.3);
    border-radius: 15px;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Space Grotesk', sans-serif;
    color: white;
}

.operation-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(192, 38, 211, 0.4);
}

.operation-btn.selected {
    background: rgba(192, 38, 211, 0.4);
    border-color: #c026d3;
    box-shadow: 0 0 20px rgba(192, 38, 211, 0.6);
}

.op-symbol {
    font-size: 2rem;
}

.op-name {
    font-size: 1rem;
    font-weight: 600;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.difficulty-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(192, 38, 211, 0.3);
    border-radius: 15px;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Space Grotesk', sans-serif;
    color: white;
}

.difficulty-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.difficulty-btn.selected {
    background: rgba(192, 38, 211, 0.4);
    border-color: #c026d3;
    box-shadow: 0 0 20px rgba(192, 38, 211, 0.6);
}

.diff-emoji {
    font-size: 2.5rem;
}

.diff-name {
    font-size: 1.1rem;
    font-weight: 700;
}

.diff-desc {
    font-size: 0.9rem;
    opacity: 0.8;
}

.input-group {
    margin: 25px 0;
}

.input-group label {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.input-group input {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(192, 38, 211, 0.4);
    border-radius: 15px;
    padding: 12px 20px;
    font-size: 1.3rem;
    color: white;
    text-align: center;
    width: 120px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}

.input-group input:focus {
    outline: none;
    border-color: #c026d3;
    box-shadow: 0 0 15px rgba(192, 38, 211, 0.5);
}

.main-btn {
    background: linear-gradient(135deg, #c026d3 0%, #7e22ce 100%);
    border: none;
    border-radius: 50px;
    padding: 18px 40px;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Space Grotesk', sans-serif;
    text-transform: uppercase;
    box-shadow: 0 6px 25px rgba(192, 38, 211, 0.5);
    margin: 10px;
}

.main-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 35px rgba(192, 38, 211, 0.7);
}

.main-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    border: none;
    border-radius: 50px;
    padding: 18px 40px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 6px 25px rgba(42, 82, 152, 0.5);
    margin: 10px;
}

.secondary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 35px rgba(42, 82, 152, 0.7);
}

.progress-bar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 25px;
    height: 50px;
    position: relative;
    margin-bottom: 30px;
    overflow: hidden;
    border: 2px solid rgba(192, 38, 211, 0.3);
}

.progress-fill {
    background: linear-gradient(90deg, #c026d3 0%, #7e22ce 100%);
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 25px;
    box-shadow: 0 0 20px rgba(192, 38, 211, 0.6);
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.question-panel {
    text-align: center;
    margin: 40px 0;
}

.question {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 25px;
    text-shadow: 0 0 20px rgba(192, 38, 211, 0.8);
}

.place-value-hint {
    background: rgba(192, 38, 211, 0.2);
    border: 2px solid rgba(192, 38, 211, 0.5);
    border-radius: 15px;
    padding: 12px;
    margin: 15px auto;
    max-width: 400px;
    font-size: 1rem;
    font-weight: 600;
}

.pv-label {
    color: #fbbf24;
}

.feedback {
    font-size: 1.5rem;
    font-weight: 700;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    border-radius: 20px;
    padding: 15px;
    transition: all 0.3s ease;
    white-space: pre-line;
    text-align: center;
    max-width: 700px;
}

.feedback.correct {
    background: rgba(52, 211, 153, 0.3);
    border: 3px solid #34D399;
    animation: pulse 0.6s ease;
}

.feedback.incorrect {
    background: rgba(248, 113, 113, 0.3);
    border: 3px solid #F87171;
    animation: shake 0.6s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.text-input-wrapper {
    display: flex;
    justify-content: center;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
    flex-wrap: wrap;
}

#answer-input {
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(192, 38, 211, 0.5);
    border-radius: 20px;
    padding: 20px 30px;
    font-size: 2rem;
    color: white;
    text-align: center;
    width: 280px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}

#answer-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#answer-input:focus {
    outline: none;
    border-color: #c026d3;
    box-shadow: 0 0 25px rgba(192, 38, 211, 0.6);
}

#answer-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-btn {
    background: linear-gradient(135deg, #c026d3 0%, #7e22ce 100%);
    border: none;
    border-radius: 20px;
    padding: 20px 35px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 4px 20px rgba(192, 38, 211, 0.5);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(192, 38, 211, 0.7);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-btn.hidden {
    display: none;
}

.next-btn {
    background: linear-gradient(135deg, #2a5298 0%, #1e3c72 100%);
    border: none;
    border-radius: 20px;
    padding: 20px 35px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 4px 20px rgba(42, 82, 152, 0.5);
}

.next-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(42, 82, 152, 0.7);
}

.next-btn.hidden {
    display: none;
}

.results-panel h2 {
    font-size: 2.2rem;
    margin-bottom: 30px;
    font-weight: 700;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat {
    background: rgba(192, 38, 211, 0.2);
    border: 2px solid rgba(192, 38, 211, 0.5);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 1rem;
    margin-bottom: 10px;
    opacity: 0.9;
    font-weight: 600;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fbbf24;
}

.missed-section {
    margin: 30px 0;
}

.missed-section h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    font-weight: 700;
}

#missed-list {
    background: rgba(248, 113, 113, 0.15);
    border: 2px solid #F87171;
    border-radius: 15px;
    padding: 20px;
    max-height: 250px;
    overflow-y: auto;
    text-align: left;
}

.missed-problem {
    background: rgba(248, 113, 113, 0.3);
    border-left: 4px solid #F87171;
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
    font-size: 1.1rem;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .game-title {
        font-size: 1.8rem;
    }

    .question {
        font-size: 2.5rem;
    }

    .operation-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .difficulty-buttons {
        grid-template-columns: 1fr;
    }

    .text-input-wrapper {
        flex-direction: column;
        align-items: center;
    }

    #answer-input {
        width: 100%;
        max-width: 300px;
    }
}

#missed-list::-webkit-scrollbar {
    width: 8px;
}

#missed-list::-webkit-scrollbar-track {
    background: rgba(248, 113, 113, 0.1);
    border-radius: 10px;
}

#missed-list::-webkit-scrollbar-thumb {
    background: rgba(248, 113, 113, 0.5);
    border-radius: 10px;
}
