:root {
    --bg-gradient: radial-gradient(circle at center, #2b32b2, #1488cc);
    --bg-dark: #0f2027;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-color: #ffffff;
    --text-muted: #b2bec3;
    
    /* Neon/Chemical Colors */
    --mole-color: #f39c12;   
    --volume-color: #00cec9; 
    --mass-color: #e17055;   
    --particles-color: #74b9ff; 
    
    --active-color: #00cec9; 
    --line-color: rgba(255, 255, 255, 0.2);
}

body {
    margin: 0;
    font-family: 'Kanit', sans-serif;
    background: linear-gradient(to right, #243b55, #141e30);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    color: var(--text-color);
}

.app-container {
    background: var(--card-bg);
    width: 100%; /* Changed from fixed 1100px */
    max-width: 1100px;
    min-height: 900px;
    border-radius: 30px;
    box-shadow: 0 40px 80px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0 0 0;
    position: relative;
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-sizing: border-box;
    overflow: hidden;
}

h1 {
    color: #fff;
    margin: 0 0 10px 0;
    font-size: 2.5rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    letter-spacing: 1px;
    padding: 0 30px;
}

.instruction {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 1.1rem;
    padding: 0 30px;
}

.map-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 600px;
    margin-bottom: 20px;
    flex-grow: 1;
}

.arrows-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.connection-line {
    stroke: rgba(255, 255, 255, 0.5); /* Increased opacity */
    stroke-width: 5; /* Thicker static lines */
    transition: all 0.4s;
    stroke-dasharray: 8, 8; /* Larger dashes */
}

.connection-line.active {
    stroke: var(--active-color);
    stroke-width: 6; /* Thicker active lines */
    stroke-dasharray: none;
    filter: drop-shadow(0 0 10px var(--active-color));
}

.node {
    position: absolute;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
    z-index: 10;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 20px rgba(255,255,255,0.2), 
                0 10px 20px rgba(0,0,0,0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

.node:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: inset 0 0 30px rgba(255,255,255,0.4), 
                0 15px 30px rgba(0,0,0,0.4);
}

.node.selected {
    border-color: var(--active-color);
    box-shadow: 0 0 15px var(--active-color), inset 0 0 10px var(--active-color);
    transform: none;
}

.node.selected::after {
    background: var(--active-color);
    border: 2px solid #fff;
    content: attr(data-order);
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(20%, -20%);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 20;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: translate(20%, -20%) scale(0); }
    to { transform: translate(20%, -20%) scale(1); }
}

.node .icon {
    font-size: 2.5rem;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.5));
}

.node .label {
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    line-height: 1.2;
}

.node-mole {
    top: 300px; /* Y=300 */
    left: 50%;
    margin-left: -65px;
    margin-top: -65px;
    background: radial-gradient(circle at 30% 30%, rgba(243, 156, 18, 0.8), rgba(243, 156, 18, 0.2));
}

.node-volume {
    top: 80px; /* Y=80 (center, not edge) */
    left: 50%;
    margin-left: -65px;
    margin-top: -65px;
    background: radial-gradient(circle at 30% 30%, rgba(0, 206, 201, 0.8), rgba(0, 206, 201, 0.2));
}

.node-particles {
    top: 410px; /* Y=410 */
    left: 50%;
    margin-left: 125px; /* X = 400 + 125 + 65 = 590 center */
    margin-top: -65px;
    background: radial-gradient(circle at 30% 30%, rgba(116, 185, 255, 0.8), rgba(116, 185, 255, 0.2));
}

.node-mass {
    top: 410px; /* Y=410 */
    left: 50%;
    margin-left: -255px; /* X = 400 - 255 + 65 = 210 center */
    margin-top: -65px;
    background: radial-gradient(circle at 30% 30%, rgba(225, 112, 85, 0.8), rgba(225, 112, 85, 0.2));
}

/* --- DOCKED FOOTER / RESULT PANEL (CENTERED) --- */

.result-panel {
    background: rgba(0, 0, 0, 0.4);
    width: 100%;
    padding: 30px 50px;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center Everything Horizontally */
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.2);
    margin-top: auto;
    gap: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(15px);
}

/* Row 1: Sequence */
.result-content-wrapper {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-right: 0;
    padding-bottom: 15px;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center Content */
}

.sequence-label, .factor-label {
    color: var(--text-muted);
    font-family: 'Kanit', sans-serif;
    letter-spacing: 0.5px;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 10px;
    align-self: center; /* Center Labels */
}

.result-content {
    color: #fff;
    font-weight: 400;
    font-size: 1.5rem;
    display: flex;
    justify-content: center; /* Center Text */
    align-items: center;
    flex-wrap: wrap; 
    gap: 15px;
    width: 100%; 
}

.arrow {
    color: var(--active-color);
    font-size: 1.8rem;
    font-weight: bold;
}

/* Row 2: Factor */
.factor-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; /* Center Content */
}

/* Center box content */
.factor-display {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 206, 201, 0.3);
    color: #fff;
    box-shadow: 0 0 30px rgba(0, 206, 201, 0.1);
    min-height: 120px;
    width: 100%; 
    max-width: none; 
    display: flex;
    justify-content: center; 
    align-items: center;
    padding: 20px 30px;
    font-family: 'Roboto Mono', monospace;
    border-radius: 16px;
    box-sizing: border-box;
}

.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    font-size: 1.8rem; 
    color: #fff;
    margin: 0 15px;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
    white-space: nowrap; 
}

.fraction .numerator {
    border-bottom: 2px solid rgba(255, 255, 255, 0.9);
    padding: 0 10px 5px 10px;
    text-align: center;
    font-weight: 700;
}

.fraction .denominator {
    padding: 8px 10px 0 10px;
    text-align: center;
    font-weight: 700;
}

.multiply-sign {
    font-size: 2.5rem;
    color: var(--active-color);
    margin: 0 10px;
    text-shadow: 0 0 10px var(--active-color);
}

/* Row 3: Button */
.reset-btn {
    align-self: center; /* Center Button */
    background: linear-gradient(135deg, #ff7675, #d63031);
    color: white;
    border: none;
    padding: 12px 35px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.2s;
    box-shadow: 0 5px 20px rgba(214, 48, 49, 0.4);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 5px; 
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(214, 48, 49, 0.6);
    background: linear-gradient(135deg, #ff6b6b, #e17055);
}

/* Formula Reference Section */
.formula-reference {
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.formula-title {
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: 500;
}

.formula-box {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-family: 'Roboto Mono', monospace;
    min-height: 60px;
}

.formula-placeholder {
    color: var(--text-muted);
    font-size: 1rem;
    font-style: italic;
}

.formula-main {
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff; /* Changed to white */
}

.formula-equals {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.7);
}

.formula-fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(0, 206, 201, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: 0 0 10px rgba(0, 206, 201, 0.3);
}

.formula-num {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--active-color);
    padding: 0 8px;
}

.formula-den {
    font-size: 1rem;
    color: var(--active-color);
    border-top: 2px solid var(--active-color);
    padding: 4px 8px 0;
}

@media (max-width: 1200px) {
    .app-container {
        width: 95%;
        height: auto;
        min-height: 90vh;
        padding-top: 20px;
    }
}

@media (max-width: 850px) {
    /* Scale down the map for tablets/mobile since it uses fixed coordinates */
    .map-container {
        transform: scale(0.7);
        transform-origin: top center;
        margin-bottom: -150px; /* Counteract the empty space left by scaling */
    }
    
    .app-container {
        min-height: auto;
    }

    h1 {
        font-size: 2rem;
    }
    
    .instruction {
        font-size: 1rem;
        text-align: center;
    }
}

@media (max-width: 600px) {
    .map-container {
        transform: scale(0.55); /* Increased from 0.45 for visibility */
        margin-bottom: -250px;
    }

    .app-container {
        padding: 10px;
        width: 100%;
        border-radius: 0; /* Full screen on mobile */
    }
    
    .result-panel {
        padding: 20px;
        gap: 15px;
    }
    
    .result-content {
        font-size: 1.1rem;
        flex-wrap: wrap; /* Allow wrapping on very small screens if needed */
        justify-content: center;
    }
    
    .fraction {
        font-size: 1.2rem;
        margin: 0 5px;
    }
    
    .multiply-sign {
        font-size: 1.5rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
}
