* {
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #121212 0%, #1a1a2e 50%, #16213e 100%);
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container {
    max-width: 95%;
    width: 95%;
    padding: 5%;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
    text-align: center;
}

h1 {
    font-size: 1.3em;
    margin: 0 0 15px 0;
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(40, 40, 40, 0.8);
    border-radius: 12px;
    font-size: 0.95em;
    font-weight: 600;
}

#de-bai {
    margin: 20px 0;
    text-align: left;
    padding: 15px;
    background: rgba(20, 20, 20, 0.7);
    border-radius: 10px;
    border-left: 4px solid #4facfe;
    line-height: 1.5;
    font-size: 1em;
}

/* 🔥 PHẦN PHÂN SỐ SIÊU CHÍNH XÁC 🔥 */
.ty-le-thuc {
    margin: 30px 0;
    padding: 20px;
    background: rgba(25, 25, 25, 0.9);
    border-radius: 16px;
    border: 2px solid rgba(79, 172, 254, 0.3);
}

.ty-le-thuc p {
    margin: 0 0 20px 0;
    font-weight: 600;
    color: #b0b0b0;
}

.ratio-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.fraction {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    height: 80px;
    margin: 0 5px;
}

.fraction-top {
    font-size: 1em;
    font-weight: 700;
    color: #4facfe;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fraction-bottom {
    font-size: 1.2em;
    font-weight: 700;
    color: #ffffff;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fraction-line {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85px;
    height: 3px;
    background: linear-gradient(90deg, #4facfe, #00f2fe);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(79, 172, 254, 0.5);
    z-index: 1;
}

input[type="number"] {
    width: 90px;
    height: 35px;
    padding: 8px 12px;
    margin: 5px 0;
    border: none;
    background: rgba(40, 40, 40, 0.8);
    color: #ffffff;
    font-size: 1.2em;
    font-weight: 700;
    text-align: center;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
}

input[type="number"]:focus {
    outline: none;
    border-bottom-color: #4facfe;
    background: rgba(79, 172, 254, 0.1);
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.3);
}

input[type="number"]::placeholder {
    color: #666;
}

.equal {
    font-size: 2em;
    font-weight: 800;
    color: #00f2fe;
    margin: 0 15px;
    text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
}

.xu-ra-x {
    margin: 25px 0;
    padding: 15px;
    background: rgba(25, 25, 25, 0.9);
    border-radius: 12px;
    border-left: 4px solid #00f2fe;
    font-size: 1.1em;
    font-weight: 600;
}

button {
    background: linear-gradient(45deg, #333 0%, #444 100%);
    color: #e0e0e0;
    border: none;
    padding: 12px 24px;
    margin: 8px 4px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

#kiem-tra {
    background: linear-gradient(45deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    min-width: 120px;
}

#kiem-tra:hover {
    box-shadow: 0 6px 25px rgba(79, 172, 254, 0.6);
}

#bai-moi {
    background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
}

#xem-lich-su, #dong-lich-su {
    background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
    font-size: 0.9em;
    padding: 10px 20px;
}

#ket-qua {
    margin: 20px 0;
    padding: 15px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: 700;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
}

.stats, #lich-su {
    font-size: 0.95em;
}

#lich-su {
    max-height: 350px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #4facfe #333;
}

.lich-su-item {
    margin-bottom: 15px;
    padding: 12px;
    background: rgba(40, 40, 40, 0.6);
    border-radius: 10px;
    border-left: 4px solid #4facfe;
}

.dung { color: #4caf50 !important; }
.sai  { color: #f44336 !important; }

@media (max-width: 480px) {
    .container {
        width: 98vw;
        padding: 20px 15px;
        margin: 5px;
    }
    
    .fraction {
        width: 60px;
        height: 70px;
    }
    
    .fraction-top, .fraction-bottom {
        font-size: 1.2em;
    }
    
    .fraction-line {
        width: 50px;
    }
    
    .ratio-container {
        gap: 15px;
    }
    
    .equal {
        font-size: 1.8em;
        margin: 0 10px;
    }
}

/* Animation cho input */
@keyframes inputGlow {
    0% { box-shadow: 0 0 5px rgba(79,172,254,0.3); }
    50% { box-shadow: 0 0 20px rgba(79,172,254,0.6); }
    100% { box-shadow: 0 0 5px rgba(79,172,254,0.3); }
}

input:focus {
    animation: inputGlow 1s ease-in-out;
}