* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: url('bg.jpg') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative;
}

body::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    animation: float 15s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, -30px);
    }
}

#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('bg.jpg') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s, visibility 0.5s;
}

#preloader.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
}

.loader {
    width: 100%;
    height: 100%;
    border: 6px solid transparent;
    border-top: 6px solid #fff;
    border-right: 6px solid #fff;
    border-radius: 50%;
    animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    position: absolute;
}

.loader-inner {
    width: 80px;
    height: 80px;
    border: 6px solid transparent;
    border-bottom: 6px solid #ffd700;
    border-left: 6px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite reverse;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.loader-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

#preloader h2 {
    color: white;
    font-size: 32px;
    margin-bottom: 15px;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.8s ease-out;
    letter-spacing: 2px;
}

#preloader p {
    color: rgba(255, 255, 255, 0.95);
    font-size: 18px;
    text-align: center;
    max-width: 400px;
    padding: 0 20px;
    animation: fadeInUp 0.8s ease-out 0.2s both;
    line-height: 1.6;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#game-container {
    width: 90%;
    max-width: 900px;
    height: auto;
    min-height: 500px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 30px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: scale(0.9);
    animation: fadeIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    z-index: 1;
}

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

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

header::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent 30%,
            rgba(255, 255, 255, 0.1) 50%,
            transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

#game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 25px;
    gap: 20px;
}

#score-container {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
}

.score-box {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 6px 20px rgba(240, 147, 251, 0.4);
    font-weight: bold;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

.score-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(240, 147, 251, 0.5);
}

.score-box:nth-child(2) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.score-box:nth-child(2):hover {
    box-shadow: 0 10px 30px rgba(79, 172, 254, 0.5);
}

.score-box i {
    font-size: 20px;
}

#problem-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    border-radius: 20px;
    box-shadow:
        inset 0 2px 10px rgba(0, 0, 0, 0.1),
        0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    min-height: 170px;
    padding: 20px;
}

#problem-container::before {
    content: "";
    position: absolute;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.1) 0%, transparent 70%);
    border-radius: 50%;
    top: -100px;
    right: -100px;
    animation: float 10s ease-in-out infinite;
}

#problem {
    font-size: 48px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    position: relative;
    z-index: 1;
}

.number {
    padding: 15px 30px;
    background: linear-gradient(135deg, #ffffff 0%, #f5f7fa 100%);
    border-radius: 15px;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.1),
        inset 0 -2px 5px rgba(0, 0, 0, 0.05);
    min-width: 80px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.number.highlight {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
    transform: scale(1.15) rotate(2deg);
    box-shadow: 0 10px 30px rgba(255, 216, 155, 0.5);
}

.operator-placeholder {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    color: white;
    box-shadow: 0 8px 20px rgba(142, 197, 252, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.operator-placeholder.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    transform: scale(1.2) rotate(360deg);
    animation: none;
}

.operator-placeholder.wrong {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px) rotate(-5deg);
    }

    75% {
        transform: translateX(10px) rotate(5deg);
    }
}

#operators-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.operator-btn {
    width: 80px;
    height: 70px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 20px;
    font-size: 36px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    box-shadow: 0 8px 0 #5568d3, 0 10px 25px rgba(102, 126, 234, 0.4);
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.operator-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.operator-btn:hover::before {
    left: 100%;
}

.operator-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 0 #5568d3, 0 15px 30px rgba(102, 126, 234, 0.5);
}

.operator-btn:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 #5568d3, 0 5px 15px rgba(102, 126, 234, 0.3);
}

.operator-btn.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    box-shadow: 0 8px 0 #0e8074, 0 10px 25px rgba(17, 153, 142, 0.5);
}

.operator-btn.wrong {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    box-shadow: 0 8px 0 #c20764, 0 10px 25px rgba(238, 9, 121, 0.5);
}

#message {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: all 0.3s;
}

#message.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transform: scale(1.1);
}

#message.wrong {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: messagePulse 0.5s;
}

@keyframes messagePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

#controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 15px 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 0 #5568d3, 0 8px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 #5568d3, 0 12px 25px rgba(102, 126, 234, 0.5);
}

.control-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #5568d3, 0 4px 15px rgba(102, 126, 234, 0.3);
}

.control-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 36px;
    z-index: 10;
    animation: fadeIn 0.5s;
}

#game-over.show {
    display: flex;
}

#game-over>div:first-child {
    font-size: 48px;
    margin-bottom: 10px;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

#final-score {
    font-size: 56px;
    margin: 20px 0;
    color: #ffd700;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    animation: scoreAppear 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #f00;
    opacity: 0;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

#sound-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    transition: all 0.3s;
    z-index: 10;
}

#sound-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1) rotate(15deg);
}

/* Responsive Design */
@media (max-width: 768px) {
    #game-container {
        width: 95%;
        min-height: auto;
        border-radius: 20px;
    }

    header {
        font-size: 22px;
        padding: 15px;
    }

    #game-area {
        padding: 15px;
        gap: 15px;
    }

    .score-box {
        padding: 12px 20px;
        font-size: 16px;
        min-width: 120px;
    }

    .score-box i {
        font-size: 16px;
    }

    #problem {
        font-size: 36px;
        gap: 10px;
    }

    .number {
        padding: 12px 20px;
        min-width: 60px;
        font-size: 36px;
    }

    .operator-placeholder {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .operator-btn {
        width: 70px;
        height: 70px;
        font-size: 30px;
        border-radius: 15px;
    }

    #message {
        font-size: 18px;
    }

    .control-btn {
        padding: 12px 25px;
        font-size: 16px;
    }

    #game-over>div:first-child {
        font-size: 36px;
    }

    #final-score {
        font-size: 42px;
    }

    #sound-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
        top: 5px;
    }

    .loader-wrapper {
        width: 100px;
        height: 100px;
    }

    .loader-inner {
        width: 70px;
        height: 70px;
    }

    .loader-icon {
        font-size: 30px;
    }

    #preloader h2 {
        font-size: 26px;
    }

    #preloader p {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    header {
        font-size: 18px;
        padding: 12px;
    }

    #problem {
        font-size: 28px;
        gap: 8px;
    }

    .number {
        padding: 10px 15px;
        min-width: 50px;
        font-size: 28px;
    }

    .operator-placeholder {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .operator-btn {
        width: 60px;
        height: 60px;
        font-size: 26px;
        gap: 10px;
    }

    .score-box {
        font-size: 14px;
        padding: 10px 15px;
    }

    #message {
        font-size: 16px;
    }

    .control-btn {
        padding: 10px 20px;
        font-size: 14px;
        gap: 6px;
    }

    #preloader h2 {
        font-size: 22px;
    }

    #preloader p {
        font-size: 14px;
    }
}

@media (max-height: 600px) {
    #game-container {
        height: 95vh;
        min-height: auto;
    }

    #game-area {
        padding: 10px;
        gap: 10px;
    }

    #problem-container {
        min-height: 150px;
    }
}